Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#334 Allow Inforequest, InforequestDraft and WizardDraft models admin bulk delete #417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions chcemvediet/apps/inforequests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ class InforequestAdmin(admin.ModelAdmin):
inlines = [
BranchInline,
]
actions = [
u'delete_selected',
Copy link
Owner

@martinmacko47 martinmacko47 Sep 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viliambalaz IMHO nie je dobre to takto miesat, ze pri niektorych modeloch pouzivame nase delete_selected a pri niektorych built-in delete_selected. Bude z toho chaos do buducnosti. Lepsie je pri vsetkych modeloch pouzivat iba nase delete_selected, aby sme sa pri buducich zmenach mohli spolahnut, ze vsetko funguje vsade rovnako.

Na druhej strane pri tychto modeloch su delete_warnings aj delete_constraints prazdne, takze je zbytocne definovat pre ne prazdne metody.

Nastal teda asi cas naprv implementovat vseobecny mixin pre nasu implementaciu delete_selected, ktory bude v sebe defaultne obsahovat prazdne delete_warnings a delete_constraints, a ktory poriesi vsetko okolo deletovania. Potom tu iba tento mixin pouzijeme, bez nutnosti nieco definovat.

Mixin by mal riesit vsetky veci okolo delete_warnings a delete_constraints, tak aby potom pri kazdom modeli stacilo pouzit ten mixin, overridnut delete_warnings a delete_constraints a deletovanie bude fungovat.

Logika specificka pre konkretny model, ako napriklad snooze pri ActionAdmin, nebude v mixine, ale ostane nadalej iba model admine. Model admin overridne prislusne metody a doplni ich.

Pls mixin sprav v separatnom PR, aplikuj ho na modely, pre ktore mame deletovanie uz implementovane. A az potom po mergnuti PR s mixinom, sa vratime sem a upravime tento PR aby pouzival mixin aj pre tieto modely. Nateraz tento PR oznacujem labelom ako blocked. Potom, po implementovali mixinu, ked sa k tomuto PR vratis, label blocked zrus.

]

def get_queryset(self, request):
queryset = super(InforequestAdmin, self).get_queryset(request)
Expand Down Expand Up @@ -208,6 +211,9 @@ class InforequestDraftAdmin(admin.ModelAdmin):
]
inlines = [
]
actions = [
u'delete_selected',
]

def get_queryset(self, request):
queryset = super(InforequestDraftAdmin, self).get_queryset(request)
Expand Down
3 changes: 3 additions & 0 deletions chcemvediet/apps/wizards/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class WizardDraftAdmin(admin.ModelAdmin):
]
inlines = [
]
actions = [
u'delete_selected',
]

def get_queryset(self, request):
queryset = super(WizardDraftAdmin, self).get_queryset(request)
Expand Down