mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Add location when subscribing
This commit is contained in:
parent
260a17ae4f
commit
aa17c44bcc
@ -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"),
|
||||
|
20
subscription/migrations/0003_subscription_location.py
Normal file
20
subscription/migrations/0003_subscription_location.py
Normal file
@ -0,0 +1,20 @@
|
||||
# -*- 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,
|
||||
),
|
||||
]
|
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user