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
7a267dbc
Commit
7a267dbc
authored
Jul 20, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create the customer when subscribing if it does not exists yet
parent
97ff4341
Pipeline
#59
failed with stage
in 1 minute and 4 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
counter/models.py
counter/models.py
+4
-0
subscription/models.py
subscription/models.py
+6
-6
No files found.
counter/models.py
View file @
7a267dbc
...
...
@@ -5,6 +5,7 @@ from django.conf import settings
from
django.core.urlresolvers
import
reverse
from
datetime
import
timedelta
from
random
import
randrange
from
club.models
import
Club
from
accounting.models
import
CurrencyField
...
...
@@ -27,6 +28,9 @@ class Customer(models.Model):
def
__str__
(
self
):
return
self
.
user
.
username
def
generate_account_id
():
return
randrange
(
0
,
4000
)
# TODO: improve me!
class
ProductType
(
models
.
Model
):
"""
This describes a product type
...
...
subscription/models.py
View file @
7a267dbc
...
...
@@ -35,10 +35,7 @@ class Subscription(models.Model):
# TODO add location!
class
Meta
:
permissions
=
(
(
'change_subscription'
,
'Can make someone become a subscriber'
),
(
'view_subscription'
,
'Can view who is a subscriber'
),
)
ordering
=
[
'subscription_start'
,]
def
clean
(
self
):
try
:
...
...
@@ -50,8 +47,11 @@ class Subscription(models.Model):
# TODO see SubscriptionForm's clean method
raise
ValidationError
(
_
(
"You are trying to create a subscription without member"
))
class
Meta
:
ordering
=
[
'subscription_start'
,]
def
save
(
self
):
super
(
Subscription
,
self
).
save
()
from
counter.models
import
Customer
if
not
Customer
.
objects
.
filter
(
user
=
self
.
member
).
exists
():
Customer
(
user
=
self
.
member
,
account_id
=
Customer
.
generate_account_id
(),
amount
=
0
).
save
()
def
get_absolute_url
(
self
):
return
reverse
(
'core:user_profile'
,
kwargs
=
{
'user_id'
:
self
.
member
.
pk
})
...
...
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