Merge remote-tracking branch 'origin/tmp' into michele.orru/gestioCOF-supportBDS

This commit is contained in:
Qwann 2017-02-11 18:02:05 +01:00
commit fcf392f40d
4 changed files with 22 additions and 16 deletions

View file

@ -77,7 +77,7 @@ class Command(MyBaseCommand):
self.stdout.write("Inscription des utilisateurs aux tirages") self.stdout.write("Inscription des utilisateurs aux tirages")
ChoixSpectacle.objects.all().delete() ChoixSpectacle.objects.all().delete()
choices = [] choices = []
for user in User.objects.filter(profile__is_cof=True): for user in User.objects.filter(profile__cof__is_cof=True):
for tirage in tirages: for tirage in tirages:
part, _ = Participant.objects.get_or_create( part, _ = Participant.objects.get_or_create(
user=user, user=user,

View file

@ -9,8 +9,8 @@ from django_cas_ng.decorators import user_passes_test
def is_cof(user): def is_cof(user):
try: try:
profile = user.profile cofprofile = user.profile.cof
return profile.is_cof return cofprofile.is_cof
except: except:
return False return False
@ -21,8 +21,8 @@ cof_required_customdenied = user_passes_test(lambda u: is_cof(u),
def is_buro(user): def is_buro(user):
try: try:
profile = user.profile cofprofile = user.profile.cof
return profile.is_buro return cofprofile.is_buro
except: except:
return False return False

View file

@ -19,6 +19,8 @@ from cof.petits_cours_models import (
PetitCoursAttributionCounter PetitCoursAttributionCounter
) )
from cof.models import CofProfile
# Où sont stockés les fichiers json # Où sont stockés les fichiers json
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)),
'data') 'data')
@ -47,8 +49,10 @@ class Command(MyBaseCommand):
# Gaulois # Gaulois
gaulois = self.from_json('gaulois.json', DATA_DIR, User) gaulois = self.from_json('gaulois.json', DATA_DIR, User)
for user in gaulois: for user in gaulois:
user.profile.is_cof = True CofProfile.objects.create(
user.profile.save() profile=user.profile,
is_cof=True
)
# Romains # Romains
self.from_json('romains.json', DATA_DIR, User) self.from_json('romains.json', DATA_DIR, User)
@ -65,10 +69,12 @@ class Command(MyBaseCommand):
root.set_password('root') root.set_password('root')
root.is_staff = True root.is_staff = True
root.is_superuser = True root.is_superuser = True
root.profile.is_cof = True
root.profile.is_buro = True
root.profile.save()
root.save() root.save()
CofProfile.objects.create(
profile=root.profile,
is_cof=True,
is_buro=True
)
# --- # ---
# Petits cours # Petits cours

View file

@ -7,7 +7,7 @@
<div class="container hidden-xs espace"></div> <div class="container hidden-xs espace"></div>
<div class="container"> <div class="container">
<div class="home-menu row"> <div class="home-menu row">
<div class="{% if user.profile.is_buro %}col-sm-6 {% else %}col-sm-8 col-sm-offset-2 col-xs-12 {%endif%}normal-user-hm"> <div class="{% if user.profile.cof.is_buro %}col-sm-6 {% else %}col-sm-8 col-sm-offset-2 col-xs-12 {%endif%}normal-user-hm">
<!-- {% if open_events %} <!-- {% if open_events %}
<h3 class="block-title">Événements<span class="pull-right glyphicon glyphicon-calendar"></span></h3> <h3 class="block-title">Événements<span class="pull-right glyphicon glyphicon-calendar"></span></h3>
<div class="hm-block"> <div class="hm-block">
@ -30,7 +30,7 @@
{% endif %} {% endif %}
{% if user.profile.is_cof %} {% if user.profile.cof.is_cof %}
{% if open_tirages %} {% if open_tirages %}
<h3 class="block-title">Tirages du BdA<span class="pull-right glyphicon glyphicon-th-list"></span></h3> <h3 class="block-title">Tirages du BdA<span class="pull-right glyphicon glyphicon-th-list"></span></h3>
<div class="hm-block"> <div class="hm-block">
@ -55,15 +55,15 @@
<div class="hm-block"> <div class="hm-block">
<ul> <ul>
<li><a href="{% url "cof.views.calendar" %}">Calendrier dynamique</a></li> <li><a href="{% url "cof.views.calendar" %}">Calendrier dynamique</a></li>
{% if user.profile.is_cof %}<li><a href="{% url "petits-cours-inscription" %}">Inscription pour donner des petits cours</a></li>{% endif %} {% if user.profile.cof.is_cof %}<li><a href="{% url "petits-cours-inscription" %}">Inscription pour donner des petits cours</a></li>{% endif %}
<li><a href="{% url "cof.views.profile" %}">Éditer mon profil</a></li> <li><a href="{% url "profile" %}">Éditer mon profil</a></li>
{% if not user.profile.login_clipper %}<li><a href="{% url "django.contrib.auth.views.password_change" %}">Changer mon mot de passe</a></li>{% endif %} {% if not user.profile.login_clipper %}<li><a href="{% url "django.contrib.auth.views.password_change" %}">Changer mon mot de passe</a></li>{% endif %}
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% if user.profile.is_buro %} {% if user.profile.cof.is_buro %}
<div class="col-sm-6 buro-user-hm"> <div class="col-sm-6 buro-user-hm">
<h3 class="block-title">Administration<span class="pull-right glyphicon glyphicon-cog"></span></h3> <h3 class="block-title">Administration<span class="pull-right glyphicon glyphicon-cog"></span></h3>
<div class="hm-block"> <div class="hm-block">
@ -113,7 +113,7 @@
{% endif %} {% endif %}
</div> <!-- /.row.home-menu --> </div> <!-- /.row.home-menu -->
<div class="container hidden-xs espace"></div> <div class="container hidden-xs espace"></div>
{% if not user.profile.is_buro %} {% if not user.profile.cof.is_buro %}
<div class="home-menu row row-centered"> <div class="home-menu row row-centered">
<div class="col-sm-8 col-sm-offset-2 col-xs-12 normal-user-hm"> <div class="col-sm-8 col-sm-offset-2 col-xs-12 normal-user-hm">
<div class="foot-banner"> <div class="foot-banner">