...
 
Commits (3)
......@@ -13,5 +13,19 @@
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/test.sqlite</jdbc-url>
</data-source>
<data-source source="LOCAL" name="db" uuid="99e3ba84-13c7-4a70-9621-1a27245c4fa6">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db.sqlite</jdbc-url>
<libraries>
<library>
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.25.1/sqlite-jdbc-3.25.1.jar</url>
</library>
<library>
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.25.1/license.txt</url>
</library>
</libraries>
</data-source>
</component>
</project>
\ No newline at end of file
......@@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/Pytition" vcs="Git" />
</component>
</project>
\ No newline at end of file
from pathlib import Path
import os
from app import conf
from pathlib import Path
from flask import Flask
from app.routes import main_bp
from app.utils import db, migrate
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from flask_admin.base import MenuLink
from flask import url_for
from flask_admin.contrib.sqla import ModelView
from app import conf
from app.routes import main_bp
from app.utils import db, migrate
def create_app():
......@@ -25,13 +26,15 @@ def create_app():
admin = Admin(app, name=app.config["APP_NAME"], template_mode='bootstrap3')
from app.models import TerritoryUnit, PositionType, Person, Recipient, RecipientAdmin, PersonAdmin, ContractType
admin.add_view(PersonAdmin(Person, db.session))
admin.add_view(ModelView(TerritoryUnit, db.session))
admin.add_view(ModelView(ContractType, db.session))
admin.add_view(ModelView(PositionType, db.session))
admin.add_view(RecipientAdmin(Recipient, db.session))
from app.models import TerritoryUnit, PositionType, Person, Recipient, RecipientAdmin, PersonAdmin, ContractType, \
TeamsList
admin.add_link(MenuLink(name='Site publique', category='', url='/'))
admin.add_view(PersonAdmin(Person, db.session, name='Personnes déclarées'))
admin.add_view(ModelView(TerritoryUnit, db.session, name='Délégations'))
admin.add_view(ModelView(ContractType, db.session, name='Contrats'))
admin.add_view(ModelView(PositionType, db.session, name='Postes'))
admin.add_view(ModelView(TeamsList, db.session, name='Listes teams'))
admin.add_view(RecipientAdmin(Recipient, db.session, name='Destinataires'))
with app.app_context():
db.create_all()
......
from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField
from wtforms.ext.sqlalchemy.fields import QuerySelectField
from wtforms.ext.sqlalchemy.fields import QuerySelectField, QuerySelectMultipleField
from wtforms.fields import DateField
from wtforms.fields.html5 import EmailField
from wtforms.validators import DataRequired, Email
from app.models import TerritoryUnit, PositionType, ContractType
from app.models import TerritoryUnit, PositionType, ContractType, TeamsList
common_input = {'class': 'form-control'}
datepicker = {'class': 'form-control datepicker'}
big_textarea_input= common_input.copy()
big_textarea_input['rows']=20
big_textarea_input = common_input.copy()
big_textarea_input['rows'] = 20
def get_territory_unit():
......@@ -20,22 +20,27 @@ def get_territory_unit():
def get_position_type():
return PositionType.query
def get_contract_type():
return ContractType.query
def get_teams_list():
return TeamsList.query
class PersonForm(FlaskForm):
email_declarator = EmailField("Votre email (pour envoi d'une confirmation)", validators=[DataRequired(), Email()],
render_kw=common_input)
render_kw=common_input)
name = StringField('Nom', validators=[DataRequired()], render_kw=common_input)
surname = StringField('Prénom', validators=[DataRequired()], render_kw=common_input)
email = EmailField('Email', validators=[DataRequired(), Email()], render_kw=common_input)
arrival_date = DateField('Date d\'arrivée', validators=[DataRequired()], render_kw=datepicker)
departure_date = DateField('Date de départ', render_kw=datepicker)
territory_unit = QuerySelectField('Délégation territoriale', validators=[DataRequired()],
query_factory=get_territory_unit, get_label='name',
get_pk=lambda a: a.name,
render_kw=common_input)
query_factory=get_territory_unit, get_label='name',
get_pk=lambda a: a.name,
render_kw=common_input)
email_referent = EmailField('Email responsable', validators=[DataRequired(), Email()], render_kw=common_input)
service = StringField('Service/Pôle', render_kw=common_input)
workplace_address = TextAreaField('Adresse du lieu de travail', validators=[DataRequired()],
......@@ -43,13 +48,17 @@ class PersonForm(FlaskForm):
workplace_city = StringField('Ville du lieu de travail', validators=[DataRequired()], render_kw=common_input)
phone_number = StringField('Numéro de téléphone', render_kw=common_input)
contract_type = QuerySelectField('Type de contrat', validators=[DataRequired()], query_factory=get_contract_type,
get_label='name',
get_pk=lambda a: a.name,
render_kw=common_input)
get_label='name',
get_pk=lambda a: a.name,
render_kw=common_input)
position_type = QuerySelectField('Type de poste', validators=[DataRequired()], query_factory=get_position_type,
get_label='name',
get_pk=lambda a: a.name,
render_kw=common_input)
get_label='name',
get_pk=lambda a: a.name,
render_kw=common_input)
teams_list = QuerySelectMultipleField('Listes Teams©', query_factory=get_teams_list,
get_label='name',
get_pk=lambda a: a.name,
render_kw=common_input)
comment = TextAreaField('Commentaire', render_kw=common_input)
......
......@@ -14,11 +14,17 @@ class PositionType(db.Model, SaveMixin):
id_position_type = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(256), nullable=False, unique=True)
class ContractType(db.Model, SaveMixin):
id_contract_type = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(256), nullable=False, unique=True)
class TeamsList(db.Model, SaveMixin):
id_contract_type = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(256), nullable=False, unique=True)
class Recipient(db.Model, SaveMixin):
id_email_received_model = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(256), nullable=False)
......@@ -55,6 +61,7 @@ class Person(db.Model, SaveMixin):
contract_type = db.Column(db.String(256), db.ForeignKey('contract_type.name'), nullable=False)
position_type = db.Column(db.String(256), db.ForeignKey('position_type.name'), nullable=False)
job_title = db.Column(db.String(256), nullable=True)
teams_list = db.Column(db.String(1000), nullable=True)
comment = db.Column(db.String(), nullable=True)
create_ts = db.Column(db.DateTime, nullable=False, default=datetime.now())
......
from datetime import datetime
from flask import Blueprint, render_template, request, redirect, url_for, flash
import config
from app.form import PersonForm, RecipientForm
from app.models import Person, Recipient
......@@ -32,9 +34,12 @@ def person_add():
person_data = {}
if data:
for d in data:
print(d, data[d])
print("key {}, type {}, data {}".format(d, type(data.getlist(d)), data.getlist(d)))
if hasattr(Person, d) and data[d] != '':
person_data[d] = data[d]
if len(data.getlist(d)) == 1:
person_data[d] = data[d]
else:
person_data[d] = '; '.join(data.getlist(d))
# Convert Date string to python datetime object
person_data['arrival_date'] = datetime.strptime(person_data['arrival_date'], '%Y-%m-%d').date()
......@@ -60,7 +65,6 @@ def person_add():
print('<new_person_dict 2>', new_person_dict)
for recipient in recipient_list:
sendmail(recipient.subject, recipient.body, recipient.email, new_person_dict)
sendmail("Déclaration d'une nouvelle arrivée",
......
Generic single-database configuration.
\ No newline at end of file