From 55bcc78670fd703fdf661dc9a3097afbcac54206 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 2 Mar 2018 00:31:10 +0200 Subject: [PATCH] Sorted roles by committees and some basic layout --- webapp/migrations/0037_auto_20180301_2111.py | 19 +++++ webapp/models.py | 9 +++ webapp/static/css/contact.css | 6 ++ webapp/templates/contact.html | 83 +++++++++----------- webapp/views.py | 9 +-- 5 files changed, 72 insertions(+), 54 deletions(-) create mode 100644 webapp/migrations/0037_auto_20180301_2111.py create mode 100644 webapp/static/css/contact.css diff --git a/webapp/migrations/0037_auto_20180301_2111.py b/webapp/migrations/0037_auto_20180301_2111.py new file mode 100644 index 0000000..b5cab47 --- /dev/null +++ b/webapp/migrations/0037_auto_20180301_2111.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2018-03-01 19:11 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('webapp', '0036_auto_20180301_2011'), + ] + + operations = [ + migrations.AlterModelOptions( + name='committee', + options={'verbose_name': 'Committee', 'verbose_name_plural': 'Committees'}, + ), + ] diff --git a/webapp/models.py b/webapp/models.py index 3010192..6f40f60 100644 --- a/webapp/models.py +++ b/webapp/models.py @@ -243,6 +243,15 @@ class Committee(models.Model): Has many Roles found under variable roles """ + class Meta: + """Meta class for Committee class.""" + + verbose_name = _('Committee') + verbose_name_plural = _('Committees') + + def __str__(self): + return _('Committee: {}').format(self.name) + name = models.CharField(max_length=255) diff --git a/webapp/static/css/contact.css b/webapp/static/css/contact.css new file mode 100644 index 0000000..d935e46 --- /dev/null +++ b/webapp/static/css/contact.css @@ -0,0 +1,6 @@ + +.role-container { + background-color: aqua; + width: 200px; + text-align: center; +} \ No newline at end of file diff --git a/webapp/templates/contact.html b/webapp/templates/contact.html index c400a99..bf51df3 100644 --- a/webapp/templates/contact.html +++ b/webapp/templates/contact.html @@ -4,55 +4,42 @@ {% load i18n %}
-
- -

{% trans "Contact" %}

-
- {% if all_roles %} - {% load static %} -

Kaikki Roolit

- - {% for role in all_roles %} - - - - - {% endfor %} -
- + {% load static %} + +

{% trans "Contact" %}

+ + {% if committee_list %} + + {% for com in committee_list %} + + +

{{ com.committee.name }}

+ + + {% if com.roles_list %} + {% for role in com.roles_list %} +
+
+
-
-

{{role}} -

{{ role.official.first_name }} {{ rooli.official.last_name }}

- {{ role.official.email }} - {{ role.official.phone_number }} -

-
- {% else%} -

Ei rooleja

- {% endif %} - - {% if all_committees %} - {% load static %} -

Kaikki Toimikunnat

- {% for com in all_committees %} -

{{committee.name}}

- {% if roles_list %} - {% for role in roles_list %} -

{{role.name}}

- {% endfor %} - {% else %} -

Ei ole rooleja tällä toimikunnalla

- {% endif %} - {% endfor %} - {% else%} -

Ei Toimikuntia

- {% endif %} -
- -
+
+ +
+
+
{{role.name}}
+

{{role.official.first_name}} + {{role.official.last_name}} + {{role.official.email}}

+
+
+ + {% endfor %} + {%endif%} + + {% endfor %} + {% else%} +

Ei Toimikuntia

+ {% endif %} {% endblock %} diff --git a/webapp/views.py b/webapp/views.py index 9107645..6112a36 100644 --- a/webapp/views.py +++ b/webapp/views.py @@ -145,8 +145,6 @@ def sosso_view(request, *args, **kwargs): def contact_view(request, *args, **kwargs): """Render "Contact" page.""" - # TODO - # # Lajitellaan roolit toimikunnittain # in format: context = { # committee_list: [ @@ -162,15 +160,14 @@ def contact_view(request, *args, **kwargs): # ]} # - #all_officials = Official.objects.all() all_roles = Role.objects.all() - all_committees = Committee.objects.all() + all_committees = Committee.objects.order_by('name') committee_list = [] for committee in all_committees: - committee_list.append({"committee":committee, "roles_list":committee.roles}) + committee_list.append({"committee":committee, "roles_list":committee.roles.all()}) - context = {"all_roles": all_roles, "all_committees": committee_list} + context = {"all_roles": all_roles, "committee_list": committee_list} return render(request, "contact.html", context)