Edit models and create list view
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11 on 2017-10-11 15:28
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('webapp', '0015_auto_20170928_2331'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='KaehmyFormSelectedRole',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
],
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='customkaehmyrole',
|
||||
name='form',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='presetkaehmyrole',
|
||||
name='form',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='kaehmyform',
|
||||
name='custom_roles',
|
||||
field=models.ManyToManyField(blank=True, related_name='forms', to='webapp.CustomKaehmyRole'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='kaehmyform',
|
||||
name='preset_roles',
|
||||
field=models.ManyToManyField(blank=True, related_name='forms', to='webapp.PresetKaehmyRole'),
|
||||
),
|
||||
]
|
||||
+13
-3
@@ -91,6 +91,9 @@ class BaseRole(models.Model):
|
||||
name = models.CharField(_('Name'), max_length=255)
|
||||
is_board = models.BooleanField(_('Board member'))
|
||||
|
||||
def __str__(self):
|
||||
return self.name.capitalize()
|
||||
|
||||
|
||||
class PresetRole(BaseRole):
|
||||
"""Model representing a preset occupation in the guild."""
|
||||
@@ -101,14 +104,16 @@ class PresetRole(BaseRole):
|
||||
|
||||
class PresetKaehmyRole(PresetRole):
|
||||
"""Model for kaehmy role."""
|
||||
|
||||
form = models.ForeignKey('KaehmyForm', related_name='preset_roles')
|
||||
pass
|
||||
|
||||
|
||||
class CustomKaehmyRole(BaseRole):
|
||||
"""Model representing a user-specified custom occupation."""
|
||||
pass
|
||||
|
||||
form = models.ForeignKey('KaehmyForm', related_name='custom_roles')
|
||||
|
||||
class KaehmyFormSelectedRole(models.Model):
|
||||
pass
|
||||
|
||||
|
||||
class MessageParent(models.Model):
|
||||
@@ -138,6 +143,11 @@ class KaehmyForm(MessageParent):
|
||||
name = models.CharField(_('Name'), max_length=255)
|
||||
email = models.EmailField(_('Email'))
|
||||
year = models.IntegerField(_('Year'))
|
||||
custom_roles = models.ManyToManyField('CustomKaehmyRole', related_name='forms', blank=True)
|
||||
preset_roles = models.ManyToManyField('PresetKaehmyRole', related_name='forms', blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return _('Hakemus: {}').format(self.name)
|
||||
|
||||
|
||||
class Role(PresetRole):
|
||||
|
||||
@@ -16,17 +16,23 @@
|
||||
|
||||
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||
<script src="{% static "js/lib/jquery-3.1.0.min.js" %}"></script>
|
||||
<script src="{% static "js/lib/bootstrap.min.js" %}"></script>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{% static "css/lib/bootstrap.min.css" %}">
|
||||
<script src="{% static "js/lib/underscore-min.js" %}"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% block header %}
|
||||
<div class="header">
|
||||
{% include "sik_header.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
<div class="page-content">
|
||||
{% include "navigation.html" %}
|
||||
{% block navigation %}
|
||||
{% include "navigation.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block navigation %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<div>
|
||||
<h2>{% trans "All kaehmys" %}</h2>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h6>{% trans "Total kaehmys:" %} {{ application_count }}</h6>
|
||||
</div>
|
||||
|
||||
{% for application in applications %}
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">{{ application.name }}</h4>
|
||||
<h5 class=class="card-subtitle mb-2 text-muted">{% trans "Roles" %}:</h5>
|
||||
{% for role in application.custom_roles.all %}
|
||||
<h6>{{ role.name }}</h6>
|
||||
{% endfor %}
|
||||
{% for role in application.preset_roles.all %}
|
||||
<h6>{{ role.name }}</h6>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock content %}
|
||||
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
|
||||
<div class="ohlhafv_count">
|
||||
<span>{% trans "Total challenges:" %} {{ challenge_count }}</span>
|
||||
<span>{% trans "Total challenges:" %}{{ application_count }}</span>
|
||||
</div>
|
||||
|
||||
{{ table|safe }}
|
||||
|
||||
@@ -18,6 +18,7 @@ from webapp.views import event_calendar_view
|
||||
from webapp.views import international_view
|
||||
from webapp.views import sosso_view
|
||||
from webapp.views import contact_view
|
||||
from webapp.views import kaehmy_list_view
|
||||
|
||||
urlpatterns = [
|
||||
# main
|
||||
@@ -30,6 +31,8 @@ urlpatterns = [
|
||||
|
||||
# git revision
|
||||
url(r'^about', about_view),
|
||||
|
||||
# pages
|
||||
url(r'^guild', guild_view),
|
||||
url(r'^freshmen', freshmen_view),
|
||||
url(r'^event_calendar', event_calendar_view),
|
||||
@@ -44,4 +47,7 @@ urlpatterns = [
|
||||
url(r'^ohlhafv$', ohlhafv_view),
|
||||
url(r'^ohlhafv/submit', ohlhafv_submit),
|
||||
url(r'^ohlhafv/list', ohlhafv_list),
|
||||
|
||||
# kaehmy
|
||||
url(r'^kaehmy', kaehmy_list_view),
|
||||
]
|
||||
|
||||
+15
-1
@@ -8,7 +8,7 @@ from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.contrib.auth.decorators import permission_required, login_required
|
||||
from django.conf import settings
|
||||
import logging
|
||||
from webapp.models import OhlhafvChallenge
|
||||
from webapp.models import OhlhafvChallenge, KaehmyForm
|
||||
from webapp.forms import OhlhafvForm
|
||||
from webapp.tables import OhlhafvTable
|
||||
|
||||
@@ -146,3 +146,17 @@ def ohlhafv_list(request, *args, **kwargs):
|
||||
'challenge_count': len(challenges),
|
||||
}
|
||||
return render(request, 'ohlhafv_list.html', context)
|
||||
|
||||
|
||||
@ensure_csrf_cookie
|
||||
@require_http_methods(["GET"])
|
||||
def kaehmy_list_view(request, *args, **kwargs):
|
||||
"""Kaehmy application list"""
|
||||
|
||||
applications = KaehmyForm.objects.all()
|
||||
|
||||
context = {
|
||||
'applications': applications,
|
||||
'application_count': len(applications)
|
||||
}
|
||||
return render(request, 'kaehmy_list.html', context)
|
||||
|
||||
Reference in New Issue
Block a user