s/cofprofile/profile/g into k-fêt.

This commit also restores the only unittest present.
This commit is contained in:
Michele Orrù 2017-02-10 22:58:01 +01:00
parent f39d1545f0
commit 22da04c3e2
9 changed files with 158 additions and 150 deletions

View file

@ -63,17 +63,6 @@ class CofProfile(models.Model):
return self.user.username
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
CofProfile.objects.get_or_create(user=instance)
@receiver(post_delete, sender=CofProfile)
def post_delete_user(sender, instance, *args, **kwargs):
instance.user.delete()
@python_2_unicode_compatible
class Club(models.Model):
name = models.CharField("Nom", max_length=200, unique=True)

View file

@ -1,33 +1,3 @@
# -*- coding: utf-8 -*-
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from django.test import TestCase
from .models import CofProfile, User
class SimpleTest(TestCase):
def test_delete_user(self):
u = User(username='foo', first_name='foo', last_name='bar')
# to each user there's a cofprofile associated
u.save()
self.assertTrue(CofProfile.objects.filter(user__username='foo').exists())
# there's no point in having a cofprofile without a user associated.
u.delete()
self.assertFalse(CofProfile.objects.filter(user__username='foo').exists())
# there's no point in having a user without a cofprofile associated.
u.save()
CofProfile.objects.get(user__username='foo').delete()
self.assertFalse(User.objects.filter(username='foo').exists())
# Create your tests here.

View file

@ -1,3 +1,33 @@
# -*- coding: utf-8 -*-
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from django.test import TestCase
# Create your tests here.
from gestion.models import Profile, User
class SimpleTest(TestCase):
def test_delete_user(self):
u = User(username='foo', first_name='foo', last_name='bar')
# to each user there's a cofprofile associated
u.save()
self.assertTrue(Profile.objects.filter(user__username='foo').exists())
# there's no point in having a cofprofile without a user associated.
u.delete()
self.assertFalse(Profile.objects.filter(user__username='foo').exists())
# there's no point in having a user without a cofprofile associated.
u.save()
Profile.objects.get(user__username='foo').delete()
self.assertFalse(User.objects.filter(username='foo').exists())

View file

