summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2025-06-02 15:07:40 +0000
committerMagnus Hagander2025-06-02 15:11:07 +0000
commiteccdeaa571c23cf324d73c28670b5e646128a214 (patch)
tree826fdf646d2a2ce7bd444ec9ca39968855e46f1a
parente3b492e6fd2bd736c49c3b9ccf58f2ae64e0da73 (diff)
Move form guts out to a separate file
-rw-r--r--pgmailmgr/mailmgr/templates/form.html21
-rw-r--r--pgmailmgr/mailmgr/templates/form_contents.html21
-rw-r--r--pgmailmgr/mailmgr/templates/mailbox.html20
-rw-r--r--pgmailmgr/mailmgr/views.py3
4 files changed, 26 insertions, 39 deletions
diff --git a/pgmailmgr/mailmgr/templates/form.html b/pgmailmgr/mailmgr/templates/form.html
index a366cca..93bc5de 100644
--- a/pgmailmgr/mailmgr/templates/form.html
+++ b/pgmailmgr/mailmgr/templates/form.html
@@ -7,25 +7,6 @@
{%block content%}
<h1>Edit</h1>
-<form method="post" action=".">
-{% csrf_token %}
-{%if form.non_field_errors%}
- <div class="alert alert-danger">{{form.non_field_errors}}</div>
-{%endif%}
-{%for field in form%}
-{%include "form_field.html"%}
-{%endfor%}
+{% include "form_contents.html" %}
- <div class="form-group">
- <div class="col-lg-12">
- <div class="control">
- <input type="submit" name="submit" class="col-md-2 mb-2 mr-2 btn btn-primary" value="{{savebutton|default:"Save"}}">
-{%if cancelurl%}
- <a class="col-md-2 mb-2 mr-2 btn btn-secondary" href="{{cancelurl}}">{{cancelname|default:"Cancel"}}</a>
-{%endif%}
- </div>
- </div>
- </div>
-
-</form>
{%endblock%}
diff --git a/pgmailmgr/mailmgr/templates/form_contents.html b/pgmailmgr/mailmgr/templates/form_contents.html
new file mode 100644
index 0000000..2243b1b
--- /dev/null
+++ b/pgmailmgr/mailmgr/templates/form_contents.html
@@ -0,0 +1,21 @@
+<form method="post" action=".">
+{% csrf_token %}
+{%if form.non_field_errors%}
+ <div class="alert alert-danger">{{form.non_field_errors}}</div>
+{%endif%}
+{%for field in form%}
+{%include "form_field.html"%}
+{%endfor%}
+
+ <div class="form-group">
+ <div class="col-lg-12">
+ <div class="control">
+ <input type="submit" name="submit" class="col-md-2 mb-2 mr-2 btn btn-primary" value="{{savebutton|default:"Save"}}">
+{% for title, href in extrabuttons %}
+ <a class="col-md-2 mb-2 mr-2 btn btn-secondary" href="{{href}}">{{title}}</a>
+{% endfor %}
+ </div>
+ </div>
+ </div>
+
+</form>
diff --git a/pgmailmgr/mailmgr/templates/mailbox.html b/pgmailmgr/mailmgr/templates/mailbox.html
index 28a0235..8772083 100644
--- a/pgmailmgr/mailmgr/templates/mailbox.html
+++ b/pgmailmgr/mailmgr/templates/mailbox.html
@@ -4,23 +4,5 @@
<h2>Change password</h2>
-<form method="post" action=".">
-{% csrf_token %}
-{%if form.non_field_errors%}
- <div class="alert alert-danger">{{form.non_field_errors}}</div>
-{%endif%}
-{%for field in form%}
-{%include "form_field.html"%}
-{%endfor%}
-
- <div class="form-group">
- <div class="col-lg-12">
- <div class="control">
- <input type="submit" name="submit" class="col-md-2 mb-2 mr-2 btn btn-primary" value="Change password">
- <a class="col-md-2 mb-2 mr-2 btn btn-secondary" href="/">Cancel</a>
- </div>
- </div>
- </div>
-
-</form>
+{% include "form_contents.html" %}
{%endblock%}
diff --git a/pgmailmgr/mailmgr/views.py b/pgmailmgr/mailmgr/views.py
index 5e7c8e4..d328954 100644
--- a/pgmailmgr/mailmgr/views.py
+++ b/pgmailmgr/mailmgr/views.py
@@ -55,6 +55,9 @@ def mailbox(request, virtualid):
return render(request, 'mailbox.html', {
'mailbox': mailbox,
'form': form,
+ 'extrabuttons': [
+ ('Cancel', '/'),
+ ],
})