Commit 7fe0964a authored by Skia's avatar Skia
Browse files

Merge branch 'sli' into 'master'

Add automatic mail when an eticket has been bought

See merge request !19
parents 3e99f97b 677c50a4
Pipeline #322 failed with stage
in 3 minutes and 38 seconds
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, [self.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,13 @@ class Customer(models.Model):
self.amount -= s.quantity * s.unit_price
self.save()
def get_absolute_url(self):
return reverse('core:user_account', kwargs={'user_id': self.user.pk})
def get_full_url(self):
return ''.join(['https://', settings.SITH_URL, self.get_absolute_url()])
class ProductType(models.Model):
"""
This describes a product type
......@@ -292,6 +300,33 @@ class Selling(models.Model):
self.customer.save()
super(Selling, self).delete(*args, **kwargs)
def send_mail_customer(self):
event = self.product.eticket.event_title or _("Unknown event")
subject = _('Eticket bought for the event %(event)s') % {'event': event}
message_html = _(
"You bought an eticket for the event %(event)s.\nYou can download it on this page %(url)s."
) % {
'event': event,
'url':''.join((
'<a href="',
self.customer.get_full_url(),
'">',
self.customer.get_full_url(),
'</a>'
))
}
message_txt = _(
"You bought an eticket for the event %(event)s.\nYou can download it on this page %(url)s."
) % {
'event': event,
'url': self.customer.get_full_url(),
}
self.customer.user.email_user(
subject,
message_txt,
html_message=message_html
)
def save(self, *args, **kwargs):
if not self.date:
self.date = timezone.now()
......@@ -330,6 +365,10 @@ class Selling(models.Model):
duration=settings.SITH_SUBSCRIPTIONS[sub.subscription_type]['duration'],
start=sub.subscription_start)
sub.save()
try:
if self.product.eticket:
self.send_mail_customer()
except: pass
super(Selling, self).save(*args, **kwargs)
class Permanency(models.Model):
......
......@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-10-18 23:31+0200\n"
"POT-Creation-Date: 2016-10-25 21:49+0200\n"
"PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n"
......@@ -17,8 +17,8 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: accounting/models.py:36 accounting/models.py:55 accounting/models.py:82
#: accounting/models.py:141 club/models.py:19 counter/models.py:62
#: counter/models.py:87 counter/models.py:122 launderette/models.py:15
#: accounting/models.py:141 club/models.py:19 counter/models.py:70
#: counter/models.py:95 counter/models.py:130 launderette/models.py:15
#: launderette/models.py:60 launderette/models.py:85
msgid "name"
msgstr "nom"
......@@ -39,7 +39,7 @@ msgstr "code postal"
msgid "country"
msgstr "pays"
#: accounting/models.py:41 core/models.py:166
#: accounting/models.py:41 core/models.py:167
msgid "phone"
msgstr "téléphone"
......@@ -64,7 +64,7 @@ msgid "account number"
msgstr "numero de compte"
#: accounting/models.py:58 accounting/models.py:83 club/models.py:145
#: counter/models.py:96 counter/models.py:123
#: counter/models.py:104 counter/models.py:131
msgid "club"
msgstr "club"
......@@ -85,12 +85,12 @@ msgstr "Compte club"
msgid "%(club_account)s on %(bank_account)s"
msgstr "%(club_account)s sur %(bank_account)s"
#: accounting/models.py:139 club/models.py:146 counter/models.py:341
#: accounting/models.py:139 club/models.py:146 counter/models.py:380
#: launderette/models.py:122
msgid "start date"
msgstr "date de début"
#: accounting/models.py:140 club/models.py:147 counter/models.py:342
#: accounting/models.py:140 club/models.py:147 counter/models.py:381
msgid "end date"
msgstr "date de fin"
......@@ -102,8 +102,8 @@ msgstr "est fermé"
msgid "club account"
msgstr "compte club"
#: accounting/models.py:144 accounting/models.py:190 counter/models.py:27
#: counter/models.py:226
#: accounting/models.py:144 accounting/models.py:190 counter/models.py:28
#: counter/models.py:234
msgid "amount"
msgstr "montant"
......@@ -123,17 +123,17 @@ msgstr "numéro"
msgid "journal"
msgstr "classeur"
#: accounting/models.py:191 core/models.py:495 core/models.py:773
#: counter/models.py:229 counter/models.py:272 counter/models.py:358
#: accounting/models.py:191 core/models.py:498 core/models.py:776
#: counter/models.py:237 counter/models.py:280 counter/models.py:397
#: eboutic/models.py:15 eboutic/models.py:48
msgid "date"
msgstr "date"
#: accounting/models.py:192 counter/models.py:359
#: accounting/models.py:192 counter/models.py:398
msgid "comment"
msgstr "commentaire"
#: accounting/models.py:193 counter/models.py:230 counter/models.py:273
#: accounting/models.py:193 counter/models.py:238 counter/models.py:281
#: subscription/models.py:57
msgid "payment method"
msgstr "méthode de paiement"
......@@ -159,7 +159,7 @@ msgid "accounting type"
msgstr "type comptable"
#: accounting/models.py:202 accounting/models.py:296 accounting/models.py:322
#: accounting/models.py:345 counter/models.py:264
#: accounting/models.py:345 counter/models.py:272
msgid "label"
msgstr "intitulé"
......@@ -167,11 +167,18 @@ msgstr "intitulé"
msgid "target type"
msgstr "type de cible"
#: accounting/models.py:204
#: accounting/models.py:204 club/templates/club/club_members.jinja:8
#: club/templates/club/club_old_members.jinja:8
#: core/templates/core/user_clubs.jinja:15
#: core/templates/core/user_clubs.jinja:41
#: counter/templates/counter/cash_summary_list.jinja:32
#: counter/templates/counter/stats.jinja:15
#: launderette/templates/launderette/launderette_admin.jinja:44
msgid "User"
msgstr "Utilisateur"
#: accounting/models.py:204
#: accounting/models.py:204 club/templates/club/club_detail.jinja:5
#: counter/templates/counter/invoices_call.jinja:20
msgid "Club"
msgstr "Club"
......@@ -225,7 +232,7 @@ msgstr ""
"Vous devez fournir soit un type comptable simplifié ou un type comptable "
"standard"
#: accounting/models.py:291 counter/models.py:91
#: accounting/models.py:291 counter/models.py:99
msgid "code"
msgstr "code"
......@@ -257,6 +264,300 @@ msgstr "type simplifié"
msgid "simplified type"
msgstr "type simplifié"
#: accounting/templates/accounting/accountingtype_list.jinja:4
#: accounting/templates/accounting/accountingtype_list.jinja:15
msgid "Accounting type list"
msgstr "Liste des types comptable"
#: accounting/templates/accounting/accountingtype_list.jinja:9
#: accounting/templates/accounting/bank_account_details.jinja:9
#: accounting/templates/accounting/bank_account_list.jinja:9
#: accounting/templates/accounting/club_account_details.jinja:9
#: accounting/templates/accounting/journal_details.jinja:9
#: accounting/templates/accounting/label_list.jinja:9
#: accounting/templates/accounting/operation_edit.jinja:9
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:9
#: core/templates/core/user_tools.jinja:43
msgid "Accounting"
msgstr "Comptabilité"
#: accounting/templates/accounting/accountingtype_list.jinja:10
msgid "Accounting types"
msgstr "Type comptable"
#: accounting/templates/accounting/accountingtype_list.jinja:13
msgid "New accounting type"
msgstr "Nouveau type comptable"
#: accounting/templates/accounting/accountingtype_list.jinja:22
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:22
msgid "There is no types in this website."
msgstr "Il n'y a pas de types comptable dans ce site web."
#: accounting/templates/accounting/bank_account_details.jinja:4
#: accounting/templates/accounting/bank_account_details.jinja:13
#: core/templates/core/user_tools.jinja:50
msgid "Bank account: "
msgstr "Compte en banque : "
#: accounting/templates/accounting/bank_account_details.jinja:15
#: accounting/templates/accounting/club_account_details.jinja:16
#: accounting/templates/accounting/label_list.jinja:21
#: club/templates/club/club_sellings.jinja:48
#: core/templates/core/file_detail.jinja:43
#: core/templates/core/group_list.jinja:13 core/templates/core/macros.jinja:66
#: core/templates/core/user_account_detail.jinja:38
#: core/templates/core/user_edit.jinja:18
#: counter/templates/counter/last_ops.jinja:29
#: counter/templates/counter/last_ops.jinja:59
#: launderette/templates/launderette/launderette_admin.jinja:16
#: launderette/views.py:146
msgid "Delete"
msgstr "Supprimer"
#: accounting/templates/accounting/bank_account_details.jinja:17
#: club/views.py:31 core/views/user.py:130
msgid "Infos"
msgstr "Infos"
#: accounting/templates/accounting/bank_account_details.jinja:19
msgid "IBAN: "
msgstr "IBAN : "
#: accounting/templates/accounting/bank_account_details.jinja:20
msgid "Number: "
msgstr "Numéro : "
#: accounting/templates/accounting/bank_account_details.jinja:22
msgid "New club account"
msgstr "Nouveau compte club"
#: accounting/templates/accounting/bank_account_details.jinja:26
#: accounting/templates/accounting/bank_account_list.jinja:21
#: accounting/templates/accounting/club_account_details.jinja:55
#: accounting/templates/accounting/journal_details.jinja:70 club/views.py:53
#: core/templates/core/file.jinja:38 core/templates/core/page.jinja:31
#: core/templates/core/user_tools.jinja:36 core/views/user.py:147
#: counter/templates/counter/cash_summary_list.jinja:53
#: counter/templates/counter/counter_list.jinja:17
#: counter/templates/counter/counter_list.jinja:32
#: counter/templates/counter/counter_list.jinja:47
#: launderette/templates/launderette/launderette_list.jinja:16
msgid "Edit"
msgstr "Éditer"
#: accounting/templates/accounting/bank_account_list.jinja:4
#: accounting/templates/accounting/bank_account_list.jinja:17
msgid "Bank account list"
msgstr "Liste des comptes en banque"
#: accounting/templates/accounting/bank_account_list.jinja:12
msgid "Manage simplified types"
msgstr "Gérer les types simplifiés"
#: accounting/templates/accounting/bank_account_list.jinja:13
msgid "Manage accounting types"
msgstr "Gérer les types comptable"
#: accounting/templates/accounting/bank_account_list.jinja:14
msgid "New bank account"
msgstr "Nouveau compte en banque"
#: accounting/templates/accounting/bank_account_list.jinja:26
msgid "There is no accounts in this website."
msgstr "Il n'y a pas de comptes dans ce site web."
#: accounting/templates/accounting/club_account_details.jinja:4
#: accounting/templates/accounting/club_account_details.jinja:14
msgid "Club account:"
msgstr "Compte club : "
#: accounting/templates/accounting/club_account_details.jinja:18
#: accounting/templates/accounting/journal_details.jinja:16
#: accounting/templates/accounting/label_list.jinja:15
msgid "New label"
msgstr "Nouvelle étiquette"
#: accounting/templates/accounting/club_account_details.jinja:19
#: accounting/templates/accounting/journal_details.jinja:17
#: accounting/templates/accounting/label_list.jinja:4
#: accounting/templates/accounting/label_list.jinja:17
msgid "Label list"
msgstr "Liste des étiquettes"
#: accounting/templates/accounting/club_account_details.jinja:21
msgid "New journal"
msgstr "Nouveau classeur"
#: accounting/templates/accounting/club_account_details.jinja:23
msgid "You can not create new journal while you still have one opened"
msgstr "Vous ne pouvez pas créer de journal tant qu'il y en a un d'ouvert"
#: accounting/templates/accounting/club_account_details.jinja:28
#: launderette/templates/launderette/launderette_admin.jinja:43
msgid "Name"
msgstr "Nom"
#: accounting/templates/accounting/club_account_details.jinja:29
msgid "Start"
msgstr ""
#: accounting/templates/accounting/club_account_details.jinja:30
#, fuzzy
#| msgid "End"
msgid "End"
msgstr "Fin"
#: accounting/templates/accounting/club_account_details.jinja:31
#: accounting/templates/accounting/journal_details.jinja:31
#: core/templates/core/user_account_detail.jinja:53
#: core/templates/core/user_account_detail.jinja:81
#: counter/templates/counter/last_ops.jinja:17
msgid "Amount"
msgstr "Montant"
#: accounting/templates/accounting/club_account_details.jinja:32
msgid "Effective amount"
msgstr "Montant effectif"
#: accounting/templates/accounting/club_account_details.jinja:33
msgid "Closed"
msgstr "Fermé"
#: accounting/templates/accounting/club_account_details.jinja:34
#: accounting/templates/accounting/journal_details.jinja:39
msgid "Actions"
msgstr "Actions"
#: accounting/templates/accounting/club_account_details.jinja:50
#: accounting/templates/accounting/journal_details.jinja:58
msgid "Yes"
msgstr "Oui"
#: accounting/templates/accounting/club_account_details.jinja:52
#: accounting/templates/accounting/journal_details.jinja:60
msgid "No"
msgstr "Non"
#: accounting/templates/accounting/club_account_details.jinja:54
#: core/templates/core/file.jinja:36 core/templates/core/page.jinja:28
msgid "View"
msgstr "Voir"
#: accounting/templates/accounting/journal_details.jinja:4
#: accounting/templates/accounting/journal_details.jinja:15
msgid "General journal:"
msgstr "Classeur : "
#: accounting/templates/accounting/journal_details.jinja:18
#: core/templates/core/user_account.jinja:38
#: core/templates/core/user_account_detail.jinja:10
#: counter/templates/counter/counter_click.jinja:32
msgid "Amount: "
msgstr "Montant: "
#: accounting/templates/accounting/journal_details.jinja:19
msgid "Effective amount: "
msgstr "Montant effectif: "
#: accounting/templates/accounting/journal_details.jinja:21
msgid "Journal is closed, you can not create operation"
msgstr "Le classeur est fermé, vous ne pouvez pas créer d'opération"
#: accounting/templates/accounting/journal_details.jinja:23
msgid "New operation"
msgstr "Nouvelle opération"
#: accounting/templates/accounting/journal_details.jinja:28
#: counter/templates/counter/stats.jinja:14
msgid "Nb"
msgstr "No"
#: accounting/templates/accounting/journal_details.jinja:29
#: club/templates/club/club_sellings.jinja:18
#: core/templates/core/user_account_detail.jinja:17
#: core/templates/core/user_account_detail.jinja:50
#: core/templates/core/user_account_detail.jinja:79
#: counter/templates/counter/cash_summary_list.jinja:34
#: counter/templates/counter/last_ops.jinja:14
#: counter/templates/counter/last_ops.jinja:39
msgid "Date"
msgstr "Date"
#: accounting/templates/accounting/journal_details.jinja:30
#: club/templates/club/club_sellings.jinja:22
#: core/templates/core/user_account_detail.jinja:20
#: counter/templates/counter/last_ops.jinja:42
msgid "Label"
msgstr "Étiquette"
#: accounting/templates/accounting/journal_details.jinja:32
msgid "Payment mode"
msgstr "Méthode de paiement"
#: accounting/templates/accounting/journal_details.jinja:33
msgid "Target"
msgstr "Cible"
#: accounting/templates/accounting/journal_details.jinja:34
msgid "Code"
msgstr "Code"
#: accounting/templates/accounting/journal_details.jinja:35
msgid "Nature"
msgstr "Nature"
#: accounting/templates/accounting/journal_details.jinja:36
msgid "Done"
msgstr "Effectué"
#: accounting/templates/accounting/journal_details.jinja:37
#: counter/templates/counter/cash_summary_list.jinja:37 counter/views.py:711
msgid "Comment"
msgstr "Commentaire"
#: accounting/templates/accounting/journal_details.jinja:38
msgid "File"
msgstr "Fichier"
#: accounting/templates/accounting/label_list.jinja:14
msgid "Back to club account"
msgstr "Retour au compte club"
#: accounting/templates/accounting/label_list.jinja:26
msgid "There is no label in this club account."
msgstr "Il n'y a pas d'étiquette dans ce compte club."
#: accounting/templates/accounting/operation_edit.jinja:4
#: accounting/templates/accounting/operation_edit.jinja:13
#: accounting/templates/accounting/operation_edit.jinja:16
msgid "Edit operation"
msgstr "Éditer l'opération"
#: accounting/templates/accounting/operation_edit.jinja:40
#: core/templates/core/create.jinja:12 core/templates/core/edit.jinja:7
#: core/templates/core/edit.jinja.py:15 core/templates/core/edit.jinja:20
#: core/templates/core/file_edit.jinja:8 core/templates/core/page_prop.jinja:8
#: core/templates/core/pagerev_edit.jinja:24
#: core/templates/core/user_godfathers.jinja:35
#: counter/templates/counter/cash_register_summary.jinja:22
#: subscription/templates/subscription/subscription.jinja:23
msgid "Save"
msgstr "Sauver"
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:4
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:15
msgid "Simplified type list"
msgstr "Liste des types simplifiés"
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:10
msgid "Simplified types"
msgstr "Types simplifiés"
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:13
msgid "New simplified type"
msgstr "Nouveau type simplifié"
#: club/models.py:21
msgid "unix name"
msgstr "nom unix"
......@@ -273,11 +574,11 @@ msgstr ""
msgid "A club with that unix name already exists."
msgstr "Un club avec ce nom UNIX existe déjà."
#: club/models.py:33 core/models.py:168
#: club/models.py:33 core/models.py:169
msgid "address"
msgstr "Adresse"
#: club/models.py:39 core/models.py:117
#: club/models.py:39 core/models.py:118
msgid "home"
msgstr "home"
......@@ -289,18 +590,18 @@ msgstr "Vous ne pouvez pas faire de boucles dans les clubs"
msgid "A club with that unix_name already exists"
msgstr "Un club avec ce nom UNIX existe déjà."
#: club/models.py:144 counter/models.py:339 counter/models.py:356
#: club/models.py:144 counter/models.py:378 counter/models.py:395
#: eboutic/models.py:14 eboutic/models.py:47 launderette/models.py:89
#: launderette/models.py:126
msgid "user"
msgstr "nom d'utilisateur"
#: club/models.py:148 core/models.py:135
#: club/models.py:148 core/models.py:136
msgid "role"
msgstr "rôle"
#: club/models.py:150 core/models.py:32 counter/models.py:63
#: counter/models.py:88
#: club/models.py:150 core/models.py:33 counter/models.py:71
#: counter/models.py:96
msgid "description"
msgstr "description"
......@@ -316,9 +617,158 @@ msgstr "L'utilisateur est déjà membre de ce club"
msgid "past member"
msgstr "Anciens membres"
#: club/views.py:31 core/views/user.py:130
msgid "Infos"
msgstr "Infos"
#: club/templates/club/club_list.jinja:4 club/templates/club/club_list.jinja:24
msgid "Club list"
msgstr "Liste des clubs"
#: club/templates/club/club_list.jinja:21
#: core/templates/core/user_tools.jinja:19
msgid "New club"
msgstr "Nouveau club"
#: club/templates/club/club_list.jinja:31
msgid "There is no club in this website."
msgstr "Il n'y a pas de club dans ce site web."
#: club/templates/club/club_members.jinja:5
msgid "Club members"
msgstr "Membres du club"
#: club/templates/club/club_members.jinja:9
#: club/templates/club/club_old_members.jinja:9
#: core/templates/core/user_clubs.jinja:16
#: core/templates/core/user_clubs.jinja:42
msgid "Role"
msgstr "Rôle"
#: club/templates/club/club_members.jinja:10
#: club/templates/club/club_old_members.jinja:10
#: core/templates/core/user_clubs.jinja:17
#: core/templates/core/user_clubs.jinja:43
#, fuzzy
#| msgid "description"
msgid "Description"
msgstr "description"
#: club/templates/club/club_members.jinja:11
#: core/templates/core/user_clubs.jinja:18
#: launderette/templates/launderette/launderette_admin.jinja:45
msgid "Since"
msgstr "Depuis"
#: club/templates/club/club_members.jinja:21
#: core/templates/core/user_clubs.jinja:29
msgid "Mark as old"
msgstr "Marquer comme ancien"
#: club/templates/club/club_members.jinja:30
#: core/templates/core/file_detail.jinja:19 core/views/forms.py:203
#: launderette/views.py:146
msgid "Add"
msgstr "Ajouter"
#: club/templates/club/club_old_members.jinja:5
msgid "Club old members"
msgstr "Anciens membres du club"
#: club/templates/club/club_old_members.jinja:11
#: core/templates/core/user_clubs.jinja:44
msgid "From"
msgstr "Du"
#: club/templates/club/club_old_members.jinja:12
#: core/templates/core/user_clubs.jinja:45
msgid "To"
msgstr "Au"
#: club/templates/club/club_sellings.jinja:5 club/views.py:58
#: counter/templates/counter/counter_main.jinja:19
#: counter/templates/counter/last_ops.jinja:35
msgid "Sellings"
msgstr "Ventes"
#: club/templates/club/club_sellings.jinja:9
#: counter/templates/counter/cash_summary_list.jinja:15
msgid "Show"
msgstr "Montrer"
#: club/templates/club/club_sellings.jinja:12
msgid "Quantity: "
msgstr "Quantité : "
#: club/templates/club/club_sellings.jinja:12
msgid "units"
msgstr "unités"
#: club/templates/club/club_sellings.jinja:13
#: counter/templates/counter/counter_click.jinja:70
#: counter/templates/counter/counter_main.jinja:28
#: eboutic/templates/eboutic/eboutic_main.jinja:34
msgid "Total: "
msgstr "Total : "
#: club/templates/club/club_sellings.jinja:19 club/views.py:165