Rajoute des champs pour ajouter une question/option

This commit is contained in:
Tom Hubrecht 2020-12-19 12:58:49 +01:00
parent 35a8df0501
commit 786ac214a8
3 changed files with 96 additions and 5 deletions

View file

@ -7,13 +7,14 @@
<head> <head>
<title>{{ site.name }}</title> <title>{{ site.name }}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
{# CSS #} {# CSS #}
<link rel="stylesheet" href="{% static 'css/main.css' %}"> <link rel="stylesheet" href="{% static 'css/main.css' %}">
<link rel="stylesheet" href="{% static 'vendor/font-awesome/css/font-awesome.min.css' %}"> <link rel="stylesheet" href="{% static 'vendor/font-awesome/css/font-awesome.min.css' %}">
<link rel="stylesheet" href="{% static 'vendor/font-awesome/css/solid.min.css' %}">
{# Javascript #} {# Javascript #}
<script src="{% static 'vendor/jquery/jquery-3.5.1.min.js' %}"></script> <script src="{% static 'vendor/jquery/jquery-3.5.1.min.js' %}"></script>
@ -53,7 +54,7 @@
<div class="main-content"> <div class="main-content">
<div class="columns is-centered"> <div class="columns is-centered">
<div class="column is-two-thirds"> <div class="column is-two-thirds">
<section class="section"> <section class="section pt-3">
{% if messages %} {% if messages %}
{% for message in messages %} {% for message in messages %}

View file

@ -0,0 +1,72 @@
{% extends "elections/base.html" %}
{% load i18n %}
{% block content %}
<h1 class="title">{{ election.name }}</h1>
<hr>
<div class="message is-info">
<p class="message-body">{{ election.description }}</p>
</div>
<div class="container">
{% for q in election.questions.all %}
<div class="panel">
<div class="panel-heading is-size-6">
<a class="tag is-small is-outlined is-light is-danger">{% trans "Supprimer" %}</a>
<a class="tag is-small is-outlined is-light is-info">{% trans "Modifier" %}</a>
{{ q.text }}
</div>
{% for o in q.options.all %}
<div class="panel-block">
<div class="tags has-addons">
<a class="tag is-danger">{% trans "Supprimer" %}</a>
<a class="tag is-info">{% trans "Modifier" %}</a>
</div>
&nbsp;&nbsp;{{ o.text }}
</div>
{% endfor %}
<form action="" method="POST">
<div class="panel-block field has-addons">
{% csrf_token %}
<div class="control has-icons-left is-expanded">
<input class="input is-success" type="text" name="text" id="id_text" placeholder="{% trans "Rajouter une option" %}">
<span class="icon is-left">
<i class="fas fa-plus"></i>
</span>
</div>
<div class="control">
<button class="button is-success">{% trans "Valider" %}</button>
</div>
</div>
</form>
</div>
{% endfor %}
<div class="columns is-centered">
<div class="column is-two-thirds">
<form action="" method="POST">
{% csrf_token %}
<div class="field has-addons">
<div class="control has-icons-left is-expanded">
<input class="input" type="text" name="text" id="id_text" placeholder="{% trans "Rajouter une question" %}">
<span class="icon is-left">
<i class="fas fa-question"></i>
</span>
</div>
<div class="control">
<button class="button">{% trans "Valider" %}</button>
</div>
</div>
</form>
</div>
</div>
</div>
{% endblock %}

View file

@ -1,7 +1,25 @@
{% extends "elections/base.html" %} {% extends "elections/base.html" %}
{% load i18n %} {% load i18n static %}
{% block extra_head %}
{# DateTimePicker #}
<script src={% static 'vendor/datepicker/datetimepicker.js' %}></script>
<link rel="stylesheet" href="{% static 'vendor/datepicker/datetimepicker.css' %}">
<script>
$(document).ready(function($) {
$('#id_start_date').datetimepicker({
format: 'Y-m-d H:i'
});
$('#id_end_date').datetimepicker({
format: 'Y-m-d H:i'
});
});
</script>
{% endblock %}
{% block content %} {% block content %}
{% for error in form.non_field_errors %} {% for error in form.non_field_errors %}
@ -16,11 +34,11 @@
<form action="" method="post"> <form action="" method="post">
{% csrf_token %} {% csrf_token %}
{% include "elections/forms/form.html" with form=form errors=False %} {% include "elections/forms/form.html" with errors=False %}
<div class="field"> <div class="field">
<p class="control"> <p class="control">
<input class="button is-fullwidth" type="submit" value={% trans "Enregistrer" %}> <input class="button is-fullwidth" type="submit" value={% trans "Enregistrer" %}>
</p> </p>
</div> </div>
</form> </form>