From a2ba61183325ec15c42742aa30bce82e4dd3b963 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Tue, 5 Mar 2019 04:36:51 +0100 Subject: [PATCH] Basic views --- forums/forms.py | 13 ++++++++ forums/templates/forums/base.html | 13 ++++++++ forums/templates/forums/forum_detail.html | 21 +++++++++++++ forums/templates/forums/forum_form.html | 25 +++++++++++++++ forums/templates/forums/forum_list.html | 38 +++++++++++++++++++++++ forums/urls.py | 25 +++++++++++++++ 6 files changed, 135 insertions(+) create mode 100644 forums/forms.py create mode 100644 forums/templates/forums/base.html create mode 100644 forums/templates/forums/forum_detail.html create mode 100644 forums/templates/forums/forum_form.html create mode 100644 forums/templates/forums/forum_list.html create mode 100644 forums/urls.py diff --git a/forums/forms.py b/forums/forms.py new file mode 100644 index 000000000..8edd8b118 --- /dev/null +++ b/forums/forms.py @@ -0,0 +1,13 @@ +__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + + +from django import forms + +from .models import Forum + + +class ForumForm(forms.ModelForm): + class Meta: + model = Forum + fields = ['name', 'slug', 'publicly_visible', 'moderators'] diff --git a/forums/templates/forums/base.html b/forums/templates/forums/base.html new file mode 100644 index 000000000..83076f2ac --- /dev/null +++ b/forums/templates/forums/base.html @@ -0,0 +1,13 @@ +{% extends 'scipost/base.html' %} + +{% block breadcrumb %} + <div class="container-outside header"> + <div class="container"> + <nav class="breadcrumb hidden-sm-down"> + {% block breadcrumb_items %} + <a href="{% url 'forums:forums' %}" class="breadcrumb-item">Forums</a> + {% endblock %} + </nav> + </div> + </div> +{% endblock %} diff --git a/forums/templates/forums/forum_detail.html b/forums/templates/forums/forum_detail.html new file mode 100644 index 000000000..e143e851e --- /dev/null +++ b/forums/templates/forums/forum_detail.html @@ -0,0 +1,21 @@ +{% extends 'forums/base.html' %} + +{% load bootstrap %} + +{% block breadcrumb_items %} + {{ block.super }} +<span class="breadcrumb-item">Details</span> +{% endblock %} + +{% load scipost_extras %} + +{% block pagetitle %}: Forum details{% endblock pagetitle %} + +{% block content %} +<div class="row"> + <div class="col-12"> + <p>{{ forum }}</p> + </div> +</div> + +{% endblock content %} diff --git a/forums/templates/forums/forum_form.html b/forums/templates/forums/forum_form.html new file mode 100644 index 000000000..578e4e4b4 --- /dev/null +++ b/forums/templates/forums/forum_form.html @@ -0,0 +1,25 @@ +{% extends 'forums/base.html' %} + +{% load bootstrap %} + +{% block breadcrumb_items %} +{{ block.super }} +<span class="breadcrumb-item">{% if form.instance.id %}Update {{ form.instance }}{% else %}Add new Forum{% endif %}</span> +{% endblock %} + +{% block pagetitle %}: Forums{% endblock pagetitle %} + + +{% block content %} + +<div class="row"> + <div class="col-12"> + <form action="" method="post"> + {% csrf_token %} + {{ form|bootstrap }} + <input type="submit" value="Submit" class="btn btn-primary"> + </div> +</div> + + +{% endblock content %} diff --git a/forums/templates/forums/forum_list.html b/forums/templates/forums/forum_list.html new file mode 100644 index 000000000..88c33f568 --- /dev/null +++ b/forums/templates/forums/forum_list.html @@ -0,0 +1,38 @@ +{% extends 'forums/base.html' %} + +{% load bootstrap %} + + +{% block breadcrumb_items %} +{{ block.super }} +<span class="breadcrumb-item">Forums</span> +{% endblock %} + + +{% block pagetitle %}: Forums{% endblock pagetitle %} + +{% block content %} + +<div class="row"> + <div class="col-12"> + <h3 class="highlight">Forums</h3> + <ul> + <li><a href="{% url 'forums:forum_create' %}">Create a new Forum</a></li> + </ul> + <table class="table"> + <tbody> + {% for forum in object_list %} + <tr> + <td>{{ forum }}</td> + </tr> + {% empty %} + <tr> + <td>No Forum defined</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> +</div> + +{% endblock content %} diff --git a/forums/urls.py b/forums/urls.py new file mode 100644 index 000000000..76098d09a --- /dev/null +++ b/forums/urls.py @@ -0,0 +1,25 @@ +__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + + +from django.conf.urls import url + +from . import views + +urlpatterns = [ + url( + r'^add/$', + views.ForumCreateView.as_view(), + name='forum_create' + ), + url( + r'^(?P<slug>[\w-]+)/$', + views.ForumDetailView.as_view(), + name='forum_detail' + ), + url( + r'^$', + views.ForumListView.as_view(), + name='forums' + ), +] -- GitLab