Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
b00fc23f
Commit
b00fc23f
authored
Oct 21, 2016
by
Sli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add automatic mail when an eticket has been bought
parent
3e99f97b
Pipeline
#314
failed with stage
in 4 minutes and 1 second
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2110 additions
and
2449 deletions
+2110
-2449
core/models.py
core/models.py
+3
-0
counter/models.py
counter/models.py
+40
-0
locale/fr/LC_MESSAGES/django.mo
locale/fr/LC_MESSAGES/django.mo
+0
-0
locale/fr/LC_MESSAGES/django.po
locale/fr/LC_MESSAGES/django.po
+2067
-2449
No files found.
core/models.py
View file @
b00fc23f
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
):
...
...
counter/models.py
View file @
b00fc23f
...
...
@@ -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
self
.
save
()
def
get_absolute_url
(
self
):
return
reverse
(
'core:user_account'
,
kwargs
=
{
'user_id'
:
self
.
user
.
pk
})
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):
self
.
customer
.
save
()
super
(
Selling
,
self
).
delete
(
*
args
,
**
kwargs
)
def
send_mail_customer
(
self
):
subject
=
_
(
'Eticket bought for the event %(event)s'
)
%
{
'event'
:
self
.
product
.
name
}
message_html
=
_
(
"You bought an eticket for the event %(event)s.
\n
You can download it on this page %(url)s."
)
%
{
'event'
:
self
.
product
.
name
,
'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.
\n
You can download it on this page %(url)s."
)
%
{
'event'
:
self
.
product
.
name
,
'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 +366,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
):
...
...
locale/fr/LC_MESSAGES/django.mo
View file @
b00fc23f
No preview for this file type
locale/fr/LC_MESSAGES/django.po
View file @
b00fc23f
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment