Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
aa17c44b
Commit
aa17c44b
authored
Aug 05, 2016
by
Skia
🤘
Browse files
Add location when subscribing
parent
260a17ae
Pipeline
#86
passed with stage
in 2 minutes and 38 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
sith/settings_sample.py
View file @
aa17c44b
...
...
@@ -257,6 +257,12 @@ SITH_SUBSCRIPTION_PAYMENT_METHOD = [
(
'other'
,
_
(
'Other'
)),
]
SITH_SUBSCRIPTION_LOCATIONS
=
[
(
'BELFORT'
,
_
(
'Belfort'
)),
(
'SEVENANS'
,
_
(
'Sevenans'
)),
(
'MONTBELIARD'
,
_
(
'Montbéliard'
)),
]
SITH_COUNTER_BARS
=
[
(
1
,
"Foyer"
),
(
2
,
"MDE"
),
...
...
subscription/migrations/0003_subscription_location.py
0 → 100644
View file @
aa17c44b
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'subscription'
,
'0002_auto_20160718_1805'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'subscription'
,
name
=
'location'
,
field
=
models
.
CharField
(
max_length
=
20
,
verbose_name
=
'location'
,
choices
=
[(
'BELFORT'
,
'Belfort'
),
(
'SEVENANS'
,
'Sevenans'
),
(
'MONTBELIARD'
,
'Montbéliard'
)],
default
=
'BELFORT'
),
preserve_default
=
False
,
),
]
subscription/models.py
View file @
aa17c44b
...
...
@@ -32,6 +32,8 @@ class Subscription(models.Model):
subscription_start
=
models
.
DateField
(
_
(
'subscription start'
))
subscription_end
=
models
.
DateField
(
_
(
'subscription end'
))
payment_method
=
models
.
CharField
(
_
(
'payment method'
),
max_length
=
255
,
choices
=
settings
.
SITH_SUBSCRIPTION_PAYMENT_METHOD
)
location
=
models
.
CharField
(
choices
=
settings
.
SITH_SUBSCRIPTION_LOCATIONS
,
max_length
=
20
,
verbose_name
=
_
(
'location'
))
# TODO add location!
class
Meta
:
...
...
subscription/views.py
View file @
aa17c44b
...
...
@@ -19,7 +19,7 @@ def get_subscriber(user):
class
SubscriptionForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Subscription
fields
=
[
'member'
,
'subscription_type'
,
'payment_method'
]
fields
=
[
'member'
,
'subscription_type'
,
'payment_method'
,
'location'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
SubscriptionForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -29,6 +29,7 @@ class SubscriptionForm(forms.ModelForm):
self
.
fields
[
'email'
]
=
forms
.
EmailField
()
self
.
fields
.
move_to_end
(
'subscription_type'
)
self
.
fields
.
move_to_end
(
'payment_method'
)
self
.
fields
.
move_to_end
(
'location'
)
def
clean
(
self
):
cleaned_data
=
super
(
SubscriptionForm
,
self
).
clean
()
...
...
@@ -56,7 +57,7 @@ class SubscriptionForm(forms.ModelForm):
raise
ValidationError
(
_
(
"You must either choose an existing user or create a new one properly"
))
return
cleaned_data
class
NewSubscription
(
CanEditMixin
,
CreateView
):
# TODO: this must be able to create a new user if needed
class
NewSubscription
(
CanEditMixin
,
CreateView
):
template_name
=
'subscription/subscription.jinja'
form_class
=
SubscriptionForm
...
...
Write
Preview
Supports
Markdown
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