コード例 #1
0
    def save(self, *args, **kwargs):
        if not self.guid:
            self.guid = unicode(uuid4())

        if not self.code:
            self.code = ''.join(
                random.sample(string.letters + string.digits, 10)).upper()

        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='signup/mail/validate.txt',
                           context={
                               'name': self.user.first_name
                               or self.user.username,
                               'guid': self.guid,
                               'code': self.code,
                               'next': self.next_url
                           },
                           recipient=self.user)
コード例 #2
0
ファイル: handlers.py プロジェクト: iselu/bambu-tools
    def notify(self, success=True):
        if 'bambu.notifications' in settings.INSTALLED_APPS:
            from bambu.notifications import notify

            if not success:
                actions = [{
                    'urlname': 'enquiry',
                    'title': 'Contact us with any questions'
                }]
            else:
                actions = []

            notify('bambu.dataportability.import_%s' %
                   (success and 'success' or 'fail'),
                   self.handler.job.user,
                   job=self.handler.job,
                   actions=actions)
        else:
            from bambu.mail import render_to_mail

            render_to_mail(
                'Importing %s was %s' %
                (self.handler.job.name,
                 (success and 'successful' or 'not successful')),
                'dataportability/mail/%s.txt' %
                (success and 'success' or 'fail'), {
                    'job': self.handler.job,
                    'warnings':
                    self.handler.job.updates.filter(kind='warning'),
                    'errors': self.handler.job.updates.filter(kind='error')
                }, self.handler.job.user)
コード例 #3
0
ファイル: models.py プロジェクト: cheekybastard/bambu-tools
	def save(self, *args, **kwargs):
		if not self.guid:
			self.guid = unicode(uuid4())
		
		if not self.code:
			self.code = ''.join(
				random.sample(string.letters + string.digits, 10)
			).upper()
		
		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 = 'signup/mail/validate.txt',
				context = {
					'name': self.user.first_name or self.user.username,
					'guid': self.guid,
					'code': self.code,
					'next': self.next_url
				},
				recipient = self.user
			)
コード例 #4
0
ファイル: models.py プロジェクト: iamsteadman/bambu-tools
	def save(self, *args, **kwargs):
		new = not self.pk
		super(Status, self).save(*args, **kwargs)
		
		def get_currency_symbol(currency):
			d = {}
			for (x, y, z) in getattr(settings, 'CURRENCIES', ()):
				d[x] = z
			
			return d.get(currency, u'£')
		
		if new:
			if self.state in (states.PAYMENT_ERROR, states.PAYMENT_FAILED):
				if self.state == states.PAYMENT_FAILED:
					render_to_mail(
						u'Your %s was not successful' % (
							self.payment.recurring and 'billing agreement' or 'payment'
						),
						'payments/error.txt',
						{
							'payment': self.payment,
							'currency': get_currency_symbol(self.payment.currency)
						},
						self.payment.customer
					)
				
				signals.payment_error.send(
					type(self.payment.content_object),
					payment = self.payment
				)
			elif self.state == states.PAYMENT_CANCELLED:
				signals.payment_cancelled.send(
					type(self.payment.content_object),
					payment = self.payment
				)
			elif self.state == states.PAYMENT_COMPLETE:
				signals.payment_complete.send(
					type(self.payment.content_object),
					payment = self.payment
				)
				
				render_to_mail(
					u'Your %s was successful' % (
						self.payment.recurring and 'billing agreement' or 'payment'
					),
					'payments/receipt.txt',
					{
						'payment': self.payment,
						'currency': get_currency_symbol(self.payment.currency)
					},
					self.payment.customer
				)
			elif self.state == states.PAYMENT_TERMINATED:
				signals.payment_terminated.send(
					type(self.payment.content_object),
					payment = self.payment
				)
コード例 #5
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='signup/mail/password.txt',
                       context={
                           'name': self.user.first_name or self.user.username,
                           'username': self.user.username,
                           'password': password,
                           'next': self.next_url
                       },
                       recipient=self.user)
