def save(self, *args, **kwargs):
		notify = kwargs.pop('notify', True)
		
		if self.spam:
			self.approved = False
		
		new = not self.pk and not self.spam
		if new and not self.approved and not self.spam:
			self.approved = self.check_for_approval()
		
		super(Comment, self).save(*args, **kwargs)
		
		if new and notify:
			if not 'bambu.notifications' in settings.INSTALLED_APPS:
				render_to_mail(
					u'New comment submitted',
					'socialcomments/mail.txt',
					{
						'comment': self,
						'author': self.content_object.author
					},
					self.content_object.author
				)
			else:
				notifications.notify('socialcomments.comment_posted',
					self.content_object.author,
					comment = self,
					actions = [
						{
							'urlname': 'admin:comments_comment_change',
							'args': [self.pk],
							'title': 'View the comment'
						}
					]
				)
Exemple #2
0
    def save(self, *args, **kwargs):
        from bambu.mail.shortcuts import render_to_mail
        from django.contrib.auth.models import User
        from django.contrib.sites.models import Site

        site = Site.objects.get_current()

        render_to_mail(
            subject=u"Enquiry from %s" % site.name,
            template="enquiries/mail.txt",
            context={"name": self.name, "email": self.email, "subject": self.subject, "message": self.message},
            recipient=User.objects.filter(is_staff=True),
        )
Exemple #3
0
    def send(self):
        site = Site.objects.get_current()
        sender_name = self.sender.get_full_name() or self.sender.username

        render_to_mail(u'Invitation to join %s on %s' %
                       (sender_name, site.name),
                       'saas/mail/invitation.txt', {
                           'sender': sender_name,
                           'guid': self.guid,
                           'reminder': not self.pk is None
                       },
                       self.email,
                       fail_silently=True)
Exemple #4
0
    def reset(self):
        password = User.objects.make_random_password(10)

        self.user.set_password(password)
        self.user.save()
        self.delete()

        render_to_mail(subject=u'Your new password',
                       template='saas/mail/password.txt',
                       context={
                           'name': self.user.first_name or self.user.username,
                           'username': self.user.username,
                           'password': password
                       },
                       recipient=self.user)
Exemple #5
0
    def save(self, *args, **kwargs):
        if not self.guid:
            self.guid = unicode(uuid4())

        new = not self.pk
        super(PasswordReset, self).save(*args, **kwargs)

        if new:
            render_to_mail(subject=u'Forgotten your password?',
                           template='saas/mail/password-reset.txt',
                           context={
                               'name': self.user.first_name
                               or self.user.username,
                               'guid': self.guid
                           },
                           recipient=self.user)
Exemple #6
0
    def save(self, *args, **kwargs):
        notify = kwargs.pop('notify', True)
        super(Enquiry, self).save(*args, **kwargs)

        if notify:
            site = Site.objects.get_current()

            render_to_mail(
                subject=u'Enquiry from %s' % site.name,
                template='enquiries/mail.txt',
                context={
                    'name': self.name,
                    'email': self.email,
                    'subject': self.subject,
                    'message': self.message
                },
                recipient=[u for u in User.objects.filter(is_staff=True)])
Exemple #7
0
	def reset(self):
		password = User.objects.make_random_password(10)
		
		self.user.set_password(password)
		self.user.save()
		self.delete()
		
		render_to_mail(
			subject = u'Your new password',
			template = 'saas/mail/password.txt',
			context = {
				'name': self.user.first_name or self.user.username,
				'username': self.user.username,
				'password': password
			},
			recipient = self.user
		)
Exemple #8
0
	def save(self, *args, **kwargs):
		if not self.guid:
			self.guid = unicode(uuid4())
		
		new = not self.pk
		super(PasswordReset, self).save(*args, **kwargs)
		
		if new:
			render_to_mail(
				subject = u'Forgotten your password?',
				template = 'saas/mail/password-reset.txt',
				context = {
					'name': self.user.first_name or self.user.username,
					'guid': self.guid
				},
				recipient = self.user
			)
