Skip to content

Commit

Permalink
fix preavis path when no affaire_path is set
Browse files Browse the repository at this point in the history
  • Loading branch information
rufener committed Jul 16, 2021
1 parent 1634429 commit 2e88382
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
4 changes: 1 addition & 3 deletions back/infolica/scripts/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*--
from datetime import date, datetime
from sqlalchemy import func, and_, desc
from infolica.models.models import Numero, AffaireNumero, Fonction, Role, FonctionRole, ReservationNumerosMO
from infolica.models.models import SuiviMandat, ControleGeometre, ControleMutation, ControlePPE
from infolica.models.models import AffaireEtape, Cadastre, Operateur
from infolica.models.models import Numero, AffaireNumero, Fonction, Role, FonctionRole, ReservationNumerosMO, Cadastre, Operateur
from infolica.scripts.ldap_query import LDAPQuery
from infolica.scripts.mailer import send_mail

Expand Down
23 changes: 14 additions & 9 deletions back/infolica/views/document.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# -*- coding: utf-8 -*--
from pyramid.view import view_config
import pyramid.httpexceptions as exc

from infolica.exceptions.custom_error import CustomError
from infolica.models.constant import Constant
from infolica.models.models import Service
from infolica.models.models import Affaire, Service
from infolica.scripts.utils import Utils

import os
import json
from datetime import datetime
from docxtpl import DocxTemplate, RichText


Expand Down Expand Up @@ -37,12 +33,21 @@ def save_document_view(request):
output_file_name += "_" + service.abreviation
relPath = service.relpath.strip('/').strip('\\')

affaire_relpath = request.dbsession.query(Affaire).filter(Affaire.id == affaire_id).first().chemin

if affaire_relpath is None:
affaire_relpath = affaire_id

affaire_path = os.path.normcase(os.path.join(affaires_directory, affaire_relpath))

filename = output_file_name + '.docx'
file_path = os.path.normcase(os.path.join(affaires_directory, affaire_id, relPath, filename))
folder_path = os.path.dirname(file_path)
file_path = os.path.normcase(os.path.join(affaire_path, relPath, filename))

if not os.path.exists(folder_path):
Utils.create_affaire_folder(request, folder_path)
if not os.path.exists(affaire_path):
Utils.create_affaire_folder(request, affaire_path)
# update affaire chemin
affaire = request.dbsession.query(Affaire).filter(Affaire.id == affaire_id).first()
affaire.chemin = affaire_relpath

# Set context
context = json.loads(values)
Expand Down
5 changes: 4 additions & 1 deletion front/src/components/Affaires/Documents/Documents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ export default {
this.searchAffaireDocuments();
this.searchAffaireDossier();
this.$root.$on("searchAffaireDocuments", () => this.searchAffaireDocuments())
this.$root.$on("searchAffaireDocuments", () => {
this.searchAffaireDossier()
this.searchAffaireDocuments()
})
// show edit affaire path
if(checkPermission(process.env.VUE_APP_FONCTION_ADMIN)) {
Expand Down

0 comments on commit 2e88382

Please sign in to comment.