mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Send a mail when someone is subscribed
This commit is contained in:
@ -5,6 +5,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.forms import PasswordResetForm
|
||||
|
||||
from core.models import User
|
||||
|
||||
@ -70,8 +71,12 @@ class Subscription(models.Model):
|
||||
super(Subscription, self).save()
|
||||
from counter.models import Customer
|
||||
if not Customer.objects.filter(user=self.member).exists():
|
||||
last_id = Customer.objects.count() + 5195 # Number to keep a continuity with the old site
|
||||
last_id = Customer.objects.count() + 1504 # Number to keep a continuity with the old site
|
||||
Customer(user=self.member, account_id=Customer.generate_account_id(last_id+1), amount=0).save()
|
||||
form = PasswordResetForm({'email': self.member.email})
|
||||
if form.is_valid():
|
||||
form.save(use_https=True, email_template_name='core/new_user_email.jinja',
|
||||
subject_template_name='core/new_user_email_subject.jinja', from_email="ae@utbm.fr")
|
||||
self.member.make_home()
|
||||
try: # Create subscription on the old site: TODO remove me!
|
||||
LOCATION = {
|
||||
|
@ -9,6 +9,7 @@ from django.forms import Select
|
||||
from django.conf import settings
|
||||
|
||||
from ajax_select.fields import AutoCompleteSelectField
|
||||
import random
|
||||
|
||||
from subscription.models import Subscriber, Subscription
|
||||
from core.views import CanEditMixin, CanEditPropMixin, CanViewMixin
|
||||
@ -54,6 +55,7 @@ class SubscriptionForm(forms.ModelForm):
|
||||
first_name = self.cleaned_data.get("first_name"),
|
||||
email = self.cleaned_data.get("email"))
|
||||
u.generate_username()
|
||||
u.set_password(str(random.randrange(1000000, 10000000)))
|
||||
u.save()
|
||||
cleaned_data["member"] = u
|
||||
elif cleaned_data.get("member") is not None:
|
||||
|
Reference in New Issue
Block a user