Add location when subscribing

This commit is contained in:
Skia 2016-08-05 00:50:42 +02:00
parent 260a17ae4f
commit aa17c44bcc
4 changed files with 31 additions and 2 deletions

View File

@ -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"),

View 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,
),
]

View File

@ -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:

View File

@ -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