@ -32,9 +32,9 @@ def account_create(request):
for word in search_words:
queries['kfet'] = queries['kfet'].filter(
Q(cofprofile__user__username__icontains = word)
| Q(cofprofile__user__first_name__icontains = word)
| Q(cofprofile__user__last_name__icontains = word)
Q(profile__user__username__icontains = word)
| Q(profile__user__first_name__icontains = word)
| Q(profile__user__last_name__icontains = word)
)
queries['users_cof'] = queries['users_cof'].filter(
Q(username__icontains = word)
@ -54,9 +54,9 @@ def account_create(request):
queries['kfet'] = queries['kfet'].distinct()
usernames = list( \
queries['kfet'].values_list('cofprofile__user__username', flat=True))
queries['kfet'].values_list('profile__user__username', flat=True))
queries['kfet'] = [ (account, account.cofprofile.user) \
queries['kfet'] = [ (account, account.profile.user) \
for account in queries['kfet'] ]
queries['users_cof'] = \

View file

@ -20,7 +20,7 @@ class KFetBackend(object):
try:
password_sha256 = hashlib.sha256(password.encode('utf-8')).hexdigest()
account = Account.objects.get(password=password_sha256)
user = account.cofprofile.user
user = account.profile.user
except Account.DoesNotExist:
return None
@ -34,7 +34,7 @@ class GenericTeamBackend(object):
user, _ = User.objects.get_or_create(username='kfet_genericteam')
profile, _ = CofProfile.objects.get_or_create(user=user)
account, _ = Account.objects.get_or_create(
cofprofile=profile,
profile=profile,
trigramme='GNR')
# Ajoute la permission kfet.is_team à ce user

View file

@ -4,7 +4,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 1,
"profile": 1,
"created_at": "2017-01-02T23:13:49.236Z",
"is_frozen": false,
"balance": "0.00",
@ -18,7 +18,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 2,
"profile": 2,
"created_at": "2017-01-02T23:13:49.242Z",
"is_frozen": false,
"balance": "0.00",
@ -32,7 +32,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 3,
"profile": 3,
"created_at": "2017-01-02T23:13:49.245Z",
"is_frozen": false,
"balance": "0.00",
@ -46,7 +46,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 4,
"profile": 4,
"created_at": "2017-01-02T23:13:49.250Z",
"is_frozen": false,
"balance": "0.00",
@ -60,7 +60,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 5,
"profile": 5,
"created_at": "2017-01-02T23:13:49.253Z",
"is_frozen": false,
"balance": "0.00",
@ -74,7 +74,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 6,
"profile": 6,
"created_at": "2017-01-02T23:13:49.256Z",
"is_frozen": false,
"balance": "0.00",
@ -88,7 +88,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 7,
"profile": 7,
"created_at": "2017-01-02T23:13:49.258Z",
"is_frozen": false,
"balance": "0.00",
@ -102,7 +102,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 8,
"profile": 8,
"created_at": "2017-01-02T23:13:49.259Z",
"is_frozen": false,
"balance": "0.00",
@ -116,7 +116,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 9,
"profile": 9,
"created_at": "2017-01-02T23:13:49.261Z",
"is_frozen": false,
"balance": "0.00",
@ -130,7 +130,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 10,
"profile": 10,
"created_at": "2017-01-02T23:13:49.262Z",
"is_frozen": false,
"balance": "0.00",
@ -144,7 +144,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 11,
"profile": 11,
"created_at": "2017-01-02T23:13:49.264Z",
"is_frozen": false,
"balance": "0.00",
@ -158,7 +158,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 12,
"profile": 12,
"created_at": "2017-01-02T23:13:49.265Z",
"is_frozen": false,
"balance": "0.00",
@ -172,7 +172,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 13,
"profile": 13,
"created_at": "2017-01-02T23:13:49.266Z",
"is_frozen": false,
"balance": "0.00",
@ -186,7 +186,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 14,
"profile": 14,
"created_at": "2017-01-02T23:13:49.267Z",
"is_frozen": false,
"balance": "0.00",
@ -200,7 +200,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 15,
"profile": 15,
"created_at": "2017-01-02T23:13:49.268Z",
"is_frozen": false,
"balance": "0.00",
@ -214,7 +214,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 16,
"profile": 16,
"created_at": "2017-01-02T23:13:49.269Z",
"is_frozen": false,
"balance": "0.00",
@ -228,7 +228,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 17,
"profile": 17,
"created_at": "2017-01-02T23:13:49.270Z",
"is_frozen": false,
"balance": "0.00",
@ -242,7 +242,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 18,
"profile": 18,
"created_at": "2017-01-02T23:13:49.271Z",
"is_frozen": false,
"balance": "0.00",
@ -256,7 +256,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 19,
"profile": 19,
"created_at": "2017-01-02T23:13:49.272Z",
"is_frozen": false,
"balance": "0.00",
@ -270,7 +270,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 20,
"profile": 20,
"created_at": "2017-01-02T23:13:49.273Z",
"is_frozen": false,
"balance": "0.00",
@ -284,7 +284,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 21,
"profile": 21,
"created_at": "2017-01-02T23:13:49.274Z",
"is_frozen": false,
"balance": "0.00",
@ -298,7 +298,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 22,
"profile": 22,
"created_at": "2017-01-02T23:13:49.274Z",
"is_frozen": false,
"balance": "0.00",
@ -312,7 +312,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 23,
"profile": 23,
"created_at": "2017-01-02T23:13:49.275Z",
"is_frozen": false,
"balance": "0.00",
@ -326,7 +326,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 24,
"profile": 24,
"created_at": "2017-01-02T23:13:49.276Z",
"is_frozen": false,
"balance": "0.00",
@ -340,7 +340,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 25,
"profile": 25,
"created_at": "2017-01-02T23:13:49.277Z",
"is_frozen": false,
"balance": "0.00",
@ -354,7 +354,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 26,
"profile": 26,
"created_at": "2017-01-02T23:13:49.296Z",
"is_frozen": false,
"balance": "0.00",
@ -368,7 +368,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 27,
"profile": 27,
"created_at": "2017-01-02T23:13:49.297Z",
"is_frozen": false,
"balance": "0.00",
@ -382,7 +382,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 28,
"profile": 28,
"created_at": "2017-01-02T23:13:49.298Z",
"is_frozen": false,
"balance": "0.00",
@ -396,7 +396,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 29,
"profile": 29,
"created_at": "2017-01-02T23:13:49.299Z",
"is_frozen": false,
"balance": "0.00",
@ -410,7 +410,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 30,
"profile": 30,
"created_at": "2017-01-02T23:13:49.300Z",
"is_frozen": false,
"balance": "0.00",
@ -424,7 +424,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 31,
"profile": 31,
"created_at": "2017-01-02T23:13:49.301Z",
"is_frozen": false,
"balance": "0.00",
@ -438,7 +438,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 32,
"profile": 32,
"created_at": "2017-01-02T23:13:49.302Z",
"is_frozen": false,
"balance": "0.00",
@ -452,7 +452,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 33,
"profile": 33,
"created_at": "2017-01-02T23:13:49.302Z",
"is_frozen": false,
"balance": "0.00",
@ -466,7 +466,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 34,
"profile": 34,
"created_at": "2017-01-02T23:13:49.303Z",
"is_frozen": false,
"balance": "0.00",
@ -480,7 +480,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 35,
"profile": 35,
"created_at": "2017-01-02T23:13:49.304Z",
"is_frozen": false,
"balance": "0.00",
@ -494,7 +494,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 36,
"profile": 36,
"created_at": "2017-01-02T23:13:49.305Z",
"is_frozen": false,
"balance": "0.00",
@ -508,7 +508,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 37,
"profile": 37,
"created_at": "2017-01-02T23:13:49.306Z",
"is_frozen": false,
"balance": "0.00",
@ -522,7 +522,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 38,
"profile": 38,
"created_at": "2017-01-02T23:13:49.307Z",
"is_frozen": false,
"balance": "0.00",
@ -536,7 +536,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 39,
"profile": 39,
"created_at": "2017-01-02T23:13:49.307Z",
"is_frozen": false,
"balance": "0.00",
@ -550,7 +550,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 40,
"profile": 40,
"created_at": "2017-01-02T23:13:49.308Z",
"is_frozen": false,
"balance": "0.00",
@ -564,7 +564,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 64,
"profile": 64,
"created_at": "2017-01-02T23:21:11.760Z",
"is_frozen": false,
"balance": "0.00",
@ -578,7 +578,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 65,
"profile": 65,
"created_at": "2017-01-02T23:21:11.766Z",
"is_frozen": false,
"balance": "0.00",
@ -592,7 +592,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 66,
"profile": 66,
"created_at": "2017-01-02T23:21:11.768Z",
"is_frozen": false,
"balance": "0.00",
@ -606,7 +606,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 67,
"profile": 67,
"created_at": "2017-01-02T23:21:11.769Z",
"is_frozen": false,
"balance": "0.00",
@ -620,7 +620,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 68,
"profile": 68,
"created_at": "2017-01-02T23:21:11.770Z",
"is_frozen": false,
"balance": "0.00",
@ -634,7 +634,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 69,
"profile": 69,
"created_at": "2017-01-02T23:21:11.771Z",
"is_frozen": false,
"balance": "0.00",
@ -648,7 +648,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 70,
"profile": 70,
"created_at": "2017-01-02T23:21:11.773Z",
"is_frozen": false,
"balance": "0.00",
@ -662,7 +662,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 71,
"profile": 71,
"created_at": "2017-01-02T23:21:11.775Z",
"is_frozen": false,
"balance": "0.00",
@ -676,7 +676,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 72,
"profile": 72,
"created_at": "2017-01-02T23:21:11.776Z",
"is_frozen": false,
"balance": "0.00",
@ -690,7 +690,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 73,
"profile": 73,
"created_at": "2017-01-02T23:21:11.777Z",
"is_frozen": false,
"balance": "0.00",
@ -704,7 +704,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 74,
"profile": 74,
"created_at": "2017-01-02T23:21:11.778Z",
"is_frozen": false,
"balance": "0.00",
@ -718,7 +718,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 75,
"profile": 75,
"created_at": "2017-01-02T23:21:11.779Z",
"is_frozen": false,
"balance": "0.00",
@ -732,7 +732,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 76,
"profile": 76,
"created_at": "2017-01-02T23:21:11.780Z",
"is_frozen": false,
"balance": "0.00",
@ -746,7 +746,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 77,
"profile": 77,
"created_at": "2017-01-02T23:21:11.781Z",
"is_frozen": false,
"balance": "0.00",
@ -760,7 +760,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 78,
"profile": 78,
"created_at": "2017-01-02T23:21:11.783Z",
"is_frozen": false,
"balance": "0.00",
@ -774,7 +774,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 79,
"profile": 79,
"created_at": "2017-01-02T23:21:11.784Z",
"is_frozen": false,
"balance": "0.00",
@ -788,7 +788,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 80,
"profile": 80,
"created_at": "2017-01-02T23:21:11.785Z",
"is_frozen": false,
"balance": "0.00",
@ -802,7 +802,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 81,
"profile": 81,
"created_at": "2017-01-02T23:21:11.786Z",
"is_frozen": false,
"balance": "0.00",
@ -816,7 +816,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 82,
"profile": 82,
"created_at": "2017-01-02T23:21:11.787Z",
"is_frozen": false,
"balance": "0.00",
@ -830,7 +830,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 83,
"profile": 83,
"created_at": "2017-01-02T23:21:11.788Z",
"is_frozen": false,
"balance": "0.00",
@ -844,7 +844,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 84,
"profile": 84,
"created_at": "2017-01-02T23:21:11.789Z",
"is_frozen": false,
"balance": "0.00",
@ -858,7 +858,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 85,
"profile": 85,
"created_at": "2017-01-02T23:21:11.790Z",
"is_frozen": false,
"balance": "0.00",
@ -872,7 +872,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 86,
"profile": 86,
"created_at": "2017-01-02T23:21:11.791Z",
"is_frozen": false,
"balance": "0.00",
@ -886,7 +886,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 87,
"profile": 87,
"created_at": "2017-01-02T23:21:11.792Z",
"is_frozen": false,
"balance": "0.00",
@ -900,7 +900,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 88,
"profile": 88,
"created_at": "2017-01-02T23:21:11.793Z",
"is_frozen": false,
"balance": "0.00",
@ -914,7 +914,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 89,
"profile": 89,
"created_at": "2017-01-02T23:21:11.794Z",
"is_frozen": false,
"balance": "0.00",
@ -928,7 +928,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 90,
"profile": 90,
"created_at": "2017-01-02T23:21:11.795Z",
"is_frozen": false,
"balance": "0.00",
@ -942,7 +942,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 91,
"profile": 91,
"created_at": "2017-01-02T23:21:11.796Z",
"is_frozen": false,
"balance": "0.00",
@ -956,7 +956,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 92,
"profile": 92,
"created_at": "2017-01-02T23:21:11.797Z",
"is_frozen": false,
"balance": "0.00",
@ -970,7 +970,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 93,
"profile": 93,
"created_at": "2017-01-02T23:21:11.798Z",
"is_frozen": false,
"balance": "0.00",
@ -984,7 +984,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 94,
"profile": 94,
"created_at": "2017-01-02T23:21:11.799Z",
"is_frozen": false,
"balance": "0.00",
@ -998,7 +998,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 95,
"profile": 95,
"created_at": "2017-01-02T23:21:11.800Z",
"is_frozen": false,
"balance": "0.00",
@ -1012,7 +1012,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 96,
"profile": 96,
"created_at": "2017-01-02T23:21:11.801Z",
"is_frozen": false,
"balance": "0.00",
@ -1026,7 +1026,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 97,
"profile": 97,
"created_at": "2017-01-02T23:21:11.802Z",
"is_frozen": false,
"balance": "0.00",
@ -1040,7 +1040,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 98,
"profile": 98,
"created_at": "2017-01-02T23:21:11.803Z",
"is_frozen": false,
"balance": "0.00",
@ -1054,7 +1054,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 99,
"profile": 99,
"created_at": "2017-01-02T23:21:11.804Z",
"is_frozen": false,
"balance": "0.00",
@ -1068,7 +1068,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 100,
"profile": 100,
"created_at": "2017-01-02T23:21:11.805Z",
"is_frozen": false,
"balance": "0.00",
@ -1082,7 +1082,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 101,
"profile": 101,
"created_at": "2017-01-02T23:21:11.806Z",
"is_frozen": false,
"balance": "0.00",
@ -1096,7 +1096,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 102,
"profile": 102,
"created_at": "2017-01-02T23:21:11.807Z",
"is_frozen": false,
"balance": "0.00",
@ -1110,7 +1110,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 103,
"profile": 103,
"created_at": "2017-01-02T23:21:11.807Z",
"is_frozen": false,
"balance": "0.00",
@ -1124,7 +1124,7 @@
"fields": {
"nickname": "",
"password": null,
"cofprofile": 63,
"profile": 63,
"created_at": "2017-01-03T00:26:41.482Z",
"is_frozen": false,
"balance": "0.00",

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('kfet', '0048_generic_profiles'),
]
operations = [
migrations.RenameField(
model_name='account',
old_name='cofprofile',
new_name='profile',
),
]

View file

@ -31,7 +31,7 @@ def default_promo():
@python_2_unicode_compatible
class Account(models.Model):
# XXX. change this to "profile"
cofprofile = models.OneToOneField(Profile,
profile = models.OneToOneField(Profile,
related_name="account_kfet",
on_delete=models.CASCADE)
trigramme = models.CharField(
@ -60,28 +60,28 @@ class Account(models.Model):
def __str__(self):
return '%s (%s)' % (self.trigramme, self.name)
# Propriétés pour accéder aux attributs de user et cofprofile et user
# Propriétés pour accéder aux attributs de user et profile et user
@property
def user(self):
return self.cofprofile.user
return self.profile.user
@property
def username(self):
return self.cofprofile.user.username
return self.profile.user.username
@property
def first_name(self):
return self.cofprofile.user.first_name
return self.profile.user.first_name
@property
def last_name(self):
return self.cofprofile.user.last_name
return self.profile.user.last_name
@property
def email(self):
return self.cofprofile.user.email
return self.profile.user.email
@property
def departement(self):
return self.cofprofile.departement
return self.profile.departement
@property
def is_cof(self):
return self.cofprofile.is_cof
return self.profile.is_cof
# Propriétés supplémentaires
@property
@ -167,7 +167,7 @@ class Account(models.Model):
user.email = data.get("email", user.email)
user.save()
# Updating CofProfile with data
cof = self.cofprofile
cof = self.profile
cof.departement = data.get("departement", cof.departement)
cof.save()
elif data:
@ -193,14 +193,14 @@ class Account(models.Model):
user.email = data['email']
user.save()
# Creating or updating CofProfile instance
(cof, _) = CofProfile.objects.get_or_create(user=user)
(cof, _) = Profile.objects.get_or_create(user=user)
if "login_clipper" in data:
cof.login_clipper = data['login_clipper']
if "departement" in data:
cof.departement = data['departement']
cof.save()
if data:
self.cofprofile = cof
self.profile = cof
super(Account, self).save(*args, **kwargs)
# Surcharge de delete

View file

@ -75,7 +75,7 @@ def put_cleaned_data_in_dict(dict, form):
@login_required
@teamkfet_required
def account(request):
accounts = Account.objects.select_related('cofprofile__user').order_by('trigramme')
accounts = Account.objects.select_related('profile__user').order_by('trigramme')
return render(request, "kfet/account.html", { 'accounts' : accounts })
@login_required
@ -358,7 +358,7 @@ def account_update(request, trigramme):
user_form = UserRestrictTeamForm(instance=account.user)
group_form = UserGroupForm(instance=account.user)
account_form = AccountForm(instance=account)
cof_form = CofRestrictForm(instance=account.cofprofile)
cof_form = CofRestrictForm(instance=account.profile)
pwd_form = AccountPwdForm()
if account.balance < 0 and not hasattr(account, 'negative'):
AccountNegative.objects.create(account=account, start=timezone.now())
@ -382,7 +382,7 @@ def account_update(request, trigramme):
if request.user.has_perm('kfet.is_team'):
account_form = AccountForm(request.POST, instance=account)
cof_form = CofRestrictForm(request.POST, instance=account.cofprofile)
cof_form = CofRestrictForm(request.POST, instance=account.profile)
user_form = UserRestrictTeamForm(request.POST, instance=account.user)
group_form = UserGroupForm(request.POST, instance=account.user)
pwd_form = AccountPwdForm(request.POST)
@ -490,7 +490,7 @@ class AccountGroupUpdate(UpdateView):
class AccountNegativeList(ListView):
queryset = (AccountNegative.objects
.select_related('account', 'account__cofprofile__user')
.select_related('account', 'account__profile__user')
.exclude(account__trigramme='#13'))
template_name = 'kfet/account_negative.html'
context_object_name = 'negatives'
@ -845,8 +845,8 @@ def kpsul_checkout_data(request):
pk = 0
data = (Checkout.objects
.annotate(
last_statement_by_first_name=F('statements__by__cofprofile__user__first_name'),
last_statement_by_last_name=F('statements__by__cofprofile__user__last_name'),
last_statement_by_first_name=F('statements__by__profile__user__first_name'),
last_statement_by_last_name=F('statements__by__profile__user__last_name'),
last_statement_by_trigramme=F('statements__by__trigramme'),
last_statement_balance=F('statements__balance_new'),
last_statement_at=F('statements__at'))
@ -858,7 +858,7 @@ def kpsul_checkout_data(request):
.select_related(
'statements'
'statements__by',
'statements__by__cofprofile__user')
'statements__by__profile__user')
.filter(pk=pk)
.order_by('statements__at')
.last())