Views
PAYMENT_METHOD = [('CHECK', _('Check')), ('CASH', _('Cash')), ('CARD', _('Credit card'))]
module-attribute
¶
SelectionDateForm(*args, **kwargs)
¶
Bases: Form
Source code in subscription/forms.py
SubscriptionExistingUserForm(*args, **kwargs)
¶
Bases: SubscriptionForm
Form to add a subscription to an existing user.
Source code in subscription/forms.py
SubscriptionNewUserForm(*args, **kwargs)
¶
Bases: SubscriptionForm
Form to create subscriptions with the user they belong to.
Examples:
```py assert not User.objects.filter(email=request.POST.get("email")).exists() form = SubscriptionNewUserForm(request.POST) if form.is_valid(): form.save()
now the user exists and is subscribed¶
user = User.objects.get(email=request.POST.get("email")) assert user.is_subscribed
Source code in subscription/forms.py
Subscription
¶
Bases: Model
semester_duration: float
property
¶
compute_start(d=None, duration=1, user=None)
staticmethod
¶
Computes the start date of the subscription.
The computation is done with respect to the given date (default is today) and the start date given in settings.SITH_SEMESTER_START_AUTUMN. It takes the nearest past start date. Exemples: with SITH_SEMESTER_START_AUTUMN = (8, 15) Today -> Start date 2015-03-17 -> 2015-02-15 2015-01-11 -> 2014-08-15.
Source code in subscription/models.py
compute_end(duration, start=None, user=None)
staticmethod
¶
Compute the end date of the subscription.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
duration
|
int | float
|
the duration of the subscription, in semester (for example, 2 => 2 semesters => 1 year) |
required |
start
|
date | None
|
The start date of the subscription |
None
|
user
|
User | None
|
the user which is (or will be) subscribed |
None
|
Exemples
Start - Duration -> End date 2015-09-18 - 1 -> 2016-03-18 2015-09-18 - 2 -> 2016-09-18 2015-09-18 - 3 -> 2017-03-18 2015-09-18 - 4 -> 2017-09-18.
Source code in subscription/models.py
CanCreateSubscriptionMixin
¶
Bases: UserPassesTestMixin
NewSubscription
¶
Bases: CanCreateSubscriptionMixin
, TemplateView
CreateSubscriptionFragment
¶
Bases: CanCreateSubscriptionMixin
, CreateView
CreateSubscriptionExistingUserFragment
¶
CreateSubscriptionNewUserFragment
¶
SubscriptionCreatedFragment
¶
Bases: CanCreateSubscriptionMixin
, DetailView
SubscriptionsStatsView
¶
Bases: FormView