diff --git a/Requirements.txt b/Requirements.txt deleted file mode 100644 index d27e2593..00000000 --- a/Requirements.txt +++ /dev/null @@ -1,12 +0,0 @@ -ConfigParser==3.5.0 -Django==1.6 -MySQL-python==1.2.5 -Pillow==2.9.0 -argparse==1.2.1 -captcha==0.1.1 -django-autocomplete-light==2.2.4 -django-autoslug==1.8.0 -django-grappelli==2.6.5 -eav-django==1.4.7 -six==1.9.0 -wsgiref==0.1.2 diff --git a/bda/admin.py b/bda/admin.py index 1a419dc4..bcbc609c 100644 --- a/bda/admin.py +++ b/bda/admin.py @@ -17,7 +17,7 @@ class AttributionInline(admin.TabularInline): class ParticipantAdmin(admin.ModelAdmin): #inlines = [ChoixSpectacleInline] inlines = [AttributionInline] - def queryset(self, request): + def get_queryset(self, request): return Participant.objects.annotate(nb_places = Count('attributions'), total = Sum('attributions__price')) def nb_places(self, obj): @@ -139,7 +139,7 @@ class AttributionAdmin(admin.ModelAdmin): import autocomplete_light class ChoixSpectacleAdmin(admin.ModelAdmin): - form = autocomplete_light.modelform_factory(ChoixSpectacle) + form = autocomplete_light.modelform_factory(ChoixSpectacle, exclude=[]) list_display = ("participant", "spectacle", "priority", "double_choice") list_filter = ("double_choice",) search_fields = ('participant__user__username', 'participant__user__first_name', 'participant__user__last_name') diff --git a/bda/models.py b/bda/models.py index 5ef4f9bf..11c9dd3b 100644 --- a/bda/models.py +++ b/bda/models.py @@ -48,7 +48,7 @@ PAYMENT_TYPES = ( ) class Participant (models.Model): - user = models.ForeignKey(User, unique = True) + user = models.OneToOneField(User) choices = models.ManyToManyField(Spectacle, through = "ChoixSpectacle", related_name = "chosen_by") attributions = models.ManyToManyField(Spectacle, through = "Attribution", related_name = "attributed_to") paid = models.BooleanField (u"A payé", default = False) diff --git a/bda2/admin.py b/bda2/admin.py index 32325b0b..84eebfa3 100644 --- a/bda2/admin.py +++ b/bda2/admin.py @@ -17,7 +17,7 @@ class AttributionInline(admin.TabularInline): class ParticipantAdmin(admin.ModelAdmin): #inlines = [ChoixSpectacleInline] inlines = [AttributionInline] - def queryset(self, request): + def get_queryset(self, request): return Participant.objects.annotate(nb_places = Count('attributions'), total = Sum('attributions__price')) def nb_places(self, obj): @@ -159,7 +159,7 @@ class AttributionAdmin(admin.ModelAdmin): import autocomplete_light class ChoixSpectacleAdmin(admin.ModelAdmin): - form = autocomplete_light.modelform_factory(ChoixSpectacle) + form = autocomplete_light.modelform_factory(ChoixSpectacle, exclude=[]) list_display = ("participant", "spectacle", "priority", "double", "autoquit") list_filter = ("double", "autoquit") search_fields = ('participant__user__username', 'participant__user__first_name', 'participant__user__last_name') diff --git a/bda2/models.py b/bda2/models.py index bcc4e15c..c9fefe6e 100644 --- a/bda2/models.py +++ b/bda2/models.py @@ -48,7 +48,7 @@ PAYMENT_TYPES = ( ) class Participant (models.Model): - user = models.ForeignKey(User, unique = True, related_name = "participants2") + user = models.OneToOneField(User, related_name = "participants2") choices = models.ManyToManyField(Spectacle, through = "ChoixSpectacle", related_name = "chosen_by") attributions = models.ManyToManyField(Spectacle, through = "Attribution", related_name = "attributed_to") paid = models.BooleanField (u"A payé", default = False) diff --git a/bda3/admin.py b/bda3/admin.py index a4c7b05a..26b0beed 100644 --- a/bda3/admin.py +++ b/bda3/admin.py @@ -17,7 +17,7 @@ class AttributionInline(admin.TabularInline): class ParticipantAdmin(admin.ModelAdmin): #inlines = [ChoixSpectacleInline] inlines = [AttributionInline] - def queryset(self, request): + def get_queryset(self, request): return Participant.objects.annotate(nb_places = Count('attributions'), total = Sum('attributions__price')) def nb_places(self, obj): @@ -162,7 +162,7 @@ class AttributionAdmin(admin.ModelAdmin): import autocomplete_light class ChoixSpectacleAdmin(admin.ModelAdmin): - form = autocomplete_light.modelform_factory(ChoixSpectacle) + form = autocomplete_light.modelform_factory(ChoixSpectacle, exclude=[]) list_display = ("participant", "spectacle", "priority", "double", "autoquit") list_filter = ("double", "autoquit") search_fields = ('participant__user__username', 'participant__user__first_name', 'participant__user__last_name') diff --git a/bda3/models.py b/bda3/models.py index 80153233..6ada1be3 100644 --- a/bda3/models.py +++ b/bda3/models.py @@ -48,7 +48,7 @@ PAYMENT_TYPES = ( ) class Participant (models.Model): - user = models.ForeignKey(User, unique = True, related_name = "participants3") + user = models.OneToOneField(User, related_name = "participants3") choices = models.ManyToManyField(Spectacle, through = "ChoixSpectacle", related_name = "chosen_by") attributions = models.ManyToManyField(Spectacle, through = "Attribution", related_name = "attributed_to") paid = models.BooleanField (u"A payé", default = False) diff --git a/gestioncof/admin.py b/gestioncof/admin.py index 8540ea44..860f37a2 100644 --- a/gestioncof/admin.py +++ b/gestioncof/admin.py @@ -97,7 +97,7 @@ class FkeyLookup(object): def ProfileInfo(field, short_description, boolean = False): def getter(self): try: - return getattr(self.get_profile(), field) + return getattr(self.profile, field) except CofProfile.DoesNotExist: return "" getter.short_description = short_description @@ -116,14 +116,14 @@ User.profile_mailing_bda_revente = ProfileInfo("mailing_bda_revente", "ML BDA-R" class UserProfileAdmin(UserAdmin): def is_buro(self, obj): try: - return obj.get_profile().is_buro + return obj.profile.is_buro except CofProfile.DoesNotExist: return False is_buro.short_description = 'Membre du Buro' is_buro.boolean = True def is_cof(self, obj): try: - return obj.get_profile().is_cof + return obj.profile.is_cof except CofProfile.DoesNotExist: return False is_cof.short_description = 'Membre du COF' @@ -144,7 +144,7 @@ def user_unicode(self): return self.username User.__unicode__ = user_unicode class EventRegistrationAdmin(admin.ModelAdmin): - form = autocomplete_light.modelform_factory(EventRegistration) + form = autocomplete_light.modelform_factory(EventRegistration, exclude=[]) list_display = ('__unicode__','event','user','paid') list_filter = ('paid',) search_fields = ('user__username', 'user__first_name', 'user__last_name', 'user__email', 'event__title') @@ -212,14 +212,14 @@ class VoterAdmin(UserProfileAdmin): def is_cof(self, obj): try: - return obj.get_profile().is_cof + return obj.profile.is_cof except CofProfile.DoesNotExist: return False is_cof.short_description = 'Membre du COF' is_cof.boolean = True def a_vote(self, obj): try: - if not obj.get_profile().eav.a_vot: + if not obj.profile.eav.a_vot: return False else: return True diff --git a/gestioncof/csv_views.py b/gestioncof/csv_views.py index 15f0b5d0..10eda18a 100644 --- a/gestioncof/csv_views.py +++ b/gestioncof/csv_views.py @@ -1,12 +1,12 @@ import csv from django.http import HttpResponse, HttpResponseForbidden from django.template.defaultfilters import slugify -from django.db.models.loading import get_model +from django.apps import apps from django.contrib.auth.models import User def export(qs, fields=None): model = qs.model - response = HttpResponse(mimetype='text/csv') + response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename=%s.csv' % slugify(model.__name__) writer = csv.writer(response) # Write headers to CSV file @@ -38,7 +38,7 @@ def admin_list_export(request, model_name, app_label, queryset=None, fields=None if not request.user.is_staff: return HttpResponseForbidden() if not queryset: - model = get_model(app_label, model_name) + model = apps.get_model(app_label, model_name) queryset = model.objects.all() filters = dict() """ diff --git a/gestioncof/decorators.py b/gestioncof/decorators.py index 4565f0cb..b276d372 100644 --- a/gestioncof/decorators.py +++ b/gestioncof/decorators.py @@ -2,7 +2,7 @@ from django_cas.decorators import user_passes_test def is_cof(user): try: - profile = user.get_profile() + profile = user.profile return profile.is_cof except: return False @@ -12,7 +12,7 @@ cof_required_customdenied = user_passes_test(lambda u: is_cof(u), login_url = "c def is_buro(user): try: - profile = user.get_profile() + profile = user.profile return profile.is_buro except: return False diff --git a/gestioncof/shared.py b/gestioncof/shared.py index fe8d9061..f46f7f90 100644 --- a/gestioncof/shared.py +++ b/gestioncof/shared.py @@ -37,7 +37,7 @@ class COFCASBackend(CASBackend): if user is None: return user try: - profile = user.get_profile() + profile = user.profile except CofProfile.DoesNotExist: profile, created = CofProfile.objects.get_or_create(user = user) profile.save() diff --git a/gestioncof/views.py b/gestioncof/views.py index bac9e574..8d99b071 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -53,7 +53,7 @@ def login_ext(request): @login_required def logout(request): try: - profile = request.user.get_profile() + profile = request.user.profile except CofProfile.DoesNotExist: profile, created = CofProfile.objects.get_or_create(user = request.user) if profile.login_clipper: @@ -409,12 +409,12 @@ class UserProfileForm(forms.ModelForm): def profile(request): success = False if request.method == "POST": - form = UserProfileForm(request.POST, instance = request.user.get_profile()) + form = UserProfileForm(request.POST, instance = request.user.profile) if form.is_valid(): form.save() success = True else: - form = UserProfileForm(instance = request.user.get_profile()) + form = UserProfileForm(instance = request.user.profile) return render(request, "profile.html", {"form": form, "success": success}) class RegistrationUserForm(forms.ModelForm): @@ -694,7 +694,7 @@ def registration(request): @buro_required def export_members(request): - response = HttpResponse(mimetype = 'text/csv') + response = HttpResponse(content_type = 'text/csv') response['Content-Disposition'] = 'attachment; filename=membres_cof.csv' writer = unicodecsv.UnicodeWriter(response) @@ -707,13 +707,13 @@ def export_members(request): @buro_required def csv_export_mega(filename, qs): - response = HttpResponse(mimetype = 'text/csv') + response = HttpResponse(content_type = 'text/csv') response['Content-Disposition'] = 'attachment; filename=' + filename writer = unicodecsv.UnicodeWriter(response) for reg in qs.all(): user = reg.user - profile = user.get_profile() + profile = user.profile comments = "---".join([comment.content for comment in reg.comments.all()]) bits = [user.username, user.first_name, user.last_name, user.email, profile.phone, profile.num, profile.comments if profile.comments else "", comments] writer.writerow([unicode(bit) for bit in bits]) @@ -723,7 +723,7 @@ def csv_export_mega(filename, qs): @buro_required def export_mega_remarksonly(request): filename = 'remarques_mega_2015.csv' - response = HttpResponse(mimetype = 'text/csv') + response = HttpResponse(content_type = 'text/csv') response['Content-Disposition'] = 'attachment; filename=' + filename writer = unicodecsv.UnicodeWriter(response) @@ -732,7 +732,7 @@ def export_mega_remarksonly(request): for val in commentfield.values.all(): reg = val.registration user = reg.user - profile = user.get_profile() + profile = user.profile bits = [user.username, user.first_name, user.last_name, user.email, profile.phone, profile.num, profile.comments, val.content] writer.writerow([unicode(bit) for bit in bits]) diff --git a/gestioncof/widgets.py b/gestioncof/widgets.py index e41ed3e7..4c864e38 100644 --- a/gestioncof/widgets.py +++ b/gestioncof/widgets.py @@ -1,5 +1,5 @@ from django.forms.widgets import Widget -from django.forms.util import flatatt +from django.forms.utils import flatatt from django.utils.safestring import mark_safe class TriStateCheckbox(Widget): diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..d8f4cc4e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,12 @@ +configparser==3.5.0 +Django==1.8.13 +django-autocomplete-light==2.3.3 +django-autoslug==1.8.0 +-e hg+https://bitbucket.org/cpcc/django-cas@47d19f3a871fa744dabe884758f90fff6ba135d5#egg=django_cas +django-grappelli==2.6.5 +django-recaptcha==1.0.5 +eav-django==1.4.7 +MySQL-python==1.2.5 +Pillow==2.9.0 +simplejson==3.8.2 +six==1.10.0 diff --git a/templates/bda/bda-attrib.html b/templates/bda/bda-attrib.html index 0946a4a3..382048c4 100644 --- a/templates/bda/bda-attrib.html +++ b/templates/bda/bda-attrib.html @@ -9,7 +9,7 @@

Attribution

Token : {{ token }}

Placés : {{ total_slots }} ; Déçus : {{ total_losers }}

-{% if user.get_profile.is_buro %}

Déficit total: {{ total_deficit }} €, Opéra: {{ opera_deficit }} €, Attribué: {{ total_sold }} €

{% endif %} +{% if user.profile.is_buro %}

Déficit total: {{ total_deficit }} €, Opéra: {{ opera_deficit }} €, Attribué: {{ total_sold }} €

{% endif %}

Temps de calcul : {{ duration|floatformat }}s

{% for show, members, losers in results %} @@ -17,7 +17,7 @@

{{ show.title }} - {{ show.date_no_seconds }} @ {{ show.location }}

{{ show.nrequests }} demandes pour {{ show.slots }} places -{{ show.price }}€ par place{% if user.get_profile.is_buro and show.nrequests < show.slots %}, {{ show.deficit }}€ de déficit{% endif %} +{{ show.price }}€ par place{% if user.profile.is_buro and show.nrequests < show.slots %}, {{ show.deficit }}€ de déficit{% endif %}

Places :