Move ohlhafv to its own app

This commit is contained in:
Jan Tuomi
2018-01-28 18:54:45 +02:00
parent 7dc9fac597
commit bdf6b469ad
44 changed files with 282 additions and 262 deletions
+1
View File
@@ -18,3 +18,4 @@ requirements_henu.txt
mydatabase mydatabase
settings.json settings.json
.vscode/ .vscode/
.DS_Store
@@ -7,7 +7,7 @@ footer {
bottom: 0; bottom: 0;
width: 100%; width: 100%;
height: 60px; /* Set the fixed height of the footer here */ height: 60px; /* Set the fixed height of the footer here */
/* line-height: 60px; /* Vertically center the text there */ */ /* line-height: 60px; /* Vertically center the text there */
margin-top: 2rem; margin-top: 2rem;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
+7 -4
View File
@@ -4,19 +4,22 @@
{% load i18n %} {% load i18n %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{% static "css/base.css" %}"> <link rel="stylesheet" href="{% static "kaehmy/css/base.css" %}">
<link rel="stylesheet" href="{% static "kaehmy/css/header.css" %}">
<link rel="stylesheet" href="{% static "kaehmy/css/nav.css" %}">
<link rel="stylesheet" href="{% static "kaehmy/css/footer.css" %}">
{% endblock styles %} {% endblock styles %}
{% block body %} {% block body %}
{% block header %} {% block header %}
<div class="kaehmy_header"> <div class="kaehmy_header">
{% include ":header.html" %} {% include "kaehmy:header.html" %}
</div> </div>
{% endblock header %} {% endblock header %}
{% block navigation %} {% block navigation %}
{% include ":navigation.html" %} {% include "kaehmy:navigation.html" %}
{% endblock %} {% endblock %}
<div class="kaehmy-content"> <div class="kaehmy-content">
@@ -25,7 +28,7 @@
</div> </div>
<div class="footer"> <div class="footer">
{% block footer %} {% block footer %}
{% include ":footer.html" %} {% include "kaehmy:footer.html" %}
{% endblock footer %} {% endblock footer %}
</div> </div>
-1
View File
@@ -1,5 +1,4 @@
{% load i18n %} {% load i18n %}
<link rel="stylesheet" href="/static/css/kaehmy_header.css">
<div class="kaehmy_header-content"> <div class="kaehmy_header-content">
<div class="kaehmy-banner logo"> <div class="kaehmy-banner logo">
-1
View File
@@ -1,7 +1,6 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
<link rel="stylesheet" href="{% static "css/nav.css" %}">
<div class="kaehmy_navigation"> <div class="kaehmy_navigation">
<nav class="navbar-border navbar navbar-toggleable-md navbar-light bg-faded"> <nav class="navbar-border navbar navbar-toggleable-md navbar-light bg-faded">
<div class="navbar-nav"> <div class="navbar-nav">
View File
+4
View File
@@ -0,0 +1,4 @@
from django.contrib import admin
from ohlhafv.models import OhlhafvChallenge
admin.site.register(OhlhafvChallenge)
+5
View File
@@ -0,0 +1,5 @@
from django.apps import AppConfig
class OhlhafvConfig(AppConfig):
name = 'ohlhafv'
+18
View File
@@ -0,0 +1,18 @@
"""File containing Ohlhafv forms."""
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ValidationError
from ohlhafv.models import OhlhafvChallenge
class OhlhafvForm(forms.ModelForm):
"""Class representing Ohlhafv form."""
class Meta:
"""Meta class for Ohlhafv form."""
model = OhlhafvChallenge
fields = ['challenger', 'challenger_email',
'victim', 'victim_email', 'series', 'message']
+32
View File
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-01-28 15:48
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='OhlhafvChallenge',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('challenger', models.CharField(max_length=255, verbose_name='Challenger')),
('victim', models.CharField(max_length=255, verbose_name='Victim')),
('challenger_email', models.EmailField(max_length=254, verbose_name='Challenger email')),
('victim_email', models.EmailField(max_length=254, verbose_name='Victim email')),
('series', models.CharField(choices=[('0.33 L', '0.33 L'), ('0.5 L', '0.5 L'), ('1.0 L', '1.0 L'), ('Team', 'Team Challenge (1 x 0.33 L, 2 x 0.5 L, 1 x 1.0 L)')], max_length=10, verbose_name='Series')),
('message', models.TextField(blank=True, verbose_name='Message')),
],
options={
'verbose_name': 'Ohlhafv challenge',
'verbose_name_plural': 'Ohlhafv challenges',
},
),
]
View File
+44
View File
@@ -0,0 +1,44 @@
"""Ohlhafv app models."""
from django.db import models
from django.utils import timezone
from datetime import timedelta
from django.contrib.auth.models import User
from webapp.utils import month_from_now
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from auditlog.registry import auditlog
from phonenumber_field.modelfields import PhoneNumberField
from django.contrib.postgres.fields import JSONField
import logging
VERBOSE_NAME = _('Ohlhafv')
class OhlhafvChallenge(models.Model):
"""Model containing all info about ohlhafv challenge."""
class Meta:
verbose_name = _('Ohlhafv challenge')
verbose_name_plural = _('Ohlhafv challenges')
SERIES_CHOICES = (
('0.33 L', '0.33 L'),
('0.5 L', '0.5 L'),
('1.0 L', '1.0 L'),
('Team', _('Team Challenge (1 x 0.33 L, 2 x 0.5 L, 1 x 1.0 L)'))
)
challenger = models.CharField(_('Challenger'), max_length=255)
victim = models.CharField(_('Victim'), max_length=255)
challenger_email = models.EmailField(_('Challenger email'))
victim_email = models.EmailField(_('Victim email'))
series = models.CharField(_('Series'), choices=SERIES_CHOICES, max_length=10)
message = models.TextField(_('Message'), blank=True, null=False)
def __str__(self):
"""Return model info."""
return _('Ohlhafv challenge: {} vs. {}').format(self.challenger, self.victim)
auditlog.register(OhlhafvChallenge)
@@ -4,6 +4,8 @@ html, body {
body { body {
padding: 0 1rem 0; padding: 0 1rem 0;
max-width: 1000px;
margin: 0 auto 0;
} }
.bg-faded, .form-control { .bg-faded, .form-control {
@@ -12,6 +14,8 @@ body {
color: black; color: black;
border-radius: 0; border-radius: 0;
-webkit-appearance: none;
box-shadow: 10px 10px rgba(0, 0, 0, 0.5); box-shadow: 10px 10px rgba(0, 0, 0, 0.5);
} }
@@ -84,6 +88,7 @@ h3 {
.card h5 { .card h5 {
color: black; color: black;
padding: 1rem 0 1rem;
} }
.card p { .card p {
@@ -7,7 +7,7 @@ footer {
bottom: 0; bottom: 0;
width: 100%; width: 100%;
height: 60px; /* Set the fixed height of the footer here */ height: 60px; /* Set the fixed height of the footer here */
/* line-height: 60px; /* Vertically center the text there */ */ /* line-height: 60px; /* Vertically center the text there */
margin-top: 2rem; margin-top: 2rem;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
@@ -1,11 +1,3 @@
.header-content {
}
.header-content .logo {
}
.header-content .logo img { .header-content .logo img {
display: block; display: block;
height: auto; height: auto;
@@ -1,4 +1,4 @@
.kaehmy_navigation { .ohlhafv_navigation {
margin-bottom: 10px; margin-bottom: 10px;
} }

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

+10
View File
@@ -0,0 +1,10 @@
import django_tables2 as tables
from django.db.models import Count, Q
from django.utils.translation import ugettext as _
from ohlhafv.models import OhlhafvChallenge
class OhlhafvTable(tables.Table):
class Meta:
model = OhlhafvChallenge
+28
View File
@@ -0,0 +1,28 @@
{% extends "project.html" %}
{% load static %}
{% load i18n %}
{% block styles %}
<link rel="stylesheet" href="{% static "ohlhafv/css/base.css" %}">
<link rel="stylesheet" href="{% static "ohlhafv/css/header.css" %}">
<link rel="stylesheet" href="{% static "ohlhafv/css/nav.css" %}">
{% endblock styles %}
{% block body %}
{% block header %}
{% include "ohlhafv:header.html" %}
{% endblock header %}
{% block navigation %}
{% include "ohlhafv:navigation.html" %}
{% endblock %}
{% block content %}
{% endblock %}
{% block footer %}
{% include "ohlhafv:footer.html" %}
{% endblock footer %}
{% endblock body %}
+25
View File
@@ -0,0 +1,25 @@
{% load i18n %}
{% load static %}
{% load staticfiles %}
<link rel="stylesheet" href="{% static "ohlhafv/css/footer.css" %}">
<footer style="text-align: center">
<div>
<form class="lang-form form" action="{% url 'set_language' %}" method="post">{% csrf_token %}
<span>
<input name="next" type="hidden" value="{{ redirect_to }}" />
<select onchange="this.form.submit()" class="lang-select form-control" name="language">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
</span>
</form>
<span>{% trans "Copyright Aalto-yliopiston Sähköinsinöörikilta ry" %} {% now 'Y' %}</span>
</div>
</footer>
@@ -1,8 +1,8 @@
{% load i18n %} {% load i18n %}
<link rel="stylesheet" href="/static/css/ohlhafv_header.css"> {% load static %}
<div class="ohlhafv-header-content"> <div class="ohlhafv-header-content">
<div class="ohlhafv-banner logo"> <div class="ohlhafv-banner logo">
<a href="/ohlhafv"><img class="ohlhafv-banner-image" src="/static/img/heevi_banner.svg" alt="Aalto-yliopiston Sähköinsinöörikilta ry"></a> <a href="/ohlhafv"><img class="ohlhafv-banner-image" src="{% static "ohlhafv/img/heevi_banner.svg" %}" alt="Aalto-yliopiston Sähköinsinöörikilta ry"></a>
</div> </div>
</div> </div>
@@ -1,4 +1,4 @@
{% extends "ohlhafv/base.html" %} {% extends "ohlhafv:base.html" %}
{% load static %} {% load static %}
{% load i18n %} {% load i18n %}
@@ -16,7 +16,7 @@
<div class="card"> <div class="card">
<h4 class="card-header">{{ challenge.challenger }} vs. {{ challenge.victim }}</h4> <h4 class="card-header">{{ challenge.challenger }} vs. {{ challenge.victim }}</h4>
<div class="card-block"> <div class="card-block">
<h5 style="padding-bottom: 1rem" class="card-subtitle mb-2 text-muted">{{ challenge.get_series_display }}</h5> <h5 class="card-subtitle mb-2">{{ challenge.get_series_display }}</h5>
<p class="card-text">{{ challenge.message|linebreaks|urlize }}</p> <p class="card-text">{{ challenge.message|linebreaks|urlize }}</p>
</div> </div>
</div> </div>
@@ -1,6 +1,5 @@
{% load i18n %} {% load i18n %}
<link rel="stylesheet" href="/static/css/kaehmy_nav.css"> <div class="ohlhafv_navigation">
<div class="kaehmy_navigation">
<nav class="navbar-border navbar navbar-toggleable-md navbar-light bg-faded"> <nav class="navbar-border navbar navbar-toggleable-md navbar-light bg-faded">
<div class="navbar-nav"> <div class="navbar-nav">
<a class="nav-item nav-link" href="/ohlhafv">{% trans "New challenge" %} <span class="sr-only">(current)</span></a> <a class="nav-item nav-link" href="/ohlhafv">{% trans "New challenge" %} <span class="sr-only">(current)</span></a>
@@ -1,10 +1,10 @@
{% extends ":base.html" %} {% extends "ohlhafv:base.html" %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% load i18n %} {% load i18n %}
{% block navigation %} {% block navigation %}
{% include ":navigation.html" %} {% include "ohlhafv:navigation.html" %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+18
View File
@@ -0,0 +1,18 @@
"""Ohlhafv urls."""
from django.conf.urls import url
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from ohlhafv.views import *
urlpatterns = [
# ohlhafv
url(r'^submit', ohlhafv_submit),
url(r'^list', ohlhafv_list),
url(r'^$', ohlhafv_view)
]
if settings.DEBUG:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
+50
View File
@@ -0,0 +1,50 @@
"""Ohlhafv views."""
from django.db.models import Count
from django.shortcuts import render, redirect
from django.contrib.auth import login, logout, authenticate
from django.views.decorators.http import require_http_methods
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
import logging
import requests
from dealer.git import git
from ohlhafv.models import OhlhafvChallenge
from ohlhafv.forms import OhlhafvForm
from ohlhafv.tables import OhlhafvTable
@require_http_methods(["GET"])
def ohlhafv_view(request, *args, **kwargs):
"""Render Ohlhafv form page."""
form = OhlhafvForm()
return render(request, 'ohlhafv:new.html', {'form': form})
@ensure_csrf_cookie
@require_http_methods(["POST"])
def ohlhafv_submit(request, *args, **kwargs):
"""Submit Ohlhafv form."""
form = OhlhafvForm(request.POST)
if form.is_valid():
form.save()
else:
pass
return HttpResponseRedirect('/ohlhafv/list/')
@ensure_csrf_cookie
@require_http_methods(["GET"])
def ohlhafv_list(request, *args, **kwargs):
"""Present Ohlhafv challenges list."""
challenges = OhlhafvChallenge.objects.all()
challenges = challenges.order_by('-id')
context = {
'challenges': challenges,
'challenge_count': len(challenges),
}
return render(request, 'ohlhafv:list.html', context)
+1
View File
@@ -80,6 +80,7 @@ INSTALLED_APPS = [
'infoscreen', 'infoscreen',
'coffee_scale', 'coffee_scale',
'kaehmy', 'kaehmy',
'ohlhafv',
'rest_framework', 'rest_framework',
'django_nose', 'django_nose',
'bootstrap3', 'bootstrap3',
+1
View File
@@ -34,6 +34,7 @@ urlpatterns = [
url(r'^infoscreen/', include('infoscreen.urls')), url(r'^infoscreen/', include('infoscreen.urls')),
url(r'^coffee/', include('coffee_scale.urls')), url(r'^coffee/', include('coffee_scale.urls')),
url(r'^kaehmy/', include('kaehmy.urls')), url(r'^kaehmy/', include('kaehmy.urls')),
url(r'^ohlhafv/', include('ohlhafv.urls')),
# admin # admin
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
-2
View File
@@ -3,7 +3,6 @@
from django.contrib import admin from django.contrib import admin
from webapp.models import Official, Role from webapp.models import Official, Role
from webapp.models import Feed, Tag, BaseFeed, Event, Registration from webapp.models import Feed, Tag, BaseFeed, Event, Registration
from webapp.models import OhlhafvChallenge
from modeltranslation.admin import TranslationAdmin from modeltranslation.admin import TranslationAdmin
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
# this is needed so that the models get registered for translation # this is needed so that the models get registered for translation
@@ -17,4 +16,3 @@ admin.site.register(Event, TranslationAdmin)
admin.site.register(Registration, TranslationAdmin) admin.site.register(Registration, TranslationAdmin)
admin.site.register(Official) admin.site.register(Official)
admin.site.register(Role) admin.site.register(Role)
admin.site.register(OhlhafvChallenge)
-14
View File
@@ -3,17 +3,3 @@
from django import forms from django import forms
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from webapp.models import BaseRole
from webapp.models import OhlhafvChallenge
class OhlhafvForm(forms.ModelForm):
"""Class representing Ohlhafv form."""
class Meta:
"""Meta class for Ohlhafv form."""
model = OhlhafvChallenge
fields = ['challenger', 'challenger_email',
'victim', 'victim_email', 'series', 'message']
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-01-28 15:48
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('webapp', '0038_auto_20180126_0031'),
]
operations = [
migrations.DeleteModel(
name='OhlhafvChallenge',
),
]
-28
View File
@@ -153,37 +153,9 @@ class Official(User):
phone_number = PhoneNumberField(_('Phone number')) phone_number = PhoneNumberField(_('Phone number'))
# Ohlhafv
class OhlhafvChallenge(models.Model):
"""Model containing all info about ohlhafv challenge."""
class Meta:
verbose_name = _('Ohlhafv challenge')
verbose_name_plural = _('Ohlhafv challenges')
SERIES_CHOICES = (
('0.33 L', '0.33 L'),
('0.5 L', '0.5 L'),
('1.0 L', '1.0 L'),
('Team', _('Team Challenge (1 x 0.33 L, 2 x 0.5 L, 1 x 1.0 L)'))
)
challenger = models.CharField(_('Challenger'), max_length=255)
victim = models.CharField(_('Victim'), max_length=255)
challenger_email = models.EmailField(_('Challenger email'))
victim_email = models.EmailField(_('Victim email'))
series = models.CharField(_('Series'), choices=SERIES_CHOICES, max_length=10)
message = models.TextField(_('Message'), blank=True, null=False)
def __str__(self):
"""Return model info."""
return _('Ohlhafv challenge: {} vs. {}').format(self.challenger, self.victim)
auditlog.register(Tag) auditlog.register(Tag)
auditlog.register(Feed) auditlog.register(Feed)
auditlog.register(Event) auditlog.register(Event)
auditlog.register(PresetRole) auditlog.register(PresetRole)
auditlog.register(Role) auditlog.register(Role)
auditlog.register(Official) auditlog.register(Official)
auditlog.register(OhlhafvChallenge)
-37
View File
@@ -1,37 +0,0 @@
.header-content {
}
.header-content .logo {
}
.header-content .logo img {
display: block;
height: auto;
margin: auto;
}
.kaehmy-banner {
max-width: 1000px;
margin-left: auto;
margin-right: auto;
}
@media screen and (min-width: 1000px) {
.kaehmy_header-content {
position: absolute;
left: 0;
top: 0;
background-color: #052f5f;
width: 100%;
}
.kaehmy_header {
margin-bottom: 331px;
}
}
.kaehmy-banner-image {
width: 100%;
}
-35
View File
@@ -1,35 +0,0 @@
.page-content {
margin-top: 1vh;
width: 90%;
margin-left: auto;
margin-right: auto;
}
body {
max-width: 1000px;
margin-left: auto !important;
margin-right: auto !important;
}
div.tooltip-inner {
max-width: 25rem;
}
.tooltip {
margin-left: 1rem;
}
.role-filter-form {
max-width: 30rem;
width: auto;
margin-bottom: 1rem;
}
.kaehmy-content {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
p {
overflow-wrap: break-word;
}
-7
View File
@@ -1,10 +1,3 @@
import django_tables2 as tables import django_tables2 as tables
from django.db.models import Count, Q from django.db.models import Count, Q
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from webapp.models import OhlhafvChallenge
class OhlhafvTable(tables.Table):
class Meta:
model = OhlhafvChallenge
-50
View File
@@ -1,50 +0,0 @@
<!DOCTYPE html>
{% load i18n %}
{% load static %}
{% load staticfiles %}
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Aalto-yliopiston Sähköinsinöörikilta ry">
<meta name="author" content="Aalto-yliopiston Sähköinsinöörikilta ry">
<link rel="stylesheet" href="/static/css/webapp_kaehmy.css">
<title>{% trans "Aalto-yliopiston Sähköinsinöörikilta ry" %}</title>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="{% static "js/lib/jquery-3.1.0.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">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script src="{% static "js/lib/underscore-min.js" %}"></script>
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
</head>
<body>
<div class="header">
{% block header %}
{% endblock header %}
</div>
<div class="navigation">
{% block navigation %}
{% endblock %}
</div>
<div class="content">
{% block content %}
{% endblock %}
</div>
<div class="footer">
{% block footer %}
{% endblock footer %}
</div>
</body>
</html>
-20
View File
@@ -1,20 +0,0 @@
{% extends "form_base.html" %}
{% load static %}
{% load i18n %}
{% block header %}
<link rel="stylesheet" href="/static/css/ohlhafv/base.css">
{% include "ohlhafv/header.html" %}
{% endblock header %}
{% block navigation %}
{% include "ohlhafv/navigation.html" %}
{% endblock %}
{% block content %}
{% endblock %}
{% block footer %}
{% include "kaehmy/footer.html" %}
{% endblock footer %}
-8
View File
@@ -8,9 +8,6 @@ from webapp.views import main_index
from webapp.views import login_view from webapp.views import login_view
from webapp.views import logout_view from webapp.views import logout_view
from webapp.views import about_view from webapp.views import about_view
from webapp.views import ohlhafv_view
from webapp.views import ohlhafv_submit
from webapp.views import ohlhafv_list
from webapp.views import guild_view from webapp.views import guild_view
from webapp.views import freshmen_view from webapp.views import freshmen_view
from webapp.views import jobs_view from webapp.views import jobs_view
@@ -40,11 +37,6 @@ urlpatterns = [
# corporate # corporate
url(r'^jobs', jobs_view), url(r'^jobs', jobs_view),
# ohlhafv
url(r'^ohlhafv/submit', ohlhafv_submit),
url(r'^ohlhafv/list', ohlhafv_list),
url(r'^ohlhafv', ohlhafv_view),
] ]
+1 -35
View File
@@ -13,9 +13,7 @@ import logging
import requests import requests
from dealer.git import git from dealer.git import git
from webapp.models import Official, OhlhafvChallenge from webapp.models import Official
from webapp.forms import OhlhafvForm
from webapp.tables import OhlhafvTable
from members.views.utils import * from members.views.utils import *
@@ -121,35 +119,3 @@ def contact_view(request, *args, **kwargs):
context = {"kaikki": kaikki} context = {"kaikki": kaikki}
return render(request, "contact.html", context) return render(request, "contact.html", context)
@require_http_methods(["GET"])
def ohlhafv_view(request, *args, **kwargs):
"""Render Ohlhafv form page."""
form = OhlhafvForm()
return render(request, 'ohlhafv/new.html', {'form': form})
@ensure_csrf_cookie
@require_http_methods(["POST"])
def ohlhafv_submit(request, *args, **kwargs):
"""Submit Ohlhafv form."""
form = OhlhafvForm(request.POST)
if form.is_valid():
form.save()
else:
pass
return HttpResponseRedirect('/ohlhafv/list/')
@ensure_csrf_cookie
@require_http_methods(["GET"])
def ohlhafv_list(request, *args, **kwargs):
"""Present Ohlhafv challenges list."""
challenges = OhlhafvChallenge.objects.all()
challenges = challenges.order_by('-id')
context = {
'challenges': challenges,
'challenge_count': len(challenges),
}
return render(request, 'ohlhafv/list.html', context)