File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -325,13 +325,17 @@ class Media:
325325 js = ['admin/notification_subscription.js' ]
326326
327327 def preview_button (self , obj ):
328- url = reverse (
329- 'admin:notificationtype_preview' ,
330- args = [obj .notification_type .id ]
331- )
328+ if obj .notification_type :
329+ url = reverse (
330+ 'admin:notificationtype_preview' ,
331+ args = [obj .notification_type .id ]
332+ )
333+ return format_html (
334+ '<a class="button" target="_blank" href="{}">Preview</a>' ,
335+ url
336+ )
332337 return format_html (
333- '<a class="button" target="_blank" href="{}">Preview</a>' ,
334- url
338+ '<a class="button">Missing Notification Type!</a>' ,
335339 )
336340
337341 def get_urls (self ):
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ def clean(self):
4949 raise ValidationError (f'{ self .message_frequency !r} is not allowed for { self .notification_type .name !r} .' )
5050
5151 def __str__ (self ) -> str :
52- return f'<{ self .user } via { self .subscribed_object } subscribes to { self .notification_type .name } ({ self .message_frequency } )>'
52+ return (f'<{ self .user } via { self .subscribed_object } subscribes to '
53+ f'{ getattr (self .notification_type , 'name' , 'MISSING' )} ({ self .message_frequency } )>' )
5354
5455 class Meta :
5556 verbose_name = 'Notification Subscription'
You can’t perform that action at this time.
0 commit comments