remotes/origin/artem
Gena 11 years ago
parent 39c36eb223
commit 0896050fc9
  1. 16
      accounts/utils.py
  2. 11
      batiskaf/templates/jinja2/mail/base.jinja
  3. 8
      batiskaf/templates/jinja2/mail/order.jinja
  4. 10
      batiskaf/templates/jinja2/mail/registration.jinja
  5. 4
      store/views.py

@ -1,7 +1,21 @@
import re
from django.core.mail import send_mail
from django.conf import settings
from django.template.loader import render_to_string
def normalize_phone(phone):
retval = re.sub("\D", "", phone)
if len(retval) > 10:
retval = retval[len(retval)-10:]
return retval
return retval
def send_email(profile, subject='Робот Batiskaf-kz.kz', template='mail/base.jinja', context={}):
context['user'] = profile
message = render_to_string(template, context)
send_mail(
subject,
message,
recipient_list=[profile.email, ],
from_email=settings.DEFAULT_FROM_EMAIL
)

@ -0,0 +1,11 @@
Привет, {{ user.first_name }}!
{% block content %}
{% endblock %}
Это автоматическое сообщение. Отвечать на него не нужно!
С Уважением,
Администрация Batiskaf-kz.kz
--
Skype: batiskaf_kz
Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17

@ -0,0 +1,8 @@
{% extends 'mail/base.jinja' %}
{% block content %}
Поздравляем, вы успешно оформили заказ.
Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +7{{ user.phone }}:
http://batiskaf-kz.kz/account/
{% endblock %}

@ -0,0 +1,10 @@
{% extends 'mail/base.jinja' %}
{% block content %}
Поздравляем, вы успешно оформили заказ.
Для того, чтобы его было удобнее отслеживать, мы создали для вас аккаунт в нашем интернет-магазине.
Вы можете войти в него, используя свой номер телефона +7{{ user.phone }}:
http://batiskaf-kz.kz/account/
{% endblock %}

@ -3,7 +3,7 @@ from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from django.shortcuts import get_object_or_404, redirect, render
from django.views.generic import *
from accounts.models import Profile
from accounts.utils import normalize_phone
from accounts.utils import normalize_phone, send_email
from batiskaf.jinja2_ext.html_filters import escape
from .models import *
from store.alemtat import AlemTat
@ -216,6 +216,7 @@ class CartDetailView(TemplateView):
profile = Profile.objects.get(phone=normalize_phone(order.phone))
profile.set_password(settings.PROFILE_TEMP_PASSWORD)
profile.save()
send_email(profile, template='mail/order.jinja')
except:
profile = Profile.objects.create(
phone=normalize_phone(order.phone),
@ -225,6 +226,7 @@ class CartDetailView(TemplateView):
)
profile.set_password(settings.PROFILE_TEMP_PASSWORD)
profile.save()
send_email(profile, template='mail/registration.jinja')
user = authenticate(username=profile.phone, password=settings.PROFILE_TEMP_PASSWORD)
if user.is_active:
login(request, user)

Loading…
Cancel
Save