Commit aa17c44b authored by Skia's avatar Skia
Browse files

Add location when subscribing

parent 260a17ae
Pipeline #86 passed with stage
in 2 minutes and 38 seconds
...@@ -257,6 +257,12 @@ SITH_SUBSCRIPTION_PAYMENT_METHOD = [ ...@@ -257,6 +257,12 @@ SITH_SUBSCRIPTION_PAYMENT_METHOD = [
('other', _('Other')), ('other', _('Other')),
] ]
SITH_SUBSCRIPTION_LOCATIONS = [
('BELFORT', _('Belfort')),
('SEVENANS', _('Sevenans')),
('MONTBELIARD', _('Montbéliard')),
]
SITH_COUNTER_BARS = [ SITH_COUNTER_BARS = [
(1, "Foyer"), (1, "Foyer"),
(2, "MDE"), (2, "MDE"),
......
# -*- 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): ...@@ -32,6 +32,8 @@ class Subscription(models.Model):
subscription_start = models.DateField(_('subscription start')) subscription_start = models.DateField(_('subscription start'))
subscription_end = models.DateField(_('subscription end')) subscription_end = models.DateField(_('subscription end'))
payment_method = models.CharField(_('payment method'), max_length=255, choices=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD) 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! # TODO add location!
class Meta: class Meta:
......
...@@ -19,7 +19,7 @@ def get_subscriber(user): ...@@ -19,7 +19,7 @@ def get_subscriber(user):
class SubscriptionForm(forms.ModelForm): class SubscriptionForm(forms.ModelForm):
class Meta: class Meta:
model = Subscription model = Subscription
fields = ['member', 'subscription_type', 'payment_method'] fields = ['member', 'subscription_type', 'payment_method', 'location']
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(SubscriptionForm, self).__init__(*args, **kwargs) super(SubscriptionForm, self).__init__(*args, **kwargs)
...@@ -29,6 +29,7 @@ class SubscriptionForm(forms.ModelForm): ...@@ -29,6 +29,7 @@ class SubscriptionForm(forms.ModelForm):
self.fields['email'] = forms.EmailField() self.fields['email'] = forms.EmailField()
self.fields.move_to_end('subscription_type') self.fields.move_to_end('subscription_type')
self.fields.move_to_end('payment_method') self.fields.move_to_end('payment_method')
self.fields.move_to_end('location')
def clean(self): def clean(self):
cleaned_data = super(SubscriptionForm, self).clean() cleaned_data = super(SubscriptionForm, self).clean()
...@@ -56,7 +57,7 @@ class SubscriptionForm(forms.ModelForm): ...@@ -56,7 +57,7 @@ class SubscriptionForm(forms.ModelForm):
raise ValidationError(_("You must either choose an existing user or create a new one properly")) raise ValidationError(_("You must either choose an existing user or create a new one properly"))
return cleaned_data 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' template_name = 'subscription/subscription.jinja'
form_class = SubscriptionForm form_class = SubscriptionForm
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment