mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-03 15:38:59 +00:00
Add URLs to all modified fields in the notification message.
This commit is contained in:
@ -12,7 +12,6 @@ class PgModel(object):
|
|||||||
def PreSaveHandler(self):
|
def PreSaveHandler(self):
|
||||||
"""If send_notification is set to True, send a default formatted notification mail"""
|
"""If send_notification is set to True, send a default formatted notification mail"""
|
||||||
|
|
||||||
print "Handler called!"
|
|
||||||
if not self.send_notification:
|
if not self.send_notification:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -23,6 +22,8 @@ class PgModel(object):
|
|||||||
# or that we don't care to send out notifications about it.
|
# or that we don't care to send out notifications about it.
|
||||||
return
|
return
|
||||||
|
|
||||||
|
cont = self._build_url() + "\n\n" + cont
|
||||||
|
|
||||||
print "Sending notification to %s" % settings.NOTIFICATION_EMAIL
|
print "Sending notification to %s" % settings.NOTIFICATION_EMAIL
|
||||||
print "Generate subject: %s by %s\nGenerate contents: %s\n------------------------------" % (subj, get_current_user(), cont)
|
print "Generate subject: %s by %s\nGenerate contents: %s\n------------------------------" % (subj, get_current_user(), cont)
|
||||||
|
|
||||||
@ -71,6 +72,21 @@ class PgModel(object):
|
|||||||
|
|
||||||
return "\n".join(['%s: %s' % (n, getattr(self, n)) for n in fieldlist])
|
return "\n".join(['%s: %s' % (n, getattr(self, n)) for n in fieldlist])
|
||||||
|
|
||||||
|
def _build_url(self):
|
||||||
|
if self.id:
|
||||||
|
return "%s/admin/%s/%s/%s/" % (
|
||||||
|
settings.SITE_ROOT,
|
||||||
|
self._meta.app_label,
|
||||||
|
self._meta.module_name,
|
||||||
|
self.id,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return "%s/admin/%s/%s/" % (
|
||||||
|
settings.SITE_ROOT,
|
||||||
|
self._meta.app_label,
|
||||||
|
self._meta.module_name,
|
||||||
|
)
|
||||||
|
|
||||||
def full_text_diff(self, oldobj):
|
def full_text_diff(self, oldobj):
|
||||||
fieldlist = self._get_all_notification_fields()
|
fieldlist = self._get_all_notification_fields()
|
||||||
if not fieldlist:
|
if not fieldlist:
|
||||||
|
Reference in New Issue
Block a user