From 4af8f4974cc2a0c552bebb3db2519946197ce3a4 Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Mon, 1 Apr 2019 05:53:23 +0200
Subject: [PATCH] Separate motion creation templates from post creation ones

---
 .../forums/motion_confirm_create.html         | 58 +++++++++++++++++++
 forums/templates/forums/motion_form.html      | 27 +++++++++
 forums/templates/forums/post_card.html        |  2 +-
 forums/views.py                               |  3 +-
 4 files changed, 88 insertions(+), 2 deletions(-)
 create mode 100644 forums/templates/forums/motion_confirm_create.html
 create mode 100644 forums/templates/forums/motion_form.html

diff --git a/forums/templates/forums/motion_confirm_create.html b/forums/templates/forums/motion_confirm_create.html
new file mode 100644
index 000000000..3d626c706
--- /dev/null
+++ b/forums/templates/forums/motion_confirm_create.html
@@ -0,0 +1,58 @@
+{% extends 'forums/base.html' %}
+
+{% load bootstrap %}
+{% load restructuredtext %}
+
+
+{% block breadcrumb_items %}
+{{ block.super }}
+<span class="breadcrumb-item">Confirm Motion creation</span>
+{% endblock %}
+
+{% block pagetitle %}: Motion: confirm creation{% endblock pagetitle %}
+
+{% block content %}
+
+<div class="row">
+  <div class="col-12">
+    <h3 class="highlight">Preview</h3>
+
+    <div class="card">
+      <div class="card-header">
+	{{ form.initial.subject }}
+      </div>
+      <div class="card-body">
+	{% if form.initial.text %}
+	{{ form.initial.text|restructuredtext }}
+	{% else %}
+	<span class="text-danger">No text given</span>
+	{% endif %}
+      </div>
+    </div>
+
+    {% if form.errors %}
+    {% for field in form %}
+    {% for error in field.errors %}
+    <div class="alert alert-danger">
+      <strong>{{ field.name }} - {{ error|escape }}</strong>
+    </div>
+    {% endfor %}
+    {% endfor %}
+    {% for error in form.non_field_errors %}
+    <div class="alert alert-danger">
+      <strong>{{ error|escape }}</strong>
+    </div>
+    {% endfor %}
+    {% endif %}
+
+    <form action="" method="post">
+      {% csrf_token %}
+      {{ form|bootstrap }}
+      <input type="submit" value="Confirm Motion creation" class="btn btn-primary">
+      <span class="text-danger">&nbsp;<strong>Not satisfied?</strong> Hit your browser's back button and redraft your Motion</span>
+    </form>
+
+  </div>
+</div>
+
+{% endblock content %}
diff --git a/forums/templates/forums/motion_form.html b/forums/templates/forums/motion_form.html
new file mode 100644
index 000000000..ce4f3e20e
--- /dev/null
+++ b/forums/templates/forums/motion_form.html
@@ -0,0 +1,27 @@
+{% extends 'forums/base.html' %}
+
+{% load bootstrap %}
+{% load restructuredtext %}
+
+
+{% block breadcrumb_items %}
+{{ block.super }}
+<span class="breadcrumb-item">{% if form.instance.id %}Update {{ form.instance }}{% else %}New Motion{% endif %}</span>
+{% endblock %}
+
+{% block pagetitle %}: Motion{% endblock pagetitle %}
+
+{% block content %}
+
+<div class="row">
+  <div class="col-12">
+    <h3 class="highlight">Create a new Motion</h3>
+    <form action="" method="post">
+      {% csrf_token %}
+      {{ form|bootstrap }}
+      <input type="submit" value="Run preview" class="btn btn-primary">
+    </form>
+  </div>
+</div>
+
+{% endblock content %}
diff --git a/forums/templates/forums/post_card.html b/forums/templates/forums/post_card.html
index 78da1449f..bafd6c12a 100644
--- a/forums/templates/forums/post_card.html
+++ b/forums/templates/forums/post_card.html
@@ -1,6 +1,6 @@
 {% load restructuredtext %}
 
-<div class="card {% if post.motion %}text-white bg-dark{% else %}text-body{% endif %}" id="post{{ post.id }}">
+<div class="card m-1 {% if post.motion %}text-white bg-dark{% else %}text-body{% endif %}" id="post{{ post.id }}">
   <div class="card-header">
     {{ post.subject }}
     <div class="postInfo">
diff --git a/forums/views.py b/forums/views.py
index dc9eb8672..6f9df6f59 100644
--- a/forums/views.py
+++ b/forums/views.py
@@ -236,7 +236,7 @@ class MotionCreateView(PostCreateView):
     """
     model = Motion
     form_class = MotionForm
-    template_name = 'forums/post_form.html'
+    template_name = 'forums/motion_form.html'
 
     def get_initial(self, *args, **kwargs):
         initial = super().get_initial(*args, **kwargs)
@@ -310,6 +310,7 @@ class MotionConfirmCreateView(PostConfirmCreateView):
     Specialization of PostConfirmCreateView to Motion-class objects.
     """
     form_class = MotionForm
+    template_name = 'forums/motion_confirm_create.html'
 
     def get_initial(self, *args, **kwargs):
         initial = super().get_initial(*args, **kwargs)
-- 
GitLab