Merge branch 'feature-contacts' into develop

Conflicts:
	webapp/admin.py
	webapp/models.py
	webapp/views.py
This commit is contained in:
Aarni Halinen
2018-05-16 22:48:08 +03:00
12 changed files with 268 additions and 49 deletions
+2 -1
View File
@@ -1,7 +1,7 @@
"""File containing webapp app admin registers."""
from django.contrib import admin
from webapp.models import Official, Role
from webapp.models import Official, Role, Committee
from webapp.models import Feed, Tag, BaseFeed, Event, Registration
from modeltranslation.admin import TranslationAdmin
from django.contrib.auth.models import Permission
@@ -16,3 +16,4 @@ admin.site.register(Event, TranslationAdmin)
admin.site.register(Registration, TranslationAdmin)
admin.site.register(Official)
admin.site.register(Role)
admin.site.register(Committee)
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-03-01 18:11
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('webapp', '0035_auto_20171019_1413'),
]
operations = [
migrations.CreateModel(
name='Committee',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
],
),
migrations.AddField(
model_name='role',
name='committee',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='roles', to='webapp.Committee'),
),
]
@@ -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'},
),
]
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-05-16 18:08
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('webapp', '0037_auto_20180301_2111'),
]
operations = [
migrations.RemoveField(
model_name='baserole',
name='category',
),
migrations.RemoveField(
model_name='role',
name='committee',
),
migrations.AddField(
model_name='official',
name='committee',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='roles', to='webapp.Committee'),
),
migrations.AlterField(
model_name='role',
name='official',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='roles', to='webapp.Official'),
),
]
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-05-16 18:13
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('webapp', '0038_auto_20180516_2108'),
]
operations = [
migrations.RemoveField(
model_name='official',
name='committee',
),
migrations.RemoveField(
model_name='role',
name='official',
),
migrations.AddField(
model_name='official',
name='role',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='roles', to='webapp.Role'),
),
migrations.AddField(
model_name='role',
name='committee',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='roles', to='webapp.Committee'),
),
migrations.AlterField(
model_name='committee',
name='name',
field=models.CharField(max_length=255, verbose_name='Name'),
),
]
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-05-16 18:24
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('webapp', '0039_auto_20180516_2113'),
]
operations = [
migrations.RemoveField(
model_name='official',
name='role',
),
migrations.AddField(
model_name='official',
name='role',
field=models.ManyToManyField(null=True, related_name='roles', to='webapp.Role'),
),
]
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-05-16 19:04
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('webapp', '0040_auto_20180516_2124'),
]
operations = [
migrations.AlterField(
model_name='official',
name='role',
field=models.ManyToManyField(related_name='official', to='webapp.Role'),
),
]
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-05-16 19:49
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('webapp', '0041_auto_20180516_2204'),
('webapp', '0041_delete_ohlhafvchallenge'),
]
operations = [
]
+44 -18
View File
@@ -90,26 +90,26 @@ class Registration(models.Model):
class BaseRole(models.Model):
"""Base model for occupations/roles."""
CATEGORIES = (
('corporate', _('Corporate affairs')),
('freshman', _('Freshmen')),
('international', _('International')),
('external', _('External affairs')),
('media', _('Media')),
('tech', _('Technology')),
('wellbeing', _('Wellbeing')),
('elepaja', _('Elepaja')),
('ceremonies', _('Ceremonies')),
('culture', _('Culture')),
('studies', _('Studies')),
('sosso', _('Sössö magazine')),
('alumni', _('Alumni relations')),
('others', _('Others')),
)
# CATEGORIES = (
# ('corporate', _('Corporate affairs')),
# ('freshman', _('Freshmen')),
# ('international', _('International')),
# ('external', _('External affairs')),
# ('media', _('Media')),
# ('tech', _('Technology')),
# ('wellbeing', _('Wellbeing')),
# ('elepaja', _('Elepaja')),
# ('ceremonies', _('Ceremonies')),
# ('culture', _('Culture')),
# ('studies', _('Studies')),
# ('sosso', _('Sössö magazine')),
# ('alumni', _('Alumni relations')),
# ('others', _('Others')),
# )
name = models.CharField(_('Name'), max_length=255)
is_board = models.BooleanField(_('Board member'))
category = models.CharField(_('Category'), choices=CATEGORIES, default='others', max_length=255)
# category = models.CharField(_('Category'), choices=CATEGORIES, default='others', max_length=255)
def __str__(self):
n = self.name.capitalize()
@@ -122,6 +122,28 @@ class PresetRole(BaseRole):
description = models.TextField(_('Description'))
class Committee(models.Model):
"""
Committee 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(_("Name"), max_length=255)
@property
def current_roles(self):
return self.roles.all().filter(end_date__gte=timezone.now()).filter(start_date__lte=timezone.now())
class Role(PresetRole):
"""
Model for Role.
@@ -138,7 +160,7 @@ class Role(PresetRole):
start_date = models.DateField(_('Start date'))
end_date = models.DateField(_('End date'))
official = models.ForeignKey('Official', related_name='roles')
committee = models.ForeignKey('Committee', related_name='roles', on_delete=models.SET_NULL, null=True)
class Official(User):
@@ -151,6 +173,10 @@ class Official(User):
verbose_name_plural = _('Officials')
phone_number = PhoneNumberField(_('Phone number'))
role = models.ManyToManyField('Role', related_name='official')
def __str__(self):
return '{} {}'.format(self.first_name, self.last_name)
auditlog.register(Tag)
+6
View File
@@ -0,0 +1,6 @@
.role-container {
background-color: aqua;
width: 200px;
text-align: center;
}
+30 -27
View File
@@ -4,34 +4,37 @@
{% load i18n %}
<div class="contact_div">
<div class="container">
<div class="row">
<div class="col">
<h2>{% trans "Contact" %}</h2>
<div>
{% if kaikki %}
<table>
{% for teekkari in kaikki %}
{% load static %}
<tr>
<td>
{% load static %}
<link rel="stylesheet" href="{% static "css/contact.css" %}">
<h2>{% trans "Contact" %}</h2>
{% if committees %}
{% for committee in committees %}
<!--Committee title-->
<h4>{{ committee.name }}</h4>
{% for role in committee.current_roles %}
{% for official in role.official.all %}
<div class="role-container">
<div class="row">
<div class="col">
<img src="static/img/missing.png">
</td>
<td>
<p class="name">{{ teekkari.first_name }} {{ teekkari.last_name }}</p>
<p class="email">{{ teekkari.email }}</p>
<p class="puh">{{ teekkari.phone_number }}</p>
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>Ei henkilöitä</p>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<h5>{{role.name}}</h5>
<p>{{official.first_name}}
{{official.last_name}}
{{official.email}}</p>
</div>
</div>
</div>
{% endfor %}
{% endfor %}
{% endfor %}
{% else%}
<p>Ei Toimikuntia</p>
{% endif %}
</div>
{% endblock %}
+6 -3
View File
@@ -8,12 +8,13 @@ from django.views.decorators.csrf import ensure_csrf_cookie
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import permission_required, login_required
from django.conf import settings
from django.utils import timezone
import logging
import requests
from dealer.git import git
from webapp.models import Official
from webapp.models import Official, Committee
from members.views.utils import *
@@ -114,8 +115,10 @@ def sosso_view(request, *args, **kwargs):
@require_http_methods(["GET"])
def contact_view(request, *args, **kwargs):
"""Render "Contact" page."""
committees = Committee.objects.order_by('name')
kaikki = Official.objects.all()
context = {"kaikki": kaikki}
context = {
"committees": committees
}
return render(request, "contact.html", context)