Commit c8124aed authored by fred.lpo07's avatar fred.lpo07

update

parent ea254a2b
......@@ -133,4 +133,8 @@ dmypy.json
config.py
# flask-migrate
migrations
\ No newline at end of file
migrations
# db
*.sqlite
*.db
\ No newline at end of file
......@@ -16,7 +16,7 @@ def create_app():
app.config.from_object(conf)
with Path(__file__).parent.parent as root_dir:
database_file = "sqlite:///{}".format(os.path.join(root_dir, app.config["DB_FILE_NAME"]))
database_file = "sqlite:///{}".format(os.path.join(root_dir, 'db.sqlite'))
print('<DB FILE : {}>'.format(database_file))
app.config["SQLALCHEMY_DATABASE_URI"] = database_file
db.init_app(app)
......@@ -24,7 +24,7 @@ def create_app():
app.register_blueprint(main_bp, url_prefix="/")
admin = Admin(app, name='AutoMailSender', template_mode='bootstrap3')
admin = Admin(app, name=app.config["APP_NAME"], template_mode='bootstrap3')
from app.models import TerritoryUnit, PositionType,Person, Recipient, RecipientAdmin, PersonAdmin
admin.add_view(PersonAdmin(Person, db.session))
......
......@@ -9,6 +9,8 @@ from app.models import TerritoryUnit, PositionType
common_input = {'class': 'form-control'}
datepicker = {'class': 'form-control datepicker'}
big_textarea_input= common_input
big_textarea_input['rows']=20
def get_territory_unit():
......@@ -27,19 +29,19 @@ class PersonForm(FlaskForm):
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_id = QuerySelectField('Délégation territoriale', validators=[DataRequired()],
territory_unit = QuerySelectField('Délégation territoriale', validators=[DataRequired()],
query_factory=get_territory_unit, get_label='name',
get_pk=lambda a: a.id_territory_unit,
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', render_kw=common_input)
workplace_address = TextAreaField('Addresse du lieu de travail', validators=[DataRequired()],
service = StringField('Service/Pôle', render_kw=common_input)
workplace_address = TextAreaField('Adresse du lieu de travail', validators=[DataRequired()],
render_kw=common_input)
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)
position_type_id = QuerySelectField('Type de poste', validators=[DataRequired()], query_factory=get_position_type,
position_type = QuerySelectField('Type de poste', validators=[DataRequired()], query_factory=get_position_type,
get_label='name',
get_pk=lambda a: a.id_position_type,
get_pk=lambda a: a.name,
render_kw=common_input)
comment = TextAreaField('Commentaire', render_kw=common_input)
......@@ -47,4 +49,4 @@ class PersonForm(FlaskForm):
class RecipientForm(FlaskForm):
email = EmailField('Email du destinataire', validators=[DataRequired(), Email()], render_kw=common_input)
subject = StringField('Subject', validators=[DataRequired()], render_kw=common_input)
body = TextAreaField('Corps de texte', validators=[DataRequired()], render_kw=common_input)
body = TextAreaField('Corps de texte', validators=[DataRequired()], render_kw=big_textarea_input)
......@@ -42,13 +42,13 @@ class Person(db.Model, SaveMixin):
email = db.Column(db.String(256), nullable=False)
arrival_date = db.Column(db.Date, nullable=False)
departure_date = db.Column(db.Date, nullable=True)
territory_unit_id = db.Column(db.Integer(), db.ForeignKey('territory_unit.id_territory_unit'), nullable=False)
territory_unit = db.Column(db.String(256), db.ForeignKey('territory_unit.name'), nullable=False)
email_referent = db.Column(db.String(256), nullable=False)
service = db.Column(db.String(256), nullable=True)
workplace_address = db.Column(db.String(1000), nullable=True)
workplace_city = db.Column(db.String(256), nullable=True)
phone_number = db.Column(db.String(256), nullable=False)
position_type_id = db.Column(db.Integer(), db.ForeignKey('position_type.id_position_type'), 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)
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
from app.utils import sendmail
main_bp = Blueprint('main', __name__, template_folder='templates')
@main_bp.context_processor
def global_variables():
values = {}
values["app_name"] = config.APP_NAME
return values
@main_bp.route("/", methods=["GET", "POST"])
def home():
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -6,7 +6,7 @@
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v3.8.6">
<title>{% block title %}Ajout d'un nouvel arrivant{% endblock %}</title>
<title>{{ app_name }} | {% block title %}Ajout d'un nouvel arrivant{% endblock %}</title>
<link rel="canonical" href="https://getbootstrap.com/docs/4.4/examples/cover/">
......@@ -60,7 +60,7 @@
<header>
<!-- Fixed navbar -->
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand text-monospace" href="{{ url_for('main.home') }}">autoMail@rh</a>
<a class="navbar-brand text-monospace" href="{{ url_for('main.home') }}">{{ app_name }}</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse"
aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
......
{%extends "main.html"%}
{%block content %}
{% block header %}
<h1><i class="fa fa-users"></i> {% block title %}Nouvelles arrivées saisies{% endblock %}</h1>
<div class="row">
<div class="col-xs-12 col-md-6">
<h1><i class="fa fa-users"></i> {% block title %}Nouvelles arrivées saisies{% endblock %}</h1>
</div>
<div class="col-xs-12 col-md-6">
<div class="text-right">
<a class="btn btn-success" href="{{ url_for('main.person_add') }}"><i class="fas fa-user-plus"></i>
Déclarer une nouvelle arrivée</a>
</div>
</div>
</div>
{%endblock%}
<table id="persons" class="table table-condensed table-responsive">
<thead>
<thead>
<tr>
{% for key in persons[0].keys() %}
<th scope="col">{{ key }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
<tbody>
{% for person in persons %}
<tr>
{% for value in person.values() %}
......@@ -19,7 +29,7 @@
{% endfor %}
</tr>
{% endfor %}
</tbody>
</tbody>
</table>
<script type="text/javascript">
......
......@@ -12,52 +12,52 @@
<div class="alert alert-info">
<h3><i class="fas fa-info-circle"></i> Note</h3>
<p>Les contenus des mails sont automatiquement générés à partir des modèles que vous créerez ici. Pour ce
faire, il faut les indiquer dans le Sujet
<pre>subject</pre>
et/ou dans le corps du texte
<pre>body</pre>
. Ces variables doivent obligatoirement être entourées d'accolades. A titre d'exemple, le corps de texte
suivant
<pre>Le salarié {name} {surname}...</pre>
, ou
<pre>name</pre>
est <i>MANCEL</i> et
<pre>surname</pre>
est <i>Benoit</i> donnera ainsi un mail contenant le message suivant
<pre>Le salarié MANCEL Benoit...</pre>
faire, il faut les indiquer dans le Sujet <code>subject</code> et/ou dans le corps du texte
<code>body</code>. Ces variables doivent obligatoirement être entourées d'accolades. A titre d'exemple,
le corps de texte suivant <code>Le salarié {name} {surname}...</code> , ou <code>name</code> est <i>MANCEL</i>
et <code>surname</code> est <i>Benoit</i> donnera ainsi un mail contenant le message suivant <code>Le
salarié MANCEL Benoit...</code>
<ul>
<li>
<pre>name</pre>
: Nom
Email du déclarant: <code>{email_declarator}</code>
</li>
<li>
<pre>surname</pre>
: Prénom
Nom: <code>{name}</code>
</li>
<li>
<pre>surname</pre>
: Prénom
Email: <code>{email}</code>
</li>
<li>
Date d'arrivée: <code>{arrival_date}</code>
</li>
<li>
Date de départ: <code>{departure_date}</code>
</li>
<li>
Délégation territoriale: <code>{territory_unit_id}</code>
</li>
<li>
Email responsable: <code>{email_referent}</code>
</li>
<li>
Service/Pôle: <code>{service}</code>
</li>
<li>
Adresse du lieu de travail: <code>{workplace_address}</code>
</li>
<li>
Ville du lieu de travail: <code>{workplace_city}</code>
</li>
<li>
Numéro de téléphone: <code>{phone_number}</code>
</li>
<li>
Type de poste: <code>{position_type}</code>
</li>
<li>
Commentaire: <code>{comment}</code>
</li>
</ul>
<!-- surname = StringField('Prénom', validators=[DataRequired()], render_kw=common_input)-->
<!-- email = StringField('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_id = QuerySelectField('Délégation territoriale', query_factory=get_territory_unit,-->
<!-- get_label='name',-->
<!-- get_pk=lambda a: a.id_territory_unit,-->
<!-- render_kw=common_input)-->
<!-- email_referent = StringField('Email responsable', validators=[DataRequired(), Email()],-->
<!-- render_kw=common_input)-->
<!-- service = StringField('Service', render_kw=common_input)-->
<!-- workplace_address = TextAreaField('Addresse du lieu de travail', render_kw=common_input)-->
<!-- workplace_city = StringField('Ville du lieu de travail', render_kw=common_input)-->
<!-- phone_number = StringField('Numéro de téléphone', render_kw=common_input)-->
<!-- position_type_id = QuerySelectField('Type de poste', query_factory=get_position_type, get_label='name',-->
<!-- get_pk=lambda a: a.id_position_type,-->
<!-- render_kw=common_input)-->
<!-- comment = TextAreaField('Commentaire', render_kw=common_input)-->
</div>
</div>
<div class="col-md-8">
......
......@@ -2,7 +2,17 @@
{%block content %}
{% block header %}
<div class="row">
<h1><i class="fas fa-mail-bulk"></i>{% block title %}Destinataires{% endblock %}</h1>
<div class="col-xs-12 col-md-6">
<h1><i class="fas fa-mail-bulk"></i>{% block title %}Destinataires{% endblock %}</h1>
</div>
<div class="col-xs-12 col-md-6">
<div class="text-right">
<a class="btn btn-success" href="{{ url_for('main.recipient_add') }}"><i class="fas fa-mail-bulk"></i>
Ajouter un
nouveau destinataire</a>
</div>
</div>
{%endblock%}
</div>
<div class="row">
......@@ -35,9 +45,7 @@
{% else %}
<div class="alert alert-warning">Aucun destinataire</div>
{% endif %}
<a class="btn btn-lg btn-block btn-success" href="{{ url_for('main.recipient_add') }}"><i class="fas fa-mail-bulk"></i>
Ajouter un
nouveau destinataire</a>
</div>
</div>
{%endblock%}
\ No newline at end of file
SECRET_KEY='secretKey'
DB_FILE_NAME='dbFileName'
APP_NAME='myAppName'
# SMTP Params
SMTP_HOST='smtpHost'
......
#!/bin/sh
export DB_FILE_NAME=${DB_FILE_NAME:-db.sqlite}
export SECRET_KEY=${SECRET_KEY:-$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c50)}
export SMTP_PORT=${SMTP_PORT:-587}
......@@ -11,7 +10,6 @@ export SMTP_STARTTLS=${SMTP_STARTTLS:-True}
if [ ! -f /data/config.py ]; then
echo "generate new config file"
cp /app/config.py.sample /data/config.py
sed -i "s/dbFileName/${DB_FILE_NAME}/g" /data/config.py
sed -i "s/secretKey/${SECRET_KEY}/g" /data/config.py
sed -i "s/smtpHost/${SMTP_HOST}/g" /data/config.py
sed -i "s/smtpPort/${SMTP_PORT}/g" /data/config.py
......@@ -32,8 +30,8 @@ flask db init
flask db migrate
flask db upgrade
mv /app/${DB_FILE_NAME} /data/${DB_FILE_NAME}
ln -s /data/${DB_FILE_NAME} /app/${DB_FILE_NAME}
mv /app/db.sqlite /data/db.sqlite
ln -s /data/db.sqlite /app/db.sqlite
python -m server
......
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 to comment