def __extend_subscription(self, *args):
		"""
		Extend profile subscription and send e-mail
		:param args:
		"""
		ProfileService.extend_subscription(self.__transact.user_profile, self.__transact.duration)

		message = MailMessage(settings.INFO_EMAIL, 'Продление подписки', 'mail_tmpl_subscribe_extended.html', {
			'username': self.__transact.user_profile.user.username,
			'expiration_date': self.__transact.user_profile.date_subscribe_ended
		}, self.__transact.user_profile.user.email)
		message.send()
Example #2
0
    def __extend_subscription(self, *args):
        """
		Extend profile subscription and send e-mail
		:param args:
		"""
        ProfileService.extend_subscription(self.__transact.user_profile,
                                           self.__transact.duration)

        message = MailMessage(
            settings.INFO_EMAIL, 'Продление подписки',
            'mail_tmpl_subscribe_extended.html', {
                'username':
                self.__transact.user_profile.user.username,
                'expiration_date':
                self.__transact.user_profile.date_subscribe_ended
            }, self.__transact.user_profile.user.email)
        message.send()
Example #3
0
	def setUp(self):
		self.sender = '*****@*****.**'
		self.subject = 'test message'
		self.template = 'mail_tmpl_subscribe_extended.html'
		self.context = Context({'username': '******', 'expiration_date': datetime.datetime.now()})
		self.destination = '*****@*****.**'  # '*****@*****.**'
		self.template_length = len(get_template(self.template).render(self.context).encode('cp1251'))
		self.mail_message = MailMessage(self.sender, self.subject, self.template, self.context, self.destination)
Example #4
0
def create_new_user(request, template):
	"""
	Create new user controller
	:param request: HTTP request
	:param template: html template
	:return:
	"""
	if request.POST:
		new_user_form = NewUserForm(request.POST)
		transact_id = request.POST.get('transactId')
		transact = DBService.get_transact(transact_id)

		if new_user_form.errors:
			return JsonResponse({'data': new_user_form.errors}, status=400)

		result = ProfileService.create_profile(new_user_form.data)

		if result.is_success:
			if transact:
				transact.confirm()

			message = MailMessage(settings.INFO_EMAIL, 'Данные вашего профиля', 'mail_tmpl_profile_created.html', {
					'username': new_user_form.data['userName'],
					'password': new_user_form.data['userPassword']
				}, new_user_form.data['userEmail'])
			message.send()
			return HttpResponse(status=201)

		logger.error(Code.PCRERR, data=result.data)
		return HttpResponse(status=500, content=result.data)

	else:
		params = {}
		transact_id = request.GET.get('transact_id')
		transact = DBService.get_transact(transact_id)

		if transact:
			params['transact_id'] = transact.transact_id
			params['username'] = transact.username
			params['email'] = transact.email

		return render_to_response(template, params, context_instance=RequestContext(request))