Esempio n. 1
0
def invite(request):
    form = SendInviteForm(request.POST or None, request=request)
    if request.method == 'POST':
        if form.is_valid():
            form.save(commit=False)
            invite = form.instance
            email = form.cleaned_data['email']
            subject = u"%(username)s приглашает Вас присоединиться к сервису\
 \"Уже везу\"" % {
                'username': invite.sender.get_real_name().upper()
            }
            information = render_to_string('mail/user_invite.html', {
                'site_url': settings.SITE_SHORT_URL,
                'register_link': settings.SITE_URL + reverse(
                    'accounts:invite-register', args=(invite.sid,)
                ),
                'username': invite.sender.get_real_name()

            })
            #            msg = settings.INVITE_MESSAGE % {
            #                'user': request.user.username,
            #                'link': settings.SITE_URL + reverse(
            #                    'accounts:invite-register', args=(invite.sid,)),
            #                'resource': settings.SITE_URL,
            #                'resource_name': settings.RESOURCE_NAME
            #            }

            # no mail send, no money :)
            # send_mail(
            #    subject=unicode(
            #        _('You have been invited to %s service') % \
            #                                             settings.SERVICE_NAME
            #    ),
            #    message=information,  # unicode(msg),
            #    from_email=settings.EMAIL_FROM,
            #    recipient_list=[email]
            # )

            mail_message = EmailMulti(subject, information,
                                      settings.EMAIL_FROM, [email])
            mail_message.content_subtype = 'html'
            mail_message.send()

            invite.save()
            return {'redirect': 'accounts:invite-success'}
    return {
        'form': form
    }
Esempio n. 2
0
File: views.py Progetto: tarvitz/icu
def invite(request):
    form = SendInviteForm(request.POST or None, request=request)
    if request.method == 'POST':
        if form.is_valid():
            form.save(commit=False)
            invite = form.instance
            email = form.cleaned_data['email']
            msg = settings.INVITE_MESSAGE % {
                'user': request.user.username,
                'link': "http://b3ban.blacklibrary.ru%s" % reverse('accounts:invite-register', args=(invite.sid, ))
            }
            #no mail send, no money :)
            send_mail(
                subject=unicode(_('You have been invited to b3ban service')),
                message=unicode(msg),
                from_email=settings.EMAIL_FROM,
                recipient_list=[email]
            )
            invite.save()
            return {'redirect': 'accounts:invite-success'}
    return {
        'form': form
    }