get_profile does not exist anymore (django 1.7)

This commit is contained in:
Basile Clement 2016-05-24 00:02:25 +02:00
parent 28bd07a433
commit 4857af0f7f
8 changed files with 19 additions and 19 deletions

View file

@ -97,7 +97,7 @@ class FkeyLookup(object):
def ProfileInfo(field, short_description, boolean = False): def ProfileInfo(field, short_description, boolean = False):
def getter(self): def getter(self):
try: try:
return getattr(self.get_profile(), field) return getattr(self.profile, field)
except CofProfile.DoesNotExist: except CofProfile.DoesNotExist:
return "" return ""
getter.short_description = short_description getter.short_description = short_description
@ -116,14 +116,14 @@ User.profile_mailing_bda_revente = ProfileInfo("mailing_bda_revente", "ML BDA-R"
class UserProfileAdmin(UserAdmin): class UserProfileAdmin(UserAdmin):
def is_buro(self, obj): def is_buro(self, obj):
try: try:
return obj.get_profile().is_buro return obj.profile.is_buro
except CofProfile.DoesNotExist: except CofProfile.DoesNotExist:
return False return False
is_buro.short_description = 'Membre du Buro' is_buro.short_description = 'Membre du Buro'
is_buro.boolean = True is_buro.boolean = True
def is_cof(self, obj): def is_cof(self, obj):
try: try:
return obj.get_profile().is_cof return obj.profile.is_cof
except CofProfile.DoesNotExist: except CofProfile.DoesNotExist:
return False return False
is_cof.short_description = 'Membre du COF' is_cof.short_description = 'Membre du COF'
@ -212,14 +212,14 @@ class VoterAdmin(UserProfileAdmin):
def is_cof(self, obj): def is_cof(self, obj):
try: try:
return obj.get_profile().is_cof return obj.profile.is_cof
except CofProfile.DoesNotExist: except CofProfile.DoesNotExist:
return False return False
is_cof.short_description = 'Membre du COF' is_cof.short_description = 'Membre du COF'
is_cof.boolean = True is_cof.boolean = True
def a_vote(self, obj): def a_vote(self, obj):
try: try:
if not obj.get_profile().eav.a_vot: if not obj.profile.eav.a_vot:
return False return False
else: else:
return True return True

View file

@ -2,7 +2,7 @@ from django_cas.decorators import user_passes_test
def is_cof(user): def is_cof(user):
try: try:
profile = user.get_profile() profile = user.profile
return profile.is_cof return profile.is_cof
except: except:
return False return False
@ -12,7 +12,7 @@ cof_required_customdenied = user_passes_test(lambda u: is_cof(u), login_url = "c
def is_buro(user): def is_buro(user):
try: try:
profile = user.get_profile() profile = user.profile
return profile.is_buro return profile.is_buro
except: except:
return False return False

View file

@ -37,7 +37,7 @@ class COFCASBackend(CASBackend):
if user is None: if user is None:
return user return user
try: try:
profile = user.get_profile() profile = user.profile
except CofProfile.DoesNotExist: except CofProfile.DoesNotExist:
profile, created = CofProfile.objects.get_or_create(user = user) profile, created = CofProfile.objects.get_or_create(user = user)
profile.save() profile.save()

View file

@ -53,7 +53,7 @@ def login_ext(request):
@login_required @login_required
def logout(request): def logout(request):
try: try:
profile = request.user.get_profile() profile = request.user.profile
except CofProfile.DoesNotExist: except CofProfile.DoesNotExist:
profile, created = CofProfile.objects.get_or_create(user = request.user) profile, created = CofProfile.objects.get_or_create(user = request.user)
if profile.login_clipper: if profile.login_clipper:
@ -409,12 +409,12 @@ class UserProfileForm(forms.ModelForm):
def profile(request): def profile(request):
success = False success = False
if request.method == "POST": 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(): if form.is_valid():
form.save() form.save()
success = True success = True
else: else:
form = UserProfileForm(instance = request.user.get_profile()) form = UserProfileForm(instance = request.user.profile)
return render(request, "profile.html", {"form": form, "success": success}) return render(request, "profile.html", {"form": form, "success": success})
class RegistrationUserForm(forms.ModelForm): class RegistrationUserForm(forms.ModelForm):
@ -713,7 +713,7 @@ def csv_export_mega(filename, qs):
for reg in qs.all(): for reg in qs.all():
user = reg.user user = reg.user
profile = user.get_profile() profile = user.profile
comments = "---".join([comment.content for comment in reg.comments.all()]) 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] 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]) writer.writerow([unicode(bit) for bit in bits])
@ -732,7 +732,7 @@ def export_mega_remarksonly(request):
for val in commentfield.values.all(): for val in commentfield.values.all():
reg = val.registration reg = val.registration
user = reg.user 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] 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]) writer.writerow([unicode(bit) for bit in bits])

View file

@ -9,7 +9,7 @@
<h1>Attribution</h1> <h1>Attribution</h1>
<h2>Token : {{ token }}</h2> <h2>Token : {{ token }}</h2>
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</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> <h2>Temps de calcul : {{ duration|floatformat }}s</h2>
{% for show, members, losers in results %} {% for show, members, losers in results %}
@ -17,7 +17,7 @@
<h2>{{ show.title }} - {{ show.date_no_seconds }} @ {{ show.location }}</h2> <h2>{{ show.title }} - {{ show.date_no_seconds }} @ {{ show.location }}</h2>
<p> <p>
<strong>{{ show.nrequests }} demandes pour {{ show.slots }} places</strong> <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> </p>
Places : Places :
<ul> <ul>

View file

@ -9,14 +9,14 @@
<h1>Attribution</h1> <h1>Attribution</h1>
<h2>Token : {{ token }}</h2> <h2>Token : {{ token }}</h2>
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</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 %} {% for show, members, losers in results %}
<div class="attribresult"> <div class="attribresult">
<h2>{{ show.title }} - {{ show.date_no_seconds }} @ {{ show.location }}</h2> <h2>{{ show.title }} - {{ show.date_no_seconds }} @ {{ show.location }}</h2>
<p> <p>
<strong>{{ show.nrequests }} demandes pour {{ show.slots }} places</strong> <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> </p>
Places : Places :
<ul> <ul>

View file

@ -59,7 +59,7 @@
<li><a href="{% url "gestioncof.views.logout" %}">Se déconnecter</a></li> <li><a href="{% url "gestioncof.views.logout" %}">Se déconnecter</a></li>
</ul> </ul>
{% if user.get_profile.is_buro %} {% if user.profile.is_buro %}
<h3>Administration</h3> <h3>Administration</h3>
<ul> <ul>
<li><a href="{% url "admin:index" %}">Administration générale</a></li> <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> <h2>Inscription d'un nouveau membre</h2>
{% if success %} {% 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. <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 %} {% endif %}
<div id="form-placeholder"> <div id="form-placeholder">
{% include "registration_form.html" %} {% include "registration_form.html" %}