Skip to content

Commit

Permalink
Do not allow deleting of processed deliveries
Browse files Browse the repository at this point in the history
  • Loading branch information
kjagiello committed Feb 12, 2017
1 parent 0497e1d commit f745fc8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/shop/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class DeliveryAdmin(admin.ModelAdmin):
readonly_fields = ('total_amount', 'date_created', 'valid',
'error_message', 'locked',)
ordering = ('-date_created',)
actions_on_top = True
actions = None
form = DeliveryForm
fieldsets = (
(None, {
Expand Down Expand Up @@ -191,6 +191,12 @@ def get_urls(self):
]
return custom_urls + urls

def has_delete_permission(self, request, obj=None):
# Disable deleting of processed deliveries
if obj:
return not obj.locked
return super().has_delete_permission(request, obj)


@admin.register(models.ProductCategory)
class ProductCategoryAdmin(admin.ModelAdmin):
Expand Down

0 comments on commit f745fc8

Please sign in to comment.