wip: add stance

This commit is contained in:
Mindiell 2021-07-27 07:49:09 +02:00
parent 1f19252dcc
commit 6440bab46b
6 changed files with 71 additions and 4 deletions

19
app/controller/stance.py Normal file
View File

@ -0,0 +1,19 @@
# encoding: utf-8
from datetime import datetime
import random
from flask import g, redirect, render_template, url_for
from app import model
from app.controller.controller import Controller
from app.form.stance import AddStanceForm
from sqlalchemy import desc
from sqlalchemy.sql.expression import func
class Stance(Controller):
def add(self):
g.form = AddStanceForm()
return render_template("stance/add.html")

16
app/form/stance.py Normal file
View File

@ -0,0 +1,16 @@
# encoding: utf-8
from flask_babel import gettext as _
from flask_wtf import FlaskForm
from wtforms import DateField, HiddenField, SelectField, TextField
from wtforms.validators import DataRequired
class AddStanceForm(FlaskForm):
representative = HiddenField(_("Représentant(e)"), validators=[DataRequired()])
matter = HiddenField(_("Dossier"))
date = DateField(_("Date"), validators=[DataRequired()])
subject = TextField(_("Sujet"), validators=[DataRequired()])
extract = TextField(_("Extrait"))
source_url = TextField(_("URL de la source"), validators=[DataRequired()])

View File

@ -6,6 +6,7 @@ from app.controller.api.country import CountriesApi, CountryApi
from app.controller.api.representative import RepresentativesApi, RepresentativeApi from app.controller.api.representative import RepresentativesApi, RepresentativeApi
from app.controller.core import Core from app.controller.core import Core
from app.controller.representative import Representative from app.controller.representative import Representative
from app.controller.stance import Stance
# Adding admin endpoints # Adding admin endpoints
@ -15,9 +16,10 @@ for route in admin_routes:
# Listing normal endpoints # Listing normal endpoints
routes = [ routes = [
("/", Core.as_view("home")), ("/", Core.as_view("home")),
("/representative/<int:representative_id>", Representative.as_view("view")),
("/about", Core.as_view("about")), ("/about", Core.as_view("about")),
("/who", Core.as_view("who")), ("/who", Core.as_view("who")),
("/representative/<int:representative_id>", Representative.as_view("view")),
("/stance/add", Stance.as_view("add")),
] ]
# Listing API endpoints # Listing API endpoints

View File

@ -9,4 +9,4 @@
</ul> </ul>
{%endif%} {%endif%}
</div> </div>
{%endmacro%} {%endmacro%}

View File

@ -7,7 +7,7 @@
<li>Find a representative</li> <li>Find a representative</li>
<li>Find a matter</li> <li>Find a matter</li>
--> -->
<li><a href="">{{_("Ajouter une prise de position")}}</a></li> <li><a href="{{url_for('stance.add')}}">{{_("Ajouter une prise de position")}}</a></li>
</ul> </ul>
</nav> </nav>
</div> </div>
@ -19,4 +19,4 @@
</div> </div>
--> -->
<hr /> <hr />
</header> </header>

30
app/view/stance/add.html Normal file
View File

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block content %}
<div id="main">
<h1>{{_("Ajouter une prise de position")}}</h1>
<form method="POST" action="{{url_for('stance.add')}}">
{{g.form.hidden_tag()}}
{{g.form.representative()}}
{{g.form.matter()}}
<div class="field">
<label>{{_("Représentant :")}}</label> <input type="text" />
<span class="field-description">{{_("Le représentant ayant pris cette position")}}</span>
</div>
<div class="field">
<label>{{_("Dossier :")}}</label> <input type="text" />
<span class="field-description">{{_("Le dossier lié à cette prise de position. Ce champ reste optionnel.")}}</span>
</div>
{{render_field(g.form.date)}}
{{render_field(g.form.source_url)}}
{{render_field(g.form.extract)}}
<input type="submit" value="{{_('Ajouter')}}" class="btn" />
<a href="{{url_for('core.home')}}" class="btn">{{_("Annuler")}}</a>
</form>
</div>
{% endblock %}