Commit b00fc23f authored by Sli's avatar Sli
Browse files

Add automatic mail when an eticket has been bought

parent 3e99f97b
Pipeline #314 failed with stage
in 4 minutes and 1 second
from django.db import models
from django.core.mail import send_mail
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, UserManager, Group as AuthGroup, GroupManager as AuthGroupManager, AnonymousUser as AuthAnonymousUser
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
......@@ -332,6 +333,8 @@ class User(AbstractBaseUser):
Sends an email to this User.
if from_email is None:
from_email = settings.DEFAULT_FROM_EMAIL
send_mail(subject, message, from_email, [], **kwargs)
def generate_username(self):
......@@ -4,6 +4,7 @@ from django.utils import timezone
from django.conf import settings
from django.core.urlresolvers import reverse
from django.forms import ValidationError
from django.contrib.sites.shortcuts import get_current_site
from datetime import timedelta
import random
......@@ -54,6 +55,15 @@ class Customer(models.Model):
self.amount -= s.quantity * s.unit_price
def get_absolute_url(self):
return reverse('core:user_account', kwargs={'user_id':})
def get_full_url(self):
request = None
full_url = ''.join(['http://', settings.SITH_URL, self.get_absolute_url()])
return full_url
class ProductType(models.Model):
This describes a product type
......@@ -292,6 +302,32 @@ class Selling(models.Model):
super(Selling, self).delete(*args, **kwargs)
def send_mail_customer(self):
subject = _('Eticket bought for the event %(event)s') % {'event':}
message_html = _(
"You bought an eticket for the event %(event)s.\nYou can download it on this page %(url)s."
) % {
'<a href="',
message_txt = _(
"You bought an eticket for the event %(event)s.\nYou can download it on this page %(url)s."
) % {
'url': self.customer.get_full_url(),
def save(self, *args, **kwargs):
if not =
......@@ -330,6 +366,10 @@ class Selling(models.Model):
if self.product.eticket:
super(Selling, self).save(*args, **kwargs)
class Permanency(models.Model):
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment