Browse Source

wip: add stance

develop
Mindiell 1 year ago
parent
commit
6440bab46b
  1. 19
      app/controller/stance.py
  2. 16
      app/form/stance.py
  3. 4
      app/routes.py
  4. 2
      app/view/form_helper.html
  5. 4
      app/view/menu.html
  6. 30
      app/view/stance/add.html

19
app/controller/stance.py

@ -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

@ -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()])

4
app/routes.py

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

2
app/view/form_helper.html

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

4
app/view/menu.html

@ -7,7 +7,7 @@
<li>Find a representative</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>
</nav>
</div>
@ -19,4 +19,4 @@
</div>
-->
<hr />
</header>
</header>

30
app/view/stance/add.html

@ -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 %}
Loading…
Cancel
Save