Skip to content

Commit

Permalink
Merge pull request #758 from rufener/bugfix
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
rufener authored Mar 27, 2024
2 parents 73a3826 + 125dcca commit db6e5f5
Show file tree
Hide file tree
Showing 21 changed files with 359 additions and 165 deletions.
28 changes: 28 additions & 0 deletions back/infolica/alembic/versions/20240321_7f61c1192ef6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""add start and end date to services
Revision ID: 7f61c1192ef6
Revises: 1317c98cd991
Create Date: 2024-03-21 11:54:07.109451
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '7f61c1192ef6'
down_revision = '1317c98cd991'
branch_labels = None
depends_on = None

def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('service', sa.Column('date_entree', sa.Date(), nullable=True))
op.add_column('service', sa.Column('date_sortie', sa.Date(), nullable=True))
# ### end Alembic commands ###

def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('service', 'date_sortie')
op.drop_column('service', 'date_entree')
# ### end Alembic commands ###
10 changes: 6 additions & 4 deletions back/infolica/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class Service(Base):
mail = Column(Text)
ordre = Column(BigInteger)
relpath = Column(Text)
date_entree = Column(Date)
date_sortie = Column(Date)

class Operateur(Base):
__tablename__ = 'operateur'
Expand Down Expand Up @@ -840,8 +842,8 @@ class NumeroType(Base):
id = Column(BigInteger, primary_key=True, autoincrement=True)
nom = Column(Text, nullable=False)
ordre = Column(BigInteger)


class NumeroEtat(Base):
__tablename__ = 'numero_etat'
__table_args__ = {'schema': 'infolica'}
Expand Down Expand Up @@ -1066,7 +1068,7 @@ class ControleEtapeTypeAffaire(Base):


# ======================== VUES ========================
# Ajouter l'information 'info': dict(is_view=True) aux vues
# Ajouter l'information 'info': dict(is_view=True) aux vues
# pour qu'elles ne soient pas prises en compte dans les migrations par Alembic


Expand Down Expand Up @@ -1290,7 +1292,7 @@ class VAffairesPreavis(Base):
operateur_service_id = Column(BigInteger)
operateur_service_prenom = Column(Text)
operateur_service_nom = Column(Text)


class VTableauBord(Base):
__tablename__ = 'v_tableau_de_bord'
Expand Down
1 change: 1 addition & 0 deletions back/infolica/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def includeme(config):
config.add_route('client_moral_personnes_s', '/infolica/api/client_moral_personnes/')
config.add_route('search_clients_aggregated_by_term', '/infolica/api/search_clients_aggregated_by_term')
config.add_route('search_client_aggregated_by_id', '/infolica/api/search_client_aggregated/{id}')
config.add_route('client_check_existing', '/infolica/api/client_check_existing')
#Affaires
config.add_route('affaires', '/infolica/api/affaires')
config.add_route('affaires_s', '/infolica/api/affaires/')
Expand Down
6 changes: 3 additions & 3 deletions back/infolica/scripts/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def check_connected(request, services=None):

if user is None:
return False

operateur = request.dbsession.query(Operateur).filter(
func.lower(Operateur.login) == user
).first()
Expand All @@ -40,7 +40,7 @@ def check_connected(request, services=None):


def get_user_functions(request):

results = {}

operateur = request.dbsession.query(Operateur).filter(
Expand All @@ -52,5 +52,5 @@ def get_user_functions(request):
results['role_id'] = operateur.role.id
results['role_name'] = operateur.role.nom
results['fonctions'] = [x.nom for x in fonctions]

return results
41 changes: 21 additions & 20 deletions back/infolica/scripts/mail_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def sendMailAffaireEtape(cls, request, model, chef_equipe_id, operateur_id):
VEtapesAffaires.etape_priorite == int(request.registry.settings['affaire_etape_priorite_1_id'])
)
).order_by(VEtapesAffaires.next_datetime.desc()).all()

# set affaire_nom
affaire_nom = " (" + affaire.no_access + ")" if affaire.no_access is not None else ""

Expand All @@ -46,21 +46,21 @@ def sendMailAffaireEtape(cls, request, model, chef_equipe_id, operateur_id):
mail = next((op.mail for op in operateur if op.id == em_i.operateur_id), None)
if mail:
mail_list.append(mail)

# Send mail only if step prio is 1 and if mail_list not empty
if affaire_etape_index.priorite == int(request.registry.settings['affaire_etape_priorite_1_id']) and len(mail_list)>0:
lastSteps_html = "".join(["<tr><td style='border: 1px solid black; border-collapse: collapse; padding: 5px 25px 5px 10px;'>{}</td>\
<td style='border: 1px solid black; border-collapse: collapse; padding: 5px 25px 5px 10px;'>{} {}</td>\
<td style='border: 1px solid black; border-collapse: collapse; padding: 5px 25px 5px 10px;'>{}</td>\
<td style='border: 1px solid black; border-collapse: collapse; padding: 5px 25px 5px 10px;'>{}</td>\
</tr>".format(
i.etape,
i.next_operateur_prenom if i.next_operateur_prenom else "",
i.next_operateur_nom if i.next_operateur_nom else "",
i.next_datetime.strftime("%d.%m.%Y - %H:%M") if i.next_datetime else "",
i.etape,
i.next_operateur_prenom if i.next_operateur_prenom else "",
i.next_operateur_nom if i.next_operateur_nom else "",
i.next_datetime.strftime("%d.%m.%Y - %H:%M") if i.next_datetime else "",
i.next_remarque if i.next_remarque else ""
) for i in lastSteps])

