Fix admin base for non-notification models
authorMagnus Hagander <magnus@hagander.net>
Mon, 22 Jan 2018 11:28:14 +0000 (12:28 +0100)
committerMagnus Hagander <magnus@hagander.net>
Mon, 22 Jan 2018 11:28:14 +0000 (12:28 +0100)
pgweb/util/admin.py

index 60a5f00d31281c1770ce9f7cd68fb9457899d5b6..21e2b8da516c26a60990a7593f97c040b096dd54 100644 (file)
@@ -26,7 +26,7 @@ class PgwebAdmin(admin.ModelAdmin):
                return fld
 
        def change_view(self, request, object_id, form_url='', extra_context=None):
-               if self.model.send_notification:
+               if hasattr(self.model, 'send_notification') and self.model.send_notification:
                        # Anything that sends notification supports manual notifications
                        if extra_context == None:
                                extra_context = dict()
@@ -54,7 +54,7 @@ class PgwebAdmin(admin.ModelAdmin):
        actions=['custom_delete_selected']
 
        def save_model(self, request, obj, form, change):
-               if change and self.model.send_notification:
+               if change and hasattr(self.model, 'send_notification') and self.model.send_notification:
                        # We only do processing if something changed, not when adding
                        # a new object.
                        if request.POST.has_key('new_notification') and request.POST['new_notification']: