forked from DGNum/gestioCOF
Merge branch 'master' into Aufinal/annul_reventes
This commit is contained in:
commit
1f350d60dd
214 changed files with 12511 additions and 8004 deletions
|
@ -1 +0,0 @@
|
|||
|
183
bda/admin.py
183
bda/admin.py
|
@ -1,18 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import timedelta
|
||||
from custommail.shortcuts import send_mass_custom_mail
|
||||
|
||||
from custommail.shortcuts import send_mass_custom_mail
|
||||
from dal.autocomplete import ModelSelect2
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.db.models import Sum, Count
|
||||
from django.db.models import Count, Sum
|
||||
from django.template.defaultfilters import pluralize
|
||||
from django.utils import timezone
|
||||
from django import forms
|
||||
|
||||
from dal.autocomplete import ModelSelect2
|
||||
|
||||
from bda.models import Spectacle, Salle, Participant, ChoixSpectacle,\
|
||||
Attribution, Tirage, Quote, CategorieSpectacle, SpectacleRevente
|
||||
from bda.models import (
|
||||
Attribution,
|
||||
CategorieSpectacle,
|
||||
ChoixSpectacle,
|
||||
Participant,
|
||||
Quote,
|
||||
Salle,
|
||||
Spectacle,
|
||||
SpectacleRevente,
|
||||
Tirage,
|
||||
)
|
||||
|
||||
|
||||
class ReadOnlyMixin(object):
|
||||
|
@ -29,8 +35,8 @@ class ReadOnlyMixin(object):
|
|||
class ChoixSpectacleAdminForm(forms.ModelForm):
|
||||
class Meta:
|
||||
widgets = {
|
||||
'participant': ModelSelect2(url='bda-participant-autocomplete'),
|
||||
'spectacle': ModelSelect2(url='bda-spectacle-autocomplete'),
|
||||
"participant": ModelSelect2(url="bda-participant-autocomplete"),
|
||||
"spectacle": ModelSelect2(url="bda-spectacle-autocomplete"),
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,10 +51,10 @@ class AttributionTabularAdminForm(forms.ModelForm):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
spectacles = Spectacle.objects.select_related('location')
|
||||
spectacles = Spectacle.objects.select_related("location")
|
||||
if self.listing is not None:
|
||||
spectacles = spectacles.filter(listing=self.listing)
|
||||
self.fields['spectacle'].queryset = spectacles
|
||||
self.fields["spectacle"].queryset = spectacles
|
||||
|
||||
|
||||
class WithoutListingAttributionTabularAdminForm(AttributionTabularAdminForm):
|
||||
|
@ -72,7 +78,7 @@ class AttributionInline(admin.TabularInline):
|
|||
|
||||
|
||||
class WithListingAttributionInline(AttributionInline):
|
||||
exclude = ('given', )
|
||||
exclude = ("given",)
|
||||
form = WithListingAttributionTabularAdminForm
|
||||
listing = True
|
||||
|
||||
|
@ -83,12 +89,10 @@ class WithoutListingAttributionInline(AttributionInline):
|
|||
|
||||
|
||||
class ParticipantAdminForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['choicesrevente'].queryset = (
|
||||
Spectacle.objects
|
||||
.select_related('location')
|
||||
self.fields["choicesrevente"].queryset = Spectacle.objects.select_related(
|
||||
"location"
|
||||
)
|
||||
|
||||
|
||||
|
@ -96,11 +100,13 @@ class ParticipantAdmin(ReadOnlyMixin, admin.ModelAdmin):
|
|||
inlines = [WithListingAttributionInline, WithoutListingAttributionInline]
|
||||
|
||||
def get_queryset(self, request):
|
||||
return Participant.objects.annotate(nb_places=Count('attributions'),
|
||||
total=Sum('attributions__price'))
|
||||
return Participant.objects.annotate(
|
||||
nb_places=Count("attributions"), total=Sum("attributions__price")
|
||||
)
|
||||
|
||||
def nb_places(self, obj):
|
||||
return obj.nb_places
|
||||
|
||||
nb_places.admin_order_field = "nb_places"
|
||||
nb_places.short_description = "Nombre de places"
|
||||
|
||||
|
@ -110,33 +116,32 @@ class ParticipantAdmin(ReadOnlyMixin, admin.ModelAdmin):
|
|||
return "%.02f €" % tot
|
||||
else:
|
||||
return "0 €"
|
||||
|
||||
total.admin_order_field = "total"
|
||||
total.short_description = "Total à payer"
|
||||
list_display = ("user", "nb_places", "total", "paid", "paymenttype",
|
||||
"tirage")
|
||||
list_display = ("user", "nb_places", "total", "paid", "paymenttype", "tirage")
|
||||
list_filter = ("paid", "tirage")
|
||||
search_fields = ('user__username', 'user__first_name', 'user__last_name')
|
||||
actions = ['send_attribs', ]
|
||||
search_fields = ("user__username", "user__first_name", "user__last_name")
|
||||
actions = ["send_attribs"]
|
||||
actions_on_bottom = True
|
||||
list_per_page = 400
|
||||
readonly_fields = ("total",)
|
||||
readonly_fields_update = ('user', 'tirage')
|
||||
readonly_fields_update = ("user", "tirage")
|
||||
form = ParticipantAdminForm
|
||||
|
||||
def send_attribs(self, request, queryset):
|
||||
datatuple = []
|
||||
for member in queryset.all():
|
||||
attribs = member.attributions.all()
|
||||
context = {'member': member.user}
|
||||
context = {"member": member.user}
|
||||
shortname = ""
|
||||
if len(attribs) == 0:
|
||||
shortname = "bda-attributions-decus"
|
||||
else:
|
||||
shortname = "bda-attributions"
|
||||
context['places'] = attribs
|
||||
context["places"] = attribs
|
||||
print(context)
|
||||
datatuple.append((shortname, context, "bda@ens.fr",
|
||||
[member.user.email]))
|
||||
datatuple.append((shortname, context, "bda@ens.fr", [member.user.email]))
|
||||
send_mass_custom_mail(datatuple)
|
||||
count = len(queryset.all())
|
||||
if count == 1:
|
||||
|
@ -145,49 +150,53 @@ class ParticipantAdmin(ReadOnlyMixin, admin.ModelAdmin):
|
|||
else:
|
||||
message_bit = "%d membres ont" % count
|
||||
plural = "s"
|
||||
self.message_user(request, "%s été informé%s avec succès."
|
||||
% (message_bit, plural))
|
||||
self.message_user(
|
||||
request, "%s été informé%s avec succès." % (message_bit, plural)
|
||||
)
|
||||
|
||||
send_attribs.short_description = "Envoyer les résultats par mail"
|
||||
|
||||
|
||||
class AttributionAdminForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if 'spectacle' in self.fields:
|
||||
self.fields['spectacle'].queryset = (
|
||||
Spectacle.objects
|
||||
.select_related('location')
|
||||
if "spectacle" in self.fields:
|
||||
self.fields["spectacle"].queryset = Spectacle.objects.select_related(
|
||||
"location"
|
||||
)
|
||||
if 'participant' in self.fields:
|
||||
self.fields['participant'].queryset = (
|
||||
Participant.objects
|
||||
.select_related('user', 'tirage')
|
||||
if "participant" in self.fields:
|
||||
self.fields["participant"].queryset = Participant.objects.select_related(
|
||||
"user", "tirage"
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(AttributionAdminForm, self).clean()
|
||||
cleaned_data = super().clean()
|
||||
participant = cleaned_data.get("participant")
|
||||
spectacle = cleaned_data.get("spectacle")
|
||||
if participant and spectacle:
|
||||
if participant.tirage != spectacle.tirage:
|
||||
raise forms.ValidationError(
|
||||
"Erreur : le participant et le spectacle n'appartiennent"
|
||||
"pas au même tirage")
|
||||
"pas au même tirage"
|
||||
)
|
||||
return cleaned_data
|
||||
|
||||
|
||||
class AttributionAdmin(ReadOnlyMixin, admin.ModelAdmin):
|
||||
def paid(self, obj):
|
||||
return obj.participant.paid
|
||||
paid.short_description = 'A payé'
|
||||
|
||||
paid.short_description = "A payé"
|
||||
paid.boolean = True
|
||||
list_display = ("id", "spectacle", "participant", "given", "paid")
|
||||
search_fields = ('spectacle__title', 'participant__user__username',
|
||||
'participant__user__first_name',
|
||||
'participant__user__last_name')
|
||||
search_fields = (
|
||||
"spectacle__title",
|
||||
"participant__user__username",
|
||||
"participant__user__first_name",
|
||||
"participant__user__last_name",
|
||||
)
|
||||
form = AttributionAdminForm
|
||||
readonly_fields_update = ('spectacle', 'participant')
|
||||
readonly_fields_update = ("spectacle", "participant")
|
||||
|
||||
|
||||
class ChoixSpectacleAdmin(admin.ModelAdmin):
|
||||
|
@ -195,13 +204,15 @@ class ChoixSpectacleAdmin(admin.ModelAdmin):
|
|||
|
||||
def tirage(self, obj):
|
||||
return obj.participant.tirage
|
||||
list_display = ("participant", "tirage", "spectacle", "priority",
|
||||
"double_choice")
|
||||
|
||||
list_display = ("participant", "tirage", "spectacle", "priority", "double_choice")
|
||||
list_filter = ("double_choice", "participant__tirage")
|
||||
search_fields = ('participant__user__username',
|
||||
'participant__user__first_name',
|
||||
'participant__user__last_name',
|
||||
'spectacle__title')
|
||||
search_fields = (
|
||||
"participant__user__username",
|
||||
"participant__user__first_name",
|
||||
"participant__user__last_name",
|
||||
"spectacle__title",
|
||||
)
|
||||
|
||||
|
||||
class QuoteInline(admin.TabularInline):
|
||||
|
@ -211,42 +222,36 @@ class QuoteInline(admin.TabularInline):
|
|||
class SpectacleAdmin(admin.ModelAdmin):
|
||||
inlines = [QuoteInline]
|
||||
model = Spectacle
|
||||
list_display = ("title", "date", "tirage", "location", "slots", "price",
|
||||
"listing")
|
||||
list_filter = ("location", "tirage",)
|
||||
list_display = ("title", "date", "tirage", "location", "slots", "price", "listing")
|
||||
list_filter = ("location", "tirage")
|
||||
search_fields = ("title", "location__name")
|
||||
readonly_fields = ("rappel_sent", )
|
||||
readonly_fields = ("rappel_sent",)
|
||||
|
||||
|
||||
class TirageAdmin(admin.ModelAdmin):
|
||||
model = Tirage
|
||||
list_display = ("title", "ouverture", "fermeture", "active",
|
||||
"enable_do_tirage")
|
||||
readonly_fields = ("tokens", )
|
||||
list_filter = ("active", )
|
||||
search_fields = ("title", )
|
||||
list_display = ("title", "ouverture", "fermeture", "active", "enable_do_tirage")
|
||||
readonly_fields = ("tokens",)
|
||||
list_filter = ("active",)
|
||||
search_fields = ("title",)
|
||||
|
||||
|
||||
class SalleAdmin(admin.ModelAdmin):
|
||||
model = Salle
|
||||
search_fields = ('name', 'address')
|
||||
search_fields = ("name", "address")
|
||||
|
||||
|
||||
class SpectacleReventeAdminForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['confirmed_entry'].queryset = (
|
||||
Participant.objects
|
||||
.select_related('user', 'tirage')
|
||||
self.fields["confirmed_entry"].queryset = Participant.objects.select_related(
|
||||
"user", "tirage"
|
||||
)
|
||||
self.fields['seller'].queryset = (
|
||||
Participant.objects
|
||||
.select_related('user', 'tirage')
|
||||
self.fields["seller"].queryset = Participant.objects.select_related(
|
||||
"user", "tirage"
|
||||
)
|
||||
self.fields['soldTo'].queryset = (
|
||||
Participant.objects
|
||||
.select_related('user', 'tirage')
|
||||
self.fields["soldTo"].queryset = Participant.objects.select_related(
|
||||
"user", "tirage"
|
||||
)
|
||||
|
||||
|
||||
|
@ -254,6 +259,7 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
|
|||
"""
|
||||
Administration des reventes de spectacles
|
||||
"""
|
||||
|
||||
model = SpectacleRevente
|
||||
|
||||
def spectacle(self, obj):
|
||||
|
@ -265,12 +271,14 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
|
|||
list_display = ("spectacle", "seller", "date", "soldTo")
|
||||
raw_id_fields = ("attribution",)
|
||||
readonly_fields = ("date_tirage",)
|
||||
search_fields = ['attribution__spectacle__title',
|
||||
'seller__user__username',
|
||||
'seller__user__first_name',
|
||||
'seller__user__last_name']
|
||||
search_fields = [
|
||||
"attribution__spectacle__title",
|
||||
"seller__user__username",
|
||||
"seller__user__first_name",
|
||||
"seller__user__last_name",
|
||||
]
|
||||
|
||||
actions = ['transfer', 'reinit']
|
||||
actions = ["transfer", "reinit"]
|
||||
actions_on_bottom = True
|
||||
form = SpectacleReventeAdminForm
|
||||
|
||||
|
@ -286,10 +294,10 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
|
|||
attrib.save()
|
||||
self.message_user(
|
||||
request,
|
||||
"%d attribution%s %s été transférée%s avec succès." % (
|
||||
count, pluralize(count),
|
||||
pluralize(count, "a,ont"), pluralize(count))
|
||||
)
|
||||
"%d attribution%s %s été transférée%s avec succès."
|
||||
% (count, pluralize(count), pluralize(count, "a,ont"), pluralize(count)),
|
||||
)
|
||||
|
||||
transfer.short_description = "Transférer les reventes sélectionnées"
|
||||
|
||||
def reinit(self, request, queryset):
|
||||
|
@ -298,14 +306,15 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
|
|||
"""
|
||||
count = queryset.count()
|
||||
for revente in queryset.filter(
|
||||
attribution__spectacle__date__gte=timezone.now()):
|
||||
attribution__spectacle__date__gte=timezone.now()
|
||||
):
|
||||
revente.reset(new_date=timezone.now() - timedelta(hours=1))
|
||||
self.message_user(
|
||||
request,
|
||||
"%d attribution%s %s été réinitialisée%s avec succès." % (
|
||||
count, pluralize(count),
|
||||
pluralize(count, "a,ont"), pluralize(count))
|
||||
)
|
||||
"%d attribution%s %s été réinitialisée%s avec succès."
|
||||
% (count, pluralize(count), pluralize(count, "a,ont"), pluralize(count)),
|
||||
)
|
||||
|
||||
reinit.short_description = "Réinitialiser les reventes sélectionnées"
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db.models import Max
|
||||
|
||||
import random
|
||||
|
||||
|
||||
|
@ -22,7 +14,7 @@ class Algorithm(object):
|
|||
show.requests
|
||||
- on crée des tables de demandes pour chaque personne, afin de
|
||||
pouvoir modifier les rankings"""
|
||||
self.max_group = 2*max(choice.priority for choice in choices)
|
||||
self.max_group = 2 * max(choice.priority for choice in choices)
|
||||
self.shows = []
|
||||
showdict = {}
|
||||
for show in shows:
|
||||
|
@ -60,16 +52,19 @@ class Algorithm(object):
|
|||
self.ranks[member][show] -= increment
|
||||
|
||||
def appendResult(self, l, member, show):
|
||||
l.append((member,
|
||||
self.ranks[member][show],
|
||||
self.origranks[member][show],
|
||||
self.choices[member][show].double))
|
||||
l.append(
|
||||
(
|
||||
member,
|
||||
self.ranks[member][show],
|
||||
self.origranks[member][show],
|
||||
self.choices[member][show].double,
|
||||
)
|
||||
)
|
||||
|
||||
def __call__(self, seed):
|
||||
random.seed(seed)
|
||||
results = []
|
||||
shows = sorted(self.shows, key=lambda x: x.nrequests / x.slots,
|
||||
reverse=True)
|
||||
shows = sorted(self.shows, key=lambda x: x.nrequests / x.slots, reverse=True)
|
||||
for show in shows:
|
||||
# On regroupe tous les gens ayant le même rang
|
||||
groups = dict([(i, []) for i in range(1, self.max_group + 1)])
|
||||
|
@ -88,8 +83,10 @@ class Algorithm(object):
|
|||
if len(winners) + 1 < show.slots:
|
||||
self.appendResult(winners, member, show)
|
||||
self.appendResult(winners, member, show)
|
||||
elif not self.choices[member][show].autoquit \
|
||||
and len(winners) < show.slots:
|
||||
elif (
|
||||
not self.choices[member][show].autoquit
|
||||
and len(winners) < show.slots
|
||||
):
|
||||
self.appendResult(winners, member, show)
|
||||
self.appendResult(losers, member, show)
|
||||
else:
|
||||
|
|
151
bda/forms.py
151
bda/forms.py
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django import forms
|
||||
from django.forms.models import BaseInlineFormSet
|
||||
from django.utils import timezone
|
||||
|
@ -8,7 +6,6 @@ from bda.models import Attribution, Spectacle, SpectacleRevente
|
|||
|
||||
|
||||
class InscriptionInlineFormSet(BaseInlineFormSet):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
@ -18,9 +15,9 @@ class InscriptionInlineFormSet(BaseInlineFormSet):
|
|||
# set once for all "spectacle" field choices
|
||||
# - restrict choices to the spectacles of this tirage
|
||||
# - force_choices avoid many db requests
|
||||
spectacles = tirage.spectacle_set.select_related('location')
|
||||
spectacles = tirage.spectacle_set.select_related("location")
|
||||
choices = [(sp.pk, str(sp)) for sp in spectacles]
|
||||
self.force_choices('spectacle', choices)
|
||||
self.force_choices("spectacle", choices)
|
||||
|
||||
def force_choices(self, name, choices):
|
||||
"""Set choices of a field.
|
||||
|
@ -32,7 +29,7 @@ class InscriptionInlineFormSet(BaseInlineFormSet):
|
|||
for form in self.forms:
|
||||
field = form.fields[name]
|
||||
if field.empty_label is not None:
|
||||
field.choices = [('', field.empty_label)] + choices
|
||||
field.choices = [("", field.empty_label)] + choices
|
||||
else:
|
||||
field.choices = choices
|
||||
|
||||
|
@ -58,9 +55,9 @@ class ReventeModelMultipleChoiceField(forms.ModelMultipleChoiceField):
|
|||
# C'est notre propre revente : informations sur le statut
|
||||
if obj.soldTo is not None:
|
||||
suffix = " -- Vendue à {firstname} {lastname}".format(
|
||||
firstname=obj.soldTo.user.first_name,
|
||||
lastname=obj.soldTo.user.last_name,
|
||||
)
|
||||
firstname=obj.soldTo.user.first_name,
|
||||
lastname=obj.soldTo.user.last_name,
|
||||
)
|
||||
elif obj.shotgun:
|
||||
suffix = " -- Tirage infructueux"
|
||||
elif obj.notif_sent:
|
||||
|
@ -68,119 +65,115 @@ class ReventeModelMultipleChoiceField(forms.ModelMultipleChoiceField):
|
|||
else:
|
||||
# Ce n'est pas à nous : on ne voit jamais l'acheteur
|
||||
suffix = " -- Vendue par {firstname} {lastname}".format(
|
||||
firstname=obj.seller.user.first_name,
|
||||
lastname=obj.seller.user.last_name,
|
||||
)
|
||||
firstname=obj.seller.user.first_name, lastname=obj.seller.user.last_name
|
||||
)
|
||||
|
||||
return label.format(show=str(obj.attribution.spectacle),
|
||||
suffix=suffix)
|
||||
return label.format(show=str(obj.attribution.spectacle), suffix=suffix)
|
||||
|
||||
|
||||
class ResellForm(forms.Form):
|
||||
attributions = AttributionModelMultipleChoiceField(
|
||||
label='',
|
||||
queryset=Attribution.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False)
|
||||
label="",
|
||||
queryset=Attribution.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False,
|
||||
)
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
super(ResellForm, self).__init__(*args, **kwargs)
|
||||
self.fields['attributions'].queryset = (
|
||||
participant.attribution_set
|
||||
.filter(spectacle__date__gte=timezone.now())
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["attributions"].queryset = (
|
||||
participant.attribution_set.filter(spectacle__date__gte=timezone.now())
|
||||
.exclude(revente__seller=participant)
|
||||
.select_related('spectacle', 'spectacle__location',
|
||||
'participant__user')
|
||||
.select_related("spectacle", "spectacle__location", "participant__user")
|
||||
)
|
||||
|
||||
|
||||
class AnnulForm(forms.Form):
|
||||
reventes = ReventeModelMultipleChoiceField(
|
||||
own=True,
|
||||
label='',
|
||||
queryset=Attribution.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False)
|
||||
own=True,
|
||||
label="",
|
||||
queryset=Attribution.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False,
|
||||
)
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
super(AnnulForm, self).__init__(*args, **kwargs)
|
||||
self.fields['reventes'].queryset = (
|
||||
participant.original_shows
|
||||
.filter(attribution__spectacle__date__gte=timezone.now(),
|
||||
soldTo__isnull=True)
|
||||
.select_related('attribution__spectacle',
|
||||
'attribution__spectacle__location')
|
||||
.order_by('-date')
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["reventes"].queryset = (
|
||||
participant.original_shows.filter(
|
||||
attribution__spectacle__date__gte=timezone.now(), soldTo__isnull=True
|
||||
)
|
||||
.select_related(
|
||||
"attribution__spectacle", "attribution__spectacle__location"
|
||||
)
|
||||
.order_by("-date")
|
||||
)
|
||||
|
||||
|
||||
class InscriptionReventeForm(forms.Form):
|
||||
spectacles = forms.ModelMultipleChoiceField(
|
||||
queryset=Spectacle.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False)
|
||||
queryset=Spectacle.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False,
|
||||
)
|
||||
|
||||
def __init__(self, tirage, *args, **kwargs):
|
||||
super(InscriptionReventeForm, self).__init__(*args, **kwargs)
|
||||
self.fields['spectacles'].queryset = (
|
||||
tirage.spectacle_set
|
||||
.select_related('location')
|
||||
.filter(date__gte=timezone.now())
|
||||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["spectacles"].queryset = tirage.spectacle_set.select_related(
|
||||
"location"
|
||||
).filter(date__gte=timezone.now())
|
||||
|
||||
|
||||
class ReventeTirageAnnulForm(forms.Form):
|
||||
reventes = ReventeModelMultipleChoiceField(
|
||||
own=False,
|
||||
label='',
|
||||
queryset=SpectacleRevente.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False
|
||||
)
|
||||
own=False,
|
||||
label="",
|
||||
queryset=SpectacleRevente.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False,
|
||||
)
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['reventes'].queryset = (
|
||||
participant.entered.filter(soldTo__isnull=True)
|
||||
.select_related('attribution__spectacle',
|
||||
'seller__user')
|
||||
)
|
||||
self.fields["reventes"].queryset = participant.entered.filter(
|
||||
soldTo__isnull=True
|
||||
).select_related("attribution__spectacle", "seller__user")
|
||||
|
||||
|
||||
class ReventeTirageForm(forms.Form):
|
||||
reventes = ReventeModelMultipleChoiceField(
|
||||
own=False,
|
||||
label='',
|
||||
queryset=SpectacleRevente.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False
|
||||
)
|
||||
own=False,
|
||||
label="",
|
||||
queryset=SpectacleRevente.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False,
|
||||
)
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['reventes'].queryset = (
|
||||
self.fields["reventes"].queryset = (
|
||||
SpectacleRevente.objects.filter(
|
||||
notif_sent=True,
|
||||
shotgun=False,
|
||||
tirage_done=False
|
||||
).exclude(confirmed_entry=participant)
|
||||
.select_related('attribution__spectacle')
|
||||
notif_sent=True, shotgun=False, tirage_done=False
|
||||
)
|
||||
.exclude(confirmed_entry=participant)
|
||||
.select_related("attribution__spectacle")
|
||||
)
|
||||
|
||||
|
||||
class SoldForm(forms.Form):
|
||||
reventes = ReventeModelMultipleChoiceField(
|
||||
own=True,
|
||||
label='',
|
||||
queryset=Attribution.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple)
|
||||
own=True,
|
||||
label="",
|
||||
queryset=Attribution.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
)
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
super(SoldForm, self).__init__(*args, **kwargs)
|
||||
self.fields['reventes'].queryset = (
|
||||
participant.original_shows
|
||||
.filter(soldTo__isnull=False)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["reventes"].queryset = (
|
||||
participant.original_shows.filter(soldTo__isnull=False)
|
||||
.exclude(soldTo=participant)
|
||||
.select_related('attribution__spectacle',
|
||||
'attribution__spectacle__location')
|
||||
.select_related(
|
||||
"attribution__spectacle", "attribution__spectacle__location"
|
||||
)
|
||||
)
|
||||
|
|
|
@ -5,17 +5,15 @@ Crée deux tirages de test et y inscrit les utilisateurs
|
|||
import os
|
||||
import random
|
||||
|
||||
from django.utils import timezone
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils import timezone
|
||||
|
||||
from gestioncof.management.base import MyBaseCommand
|
||||
from bda.models import Tirage, Spectacle, Salle, Participant, ChoixSpectacle
|
||||
from bda.models import ChoixSpectacle, Participant, Salle, Spectacle, Tirage
|
||||
from bda.views import do_tirage
|
||||
|
||||
from gestioncof.management.base import MyBaseCommand
|
||||
|
||||
# Où sont stockés les fichiers json
|
||||
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)),
|
||||
'data')
|
||||
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")
|
||||
|
||||
|
||||
class Command(MyBaseCommand):
|
||||
|
@ -27,27 +25,29 @@ class Command(MyBaseCommand):
|
|||
# ---
|
||||
|
||||
Tirage.objects.all().delete()
|
||||
Tirage.objects.bulk_create([
|
||||
Tirage(
|
||||
title="Tirage de test 1",
|
||||
ouverture=timezone.now()-timezone.timedelta(days=7),
|
||||
fermeture=timezone.now(),
|
||||
active=True
|
||||
),
|
||||
Tirage(
|
||||
title="Tirage de test 2",
|
||||
ouverture=timezone.now(),
|
||||
fermeture=timezone.now()+timezone.timedelta(days=60),
|
||||
active=True
|
||||
)
|
||||
])
|
||||
Tirage.objects.bulk_create(
|
||||
[
|
||||
Tirage(
|
||||
title="Tirage de test 1",
|
||||
ouverture=timezone.now() - timezone.timedelta(days=7),
|
||||
fermeture=timezone.now(),
|
||||
active=True,
|
||||
),
|
||||
Tirage(
|
||||
title="Tirage de test 2",
|
||||
ouverture=timezone.now(),
|
||||
fermeture=timezone.now() + timezone.timedelta(days=60),
|
||||
active=True,
|
||||
),
|
||||
]
|
||||
)
|
||||
tirages = Tirage.objects.all()
|
||||
|
||||
# ---
|
||||
# Salles
|
||||
# ---
|
||||
|
||||
locations = self.from_json('locations.json', DATA_DIR, Salle)
|
||||
locations = self.from_json("locations.json", DATA_DIR, Salle)
|
||||
|
||||
# ---
|
||||
# Spectacles
|
||||
|
@ -60,15 +60,13 @@ class Command(MyBaseCommand):
|
|||
"""
|
||||
show.tirage = random.choice(tirages)
|
||||
show.listing = bool(random.randint(0, 1))
|
||||
show.date = (
|
||||
show.tirage.fermeture
|
||||
+ timezone.timedelta(days=random.randint(60, 90))
|
||||
show.date = show.tirage.fermeture + timezone.timedelta(
|
||||
days=random.randint(60, 90)
|
||||
)
|
||||
show.location = random.choice(locations)
|
||||
return show
|
||||
shows = self.from_json(
|
||||
'shows.json', DATA_DIR, Spectacle, show_callback
|
||||
)
|
||||
|
||||
shows = self.from_json("shows.json", DATA_DIR, Spectacle, show_callback)
|
||||
|
||||
# ---
|
||||
# Inscriptions
|
||||
|
@ -79,23 +77,19 @@ class Command(MyBaseCommand):
|
|||
choices = []
|
||||
for user in User.objects.filter(profile__is_cof=True):
|
||||
for tirage in tirages:
|
||||
part, _ = Participant.objects.get_or_create(
|
||||
user=user,
|
||||
tirage=tirage
|
||||
)
|
||||
part, _ = Participant.objects.get_or_create(user=user, tirage=tirage)
|
||||
shows = random.sample(
|
||||
list(tirage.spectacle_set.all()),
|
||||
tirage.spectacle_set.count() // 2
|
||||
list(tirage.spectacle_set.all()), tirage.spectacle_set.count() // 2
|
||||
)
|
||||
for (rank, show) in enumerate(shows):
|
||||
choices.append(ChoixSpectacle(
|
||||
participant=part,
|
||||
spectacle=show,
|
||||
priority=rank + 1,
|
||||
double_choice=random.choice(
|
||||
['1', 'double', 'autoquit']
|
||||
choices.append(
|
||||
ChoixSpectacle(
|
||||
participant=part,
|
||||
spectacle=show,
|
||||
priority=rank + 1,
|
||||
double_choice=random.choice(["1", "double", "autoquit"]),
|
||||
)
|
||||
))
|
||||
)
|
||||
ChoixSpectacle.objects.bulk_create(choices)
|
||||
self.stdout.write("- {:d} inscriptions générées".format(len(choices)))
|
||||
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Gestion en ligne de commande des reventes.
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.management import BaseCommand
|
||||
from django.utils import timezone
|
||||
|
||||
from bda.models import SpectacleRevente
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Envoie les mails de notification et effectue " \
|
||||
"les tirages au sort des reventes"
|
||||
help = (
|
||||
"Envoie les mails de notification et effectue les tirages au sort des reventes"
|
||||
)
|
||||
leave_locale_alone = True
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
@ -32,22 +30,18 @@ class Command(BaseCommand):
|
|||
)
|
||||
|
||||
# Le spectacle est dans plus longtemps : on prévient
|
||||
elif (revente.can_notif and not revente.notif_sent):
|
||||
elif revente.can_notif and not revente.notif_sent:
|
||||
self.stdout.write(str(now))
|
||||
revente.send_notif()
|
||||
self.stdout.write(
|
||||
"Mails d'inscription à la revente [%s] envoyés"
|
||||
% revente
|
||||
"Mails d'inscription à la revente [%s] envoyés" % revente
|
||||
)
|
||||
|
||||
# On fait le tirage
|
||||
elif (now >= revente.date_tirage and not revente.tirage_done):
|
||||
elif now >= revente.date_tirage and not revente.tirage_done:
|
||||
self.stdout.write(str(now))
|
||||
winner = revente.tirage()
|
||||
self.stdout.write(
|
||||
"Tirage effectué pour la revente [%s]"
|
||||
% revente
|
||||
)
|
||||
self.stdout.write("Tirage effectué pour la revente [%s]" % revente)
|
||||
|
||||
if winner:
|
||||
self.stdout.write("Gagnant : %s" % winner.user)
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Gestion en ligne de commande des mails de rappel.
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import timezone
|
||||
|
||||
from bda.models import Spectacle
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Envoie les mails de rappel des spectacles dont la date ' \
|
||||
'approche.\nNe renvoie pas les mails déjà envoyés.'
|
||||
help = (
|
||||
"Envoie les mails de rappel des spectacles dont la date approche.\n"
|
||||
"Ne renvoie pas les mails déjà envoyés."
|
||||
)
|
||||
leave_locale_alone = True
|
||||
|
||||
def handle(self, *args, **options):
|
||||
now = timezone.now()
|
||||
delay = timedelta(days=4)
|
||||
shows = Spectacle.objects \
|
||||
.filter(date__range=(now, now+delay)) \
|
||||
.filter(tirage__active=True) \
|
||||
.filter(rappel_sent__isnull=True) \
|
||||
shows = (
|
||||
Spectacle.objects.filter(date__range=(now, now + delay))
|
||||
.filter(tirage__active=True)
|
||||
.filter(rappel_sent__isnull=True)
|
||||
.all()
|
||||
)
|
||||
for show in shows:
|
||||
show.send_rappel()
|
||||
self.stdout.write(
|
||||
'Mails de rappels pour %s envoyés avec succès.' % show)
|
||||
self.stdout.write("Mails de rappels pour %s envoyés avec succès." % show)
|
||||
if not shows:
|
||||
self.stdout.write('Aucun mail à envoyer.')
|
||||
self.stdout.write("Aucun mail à envoyer.")
|
||||
|
|
|
@ -1,108 +1,206 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Attribution',
|
||||
name="Attribution",
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('given', models.BooleanField(default=False, verbose_name='Donn\xe9e')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
verbose_name="ID",
|
||||
serialize=False,
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
),
|
||||
),
|
||||
("given", models.BooleanField(default=False, verbose_name="Donn\xe9e")),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ChoixSpectacle',
|
||||
name="ChoixSpectacle",
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('priority', models.PositiveIntegerField(verbose_name=b'Priorit\xc3\xa9')),
|
||||
('double_choice', models.CharField(default=b'1', max_length=10, verbose_name=b'Nombre de places', choices=[(b'1', b'1 place'), (b'autoquit', b'2 places si possible, 1 sinon'), (b'double', b'2 places sinon rien')])),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
verbose_name="ID",
|
||||
serialize=False,
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"priority",
|
||||
models.PositiveIntegerField(verbose_name=b"Priorit\xc3\xa9"),
|
||||
),
|
||||
(
|
||||
"double_choice",
|
||||
models.CharField(
|
||||
default=b"1",
|
||||
max_length=10,
|
||||
verbose_name=b"Nombre de places",
|
||||
choices=[
|
||||
(b"1", b"1 place"),
|
||||
(b"autoquit", b"2 places si possible, 1 sinon"),
|
||||
(b"double", b"2 places sinon rien"),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'ordering': ('priority',),
|
||||
'verbose_name': 'voeu',
|
||||
'verbose_name_plural': 'voeux',
|
||||
"ordering": ("priority",),
|
||||
"verbose_name": "voeu",
|
||||
"verbose_name_plural": "voeux",
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Participant',
|
||||
name="Participant",
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('paid', models.BooleanField(default=False, verbose_name='A pay\xe9')),
|
||||
('paymenttype', models.CharField(blank=True, max_length=6, verbose_name='Moyen de paiement', choices=[(b'cash', 'Cash'), (b'cb', b'CB'), (b'cheque', 'Ch\xe8que'), (b'autre', 'Autre')])),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
verbose_name="ID",
|
||||
serialize=False,
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
),
|
||||
),
|
||||
("paid", models.BooleanField(default=False, verbose_name="A pay\xe9")),
|
||||
(
|
||||
"paymenttype",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
max_length=6,
|
||||
verbose_name="Moyen de paiement",
|
||||
choices=[
|
||||
(b"cash", "Cash"),
|
||||
(b"cb", b"CB"),
|
||||
(b"cheque", "Ch\xe8que"),
|
||||
(b"autre", "Autre"),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Salle',
|
||||
name="Salle",
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=300, verbose_name=b'Nom')),
|
||||
('address', models.TextField(verbose_name=b'Adresse')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
verbose_name="ID",
|
||||
serialize=False,
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
),
|
||||
),
|
||||
("name", models.CharField(max_length=300, verbose_name=b"Nom")),
|
||||
("address", models.TextField(verbose_name=b"Adresse")),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Spectacle',
|
||||
name="Spectacle",
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('title', models.CharField(max_length=300, verbose_name=b'Titre')),
|
||||
('date', models.DateTimeField(verbose_name=b'Date & heure')),
|
||||
('description', models.TextField(verbose_name=b'Description', blank=True)),
|
||||
('slots_description', models.TextField(verbose_name=b'Description des places', blank=True)),
|
||||
('price', models.FloatField(verbose_name=b"Prix d'une place", blank=True)),
|
||||
('slots', models.IntegerField(verbose_name=b'Places')),
|
||||
('priority', models.IntegerField(default=1000, verbose_name=b'Priorit\xc3\xa9')),
|
||||
('location', models.ForeignKey(to='bda.Salle', on_delete=models.CASCADE)),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
verbose_name="ID",
|
||||
serialize=False,
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
),
|
||||
),
|
||||
("title", models.CharField(max_length=300, verbose_name=b"Titre")),
|
||||
("date", models.DateTimeField(verbose_name=b"Date & heure")),
|
||||
(
|
||||
"description",
|
||||
models.TextField(verbose_name=b"Description", blank=True),
|
||||
),
|
||||
(
|
||||
"slots_description",
|
||||
models.TextField(
|
||||
verbose_name=b"Description des places", blank=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"price",
|
||||
models.FloatField(verbose_name=b"Prix d'une place", blank=True),
|
||||
),
|
||||
("slots", models.IntegerField(verbose_name=b"Places")),
|
||||
(
|
||||
"priority",
|
||||
models.IntegerField(default=1000, verbose_name=b"Priorit\xc3\xa9"),
|
||||
),
|
||||
(
|
||||
"location",
|
||||
models.ForeignKey(to="bda.Salle", on_delete=models.CASCADE),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'ordering': ('priority', 'date', 'title'),
|
||||
'verbose_name': 'Spectacle',
|
||||
"ordering": ("priority", "date", "title"),
|
||||
"verbose_name": "Spectacle",
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='participant',
|
||||
name='attributions',
|
||||
field=models.ManyToManyField(related_name='attributed_to', through='bda.Attribution', to='bda.Spectacle'),
|
||||
model_name="participant",
|
||||
name="attributions",
|
||||
field=models.ManyToManyField(
|
||||
related_name="attributed_to",
|
||||
through="bda.Attribution",
|
||||
to="bda.Spectacle",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='participant',
|
||||
name='choices',
|
||||
field=models.ManyToManyField(related_name='chosen_by', through='bda.ChoixSpectacle', to='bda.Spectacle'),
|
||||
model_name="participant",
|
||||
name="choices",
|
||||
field=models.ManyToManyField(
|
||||
related_name="chosen_by",
|
||||
through="bda.ChoixSpectacle",
|
||||
to="bda.Spectacle",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='participant',
|
||||
name='user',
|
||||
field=models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE),
|
||||
model_name="participant",
|
||||
name="user",
|
||||
field=models.OneToOneField(
|
||||
to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='choixspectacle',
|
||||
name='participant',
|
||||
field=models.ForeignKey(to='bda.Participant', on_delete=models.CASCADE),
|
||||
model_name="choixspectacle",
|
||||
name="participant",
|
||||
field=models.ForeignKey(to="bda.Participant", on_delete=models.CASCADE),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='choixspectacle',
|
||||
name='spectacle',
|
||||
field=models.ForeignKey(related_name='participants', to='bda.Spectacle', on_delete=models.CASCADE),
|
||||
model_name="choixspectacle",
|
||||
name="spectacle",
|
||||
field=models.ForeignKey(
|
||||
related_name="participants",
|
||||
to="bda.Spectacle",
|
||||
on_delete=models.CASCADE,
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='attribution',
|
||||
name='participant',
|
||||
field=models.ForeignKey(to='bda.Participant', on_delete=models.CASCADE),
|
||||
model_name="attribution",
|
||||
name="participant",
|
||||
field=models.ForeignKey(to="bda.Participant", on_delete=models.CASCADE),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='attribution',
|
||||
name='spectacle',
|
||||
field=models.ForeignKey(related_name='attribues', to='bda.Spectacle', on_delete=models.CASCADE),
|
||||
model_name="attribution",
|
||||
name="spectacle",
|
||||
field=models.ForeignKey(
|
||||
related_name="attribues", to="bda.Spectacle", on_delete=models.CASCADE
|
||||
),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='choixspectacle',
|
||||
unique_together=set([('participant', 'spectacle')]),
|
||||
name="choixspectacle", unique_together=set([("participant", "spectacle")])
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
|
@ -36,49 +36,77 @@ def fill_tirage_fields(apps, schema_editor):
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0001_initial'),
|
||||
]
|
||||
dependencies = [("bda", "0001_initial")]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Tirage',
|
||||
name="Tirage",
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('title', models.CharField(max_length=300, verbose_name=b'Titre')),
|
||||
('ouverture', models.DateTimeField(verbose_name=b"Date et heure d'ouverture du tirage")),
|
||||
('fermeture', models.DateTimeField(verbose_name=b'Date et heure de fermerture du tirage')),
|
||||
('token', models.TextField(verbose_name=b'Graine du tirage', blank=True)),
|
||||
('active', models.BooleanField(default=True, verbose_name=b'Tirage actif')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
verbose_name="ID",
|
||||
serialize=False,
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
),
|
||||
),
|
||||
("title", models.CharField(max_length=300, verbose_name=b"Titre")),
|
||||
(
|
||||
"ouverture",
|
||||
models.DateTimeField(
|
||||
verbose_name=b"Date et heure d'ouverture du tirage"
|
||||
),
|
||||
),
|
||||
(
|
||||
"fermeture",
|
||||
models.DateTimeField(
|
||||
verbose_name=b"Date et heure de fermerture du tirage"
|
||||
),
|
||||
),
|
||||
(
|
||||
"token",
|
||||
models.TextField(verbose_name=b"Graine du tirage", blank=True),
|
||||
),
|
||||
(
|
||||
"active",
|
||||
models.BooleanField(default=True, verbose_name=b"Tirage actif"),
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='participant',
|
||||
name='user',
|
||||
field=models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE),
|
||||
model_name="participant",
|
||||
name="user",
|
||||
field=models.ForeignKey(
|
||||
to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE
|
||||
),
|
||||
),
|
||||
# Create fields `spectacle` for `Participant` and `Spectacle` models.
|
||||
# These fields are not nullable, but we first create them as nullable
|
||||
# to give a default value for existing instances of these models.
|
||||
migrations.AddField(
|
||||
model_name='participant',
|
||||
name='tirage',
|
||||
field=models.ForeignKey(to='bda.Tirage', null=True, on_delete=models.CASCADE),
|
||||
model_name="participant",
|
||||
name="tirage",
|
||||
field=models.ForeignKey(
|
||||
to="bda.Tirage", null=True, on_delete=models.CASCADE
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectacle',
|
||||
name='tirage',
|
||||
field=models.ForeignKey(to='bda.Tirage', null=True, on_delete=models.CASCADE),
|
||||
model_name="spectacle",
|
||||
name="tirage",
|
||||
field=models.ForeignKey(
|
||||
to="bda.Tirage", null=True, on_delete=models.CASCADE
|
||||
),
|
||||
),
|
||||
migrations.RunPython(fill_tirage_fields, migrations.RunPython.noop),
|
||||
migrations.AlterField(
|
||||
model_name='participant',
|
||||
name='tirage',
|
||||
field=models.ForeignKey(to='bda.Tirage', on_delete=models.CASCADE),
|
||||
model_name="participant",
|
||||
name="tirage",
|
||||
field=models.ForeignKey(to="bda.Tirage", on_delete=models.CASCADE),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='tirage',
|
||||
field=models.ForeignKey(to='bda.Tirage', on_delete=models.CASCADE),
|
||||
model_name="spectacle",
|
||||
name="tirage",
|
||||
field=models.ForeignKey(to="bda.Tirage", on_delete=models.CASCADE),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,19 +6,17 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0002_add_tirage'),
|
||||
]
|
||||
dependencies = [("bda", "0002_add_tirage")]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='price',
|
||||
model_name="spectacle",
|
||||
name="price",
|
||||
field=models.FloatField(verbose_name=b"Prix d'une place"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tirage',
|
||||
name='active',
|
||||
field=models.BooleanField(default=False, verbose_name=b'Tirage actif'),
|
||||
model_name="tirage",
|
||||
name="active",
|
||||
field=models.BooleanField(default=False, verbose_name=b"Tirage actif"),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,20 +6,22 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0003_update_tirage_and_spectacle'),
|
||||
]
|
||||
dependencies = [("bda", "0003_update_tirage_and_spectacle")]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='spectacle',
|
||||
name='listing',
|
||||
field=models.BooleanField(default=False, verbose_name=b'Les places sont sur listing'),
|
||||
model_name="spectacle",
|
||||
name="listing",
|
||||
field=models.BooleanField(
|
||||
default=False, verbose_name=b"Les places sont sur listing"
|
||||
),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectacle',
|
||||
name='rappel_sent',
|
||||
field=models.DateTimeField(null=True, verbose_name=b'Mail de rappel envoy\xc3\xa9', blank=True),
|
||||
model_name="spectacle",
|
||||
name="rappel_sent",
|
||||
field=models.DateTimeField(
|
||||
null=True, verbose_name=b"Mail de rappel envoy\xc3\xa9", blank=True
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,24 +6,24 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0004_mails-rappel'),
|
||||
]
|
||||
dependencies = [("bda", "0004_mails-rappel")]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='choixspectacle',
|
||||
name='priority',
|
||||
field=models.PositiveIntegerField(verbose_name='Priorit\xe9'),
|
||||
model_name="choixspectacle",
|
||||
name="priority",
|
||||
field=models.PositiveIntegerField(verbose_name="Priorit\xe9"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='priority',
|
||||
field=models.IntegerField(default=1000, verbose_name='Priorit\xe9'),
|
||||
model_name="spectacle",
|
||||
name="priority",
|
||||
field=models.IntegerField(default=1000, verbose_name="Priorit\xe9"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='rappel_sent',
|
||||
field=models.DateTimeField(null=True, verbose_name='Mail de rappel envoy\xe9', blank=True),
|
||||
model_name="spectacle",
|
||||
name="rappel_sent",
|
||||
field=models.DateTimeField(
|
||||
null=True, verbose_name="Mail de rappel envoy\xe9", blank=True
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -10,26 +10,25 @@ def forwards_func(apps, schema_editor):
|
|||
db_alias = schema_editor.connection.alias
|
||||
for tirage in Tirage.objects.using(db_alias).all():
|
||||
if tirage.tokens:
|
||||
tirage.tokens = "Before %s\n\"\"\"%s\"\"\"\n" % (
|
||||
timezone.now().strftime("%y-%m-%d %H:%M:%S"),
|
||||
tirage.tokens)
|
||||
tirage.tokens = 'Before %s\n"""%s"""\n' % (
|
||||
timezone.now().strftime("%y-%m-%d %H:%M:%S"),
|
||||
tirage.tokens,
|
||||
)
|
||||
tirage.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0005_encoding'),
|
||||
]
|
||||
dependencies = [("bda", "0005_encoding")]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField('tirage', 'token', 'tokens'),
|
||||
migrations.RenameField("tirage", "token", "tokens"),
|
||||
migrations.AddField(
|
||||
model_name='tirage',
|
||||
name='enable_do_tirage',
|
||||
model_name="tirage",
|
||||
name="enable_do_tirage",
|
||||
field=models.BooleanField(
|
||||
default=False,
|
||||
verbose_name=b'Le tirage peut \xc3\xaatre lanc\xc3\xa9'),
|
||||
default=False, verbose_name=b"Le tirage peut \xc3\xaatre lanc\xc3\xa9"
|
||||
),
|
||||
),
|
||||
migrations.RunPython(forwards_func, migrations.RunPython.noop),
|
||||
]
|
||||
|
|
|
@ -1,91 +1,100 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0006_add_tirage_switch'),
|
||||
]
|
||||
dependencies = [("bda", "0006_add_tirage_switch")]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='CategorieSpectacle',
|
||||
name="CategorieSpectacle",
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False,
|
||||
auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=100, verbose_name='Nom',
|
||||
unique=True)),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
verbose_name="ID",
|
||||
serialize=False,
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"name",
|
||||
models.CharField(max_length=100, verbose_name="Nom", unique=True),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Cat\xe9gorie',
|
||||
},
|
||||
options={"verbose_name": "Cat\xe9gorie"},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Quote',
|
||||
name="Quote",
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False,
|
||||
auto_created=True, primary_key=True)),
|
||||
('text', models.TextField(verbose_name='Citation')),
|
||||
('author', models.CharField(max_length=200,
|
||||
verbose_name='Auteur')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
verbose_name="ID",
|
||||
serialize=False,
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
),
|
||||
),
|
||||
("text", models.TextField(verbose_name="Citation")),
|
||||
("author", models.CharField(max_length=200, verbose_name="Auteur")),
|
||||
],
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='spectacle',
|
||||
options={'ordering': ('date', 'title'),
|
||||
'verbose_name': 'Spectacle'},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='spectacle',
|
||||
name='priority',
|
||||
name="spectacle",
|
||||
options={"ordering": ("date", "title"), "verbose_name": "Spectacle"},
|
||||
),
|
||||
migrations.RemoveField(model_name="spectacle", name="priority"),
|
||||
migrations.AddField(
|
||||
model_name='spectacle',
|
||||
name='ext_link',
|
||||
model_name="spectacle",
|
||||
name="ext_link",
|
||||
field=models.CharField(
|
||||
max_length=500,
|
||||
verbose_name='Lien vers le site du spectacle',
|
||||
blank=True),
|
||||
verbose_name="Lien vers le site du spectacle",
|
||||
blank=True,
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectacle',
|
||||
name='image',
|
||||
field=models.ImageField(upload_to='imgs/shows/', null=True,
|
||||
verbose_name='Image', blank=True),
|
||||
model_name="spectacle",
|
||||
name="image",
|
||||
field=models.ImageField(
|
||||
upload_to="imgs/shows/", null=True, verbose_name="Image", blank=True
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tirage',
|
||||
name='enable_do_tirage',
|
||||
model_name="tirage",
|
||||
name="enable_do_tirage",
|
||||
field=models.BooleanField(
|
||||
default=False,
|
||||
verbose_name='Le tirage peut \xeatre lanc\xe9'),
|
||||
default=False, verbose_name="Le tirage peut \xeatre lanc\xe9"
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tirage',
|
||||
name='tokens',
|
||||
field=models.TextField(verbose_name='Graine(s) du tirage',
|
||||
blank=True),
|
||||
model_name="tirage",
|
||||
name="tokens",
|
||||
field=models.TextField(verbose_name="Graine(s) du tirage", blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectacle',
|
||||
name='category',
|
||||
field=models.ForeignKey(blank=True, to='bda.CategorieSpectacle',
|
||||
on_delete=models.CASCADE,
|
||||
null=True),
|
||||
model_name="spectacle",
|
||||
name="category",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
to="bda.CategorieSpectacle",
|
||||
on_delete=models.CASCADE,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectacle',
|
||||
name='vips',
|
||||
field=models.TextField(verbose_name='Personnalit\xe9s',
|
||||
blank=True),
|
||||
model_name="spectacle",
|
||||
name="vips",
|
||||
field=models.TextField(verbose_name="Personnalit\xe9s", blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='quote',
|
||||
name='spectacle',
|
||||
field=models.ForeignKey(to='bda.Spectacle',
|
||||
on_delete=models.CASCADE),
|
||||
model_name="quote",
|
||||
name="spectacle",
|
||||
field=models.ForeignKey(to="bda.Spectacle", on_delete=models.CASCADE),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,103 +1,110 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0007_extends_spectacle'),
|
||||
]
|
||||
dependencies = [("bda", "0007_extends_spectacle")]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='choixspectacle',
|
||||
name='double_choice',
|
||||
model_name="choixspectacle",
|
||||
name="double_choice",
|
||||
field=models.CharField(
|
||||
verbose_name='Nombre de places',
|
||||
choices=[('1', '1 place'),
|
||||
('autoquit', '2 places si possible, 1 sinon'),
|
||||
('double', '2 places sinon rien')],
|
||||
max_length=10, default='1'),
|
||||
verbose_name="Nombre de places",
|
||||
choices=[
|
||||
("1", "1 place"),
|
||||
("autoquit", "2 places si possible, 1 sinon"),
|
||||
("double", "2 places sinon rien"),
|
||||
],
|
||||
max_length=10,
|
||||
default="1",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='participant',
|
||||
name='paymenttype',
|
||||
model_name="participant",
|
||||
name="paymenttype",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
choices=[('cash', 'Cash'), ('cb', 'CB'),
|
||||
('cheque', 'Chèque'), ('autre', 'Autre')],
|
||||
max_length=6, verbose_name='Moyen de paiement'),
|
||||
choices=[
|
||||
("cash", "Cash"),
|
||||
("cb", "CB"),
|
||||
("cheque", "Chèque"),
|
||||
("autre", "Autre"),
|
||||
],
|
||||
max_length=6,
|
||||
verbose_name="Moyen de paiement",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='salle',
|
||||
name='address',
|
||||
field=models.TextField(verbose_name='Adresse'),
|
||||
model_name="salle",
|
||||
name="address",
|
||||
field=models.TextField(verbose_name="Adresse"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='salle',
|
||||
name='name',
|
||||
field=models.CharField(verbose_name='Nom', max_length=300),
|
||||
model_name="salle",
|
||||
name="name",
|
||||
field=models.CharField(verbose_name="Nom", max_length=300),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='date',
|
||||
field=models.DateTimeField(verbose_name='Date & heure'),
|
||||
model_name="spectacle",
|
||||
name="date",
|
||||
field=models.DateTimeField(verbose_name="Date & heure"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='description',
|
||||
field=models.TextField(verbose_name='Description', blank=True),
|
||||
model_name="spectacle",
|
||||
name="description",
|
||||
field=models.TextField(verbose_name="Description", blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='listing',
|
||||
field=models.BooleanField(
|
||||
verbose_name='Les places sont sur listing'),
|
||||
model_name="spectacle",
|
||||
name="listing",
|
||||
field=models.BooleanField(verbose_name="Les places sont sur listing"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='price',
|
||||
model_name="spectacle",
|
||||
name="price",
|
||||
field=models.FloatField(verbose_name="Prix d'une place"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='slots',
|
||||
field=models.IntegerField(verbose_name='Places'),
|
||||
model_name="spectacle",
|
||||
name="slots",
|
||||
field=models.IntegerField(verbose_name="Places"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='slots_description',
|
||||
field=models.TextField(verbose_name='Description des places',
|
||||
blank=True),
|
||||
model_name="spectacle",
|
||||
name="slots_description",
|
||||
field=models.TextField(verbose_name="Description des places", blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectacle',
|
||||
name='title',
|
||||
field=models.CharField(verbose_name='Titre', max_length=300),
|
||||
model_name="spectacle",
|
||||
name="title",
|
||||
field=models.CharField(verbose_name="Titre", max_length=300),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tirage',
|
||||
name='active',
|
||||
field=models.BooleanField(verbose_name='Tirage actif',
|
||||
default=False),
|
||||
model_name="tirage",
|
||||
name="active",
|
||||
field=models.BooleanField(verbose_name="Tirage actif", default=False),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tirage',
|
||||
name='fermeture',
|
||||
model_name="tirage",
|
||||
name="fermeture",
|
||||
field=models.DateTimeField(
|
||||
verbose_name='Date et heure de fermerture du tirage'),
|
||||
verbose_name="Date et heure de fermerture du tirage"
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tirage',
|
||||
name='ouverture',
|
||||
model_name="tirage",
|
||||
name="ouverture",
|
||||
field=models.DateTimeField(
|
||||
verbose_name="Date et heure d'ouverture du tirage"),
|
||||
verbose_name="Date et heure d'ouverture du tirage"
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tirage',
|
||||
name='title',
|
||||
field=models.CharField(verbose_name='Titre', max_length=300),
|
||||
model_name="tirage",
|
||||
name="title",
|
||||
field=models.CharField(verbose_name="Titre", max_length=300),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,69 +1,87 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import django.utils.timezone
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0008_py3'),
|
||||
]
|
||||
dependencies = [("bda", "0008_py3")]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SpectacleRevente',
|
||||
name="SpectacleRevente",
|
||||
fields=[
|
||||
('id', models.AutoField(serialize=False, primary_key=True,
|
||||
auto_created=True, verbose_name='ID')),
|
||||
('date', models.DateTimeField(
|
||||
verbose_name='Date de mise en vente',
|
||||
default=django.utils.timezone.now)),
|
||||
('notif_sent', models.BooleanField(
|
||||
verbose_name='Notification envoyée', default=False)),
|
||||
('tirage_done', models.BooleanField(
|
||||
verbose_name='Tirage effectué', default=False)),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
serialize=False,
|
||||
primary_key=True,
|
||||
auto_created=True,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"date",
|
||||
models.DateTimeField(
|
||||
verbose_name="Date de mise en vente",
|
||||
default=django.utils.timezone.now,
|
||||
),
|
||||
),
|
||||
(
|
||||
"notif_sent",
|
||||
models.BooleanField(
|
||||
verbose_name="Notification envoyée", default=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"tirage_done",
|
||||
models.BooleanField(verbose_name="Tirage effectué", default=False),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Revente',
|
||||
},
|
||||
options={"verbose_name": "Revente"},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='participant',
|
||||
name='choicesrevente',
|
||||
field=models.ManyToManyField(to='bda.Spectacle',
|
||||
related_name='subscribed',
|
||||
blank=True),
|
||||
model_name="participant",
|
||||
name="choicesrevente",
|
||||
field=models.ManyToManyField(
|
||||
to="bda.Spectacle", related_name="subscribed", blank=True
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectaclerevente',
|
||||
name='answered_mail',
|
||||
field=models.ManyToManyField(to='bda.Participant',
|
||||
related_name='wanted',
|
||||
blank=True),
|
||||
model_name="spectaclerevente",
|
||||
name="answered_mail",
|
||||
field=models.ManyToManyField(
|
||||
to="bda.Participant", related_name="wanted", blank=True
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectaclerevente',
|
||||
name='attribution',
|
||||
field=models.OneToOneField(to='bda.Attribution',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='revente'),
|
||||
model_name="spectaclerevente",
|
||||
name="attribution",
|
||||
field=models.OneToOneField(
|
||||
to="bda.Attribution", on_delete=models.CASCADE, related_name="revente"
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectaclerevente',
|
||||
name='seller',
|
||||
field=models.ForeignKey(to='bda.Participant',
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name='Vendeur',
|
||||
related_name='original_shows'),
|
||||
model_name="spectaclerevente",
|
||||
name="seller",
|
||||
field=models.ForeignKey(
|
||||
to="bda.Participant",
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name="Vendeur",
|
||||
related_name="original_shows",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectaclerevente',
|
||||
name='soldTo',
|
||||
field=models.ForeignKey(to='bda.Participant',
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name='Vendue à', null=True,
|
||||
blank=True),
|
||||
model_name="spectaclerevente",
|
||||
name="soldTo",
|
||||
field=models.ForeignKey(
|
||||
to="bda.Participant",
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name="Vendue à",
|
||||
null=True,
|
||||
blank=True,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,33 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.utils import timezone
|
||||
from datetime import timedelta
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
def forwards_func(apps, schema_editor):
|
||||
SpectacleRevente = apps.get_model("bda", "SpectacleRevente")
|
||||
|
||||
for revente in SpectacleRevente.objects.all():
|
||||
is_expired = timezone.now() > revente.date_tirage()
|
||||
is_direct = (revente.attribution.spectacle.date >= revente.date and
|
||||
timezone.now() > revente.date + timedelta(minutes=15))
|
||||
is_direct = revente.attribution.spectacle.date >= revente.date and timezone.now() > revente.date + timedelta(
|
||||
minutes=15
|
||||
)
|
||||
revente.shotgun = is_expired or is_direct
|
||||
revente.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0009_revente'),
|
||||
]
|
||||
dependencies = [("bda", "0009_revente")]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='spectaclerevente',
|
||||
name='shotgun',
|
||||
field=models.BooleanField(default=False, verbose_name='Disponible imm\xe9diatement'),
|
||||
model_name="spectaclerevente",
|
||||
name="shotgun",
|
||||
field=models.BooleanField(
|
||||
default=False, verbose_name="Disponible imm\xe9diatement"
|
||||
),
|
||||
),
|
||||
migrations.RunPython(forwards_func, migrations.RunPython.noop),
|
||||
]
|
||||
|
|
|
@ -6,17 +6,14 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0010_spectaclerevente_shotgun'),
|
||||
]
|
||||
dependencies = [("bda", "0010_spectaclerevente_shotgun")]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='tirage',
|
||||
name='appear_catalogue',
|
||||
model_name="tirage",
|
||||
name="appear_catalogue",
|
||||
field=models.BooleanField(
|
||||
default=False,
|
||||
verbose_name='Tirage à afficher dans le catalogue'
|
||||
default=False, verbose_name="Tirage à afficher dans le catalogue"
|
||||
),
|
||||
),
|
||||
)
|
||||
]
|
||||
|
|
|
@ -6,24 +6,26 @@ from django.db import migrations, models
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bda', '0011_tirage_appear_catalogue'),
|
||||
]
|
||||
dependencies = [("bda", "0011_tirage_appear_catalogue")]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='spectaclerevente',
|
||||
old_name='answered_mail',
|
||||
new_name='confirmed_entry',
|
||||
model_name="spectaclerevente",
|
||||
old_name="answered_mail",
|
||||
new_name="confirmed_entry",
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='spectaclerevente',
|
||||
name='confirmed_entry',
|
||||
field=models.ManyToManyField(blank=True, related_name='entered', to='bda.Participant'),
|
||||
model_name="spectaclerevente",
|
||||
name="confirmed_entry",
|
||||
field=models.ManyToManyField(
|
||||
blank=True, related_name="entered", to="bda.Participant"
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='spectaclerevente',
|
||||
name='notif_time',
|
||||
field=models.DateTimeField(blank=True, verbose_name="Moment d'envoi de la notification", null=True),
|
||||
model_name="spectaclerevente",
|
||||
name="notif_time",
|
||||
field=models.DateTimeField(
|
||||
blank=True, verbose_name="Moment d'envoi de la notification", null=True
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
51
bda/migrations/0012_swap_double_choice.py
Normal file
51
bda/migrations/0012_swap_double_choice.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def swap_double_choice(apps, schema_editor):
|
||||
choices = apps.get_model("bda", "ChoixSpectacle").objects
|
||||
|
||||
choices.filter(double_choice="double").update(double_choice="tmp")
|
||||
choices.filter(double_choice="autoquit").update(double_choice="double")
|
||||
choices.filter(double_choice="tmp").update(double_choice="autoquit")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0011_tirage_appear_catalogue")]
|
||||
|
||||
operations = [
|
||||
# Temporarily allow an extra "tmp" value for the `double_choice` field
|
||||
migrations.AlterField(
|
||||
model_name="choixspectacle",
|
||||
name="double_choice",
|
||||
field=models.CharField(
|
||||
verbose_name="Nombre de places",
|
||||
max_length=10,
|
||||
default="1",
|
||||
choices=[
|
||||
("tmp", "tmp"),
|
||||
("1", "1 place"),
|
||||
("double", "2 places si possible, 1 sinon"),
|
||||
("autoquit", "2 places sinon rien"),
|
||||
],
|
||||
),
|
||||
),
|
||||
migrations.RunPython(swap_double_choice, migrations.RunPython.noop),
|
||||
migrations.AlterField(
|
||||
model_name="choixspectacle",
|
||||
name="double_choice",
|
||||
field=models.CharField(
|
||||
verbose_name="Nombre de places",
|
||||
max_length=10,
|
||||
default="1",
|
||||
choices=[
|
||||
("1", "1 place"),
|
||||
("double", "2 places si possible, 1 sinon"),
|
||||
("autoquit", "2 places sinon rien"),
|
||||
],
|
||||
),
|
||||
),
|
||||
]
|
12
bda/migrations/0013_merge_20180524_2123.py
Normal file
12
bda/migrations/0013_merge_20180524_2123.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.13 on 2018-05-24 19:23
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bda", "0012_notif_time"), ("bda", "0012_swap_double_choice")]
|
||||
|
||||
operations = []
|
254
bda/models.py
254
bda/models.py
|
@ -1,25 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import calendar
|
||||
import random
|
||||
from datetime import timedelta
|
||||
from custommail.shortcuts import send_mass_custom_mail
|
||||
|
||||
from custommail.models import CustomMail
|
||||
from custommail.shortcuts import send_mass_custom_mail
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core import mail
|
||||
from django.db import models
|
||||
from django.db.models import Count
|
||||
from django.contrib.auth.models import User
|
||||
from django.conf import settings
|
||||
from django.utils import timezone, formats
|
||||
|
||||
from custommail.models import CustomMail
|
||||
from django.utils import formats, timezone
|
||||
|
||||
|
||||
def get_generic_user():
|
||||
generic, _ = User.objects.get_or_create(
|
||||
username="bda_generic",
|
||||
defaults={"email": "bda@ens.fr", "first_name": "Bureau des arts"}
|
||||
defaults={"email": "bda@ens.fr", "first_name": "Bureau des arts"},
|
||||
)
|
||||
return generic
|
||||
|
||||
|
@ -31,15 +28,15 @@ class Tirage(models.Model):
|
|||
tokens = models.TextField("Graine(s) du tirage", blank=True)
|
||||
active = models.BooleanField("Tirage actif", default=False)
|
||||
appear_catalogue = models.BooleanField(
|
||||
"Tirage à afficher dans le catalogue",
|
||||
default=False
|
||||
"Tirage à afficher dans le catalogue", default=False
|
||||
)
|
||||
enable_do_tirage = models.BooleanField("Le tirage peut être lancé",
|
||||
default=False)
|
||||
enable_do_tirage = models.BooleanField("Le tirage peut être lancé", default=False)
|
||||
|
||||
def __str__(self):
|
||||
return "%s - %s" % (self.title, formats.localize(
|
||||
timezone.template_localtime(self.fermeture)))
|
||||
return "%s - %s" % (
|
||||
self.title,
|
||||
formats.localize(timezone.template_localtime(self.fermeture)),
|
||||
)
|
||||
|
||||
|
||||
class Salle(models.Model):
|
||||
|
@ -51,7 +48,7 @@ class Salle(models.Model):
|
|||
|
||||
|
||||
class CategorieSpectacle(models.Model):
|
||||
name = models.CharField('Nom', max_length=100, unique=True)
|
||||
name = models.CharField("Nom", max_length=100, unique=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -63,28 +60,26 @@ class CategorieSpectacle(models.Model):
|
|||
class Spectacle(models.Model):
|
||||
title = models.CharField("Titre", max_length=300)
|
||||
category = models.ForeignKey(
|
||||
CategorieSpectacle, on_delete=models.CASCADE,
|
||||
blank=True, null=True,
|
||||
CategorieSpectacle, on_delete=models.CASCADE, blank=True, null=True
|
||||
)
|
||||
date = models.DateTimeField("Date & heure")
|
||||
location = models.ForeignKey(Salle, on_delete=models.CASCADE)
|
||||
vips = models.TextField('Personnalités', blank=True)
|
||||
vips = models.TextField("Personnalités", blank=True)
|
||||
description = models.TextField("Description", blank=True)
|
||||
slots_description = models.TextField("Description des places", blank=True)
|
||||
image = models.ImageField('Image', blank=True, null=True,
|
||||
upload_to='imgs/shows/')
|
||||
ext_link = models.CharField('Lien vers le site du spectacle', blank=True,
|
||||
max_length=500)
|
||||
image = models.ImageField("Image", blank=True, null=True, upload_to="imgs/shows/")
|
||||
ext_link = models.CharField(
|
||||
"Lien vers le site du spectacle", blank=True, max_length=500
|
||||
)
|
||||
price = models.FloatField("Prix d'une place")
|
||||
slots = models.IntegerField("Places")
|
||||
tirage = models.ForeignKey(Tirage, on_delete=models.CASCADE)
|
||||
listing = models.BooleanField("Les places sont sur listing")
|
||||
rappel_sent = models.DateTimeField("Mail de rappel envoyé", blank=True,
|
||||
null=True)
|
||||
rappel_sent = models.DateTimeField("Mail de rappel envoyé", blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Spectacle"
|
||||
ordering = ("date", "title",)
|
||||
ordering = ("date", "title")
|
||||
|
||||
def timestamp(self):
|
||||
return "%d" % calendar.timegm(self.date.utctimetuple())
|
||||
|
@ -94,7 +89,7 @@ class Spectacle(models.Model):
|
|||
self.title,
|
||||
formats.localize(timezone.template_localtime(self.date)),
|
||||
self.location,
|
||||
self.price
|
||||
self.price,
|
||||
)
|
||||
|
||||
def getImgUrl(self):
|
||||
|
@ -103,7 +98,7 @@ class Spectacle(models.Model):
|
|||
"""
|
||||
try:
|
||||
return self.image.url
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def send_rappel(self):
|
||||
|
@ -113,19 +108,21 @@ class Spectacle(models.Model):
|
|||
"""
|
||||
# On récupère la liste des participants + le BdA
|
||||
members = list(
|
||||
User.objects
|
||||
.filter(participant__attributions=self)
|
||||
.annotate(nb_attr=Count("id")).order_by()
|
||||
User.objects.filter(participant__attributions=self)
|
||||
.annotate(nb_attr=Count("id"))
|
||||
.order_by()
|
||||
)
|
||||
bda_generic = get_generic_user()
|
||||
bda_generic.nb_attr = 1
|
||||
members.append(bda_generic)
|
||||
# On écrit un mail personnalisé à chaque participant
|
||||
datatuple = [(
|
||||
'bda-rappel',
|
||||
{'member': member, "nb_attr": member.nb_attr, 'show': self},
|
||||
settings.MAIL_DATA['rappels']['FROM'],
|
||||
[member.email])
|
||||
datatuple = [
|
||||
(
|
||||
"bda-rappel",
|
||||
{"member": member, "nb_attr": member.nb_attr, "show": self},
|
||||
settings.MAIL_DATA["rappels"]["FROM"],
|
||||
[member.email],
|
||||
)
|
||||
for member in members
|
||||
]
|
||||
send_mass_custom_mail(datatuple)
|
||||
|
@ -142,8 +139,8 @@ class Spectacle(models.Model):
|
|||
|
||||
class Quote(models.Model):
|
||||
spectacle = models.ForeignKey(Spectacle, on_delete=models.CASCADE)
|
||||
text = models.TextField('Citation')
|
||||
author = models.CharField('Auteur', max_length=200)
|
||||
text = models.TextField("Citation")
|
||||
author = models.CharField("Auteur", max_length=200)
|
||||
|
||||
|
||||
PAYMENT_TYPES = (
|
||||
|
@ -156,20 +153,20 @@ PAYMENT_TYPES = (
|
|||
|
||||
class Participant(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
choices = models.ManyToManyField(Spectacle,
|
||||
through="ChoixSpectacle",
|
||||
related_name="chosen_by")
|
||||
attributions = models.ManyToManyField(Spectacle,
|
||||
through="Attribution",
|
||||
related_name="attributed_to")
|
||||
choices = models.ManyToManyField(
|
||||
Spectacle, through="ChoixSpectacle", related_name="chosen_by"
|
||||
)
|
||||
attributions = models.ManyToManyField(
|
||||
Spectacle, through="Attribution", related_name="attributed_to"
|
||||
)
|
||||
paid = models.BooleanField("A payé", default=False)
|
||||
paymenttype = models.CharField("Moyen de paiement",
|
||||
max_length=6, choices=PAYMENT_TYPES,
|
||||
blank=True)
|
||||
paymenttype = models.CharField(
|
||||
"Moyen de paiement", max_length=6, choices=PAYMENT_TYPES, blank=True
|
||||
)
|
||||
tirage = models.ForeignKey(Tirage, on_delete=models.CASCADE)
|
||||
choicesrevente = models.ManyToManyField(Spectacle,
|
||||
related_name="subscribed",
|
||||
blank=True)
|
||||
choicesrevente = models.ManyToManyField(
|
||||
Spectacle, related_name="subscribed", blank=True
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return "%s - %s" % (self.user, self.tirage.title)
|
||||
|
@ -177,38 +174,40 @@ class Participant(models.Model):
|
|||
|
||||
DOUBLE_CHOICES = (
|
||||
("1", "1 place"),
|
||||
("autoquit", "2 places si possible, 1 sinon"),
|
||||
("double", "2 places sinon rien"),
|
||||
("double", "2 places si possible, 1 sinon"),
|
||||
("autoquit", "2 places sinon rien"),
|
||||
)
|
||||
|
||||
|
||||
class ChoixSpectacle(models.Model):
|
||||
participant = models.ForeignKey(Participant, on_delete=models.CASCADE)
|
||||
spectacle = models.ForeignKey(
|
||||
Spectacle, on_delete=models.CASCADE,
|
||||
related_name="participants",
|
||||
Spectacle, on_delete=models.CASCADE, related_name="participants"
|
||||
)
|
||||
priority = models.PositiveIntegerField("Priorité")
|
||||
double_choice = models.CharField("Nombre de places",
|
||||
default="1", choices=DOUBLE_CHOICES,
|
||||
max_length=10)
|
||||
double_choice = models.CharField(
|
||||
"Nombre de places", default="1", choices=DOUBLE_CHOICES, max_length=10
|
||||
)
|
||||
|
||||
def get_double(self):
|
||||
return self.double_choice != "1"
|
||||
|
||||
double = property(get_double)
|
||||
|
||||
def get_autoquit(self):
|
||||
return self.double_choice == "autoquit"
|
||||
|
||||
autoquit = property(get_autoquit)
|
||||
|
||||
def __str__(self):
|
||||
return "Vœux de %s pour %s" % (
|
||||
self.participant.user.get_full_name(),
|
||||
self.spectacle.title)
|
||||
self.participant.user.get_full_name(),
|
||||
self.spectacle.title,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ("priority",)
|
||||
unique_together = (("participant", "spectacle",),)
|
||||
unique_together = (("participant", "spectacle"),)
|
||||
verbose_name = "voeu"
|
||||
verbose_name_plural = "voeux"
|
||||
|
||||
|
@ -216,48 +215,49 @@ class ChoixSpectacle(models.Model):
|
|||
class Attribution(models.Model):
|
||||
participant = models.ForeignKey(Participant, on_delete=models.CASCADE)
|
||||
spectacle = models.ForeignKey(
|
||||
Spectacle, on_delete=models.CASCADE,
|
||||
related_name="attribues",
|
||||
Spectacle, on_delete=models.CASCADE, related_name="attribues"
|
||||
)
|
||||
given = models.BooleanField("Donnée", default=False)
|
||||
|
||||
def __str__(self):
|
||||
return "%s -- %s, %s" % (self.participant.user, self.spectacle.title,
|
||||
self.spectacle.date)
|
||||
return "%s -- %s, %s" % (
|
||||
self.participant.user,
|
||||
self.spectacle.title,
|
||||
self.spectacle.date,
|
||||
)
|
||||
|
||||
|
||||
class SpectacleRevente(models.Model):
|
||||
attribution = models.OneToOneField(
|
||||
Attribution, on_delete=models.CASCADE,
|
||||
related_name="revente",
|
||||
Attribution, on_delete=models.CASCADE, related_name="revente"
|
||||
)
|
||||
date = models.DateTimeField("Date de mise en vente", default=timezone.now)
|
||||
confirmed_entry = models.ManyToManyField(
|
||||
Participant, related_name="entered", blank=True
|
||||
)
|
||||
date = models.DateTimeField("Date de mise en vente",
|
||||
default=timezone.now)
|
||||
confirmed_entry = models.ManyToManyField(Participant,
|
||||
related_name="entered",
|
||||
blank=True)
|
||||
seller = models.ForeignKey(
|
||||
Participant, on_delete=models.CASCADE,
|
||||
Participant,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name="Vendeur",
|
||||
related_name="original_shows",
|
||||
)
|
||||
soldTo = models.ForeignKey(
|
||||
Participant, on_delete=models.CASCADE,
|
||||
Participant,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name="Vendue à",
|
||||
blank=True, null=True,
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
notif_sent = models.BooleanField("Notification envoyée",
|
||||
default=False)
|
||||
notif_sent = models.BooleanField("Notification envoyée", default=False)
|
||||
|
||||
notif_time = models.DateTimeField("Moment d'envoi de la notification",
|
||||
blank=True, null=True)
|
||||
notif_time = models.DateTimeField(
|
||||
"Moment d'envoi de la notification", blank=True, null=True
|
||||
)
|
||||
|
||||
tirage_done = models.BooleanField("Tirage effectué",
|
||||
default=False)
|
||||
tirage_done = models.BooleanField("Tirage effectué", default=False)
|
||||
|
||||
shotgun = models.BooleanField("Disponible immédiatement",
|
||||
default=False)
|
||||
shotgun = models.BooleanField("Disponible immédiatement", default=False)
|
||||
####
|
||||
# Some class attributes
|
||||
###
|
||||
|
@ -284,8 +284,9 @@ class SpectacleRevente(models.Model):
|
|||
def date_tirage(self):
|
||||
"""Renvoie la date du tirage au sort de la revente."""
|
||||
|
||||
remaining_time = (self.attribution.spectacle.date
|
||||
- self.real_notif_time - self.min_margin)
|
||||
remaining_time = (
|
||||
self.attribution.spectacle.date - self.real_notif_time - self.min_margin
|
||||
)
|
||||
|
||||
delay = min(remaining_time, self.max_wait_time)
|
||||
|
||||
|
@ -298,16 +299,14 @@ class SpectacleRevente(models.Model):
|
|||
Plus précisément, on doit avoir min_margin + min_wait_time de marge.
|
||||
"""
|
||||
spectacle_date = self.attribution.spectacle.date
|
||||
return (spectacle_date <= timezone.now() + self.min_margin
|
||||
+ self.min_wait_time)
|
||||
return spectacle_date <= timezone.now() + self.min_margin + self.min_wait_time
|
||||
|
||||
@property
|
||||
def can_notif(self):
|
||||
return (timezone.now() >= self.date + self.remorse_time)
|
||||
return timezone.now() >= self.date + self.remorse_time
|
||||
|
||||
def __str__(self):
|
||||
return "%s -- %s" % (self.seller,
|
||||
self.attribution.spectacle.title)
|
||||
return "%s -- %s" % (self.seller, self.attribution.spectacle.title)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Revente"
|
||||
|
@ -329,17 +328,19 @@ class SpectacleRevente(models.Model):
|
|||
Envoie une notification pour indiquer la mise en vente d'une place sur
|
||||
BdA-Revente à tous les intéressés.
|
||||
"""
|
||||
inscrits = self.attribution.spectacle.subscribed.select_related('user')
|
||||
datatuple = [(
|
||||
'bda-revente',
|
||||
{
|
||||
'member': participant.user,
|
||||
'show': self.attribution.spectacle,
|
||||
'revente': self,
|
||||
'site': Site.objects.get_current()
|
||||
},
|
||||
settings.MAIL_DATA['revente']['FROM'],
|
||||
[participant.user.email])
|
||||
inscrits = self.attribution.spectacle.subscribed.select_related("user")
|
||||
datatuple = [
|
||||
(
|
||||
"bda-revente",
|
||||
{
|
||||
"member": participant.user,
|
||||
"show": self.attribution.spectacle,
|
||||
"revente": self,
|
||||
"site": Site.objects.get_current(),
|
||||
},
|
||||
settings.MAIL_DATA["revente"]["FROM"],
|
||||
[participant.user.email],
|
||||
)
|
||||
for participant in inscrits
|
||||
]
|
||||
send_mass_custom_mail(datatuple)
|
||||
|
@ -352,16 +353,18 @@ class SpectacleRevente(models.Model):
|
|||
Envoie un mail à toutes les personnes intéréssées par le spectacle pour
|
||||
leur indiquer qu'il est désormais disponible au shotgun.
|
||||
"""
|
||||
inscrits = self.attribution.spectacle.subscribed.select_related('user')
|
||||
datatuple = [(
|
||||
'bda-shotgun',
|
||||
{
|
||||
'member': participant.user,
|
||||
'show': self.attribution.spectacle,
|
||||
'site': Site.objects.get_current(),
|
||||
},
|
||||
settings.MAIL_DATA['revente']['FROM'],
|
||||
[participant.user.email])
|
||||
inscrits = self.attribution.spectacle.subscribed.select_related("user")
|
||||
datatuple = [
|
||||
(
|
||||
"bda-shotgun",
|
||||
{
|
||||
"member": participant.user,
|
||||
"show": self.attribution.spectacle,
|
||||
"site": Site.objects.get_current(),
|
||||
},
|
||||
settings.MAIL_DATA["revente"]["FROM"],
|
||||
[participant.user.email],
|
||||
)
|
||||
for participant in inscrits
|
||||
]
|
||||
send_mass_custom_mail(datatuple)
|
||||
|
@ -391,30 +394,33 @@ class SpectacleRevente(models.Model):
|
|||
mails = []
|
||||
|
||||
context = {
|
||||
'acheteur': winner.user,
|
||||
'vendeur': seller.user,
|
||||
'show': spectacle,
|
||||
"acheteur": winner.user,
|
||||
"vendeur": seller.user,
|
||||
"show": spectacle,
|
||||
}
|
||||
|
||||
c_mails_qs = CustomMail.objects.filter(shortname__in=[
|
||||
'bda-revente-winner', 'bda-revente-loser',
|
||||
'bda-revente-seller',
|
||||
])
|
||||
c_mails_qs = CustomMail.objects.filter(
|
||||
shortname__in=[
|
||||
"bda-revente-winner",
|
||||
"bda-revente-loser",
|
||||
"bda-revente-seller",
|
||||
]
|
||||
)
|
||||
|
||||
c_mails = {cm.shortname: cm for cm in c_mails_qs}
|
||||
|
||||
mails.append(
|
||||
c_mails['bda-revente-winner'].get_message(
|
||||
c_mails["bda-revente-winner"].get_message(
|
||||
context,
|
||||
from_email=settings.MAIL_DATA['revente']['FROM'],
|
||||
from_email=settings.MAIL_DATA["revente"]["FROM"],
|
||||
to=[winner.user.email],
|
||||
)
|
||||
)
|
||||
|
||||
mails.append(
|
||||
c_mails['bda-revente-seller'].get_message(
|
||||
c_mails["bda-revente-seller"].get_message(
|
||||
context,
|
||||
from_email=settings.MAIL_DATA['revente']['FROM'],
|
||||
from_email=settings.MAIL_DATA["revente"]["FROM"],
|
||||
to=[seller.user.email],
|
||||
reply_to=[winner.user.email],
|
||||
)
|
||||
|
@ -424,12 +430,12 @@ class SpectacleRevente(models.Model):
|
|||
for inscrit in inscrits:
|
||||
if inscrit != winner:
|
||||
new_context = dict(context)
|
||||
new_context['acheteur'] = inscrit.user
|
||||
new_context["acheteur"] = inscrit.user
|
||||
|
||||
mails.append(
|
||||
c_mails['bda-revente-loser'].get_message(
|
||||
c_mails["bda-revente-loser"].get_message(
|
||||
new_context,
|
||||
from_email=settings.MAIL_DATA['revente']['FROM'],
|
||||
from_email=settings.MAIL_DATA["revente"]["FROM"],
|
||||
to=[inscrit.user.email],
|
||||
)
|
||||
)
|
||||
|
|
|
@ -7,28 +7,33 @@ from django.test import TestCase
|
|||
from django.utils import timezone
|
||||
|
||||
from bda.models import (
|
||||
Attribution, Participant, Salle, Spectacle, SpectacleRevente, Tirage,
|
||||
Attribution,
|
||||
Participant,
|
||||
Salle,
|
||||
Spectacle,
|
||||
SpectacleRevente,
|
||||
Tirage,
|
||||
)
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class SpectacleReventeTests(TestCase):
|
||||
fixtures = ['gestioncof/management/data/custommail.json']
|
||||
fixtures = ["gestioncof/management/data/custommail.json"]
|
||||
|
||||
def setUp(self):
|
||||
now = timezone.now()
|
||||
|
||||
self.t = Tirage.objects.create(
|
||||
title='Tirage',
|
||||
title="Tirage",
|
||||
ouverture=now - timedelta(days=7),
|
||||
fermeture=now - timedelta(days=3),
|
||||
active=True,
|
||||
)
|
||||
self.s = Spectacle.objects.create(
|
||||
title='Spectacle',
|
||||
title="Spectacle",
|
||||
date=now + timedelta(days=20),
|
||||
location=Salle.objects.create(name='Salle', address='Address'),
|
||||
location=Salle.objects.create(name="Salle", address="Address"),
|
||||
price=10.5,
|
||||
slots=5,
|
||||
tirage=self.t,
|
||||
|
@ -36,31 +41,28 @@ class SpectacleReventeTests(TestCase):
|
|||
)
|
||||
|
||||
self.seller = Participant.objects.create(
|
||||
user=User.objects.create(
|
||||
username='seller', email='seller@mail.net'),
|
||||
user=User.objects.create(username="seller", email="seller@mail.net"),
|
||||
tirage=self.t,
|
||||
)
|
||||
self.p1 = Participant.objects.create(
|
||||
user=User.objects.create(username='part1', email='part1@mail.net'),
|
||||
user=User.objects.create(username="part1", email="part1@mail.net"),
|
||||
tirage=self.t,
|
||||
)
|
||||
self.p2 = Participant.objects.create(
|
||||
user=User.objects.create(username='part2', email='part2@mail.net'),
|
||||
user=User.objects.create(username="part2", email="part2@mail.net"),
|
||||
tirage=self.t,
|
||||
)
|
||||
self.p3 = Participant.objects.create(
|
||||
user=User.objects.create(username='part3', email='part3@mail.net'),
|
||||
user=User.objects.create(username="part3", email="part3@mail.net"),
|
||||
tirage=self.t,
|
||||
)
|
||||
|
||||
self.attr = Attribution.objects.create(
|
||||
participant=self.seller,
|
||||
spectacle=self.s,
|
||||
participant=self.seller, spectacle=self.s
|
||||
)
|
||||
|
||||
self.rev = SpectacleRevente.objects.create(
|
||||
attribution=self.attr,
|
||||
seller=self.seller,
|
||||
attribution=self.attr, seller=self.seller
|
||||
)
|
||||
|
||||
def test_tirage(self):
|
||||
|
@ -69,7 +71,7 @@ class SpectacleReventeTests(TestCase):
|
|||
wanted_by = [self.p1, self.p2, self.p3]
|
||||
revente.confirmed_entry = wanted_by
|
||||
|
||||
with mock.patch('bda.models.random.choice') as mc:
|
||||
with mock.patch("bda.models.random.choice") as mc:
|
||||
# Set winner to self.p1.
|
||||
mc.return_value = self.p1
|
||||
|
||||
|
@ -87,14 +89,14 @@ class SpectacleReventeTests(TestCase):
|
|||
|
||||
self.assertEqual(len(mails), 4)
|
||||
|
||||
m_seller = mails['seller@mail.net']
|
||||
self.assertListEqual(m_seller.to, ['seller@mail.net'])
|
||||
self.assertListEqual(m_seller.reply_to, ['part1@mail.net'])
|
||||
m_seller = mails["seller@mail.net"]
|
||||
self.assertListEqual(m_seller.to, ["seller@mail.net"])
|
||||
self.assertListEqual(m_seller.reply_to, ["part1@mail.net"])
|
||||
|
||||
m_winner = mails['part1@mail.net']
|
||||
self.assertListEqual(m_winner.to, ['part1@mail.net'])
|
||||
m_winner = mails["part1@mail.net"]
|
||||
self.assertListEqual(m_winner.to, ["part1@mail.net"])
|
||||
|
||||
self.assertCountEqual(
|
||||
[mails['part2@mail.net'].to, mails['part3@mail.net'].to],
|
||||
[['part2@mail.net'], ['part3@mail.net']],
|
||||
[mails["part2@mail.net"].to, mails["part3@mail.net"].to],
|
||||
[["part2@mail.net"], ["part3@mail.net"]],
|
||||
)
|
||||
|
|
|
@ -1,60 +1,71 @@
|
|||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase, Client
|
||||
from django.utils import timezone
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
from bda.models import (Tirage, Spectacle, Salle, CategorieSpectacle,
|
||||
SpectacleRevente, Attribution, Participant)
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
|
||||
from bda.models import (
|
||||
Attribution,
|
||||
CategorieSpectacle,
|
||||
Participant,
|
||||
Salle,
|
||||
Spectacle,
|
||||
SpectacleRevente,
|
||||
Tirage,
|
||||
)
|
||||
|
||||
|
||||
class TestModels(TestCase):
|
||||
def setUp(self):
|
||||
self.tirage = Tirage.objects.create(
|
||||
title="Tirage test",
|
||||
appear_catalogue=True,
|
||||
ouverture=timezone.now(),
|
||||
fermeture=timezone.now()
|
||||
title="Tirage test",
|
||||
appear_catalogue=True,
|
||||
ouverture=timezone.now(),
|
||||
fermeture=timezone.now(),
|
||||
)
|
||||
self.category = CategorieSpectacle.objects.create(name="Category")
|
||||
self.location = Salle.objects.create(name="here")
|
||||
self.spectacle_soon = Spectacle.objects.create(
|
||||
title="foo", date=timezone.now()+timedelta(days=1),
|
||||
location=self.location, price=0, slots=42,
|
||||
tirage=self.tirage, listing=False, category=self.category
|
||||
title="foo",
|
||||
date=timezone.now() + timedelta(days=1),
|
||||
location=self.location,
|
||||
price=0,
|
||||
slots=42,
|
||||
tirage=self.tirage,
|
||||
listing=False,
|
||||
category=self.category,
|
||||
)
|
||||
self.spectacle_later = Spectacle.objects.create(
|
||||
title="bar", date=timezone.now()+timedelta(days=30),
|
||||
location=self.location, price=0, slots=42,
|
||||
tirage=self.tirage, listing=False, category=self.category
|
||||
title="bar",
|
||||
date=timezone.now() + timedelta(days=30),
|
||||
location=self.location,
|
||||
price=0,
|
||||
slots=42,
|
||||
tirage=self.tirage,
|
||||
listing=False,
|
||||
category=self.category,
|
||||
)
|
||||
|
||||
user_buyer = User.objects.create_user(
|
||||
username="bda_buyer", password="testbuyer"
|
||||
username="bda_buyer", password="testbuyer"
|
||||
)
|
||||
user_seller = User.objects.create_user(
|
||||
username="bda_seller", password="testseller"
|
||||
)
|
||||
self.buyer = Participant.objects.create(
|
||||
user=user_buyer, tirage=self.tirage
|
||||
)
|
||||
self.seller = Participant.objects.create(
|
||||
user=user_seller, tirage=self.tirage
|
||||
username="bda_seller", password="testseller"
|
||||
)
|
||||
self.buyer = Participant.objects.create(user=user_buyer, tirage=self.tirage)
|
||||
self.seller = Participant.objects.create(user=user_seller, tirage=self.tirage)
|
||||
|
||||
self.attr_soon = Attribution.objects.create(
|
||||
participant=self.seller, spectacle=self.spectacle_soon
|
||||
participant=self.seller, spectacle=self.spectacle_soon
|
||||
)
|
||||
self.attr_later = Attribution.objects.create(
|
||||
participant=self.seller, spectacle=self.spectacle_later
|
||||
participant=self.seller, spectacle=self.spectacle_later
|
||||
)
|
||||
self.revente_soon = SpectacleRevente.objects.create(
|
||||
seller=self.seller,
|
||||
attribution=self.attr_soon
|
||||
seller=self.seller, attribution=self.attr_soon
|
||||
)
|
||||
self.revente_later = SpectacleRevente.objects.create(
|
||||
seller=self.seller,
|
||||
attribution=self.attr_later
|
||||
seller=self.seller, attribution=self.attr_later
|
||||
)
|
||||
|
||||
def test_urgent(self):
|
||||
|
@ -64,6 +75,5 @@ class TestModels(TestCase):
|
|||
def test_tirage(self):
|
||||
self.revente_soon.confirmed_entry.add(self.buyer)
|
||||
|
||||
self.assertEqual(self.revente_soon.tirage(send_mails=False),
|
||||
self.buyer)
|
||||
self.assertEqual(self.revente_soon.tirage(send_mails=False), self.buyer)
|
||||
self.assertIsNone(self.revente_later.tirage(send_mails=False))
|
||||
|
|
|
@ -1,14 +1,92 @@
|
|||
import json
|
||||
from datetime import timedelta
|
||||
from unittest import mock
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase, Client
|
||||
from django.test import Client, TestCase
|
||||
from django.utils import timezone
|
||||
|
||||
from bda.models import Tirage, Spectacle, Salle, CategorieSpectacle
|
||||
from ..models import CategorieSpectacle, Salle, Spectacle, Tirage
|
||||
|
||||
|
||||
class TestBdAViews(TestCase):
|
||||
def create_user(username, is_cof=False, is_buro=False):
|
||||
user = User.objects.create_user(username=username, password=username)
|
||||
user.profile.is_cof = is_cof
|
||||
user.profile.is_buro = is_buro
|
||||
user.profile.save()
|
||||
return user
|
||||
|
||||
|
||||
def user_is_cof(user):
|
||||
return (user is not None) and user.profile.is_cof
|
||||
|
||||
|
||||
def user_is_staff(user):
|
||||
return (user is not None) and user.profile.is_buro
|
||||
|
||||
|
||||
class BdATestHelpers:
|
||||
def setUp(self):
|
||||
# Some user with different access privileges
|
||||
staff = create_user(username="bda_staff", is_cof=True, is_buro=True)
|
||||
staff_c = Client()
|
||||
staff_c.force_login(staff)
|
||||
|
||||
member = create_user(username="bda_member", is_cof=True)
|
||||
member_c = Client()
|
||||
member_c.force_login(member)
|
||||
|
||||
other = create_user(username="bda_other")
|
||||
other_c = Client()
|
||||
other_c.force_login(other)
|
||||
|
||||
self.client_matrix = [
|
||||
(staff, staff_c),
|
||||
(member, member_c),
|
||||
(other, other_c),
|
||||
(None, Client()),
|
||||
]
|
||||
|
||||
def require_custommails(self):
|
||||
from django.core.management import call_command
|
||||
|
||||
call_command("syncmails", verbosity=0)
|
||||
|
||||
def check_restricted_access(
|
||||
self, url, validate_user=user_is_cof, redirect_url=None
|
||||
):
|
||||
def craft_redirect_url(user):
|
||||
if redirect_url:
|
||||
return redirect_url
|
||||
elif user is None:
|
||||
# client is not logged in
|
||||
login_url = "/login"
|
||||
if url:
|
||||
login_url += "?{}".format(urlencode({"next": url}, safe="/"))
|
||||
return login_url
|
||||
else:
|
||||
return "/"
|
||||
|
||||
for (user, client) in self.client_matrix:
|
||||
resp = client.get(url, follow=True)
|
||||
if validate_user(user):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
else:
|
||||
self.assertRedirects(resp, craft_redirect_url(user))
|
||||
|
||||
|
||||
class TestBdAViews(BdATestHelpers, TestCase):
|
||||
def setUp(self):
|
||||
# Signals handlers on login/logout send messages.
|
||||
# Due to the way the Django' test Client performs login, this raise an
|
||||
# error. As workaround, we mock the Django' messages module.
|
||||
patcher_messages = mock.patch("gestioncof.signals.messages")
|
||||
patcher_messages.start()
|
||||
self.addCleanup(patcher_messages.stop)
|
||||
# Set up the helpers
|
||||
super().setUp()
|
||||
# Some BdA stuff
|
||||
self.tirage = Tirage.objects.create(
|
||||
title="Test tirage",
|
||||
appear_catalogue=True,
|
||||
|
@ -17,82 +95,137 @@ class TestBdAViews(TestCase):
|
|||
)
|
||||
self.category = CategorieSpectacle.objects.create(name="Category")
|
||||
self.location = Salle.objects.create(name="here")
|
||||
Spectacle.objects.bulk_create([
|
||||
Spectacle(
|
||||
title="foo", date=timezone.now(), location=self.location,
|
||||
price=0, slots=42, tirage=self.tirage, listing=False,
|
||||
category=self.category
|
||||
),
|
||||
Spectacle(
|
||||
title="bar", date=timezone.now(), location=self.location,
|
||||
price=1, slots=142, tirage=self.tirage, listing=False,
|
||||
category=self.category
|
||||
),
|
||||
Spectacle(
|
||||
title="baz", date=timezone.now(), location=self.location,
|
||||
price=2, slots=242, tirage=self.tirage, listing=False,
|
||||
category=self.category
|
||||
),
|
||||
])
|
||||
|
||||
self.bda_user = User.objects.create_user(
|
||||
username="bda_user", password="bda4ever"
|
||||
Spectacle.objects.bulk_create(
|
||||
[
|
||||
Spectacle(
|
||||
title="foo",
|
||||
date=timezone.now(),
|
||||
location=self.location,
|
||||
price=0,
|
||||
slots=42,
|
||||
tirage=self.tirage,
|
||||
listing=False,
|
||||
category=self.category,
|
||||
),
|
||||
Spectacle(
|
||||
title="bar",
|
||||
date=timezone.now(),
|
||||
location=self.location,
|
||||
price=1,
|
||||
slots=142,
|
||||
tirage=self.tirage,
|
||||
listing=False,
|
||||
category=self.category,
|
||||
),
|
||||
Spectacle(
|
||||
title="baz",
|
||||
date=timezone.now(),
|
||||
location=self.location,
|
||||
price=2,
|
||||
slots=242,
|
||||
tirage=self.tirage,
|
||||
listing=False,
|
||||
category=self.category,
|
||||
),
|
||||
]
|
||||
)
|
||||
self.bda_user.profile.is_cof = True
|
||||
self.bda_user.profile.is_buro = True
|
||||
self.bda_user.profile.save()
|
||||
|
||||
def bda_participants(self):
|
||||
"""The BdA participants views can be queried"""
|
||||
client = Client()
|
||||
def test_bda_inscriptions(self):
|
||||
# TODO: test the form
|
||||
url = "/bda/inscription/{}".format(self.tirage.id)
|
||||
self.check_restricted_access(url)
|
||||
|
||||
def test_bda_places(self):
|
||||
url = "/bda/places/{}".format(self.tirage.id)
|
||||
self.check_restricted_access(url)
|
||||
|
||||
def test_etat_places(self):
|
||||
url = "/bda/etat-places/{}".format(self.tirage.id)
|
||||
self.check_restricted_access(url)
|
||||
|
||||
def test_perform_tirage(self):
|
||||
# Only staff member can perform a tirage
|
||||
url = "/bda/tirage/{}".format(self.tirage.id)
|
||||
self.check_restricted_access(url, validate_user=user_is_staff)
|
||||
|
||||
_, staff_c = self.client_matrix[0]
|
||||
# Cannot be performed if disabled
|
||||
self.tirage.enable_do_tirage = False
|
||||
self.tirage.save()
|
||||
resp = staff_c.get(url)
|
||||
self.assertTemplateUsed(resp, "tirage-failed.html")
|
||||
# Cannot be performed if registrations are still open
|
||||
self.tirage.enable_do_tirage = True
|
||||
self.tirage.fermeture = timezone.now() + timedelta(seconds=3600)
|
||||
self.tirage.save()
|
||||
resp = staff_c.get(url)
|
||||
self.assertTemplateUsed(resp, "tirage-failed.html")
|
||||
# Otherwise, perform the tirage
|
||||
self.tirage.fermeture = timezone.now()
|
||||
self.tirage.save()
|
||||
resp = staff_c.get(url)
|
||||
self.assertTemplateNotUsed(resp, "tirage-failed.html")
|
||||
|
||||
def test_spectacles_list(self):
|
||||
url = "/bda/spectacles/{}".format(self.tirage.id)
|
||||
self.check_restricted_access(url, validate_user=user_is_staff)
|
||||
|
||||
def test_spectacle_detail(self):
|
||||
show = self.tirage.spectacle_set.first()
|
||||
url = "/bda/spectacles/{}/{}".format(self.tirage.id, show.id)
|
||||
self.check_restricted_access(url, validate_user=user_is_staff)
|
||||
|
||||
client.login(self.bda_user.username, "bda4ever")
|
||||
tirage_resp = client.get("/bda/spectacles/{}".format(self.tirage.id))
|
||||
show_resp = client.get(
|
||||
"/bda/spectacles/{}/{}".format(self.tirage.id, show.id)
|
||||
)
|
||||
reminder_url = "/bda/mails-rappel/{}".format(show.id)
|
||||
reminder_get_resp = client.get(reminder_url)
|
||||
reminder_post_resp = client.post(reminder_url)
|
||||
self.assertEqual(200, tirage_resp.status_code)
|
||||
self.assertEqual(200, show_resp.status_code)
|
||||
self.assertEqual(200, reminder_get_resp.status_code)
|
||||
self.assertEqual(200, reminder_post_resp.status_code)
|
||||
def test_tirage_unpaid(self):
|
||||
url = "/bda/spectacles/unpaid/{}".format(self.tirage.id)
|
||||
self.check_restricted_access(url, validate_user=user_is_staff)
|
||||
|
||||
def test_catalogue(self):
|
||||
"""Test the catalogue JSON API"""
|
||||
client = Client()
|
||||
def test_send_reminders(self):
|
||||
self.require_custommails()
|
||||
# Just get the page
|
||||
show = self.tirage.spectacle_set.first()
|
||||
url = "/bda/mails-rappel/{}".format(show.id)
|
||||
self.check_restricted_access(url, validate_user=user_is_staff)
|
||||
# Actually send the reminder emails
|
||||
_, staff_c = self.client_matrix[0]
|
||||
resp = staff_c.post(url)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
# TODO: check that emails are sent
|
||||
|
||||
# The `list` hook
|
||||
resp = client.get("/bda/catalogue/list")
|
||||
def test_catalogue_api(self):
|
||||
url_list = "/bda/catalogue/list"
|
||||
url_details = "/bda/catalogue/details?id={}".format(self.tirage.id)
|
||||
url_descriptions = "/bda/catalogue/descriptions?id={}".format(self.tirage.id)
|
||||
|
||||
# Anyone can get
|
||||
def anyone_can_get(url):
|
||||
self.check_restricted_access(url, validate_user=lambda user: True)
|
||||
|
||||
anyone_can_get(url_list)
|
||||
anyone_can_get(url_details)
|
||||
anyone_can_get(url_descriptions)
|
||||
|
||||
# The resulting JSON contains the information
|
||||
_, client = self.client_matrix[0]
|
||||
|
||||
# List
|
||||
resp = client.get(url_list)
|
||||
self.assertJSONEqual(
|
||||
resp.content.decode("utf-8"),
|
||||
[{"id": self.tirage.id, "title": self.tirage.title}]
|
||||
[{"id": self.tirage.id, "title": self.tirage.title}],
|
||||
)
|
||||
|
||||
# The `details` hook
|
||||
resp = client.get(
|
||||
"/bda/catalogue/details?id={}".format(self.tirage.id)
|
||||
)
|
||||
# Details
|
||||
resp = client.get(url_details)
|
||||
self.assertJSONEqual(
|
||||
resp.content.decode("utf-8"),
|
||||
{
|
||||
"categories": [{
|
||||
"id": self.category.id,
|
||||
"name": self.category.name
|
||||
}],
|
||||
"locations": [{
|
||||
"id": self.location.id,
|
||||
"name": self.location.name
|
||||
}],
|
||||
}
|
||||
"categories": [{"id": self.category.id, "name": self.category.name}],
|
||||
"locations": [{"id": self.location.id, "name": self.location.name}],
|
||||
},
|
||||
)
|
||||
|
||||
# The `descriptions` hook
|
||||
resp = client.get(
|
||||
"/bda/catalogue/descriptions?id={}".format(self.tirage.id)
|
||||
)
|
||||
# Descriptions
|
||||
resp = client.get(url_descriptions)
|
||||
raw = resp.content.decode("utf-8")
|
||||
try:
|
||||
results = json.loads(raw)
|
||||
|
@ -101,5 +234,10 @@ class TestBdAViews(TestCase):
|
|||
self.assertEqual(len(results), 3)
|
||||
self.assertEqual(
|
||||
{(s["title"], s["price"], s["slots"]) for s in results},
|
||||
{("foo", 0, 42), ("bar", 1, 142), ("baz", 2, 242)}
|
||||
{("foo", 0, 42), ("bar", 1, 142), ("baz", 2, 242)},
|
||||
)
|
||||
|
||||
|
||||
class TestBdaRevente:
|
||||
pass
|
||||
# TODO
|
||||
|
|
109
bda/urls.py
109
bda/urls.py
|
@ -1,68 +1,75 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import url
|
||||
from gestioncof.decorators import buro_required
|
||||
from bda.views import SpectacleListView
|
||||
|
||||
from bda import views
|
||||
from bda.views import SpectacleListView
|
||||
from gestioncof.decorators import buro_required
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^inscription/(?P<tirage_id>\d+)$',
|
||||
url(
|
||||
r"^inscription/(?P<tirage_id>\d+)$",
|
||||
views.inscription,
|
||||
name='bda-tirage-inscription'),
|
||||
url(r'^places/(?P<tirage_id>\d+)$',
|
||||
views.places,
|
||||
name="bda-places-attribuees"),
|
||||
url(r'^etat-places/(?P<tirage_id>\d+)$',
|
||||
views.etat_places,
|
||||
name='bda-etat-places'),
|
||||
url(r'^tirage/(?P<tirage_id>\d+)$', views.tirage),
|
||||
url(r'^spectacles/(?P<tirage_id>\d+)$',
|
||||
name="bda-tirage-inscription",
|
||||
),
|
||||
url(r"^places/(?P<tirage_id>\d+)$", views.places, name="bda-places-attribuees"),
|
||||
url(r"^etat-places/(?P<tirage_id>\d+)$", views.etat_places, name="bda-etat-places"),
|
||||
url(r"^tirage/(?P<tirage_id>\d+)$", views.tirage),
|
||||
url(
|
||||
r"^spectacles/(?P<tirage_id>\d+)$",
|
||||
buro_required(SpectacleListView.as_view()),
|
||||
name="bda-liste-spectacles"),
|
||||
url(r'^spectacles/(?P<tirage_id>\d+)/(?P<spectacle_id>\d+)$',
|
||||
name="bda-liste-spectacles",
|
||||
),
|
||||
url(
|
||||
r"^spectacles/(?P<tirage_id>\d+)/(?P<spectacle_id>\d+)$",
|
||||
views.spectacle,
|
||||
name="bda-spectacle"),
|
||||
url(r'^spectacles/unpaid/(?P<tirage_id>\d+)$',
|
||||
views.unpaid,
|
||||
name="bda-unpaid"),
|
||||
url(r'^spectacles/autocomplete$',
|
||||
name="bda-spectacle",
|
||||
),
|
||||
url(r"^spectacles/unpaid/(?P<tirage_id>\d+)$", views.unpaid, name="bda-unpaid"),
|
||||
url(
|
||||
r"^spectacles/autocomplete$",
|
||||
views.spectacle_autocomplete,
|
||||
name="bda-spectacle-autocomplete"),
|
||||
url(r'^participants/autocomplete$',
|
||||
name="bda-spectacle-autocomplete",
|
||||
),
|
||||
url(
|
||||
r"^participants/autocomplete$",
|
||||
views.participant_autocomplete,
|
||||
name="bda-participant-autocomplete"),
|
||||
|
||||
name="bda-participant-autocomplete",
|
||||
),
|
||||
# Urls BdA-Revente
|
||||
|
||||
url(r'^revente/(?P<tirage_id>\d+)/manage$',
|
||||
url(
|
||||
r"^revente/(?P<tirage_id>\d+)/manage$",
|
||||
views.revente_manage,
|
||||
name='bda-revente-manage'),
|
||||
url(r'^revente/(?P<tirage_id>\d+)/subscribe$',
|
||||
name="bda-revente-manage",
|
||||
),
|
||||
url(
|
||||
r"^revente/(?P<tirage_id>\d+)/subscribe$",
|
||||
views.revente_subscribe,
|
||||
name="bda-revente-subscribe"),
|
||||
url(r'^revente/(?P<tirage_id>\d+)/tirages$',
|
||||
name="bda-revente-subscribe",
|
||||
),
|
||||
url(
|
||||
r"^revente/(?P<tirage_id>\d+)/tirages$",
|
||||
views.revente_tirages,
|
||||
name="bda-revente-tirages"),
|
||||
url(r'^revente/(?P<spectacle_id>\d+)/buy$',
|
||||
name="bda-revente-tirages",
|
||||
),
|
||||
url(
|
||||
r"^revente/(?P<spectacle_id>\d+)/buy$",
|
||||
views.revente_buy,
|
||||
name="bda-revente-buy"),
|
||||
url(r'^revente/(?P<revente_id>\d+)/confirm$',
|
||||
name="bda-revente-buy",
|
||||
),
|
||||
url(
|
||||
r"^revente/(?P<revente_id>\d+)/confirm$",
|
||||
views.revente_confirm,
|
||||
name='bda-revente-confirm'),
|
||||
url(r'^revente/(?P<tirage_id>\d+)/shotgun$',
|
||||
name="bda-revente-confirm",
|
||||
),
|
||||
url(
|
||||
r"^revente/(?P<tirage_id>\d+)/shotgun$",
|
||||
views.revente_shotgun,
|
||||
name="bda-revente-shotgun"),
|
||||
|
||||
url(r'^mails-rappel/(?P<spectacle_id>\d+)$',
|
||||
views.send_rappel,
|
||||
name="bda-rappels"
|
||||
),
|
||||
url(r'^descriptions/(?P<tirage_id>\d+)$', views.descriptions_spectacles,
|
||||
name='bda-descriptions'),
|
||||
url(r'^catalogue/(?P<request_type>[a-z]+)$', views.catalogue,
|
||||
name='bda-catalogue'),
|
||||
name="bda-revente-shotgun",
|
||||
),
|
||||
url(r"^mails-rappel/(?P<spectacle_id>\d+)$", views.send_rappel, name="bda-rappels"),
|
||||
url(
|
||||
r"^descriptions/(?P<tirage_id>\d+)$",
|
||||
views.descriptions_spectacles,
|
||||
name="bda-descriptions",
|
||||
),
|
||||
url(r"^catalogue/(?P<request_type>[a-z]+)$", views.catalogue, name="bda-catalogue"),
|
||||
]
|
||||
|
|
659
bda/views.py
659
bda/views.py
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue