Merge branch 'Elarnon/upgrade' into 'master'

Mise à jour vers Django 1.8

Ce patch effectue la mise à jour de Django vers la version 1.8, corrigeant à la fois les erreurs fatales et problèmes de version.

Pour appliquer ce patch, il faut penser à :
 - Lancer `pip install --upgrade requirements.txt`
 - Lancer `python manage.py migrate` pour mettre à jour les modèles internes de Django
 - Supprimer la ligne `AUTH_PROFILE_MODULE = 'gestioncof.CofProfile'`, devenue obsolète, du `settings.py`

See merge request !1
This commit is contained in:
Martin Pepin 2016-05-24 09:26:16 +02:00
commit dc0880a9fc
18 changed files with 48 additions and 48 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

12
requirements.txt Normal file
View file

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

View file

@ -9,7 +9,7 @@
<h1>Attribution</h1>
<h2>Token : {{ token }}</h2>
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</h2>
{% if user.get_profile.is_buro %}<h2>Déficit total: {{ total_deficit }} €, Opéra: {{ opera_deficit }} €, Attribué: {{ total_sold }} €</h2>{% endif %}
{% if user.profile.is_buro %}<h2>Déficit total: {{ total_deficit }} €, Opéra: {{ opera_deficit }} €, Attribué: {{ total_sold }} €</h2>{% endif %}
<h2>Temps de calcul : {{ duration|floatformat }}s</h2>
{% for show, members, losers in results %}
@ -17,7 +17,7 @@
<h2>{{ show.title }} - {{ show.date_no_seconds }} @ {{ show.location }}</h2>
<p>
<strong>{{ show.nrequests }} demandes pour {{ show.slots }} places</strong>
{{ 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 %}
</p>
Places :
<ul>

View file

@ -9,14 +9,14 @@
<h1>Attribution</h1>
<h2>Token : {{ token }}</h2>
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</h2>
{% if user.get_profile.is_buro %}<h2>Déficit total: {{ total_deficit }} €, Opéra: {{ opera_deficit }} €, Attribué: {{ total_sold }} €</h2>{% endif %}
{% if user.profile.is_buro %}<h2>Déficit total: {{ total_deficit }} €, Opéra: {{ opera_deficit }} €, Attribué: {{ total_sold }} €</h2>{% endif %}
{% for show, members, losers in results %}
<div class="attribresult">
<h2>{{ show.title }} - {{ show.date_no_seconds }} @ {{ show.location }}</h2>
<p>
<strong>{{ show.nrequests }} demandes pour {{ show.slots }} places</strong>
{{ 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 %}
</p>
Places :
<ul>

View file

@ -59,7 +59,7 @@
<li><a href="{% url "gestioncof.views.logout" %}">Se déconnecter</a></li>
</ul>
{% if user.get_profile.is_buro %}
{% if user.profile.is_buro %}
<h3>Administration</h3>
<ul>
<li><a href="{% url "admin:index" %}">Administration générale</a></li>

View file

@ -4,7 +4,7 @@
<h2>Inscription d'un nouveau membre</h2>
{% if success %}
<p class="success">L'inscription de {{ member.first_name }} {{ member.last_name }} (<tt>{{ member.username }}</tt>) a été enregistrée avec succès.
{% if member.get_profile.is_cof %}Il est désormais membre du COF n°{{ member.get_profile.num }} !{% endif %}</p>
{% if member.profile.is_cof %}Il est désormais membre du COF n°{{ member.profile.num }} !{% endif %}</p>
{% endif %}
<div id="form-placeholder">
{% include "registration_form.html" %}