コード例 #6
0
	def notify(self, success = True):
		from bambu.mail import render_to_mail
		
		render_to_mail(
			'Importing %s was %s' % (
				self.handler.job.name,
				(success and 'successful' or 'not successful')
			),
			'dataportability/mail-%s.txt' % (success and 'success' or 'fail'),
			{
				'job': self.handler.job,
				'warnings': self.handler.job.updates.filter(kind = 'warning'),
				'errors': self.handler.job.updates.filter(kind = 'error')
			},
			self.handler.job.user
		)
コード例 #7
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='signup/mail/password-reset.txt',
                           context={
                               'name': self.user.first_name
                               or self.user.username,
                               'guid': self.guid,
                               'next': self.next_url
                           },
                           recipient=self.user)
コード例 #8
0
ファイル: models.py プロジェクト: iselu/bambu-tools
    def save(self, *args, **kwargs):
        new = not self.pk
        super(Status, self).save(*args, **kwargs)

        def get_currency_symbol(currency):
            d = {}
            for (x, y, z) in getattr(settings, 'CURRENCIES', ()):
                d[x] = z

            return d.get(currency, u'£')

        if new:
            if self.state in (states.PAYMENT_ERROR, states.PAYMENT_FAILED):
                if self.state == states.PAYMENT_FAILED:
                    render_to_mail(
                        u'Your %s was not successful' %
                        (self.payment.recurring and 'billing agreement'
                         or 'payment'), 'payments/error.txt', {
                             'payment': self.payment,
                             'currency': get_currency_symbol(
                                 self.payment.currency)
                         }, self.payment.customer)

                signals.payment_error.send(type(self.payment.content_object),
                                           payment=self.payment)
            elif self.state == states.PAYMENT_CANCELLED:
                signals.payment_cancelled.send(type(
                    self.payment.content_object),
                                               payment=self.payment)
            elif self.state == states.PAYMENT_COMPLETE:
                signals.payment_complete.send(type(
                    self.payment.content_object),
                                              payment=self.payment)

                render_to_mail(
                    u'Your %s was successful' %
                    (self.payment.recurring and 'billing agreement'
                     or 'payment'), 'payments/receipt.txt', {
                         'payment': self.payment,
                         'currency': get_currency_symbol(self.payment.currency)
                     }, self.payment.customer)
            elif self.state == states.PAYMENT_TERMINATED:
                signals.payment_terminated.send(type(
                    self.payment.content_object),
                                                payment=self.payment)
コード例 #9
0
ファイル: models.py プロジェクト: cheekybastard/bambu-tools
	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 = 'signup/mail/password.txt',
			context = {
				'name': self.user.first_name or self.user.username,
				'username': self.user.username,
				'password': password,
				'next': self.next_url
			},
			recipient = self.user
		)
コード例 #10
0
ファイル: models.py プロジェクト: cheekybastard/bambu-tools
	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 = 'signup/mail/password-reset.txt',
				context = {
					'name': self.user.first_name or self.user.username,
					'guid': self.guid,
					'next': self.next_url
				},
				recipient = self.user
			)
コード例 #11
0
ファイル: handlers.py プロジェクト: iamsteadman/bambu-tools
	def notify(self, success = True):
		if 'bambu.notifications' in settings.INSTALLED_APPS:
			from bambu.notifications import notify
			
			if not success:
				actions = [
					{
						'urlname': 'enquiry',
						'title': 'Contact us with any questions'
					}
				]
			else:
				actions = []
			
			notify(
				'bambu.dataportability.import_%s' % (success and 'success' or 'fail'),
				self.handler.job.user,
				job = self.handler.job,
				actions = actions
			)
		else:
			from bambu.mail import render_to_mail
			
			render_to_mail(
				'Importing %s was %s' % (
					self.handler.job.name,
					(success and 'successful' or 'not successful')
				),
				'dataportability/mail/%s.txt' % (success and 'success' or 'fail'),
				{
					'job': self.handler.job,
					'warnings': self.handler.job.updates.filter(kind = 'warning'),
					'errors': self.handler.job.updates.filter(kind = 'error')
				},
				self.handler.job.user
			)