text = "L'affaire <b><a href='" + os.path.join(request.registry.settings['infolica_url_base'], 'affaires/edit', str(v_affaire.id)) + "'>" + str(v_affaire.id) + affaire_nom + "</a></b>" + (" (avec mention urgente)" if v_affaire.urgent else "") + " est en attente pour l'étape <b>"+ affaire_etape_index.nom +"</b>."
text += "<br><br>Cadastre: " + str(v_affaire.cadastre)
text += "<br>Description: " + str(v_affaire.nom)
Expand All @@ -74,7 +74,7 @@ def sendMailAffaireEtape(cls, request, model, chef_equipe_id, operateur_id):
</tr>" + lastSteps_html + "</table>") if lastSteps_html != "" else ""
subject = "Infolica - affaire " + str(v_affaire.id) + (" - URGENT" if v_affaire.urgent else "")
send_mail(request, mail_list, "", subject, html=text)

return (lastSteps, affaire_etape_index)


Expand Down Expand Up @@ -130,7 +130,8 @@ def sendMailClientHorsCanton(cls, request, client_id, affaire_id):
return

#Contrôle que le client habite hors canton et que son numéros SAP est null
if cl.no_sap is None and int(cl.npa) not in request.registry.settings['npa_NE']:
cl_npa = int(cl.npa) if cl.npa is not None else -1
if cl.no_sap is None and cl_npa not in request.registry.settings['npa_NE']:
operateur_secretariat = request.registry.settings["operateur_secretariat"].split(",")
mail_list = request.dbsession.query(Operateur.mail).filter(Operateur.id.in_(operateur_secretariat)).all()
mail_list = [mail[0] for mail in mail_list]
Expand All @@ -139,13 +140,13 @@ def sendMailClientHorsCanton(cls, request, client_id, affaire_id):
html += "<p>Un client hors canton et sans numéro SAP a été référencé dans la facturation de l'affaire <b><a href='" + os.path.join(request.registry.settings['infolica_url_base'], 'affaires/edit', str(affaire_id)) + "'>" + str(affaire_id) + affaire_nom + "</a></b>.</p>"
html += "<ul><li>" + ", ".join([
cl.entreprise if cl.entreprise is not None else " ".join([
cl.titre if cl.titre is not None else "",
cl.prenom if cl.prenom is not None else "",
cl.titre if cl.titre is not None else "",
cl.prenom if cl.prenom is not None else "",
cl.nom if cl.nom is not None else ""
]),
cl.adresse if cl.adresse is not None else "",
]),
cl.adresse if cl.adresse is not None else "",
" ".join([
cl.npa if cl.npa is not None else "",
cl.npa if cl.npa is not None else "",
cl.localite if cl.localite is not None else ""
])
]) + " &#8594; <a href='" + os.path.join(request.registry.settings['infolica_url_base'], 'clients/edit', str(cl.id)) + "'>Lien sur la fiche du client</a>"+ "</li></ul>"
Expand All @@ -168,17 +169,17 @@ def sendMailClientHorsCanton(cls, request, client_id, affaire_id):
def sendMailPreavisReponse(cls, request, preavis_id):
preavis = request.dbsession.query(VAffairesPreavis).filter(VAffairesPreavis.id == preavis_id).first()
affaire = request.dbsession.query(Affaire).filter(Affaire.id == preavis.affaire_id).first()

affaire_nom = " (" + affaire.no_access + ")" if affaire.no_access is not None else ""

operateur_coordinateur_projets = request.registry.settings["operateur_coordinateur_projets"].split(",")
mail_list = request.dbsession.query(Operateur.mail).filter(Operateur.id.in_(operateur_coordinateur_projets)).all()
mail_list = [mail[0] for mail in mail_list]

html = "<h3>Un nouveau préavis a été saisi</h3>"
html += "<p>Le préavis du " + preavis.service + " a été saisi pour l'affaire <b><a href='" + os.path.join(request.registry.settings['infolica_url_base'], 'affaires/edit', str(preavis.affaire_id)) + "'>" + str(preavis.affaire_id) + affaire_nom + "</a></b>.<br/>"
html += "Il peut être consulté dans l'onglet Préavis de l'affaire, en cliquant sur le préavis en question dans le tableau.</p>"

send_mail(request, mail_list, "", "Infolica - Préavis saisi", html=html)
return

Expand All @@ -194,12 +195,12 @@ def sendMailPreavisDemande(cls, request, preavis_id, service_id, message=None):
em = etape_mailer.filter(EtapeMailer.operateur_id == op.id).first()
if em is not None and em.sendmail is True:
mail_list.append(op.mail)

if len(mail_list) > 0:
preavis = request.dbsession.query(VAffairesPreavis).filter(VAffairesPreavis.id == preavis_id).first()
affaire = request.dbsession.query(Affaire).filter(Affaire.id == preavis.affaire_id).first()
cadastre = request.dbsession.query(Cadastre).filter(Cadastre.id == affaire.cadastre_id).first().nom

affaire_nom = " (" + affaire.no_access + ")" if affaire.no_access is not None else ""
link = str(os.path.join(request.registry.settings['infolica_url_base'], 'preavis/edit', str(preavis_id))).replace('\\', '/')

Expand All @@ -224,7 +225,7 @@ def sendMailPreavisDemande(cls, request, preavis_id, service_id, message=None):
html += "<li>Remarque: " + message + "</li>"
html += "</ul>"
html += "</p>"

send_mail(request, mail_list, "", "Infolica - Demande de préavis" + subject_suffix, html=html, signature="Le service de la géomatique et du registre foncier")
return

Loading

0 comments on commit db6e5f5

Please sign in to comment.