mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 18:44:23 +00:00
Nice display for elections
This commit is contained in:
parent
52e69b0ac1
commit
c604282b77
@ -318,6 +318,12 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
|
|||||||
sli.save()
|
sli.save()
|
||||||
skia.view_groups=[Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first().id]
|
skia.view_groups=[Group.objects.filter(name=settings.SITH_MAIN_MEMBERS_GROUP).first().id]
|
||||||
sli.save()
|
sli.save()
|
||||||
|
# Adding user Krophil
|
||||||
|
krophil = User(username='krophil', last_name="Phil'", first_name="Kro",
|
||||||
|
email="krophil@git.an",
|
||||||
|
date_of_birth="1942-06-12")
|
||||||
|
krophil.set_password("plop")
|
||||||
|
krophil.save()
|
||||||
## Adding subscription for sli
|
## Adding subscription for sli
|
||||||
s = Subscription(member=User.objects.filter(pk=sli.pk).first(), subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[0],
|
s = Subscription(member=User.objects.filter(pk=sli.pk).first(), subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[0],
|
||||||
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])
|
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])
|
||||||
@ -326,6 +332,14 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
|
|||||||
duration=settings.SITH_SUBSCRIPTIONS[s.subscription_type]['duration'],
|
duration=settings.SITH_SUBSCRIPTIONS[s.subscription_type]['duration'],
|
||||||
start=s.subscription_start)
|
start=s.subscription_start)
|
||||||
s.save()
|
s.save()
|
||||||
|
## Adding subscription for Krophil
|
||||||
|
s = Subscription(member=User.objects.filter(pk=krophil.pk).first(), subscription_type=list(settings.SITH_SUBSCRIPTIONS.keys())[0],
|
||||||
|
payment_method=settings.SITH_SUBSCRIPTION_PAYMENT_METHOD[0])
|
||||||
|
s.subscription_start = s.compute_start()
|
||||||
|
s.subscription_end = s.compute_end(
|
||||||
|
duration=settings.SITH_SUBSCRIPTIONS[s.subscription_type]['duration'],
|
||||||
|
start=s.subscription_start)
|
||||||
|
s.save()
|
||||||
|
|
||||||
operation_list = [
|
operation_list = [
|
||||||
(27, "J'avais trop de bière", 'CASH', None, buying, 'USER', skia.id, "", None),
|
(27, "J'avais trop de bière", 'CASH', None, buying, 'USER', skia.id, "", None),
|
||||||
@ -352,8 +366,18 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
|
|||||||
el.save()
|
el.save()
|
||||||
liste = List(title="Candidature Libre", election=el)
|
liste = List(title="Candidature Libre", election=el)
|
||||||
liste.save()
|
liste.save()
|
||||||
|
listeT = List(title="Troll", election=el)
|
||||||
|
listeT.save()
|
||||||
|
pres = Role(election=el, title="Président AE", description="Roi de l'AE")
|
||||||
|
pres.save()
|
||||||
resp = Role(election=el, title="Co Respo Info", description="Ghetto++")
|
resp = Role(election=el, title="Co Respo Info", description="Ghetto++")
|
||||||
resp.save()
|
resp.save()
|
||||||
cand = Candidature(role=resp, user=skia, liste=liste, program="Refesons le site AE")
|
cand = Candidature(role=resp, user=skia, liste=liste, program="Refesons le site AE")
|
||||||
cand.save()
|
cand.save()
|
||||||
|
cand = Candidature(role=resp, user=sli, liste=liste, program="Vasy je deviens mon propre adjoint")
|
||||||
|
cand.save()
|
||||||
|
cand = Candidature(role=resp, user=krophil, liste=listeT, program="Le Pôle Troll !")
|
||||||
|
cand.save()
|
||||||
|
cand = Candidature(role=pres, user=sli, liste=listeT, program="En fait j'aime pas l'info, je voulais faire GMC")
|
||||||
|
cand.save()
|
||||||
|
|
||||||
|
@ -85,6 +85,12 @@
|
|||||||
<li><a href="{{ url('club:tools', club_id=m.club.id) }}">{{ m.club }}</a></li>
|
<li><a href="{{ url('club:tools', club_id=m.club.id) }}">{{ m.club }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
<hr>
|
||||||
|
<h4>{% trans %}Elections{% endtrans %}</h4>
|
||||||
|
<ul>
|
||||||
|
<li><a href="{{ url('election:list') }}">{% trans %}Vote{% endtrans %}</a></li>
|
||||||
|
<li><a href="">{% trans %}Candidate{% endtrans %}</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
25
election/migrations/0002_auto_20161219_0002.py
Normal file
25
election/migrations/0002_auto_20161219_0002.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('election', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='candidature',
|
||||||
|
name='has_voted',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='role',
|
||||||
|
name='has_voted',
|
||||||
|
field=models.ManyToManyField(to=settings.AUTH_USER_MODEL, related_name='has_voted', verbose_name='has voted'),
|
||||||
|
),
|
||||||
|
]
|
@ -46,6 +46,7 @@ class Role(models.Model):
|
|||||||
election = models.ForeignKey(Election, related_name='role', verbose_name=_("election"))
|
election = models.ForeignKey(Election, related_name='role', verbose_name=_("election"))
|
||||||
title = models.CharField(_('title'), max_length=255)
|
title = models.CharField(_('title'), max_length=255)
|
||||||
description = models.TextField(_('description'), null=True, blank=True)
|
description = models.TextField(_('description'), null=True, blank=True)
|
||||||
|
has_voted = models.ManyToManyField(User, verbose_name=('has voted'), related_name='has_voted')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ("%s : %s") % (self.election.title, self.title)
|
return ("%s : %s") % (self.election.title, self.title)
|
||||||
@ -66,7 +67,6 @@ class Candidature(models.Model):
|
|||||||
role = models.ForeignKey(Role, related_name='candidature', verbose_name=_("role"))
|
role = models.ForeignKey(Role, related_name='candidature', verbose_name=_("role"))
|
||||||
user = models.ForeignKey(User, verbose_name=_('user'), related_name='candidate', blank=True)
|
user = models.ForeignKey(User, verbose_name=_('user'), related_name='candidate', blank=True)
|
||||||
program = models.TextField(_('description'), null=True, blank=True)
|
program = models.TextField(_('description'), null=True, blank=True)
|
||||||
has_voted = models.ManyToManyField(User, verbose_name=_('has_voted'), related_name='has_voted')
|
|
||||||
liste = models.ForeignKey(List, related_name='candidature', verbose_name=_('list'))
|
liste = models.ForeignKey(List, related_name='candidature', verbose_name=_('list'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,17 +11,34 @@
|
|||||||
<h1>{{object.title}}</h1>
|
<h1>{{object.title}}</h1>
|
||||||
<p>{{object.description}}</p>
|
<p>{{object.description}}</p>
|
||||||
<p>{% trans %}End :{% endtrans %} {{object.end_date}}</p>
|
<p>{% trans %}End :{% endtrans %} {{object.end_date}}</p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
{% set nb_list = object.list.all().count() + 1 -%}
|
||||||
|
{% for liste in object.list.all() %}
|
||||||
|
<td>{{liste.title}}</td>
|
||||||
|
{% set nb_list = nb_list + 1 -%}
|
||||||
|
{% endfor %}
|
||||||
|
<td>{% trans %}Blank vote{% endtrans %}</td>
|
||||||
|
</tr>
|
||||||
{% for role in object.role.all() %}
|
{% for role in object.role.all() %}
|
||||||
<h2>{{role.title}}</h2>
|
<tr><td colspan={{nb_list}}>{{role.title}}</td></tr>
|
||||||
{% for candidature in role.candidature.all() %}
|
<tr>
|
||||||
<a href="{{url('core:user_profile', user_id=candidature.user.id)}}"><h3>{{candidature.user.first_name}} {{candidature.user.last_name}} ({{candidature.user.nick_name}})</h3></a>
|
{% for liste in object.list.all() %}
|
||||||
|
<td>
|
||||||
|
<ul>
|
||||||
|
{% for candidature in role.candidature.filter(liste=liste) %}
|
||||||
|
<li>
|
||||||
|
{{candidature.user.first_name}} {{candidature.user.last_name}} {{candidature.user.nick_name or ''}}
|
||||||
{% if candidature.user.profile_pict %}
|
{% if candidature.user.profile_pict %}
|
||||||
<p><img src="{{candidature.user.profile_pict.get_download_url()}}" alt="{% trans %}Profile{% endtrans %}"/></p>
|
<img src="{{candidature.user.profile_pict.get_download_url()}}" alt="{% trans %}Profile{% endtrans %}">
|
||||||
{% endif %}
|
|
||||||
{% if candidature.program %}
|
|
||||||
<h4>Programme</h4>
|
|
||||||
<p>{{candidature.program}}</p>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% for el in object_list %}
|
{% for el in object_list %}
|
||||||
{% if el.is_active %}
|
|
||||||
<p><a href="{{ url('election:detail', election_id=el.id) }}">{{el}}</a></p>
|
<p><a href="{{ url('election:detail', election_id=el.id) }}">{{el}}</a></p>
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -3,6 +3,7 @@ from django.views.generic import ListView, DetailView, RedirectView
|
|||||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView, FormView
|
from django.views.generic.edit import UpdateView, CreateView, DeleteView, FormView
|
||||||
from django.core.urlresolvers import reverse_lazy, reverse
|
from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin
|
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin
|
||||||
@ -18,6 +19,12 @@ class ElectionsListView(CanViewMixin, ListView):
|
|||||||
model = Election
|
model = Election
|
||||||
template_name = 'election/election_list.jinja'
|
template_name = 'election/election_list.jinja'
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
qs = super(ElectionsListView, self).get_queryset()
|
||||||
|
today = timezone.now()
|
||||||
|
qs = qs.filter(end_date__gte=today, start_date__lte=today)
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
class ElectionDetailView(CanViewMixin, DetailView):
|
class ElectionDetailView(CanViewMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user