Ejemplo n.º 1
0
	def PreSaveHandler(self):
		"""If send_notification is set to True, send a default formatted notification mail"""
		
		if not self.send_notification:
			return

		(subj, cont) = self._get_changes_texts()
		
		if not cont:
			# If any of these come back as None, it means that nothing actually changed,
			# or that we don't care to send out notifications about it.
			return

		cont = self._build_url() + "\n\n" + cont


		# Build the mail text
		msg = MIMEText(cont, _charset='utf-8')
		msg['Subject'] = "%s by %s" % (subj, get_current_user())
		msg['To'] = settings.NOTIFICATION_EMAIL
		msg['From'] = settings.NOTIFICATION_FROM

		if hasattr(settings,'SUPPRESS_NOTIFICATIONS') and settings.SUPPRESS_NOTIFICATIONS:
			print msg.as_string()
		else:
			sendmail(msg)
Ejemplo n.º 2
0
	def delete(self):
		# We can't compare the object, but we should be able to construct something anyway
		if self.send_notification:
			subject = "%s id %s has been deleted by %s" % (
				self._meta.verbose_name,
				self.id,
				get_current_user())

			send_simple_mail(settings.NOTIFICATION_FROM,
							 settings.NOTIFICATION_EMAIL,
							 subject,
							 self.full_text_representation())

		# Now call our super to actually delete the object
		super(PgModel, self).delete()
Ejemplo n.º 3
0
	def delete(self):
		# We can't compare the object, but we should be able to construct something anyway
		if self.send_notification:
			subject = "%s id %s has been deleted by %s" % (
				self._meta.verbose_name,
				self.id,
				get_current_user())
			msg = MIMEText(self.full_text_representation(), _charset='utf-8')
			msg['Subject'] = subject
			msg['To'] = settings.NOTIFICATION_EMAIL
			msg['From'] = settings.NOTIFICATION_FROM
			if hasattr(settings,'SUPPRESS_NOTIFICATIONS') and settings.SUPPRESS_NOTIFICATIONS:
				print msg.as_string()
			else:
				sendmail(msg)

		# Now call our super to actually delete the object
		super(PgModel, self).delete()
Ejemplo n.º 4
0
	def PreSaveHandler(self):
		"""If send_notification is set to True, send a default formatted notification mail"""
		
		if not self.send_notification:
			return

		(subj, cont) = self._get_changes_texts()
		
		if not cont:
			# If any of these come back as None, it means that nothing actually changed,
			# or that we don't care to send out notifications about it.
			return

		cont = self._build_url() + "\n\n" + cont


		# Build the mail text
		send_simple_mail(settings.NOTIFICATION_FROM,
						 settings.NOTIFICATION_EMAIL,
						 "%s by %s" % (subj, get_current_user()),
						 cont)