def corporate_order_view(request, order_type, obj_id): """ Страница заявки на оплату сессии/модуля юр. лицом """ if order_type == 'session': cls = CourseSession else: cls = EducationalModule obj = get_object_or_404(cls, id=obj_id) form = CorporatePaymentForm(request.POST or None) if request.method == 'POST': if form.is_valid(): email = getattr(settings, 'OPRO_PAYMENTS_CORPORATE_ORDER_EMAIL', '*****@*****.**') msg = Message( subject=get_template( 'opro_payments/emails/corporate_order_email_subject.txt'), html=get_template( 'opro_payments/emails/corporate_order_email_html.html'), mail_from=settings.EMAIL_NOTIFICATIONS_FROM, mail_to=form.cleaned_data['email'], headers={'Reply-To': email}) context = { 'user': request.user if request.user.is_authenticated() else None, 'order_type': order_type, 'object': obj, } context.update(get_prefix_and_site()) msg.send(context={'context': context, 'request': request}) msg = Message( subject=get_template( 'opro_payments/emails/corporate_order_ticket_subject.txt'), html=get_template( 'opro_payments/emails/corporate_order_ticket_message.html' ), mail_from=settings.EMAIL_NOTIFICATIONS_FROM, mail_to=email) context = { 'form': form, 'order_type': order_type, 'object': obj, } msg.send(context={'context': context, 'request': request}) return HttpResponseRedirect( reverse('op_payment_corporate_order_done', kwargs={'order_type': order_type})) context = { 'form': form, 'object': obj.course if order_type == 'session' else obj, 'order_type': order_type, } if order_type == 'session': context['session'] = obj else: context['module'] = obj return render(request, 'opro_payments/corporate_order.html', context)
def get_context(self, email=None): context = { 'module': self.enrollment_by_email[email].module, 'user': self.enrollment_by_email[email].user, 'course': self.session.course, 'site_url': self.get_site() } context.update(get_prefix_and_site()) return context
def edmodule_unenrolled_handler(**kwargs): """ Отправка сообщения об успешной отписке от модуля instace - EducationalModuleEnrollment """ instance = kwargs.get('instance') if instance: user = instance.user msg = Message( subject=get_template('emails/edmodule_unenrolled_subject.txt'), html=get_template('emails/edmodule_unenrolled_html.html'), mail_from=settings.EMAIL_NOTIFICATIONS_FROM, mail_to=(user.get_full_name(), user.email) ) context = {'module': instance.module, 'user': user, 'site_url': get_domain_url()} context.update(get_prefix_and_site()) msg.send(context={'context': context})
def edmodule_payed_handler(**kwargs): """ отправка сообщения об успешной оплате модуля instance - EducationalModuleEnrollmentReason """ instance = kwargs.get('instance') if instance: module = instance.enrollment.module user = instance.enrollment.user msg = Message( subject=get_template('emails/edmodule_payed_subject.txt'), html=get_template('emails/edmodule_payed_html.html'), mail_from=settings.EMAIL_NOTIFICATIONS_FROM, mail_to=(user.get_full_name(), user.email) ) context = { 'module': module, 'user': user, 'site_url': get_domain_url(), 'promocodes': kwargs.get('promocodes', []), 'shop_url': getattr(settings, 'PAYMENT_SHOP_URL', None), } context.update(get_prefix_and_site()) msg.send(context={'context': context})