Exemple #9
0
	def send(self):
		site = Site.objects.get_current()
		sender_name = self.sender.get_full_name() or self.sender.username
		
		render_to_mail(
			u'Invitation to join %s on %s' % (
				sender_name,
				site.name
			),
			'saas/mail/invitation.txt',
			{
				'sender': sender_name,
				'guid': self.guid,
				'reminder': not self.pk is None
			},
			self.email,
			fail_silently = True
		)
Exemple #10
0
    def save(self, *args, **kwargs):
        if not self.guid:
            self.guid = unicode(uuid4())

        new = not self.pk
        super(EmailValidation, self).save(*args, **kwargs)

        self.user.is_active = False
        self.user.save()

        if new:
            render_to_mail(subject=u'Please confirm your email address',
                           template='saas/mail/validate.txt',
                           context={
                               'name': self.user.first_name
                               or self.user.username,
                               'guid': self.guid
                           },
                           recipient=self.user)
Exemple #11
0
	def save(self, *args, **kwargs):
		if not self.guid:
			self.guid = unicode(uuid4())
		
		new = not self.pk
		super(EmailValidation, self).save(*args, **kwargs)
		
		self.user.is_active = False
		self.user.save()
		
		if new:
			render_to_mail(
				subject = u'Please confirm your email address',
				template = 'saas/mail/validate.txt',
				context = {
					'name': self.user.first_name or self.user.username,
					'guid': self.guid
				},
				recipient = self.user
			)
Exemple #12
0
	def save(self, *args, **kwargs):
		notify = kwargs.pop('notify', True)
		super(Enquiry, self).save(*args, **kwargs)
		
		if notify:
			site = Site.objects.get_current()
			
			render_to_mail(
				subject = u'Enquiry from %s' % site.name,
				template = 'enquiries/mail.txt',
				context = {
					'name': self.name,
					'email': self.email,
					'subject': self.subject,
					'message': self.message
				},
				recipient = [
					u for u in User.objects.filter(is_staff = True)
				]
			)
Exemple #13
0
	def save(self, *args, **kwargs):
		from bambu.mail.shortcuts import render_to_mail
		from django.contrib.auth.models import User
		from django.contrib.sites.models import Site
		
		site = Site.objects.get_current()
		
		render_to_mail(
			subject = u'Enquiry from %s' % site.name,
			template = 'enquiries/mail.txt',
			context = {
				'name': self.name,
				'email': self.email,
				'subject': self.subject,
				'message': self.message
			},
			recipient = [
				u for u in User.objects.filter(is_staff = True)
			]
		)
Exemple #14
0
	def save(self, *args, **kwargs):
		notify = kwargs.pop('notify', True)
		
		if self.spam:
			self.approved = False
		
		new = not self.pk and not self.spam
		if new and not self.approved and not self.spam:
			self.approved = Comment.objects.filter(
				email__iexact = self.email,
				approved = True,
				spam = False
			).select_for_update(
				nowait = False
			).exists()
		
		super(Comment, self).save(*args, **kwargs)
		
		if new and notify:
			if not 'bambu.notifications' in settings.INSTALLED_APPS:
				render_to_mail(
					u'New comment submitted',
					'comments/mail.txt',
					{
						'comment': self,
						'author': self.content_object.author
					},
					self.content_object.author
				)
			else:
				notifications.notify('bambu.comments.comment_posted',
					self.content_object.author,
					comment = self,
					actions = [
						{
							'urlname': 'admin:comments_comment_change',
							'args': [self.pk],
							'title': 'View the comment'
						}
					]
				)
Exemple #15
0
	def save(self, *args, **kwargs):
		if self.spam:
			self.approved = False
		
		new = not self.pk
		if new:
			self.approved = Comment.objects.filter(
				email__iexact = self.email,
				approved = True,
				spam = False
			).count() > 0
		
		super(Comment, self).save(*args, **kwargs)
		
		if new:
			render_to_mail(
				u'New comment submitted',
				'comments/mail.txt',
				{
					'comment': self,
					'author': self.content_object.author
				},
				self.content_object.author
			)