From 4857af0f7f2ea7be4408c530a19626ba2b280a7a Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Tue, 24 May 2016 00:02:25 +0200 Subject: [PATCH] get_profile does not exist anymore (django 1.7) --- gestioncof/admin.py | 10 +++++----- gestioncof/decorators.py | 4 ++-- gestioncof/shared.py | 2 +- gestioncof/views.py | 10 +++++----- templates/bda/bda-attrib.html | 4 ++-- templates/bda2/bda-attrib.html | 4 ++-- templates/gestioncof/home.html | 2 +- templates/gestioncof/registration_post.html | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gestioncof/admin.py b/gestioncof/admin.py index 8540ea44..dd96b022 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' @@ -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/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 9ef33bc2..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): @@ -713,7 +713,7 @@ def csv_export_mega(filename, qs): 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]) @@ -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/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 :