Commit c50c5e3a by Chif Gergő

request: Templates: add field form, add fields to request forms

Added template to render the RequestFieldForm, and rendering the fields in a table. Adjust template request form's template to show dynamically added fields. Added a button to request list template which redirects to the request fields page.
parent 6d41f4b8
......@@ -55,7 +55,7 @@ TYPES = (
class RequestField(Model):
fieldname = CharField(max_length=50, blank=False, unique=True)
type = CharField(choices=TYPES, default='Char', max_length=20)
choices = CharField(max_length=100, null=True)
choices = CharField(max_length=300, null=True)
required = BooleanField(default=True)
def __unicode__(self):
......
......@@ -21,6 +21,8 @@
</label>
</div>
{% endfor %}
{{ form.message|as_crispy_field }}
{% for field in form.get_dynamic_fields %}
{{ field|as_crispy_field }}
{% endfor %}
<input type="submit" class="btn btn-primary"/>
</form>
{% extends "dashboard/base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block content %}
<div class="table-responsive">
<div class="table-container">
<table class="table table-bordered table-striped table-hover" >
<thead>
<tr>
<th>{% trans "Fieldname" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Choices" %}</th>
<th>{% trans "Required" %}</th>
<th>{% trans "Delete" %}</th>
</tr>
</thead>
<tbody>
{% for field in object_list %}
<tr>
<td>{{field.fieldname}}</td>
<td>{{field.type}}</td>
<td>{{field.choices}}</td>
<td>{{field.required}}</td>
<td><a href={% url "request.views.field-delete" pk=field.pk %}>
<i class="fa fa-times"></i></a>
</td>
</tr>
{% endfor %}
<tr>
<form action={% url 'request.views.request-field-add' %} method="post">
{% csrf_token %}
{% for field in add_form %}
<td> {{field}}</td>
{% endfor %}
<td><button type="submit" class="btn btn-sm btn-success">{% trans "Add" %}</button></td>
</form>
</tr>
</tbody>
</table>
</div>
</div>
{% endblock %}
......@@ -11,9 +11,14 @@
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<a class="btn btn-xs btn-primary pull-right "href="{% url "request.views.type-list" %}">
<div class="pull-right">
<a class="btn btn-xs btn-primary"href="{% url "request.views.type-list" %}">
{% trans "Request types" %}
</a>
<a class="btn btn-xs btn-success" href="{% url "request.views.field-list" %}">
{% trans "Request fields" %}
</a>
</div>
<h3 class="no-margin"><i class="fa fa-phone"></i> {% trans "Requests" %}</h3>
</div>
<div class="panel-body">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment