diff --git a/back/infolica/models/models.py b/back/infolica/models/models.py index 2827718e..1d89b737 100644 --- a/back/infolica/models/models.py +++ b/back/infolica/models/models.py @@ -629,6 +629,8 @@ class NumeroRelation(Base): NumeroRelationType.id), nullable=False) affaire_id = Column(BigInteger, ForeignKey(Affaire.id)) + UniqueConstraint(numero_id_base, numero_id_associe, relation_type_id, affaire_id) + class AffaireNumeroType(Base): __tablename__ = 'affaire_numero_type' diff --git a/back/infolica/scripts/utils.py b/back/infolica/scripts/utils.py index 4278b604..713164a1 100644 --- a/back/infolica/scripts/utils.py +++ b/back/infolica/scripts/utils.py @@ -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 diff --git a/back/infolica/views/document.py b/back/infolica/views/document.py index ae3c938f..f4c41951 100644 --- a/back/infolica/views/document.py +++ b/back/infolica/views/document.py @@ -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 @@ -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) diff --git a/front/.env b/front/.env index 1a635727..36cbc0d5 100644 --- a/front/.env +++ b/front/.env @@ -188,9 +188,9 @@ VUE_APP_SITN_SEARCH_CATEGORIES_ALIASES = {__CATEGORY__ : __ALIAS__} #SITN couches environnement et aménagement du territoire -VUE_APP_SITN_ENVIRONNEMENT_URL = "__url/to/environment_layer__" VUE_APP_SITN_AMENAGEMENT_TERRITOIRE_URL = "__url/to/amenagement_territoire_layer__" VUE_APP_SITN_CADASTRE_URL = "__url/to/cadastre_layer__" +VUE_APP_SITN_SITES_POLLUES_URL = "__url/to/sites_pollues_layer__" #====================================== diff --git a/front/src/components/Affaires/AffairesDashboard.vue b/front/src/components/Affaires/AffairesDashboard.vue index 84e39a88..e022fe3e 100644 --- a/front/src/components/Affaires/AffairesDashboard.vue +++ b/front/src/components/Affaires/AffairesDashboard.vue @@ -426,13 +426,13 @@ export default { * Open Theme SITN */ openSitnTheme(theme) { - var route; - if (theme === "environnement") { - route = process.env.VUE_APP_SITN_ENVIRONNEMENT_URL; - } else if (theme === "amenagement_territoire") { + let route; + if (theme === "amenagement_territoire") { route = process.env.VUE_APP_SITN_AMENAGEMENT_TERRITOIRE_URL; } else if (theme === "cadastre") { route = process.env.VUE_APP_SITN_CADASTRE_URL; + } else if (theme === "sites_pollues") { + route = process.env.VUE_APP_SITN_SITES_POLLUES_URL; } else { return null; } diff --git a/front/src/components/Affaires/Documents/Documents.vue b/front/src/components/Affaires/Documents/Documents.vue index c2c32bc3..58c8d6d0 100644 --- a/front/src/components/Affaires/Documents/Documents.vue +++ b/front/src/components/Affaires/Documents/Documents.vue @@ -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)) { diff --git a/front/src/components/Affaires/affairesDashboard.html b/front/src/components/Affaires/affairesDashboard.html index 7810d009..0d1efbf6 100644 --- a/front/src/components/Affaires/affairesDashboard.html +++ b/front/src/components/Affaires/affairesDashboard.html @@ -56,7 +56,7 @@

Cadastre - Sites Pollués + Sites Pollués Aménagement du territoire
diff --git a/front/src/components/Numeros/NumerosHistory.vue b/front/src/components/Numeros/NumerosHistory.vue index 9a6c9f60..c9856c74 100644 --- a/front/src/components/Numeros/NumerosHistory.vue +++ b/front/src/components/Numeros/NumerosHistory.vue @@ -12,14 +12,17 @@ export default { props: {}, data: () => ({ cadastre_liste: [], + editionActivated: false, + editNumeroAllowed: false, + etatsNumeros: [], numero: [], - numero_edit: [], numero_affaires: [], - numero_provenance: [], + numero_associe: [], + numero_base: [], numero_destination: [], - editNumeroAllowed: false, - editionActivated: false, - etatsNumeros: [], + numero_edit: [], + numero_provenance: [], + numeroRelationTypeId_mutation: Number(process.env.VUE_APP_RELATION_TYPE_MUTATION_ID) }), methods: { @@ -27,7 +30,7 @@ export default { * Initialize permissions to edit numero */ initPermissions() { - this.editNumeroAllowed = checkPermission(process.env.VUE_APP_AFFAIRE_NUMERO_EDITION) + this.editNumeroAllowed = checkPermission(process.env.VUE_APP_AFFAIRE_NUMERO_EDITION); }, /* @@ -54,9 +57,7 @@ export default { this.numero.suffixe = "-" } } - }).catch(err => { - handleException(err, this); - }); + }).catch(err => handleException(err, this)); }, @@ -71,9 +72,7 @@ export default { return obj.nom; }); } - }).catch(err => { - handleException(err, this); - }); + }).catch(err => handleException(err, this)); }, @@ -94,9 +93,7 @@ export default { if (response && response.data) { this.numero_affaires = response.data; } - }).catch(err => { - handleException(err, this); - }) + }).catch(err => handleException(err, this)); }, @@ -114,14 +111,30 @@ export default { headers: {"Accept": "application/json"} } ).then(response => { + this.numero_provenance = []; + this.numero_base = []; if (response.data) { - this.numero_provenance = response.data.map(x => x.numero_base + x.numero_base_suffixe); + let tmp = response.data; + tmp.forEach(x => { + if (x.numero_relation_type_id === this.numeroRelationTypeId_mutation) { + this.numero_provenance.push(x.numero_base); + } else { + this.numero_base.push(x.numero_base + (x.numero_base_suffixe? "/" + x.numero_base_suffixe: "")); + } + }); + } + + if (this.numero_provenance.length === 0) { + this.numero_provenance = "-"; + } else { + this.numero_provenance = this.numero_provenance.join(", "); + } + if (this.numero_base.length === 0) { + this.numero_base = "-"; } else { - this.numero_provenance = "-" + this.numero_base = this.numero_base.join(", "); } - }).catch(err => { - handleException(err, this); - }); + }).catch(err => handleException(err, this)); }, @@ -139,14 +152,30 @@ export default { headers: {"Accept": "application/json"} } ).then(response => { + this.numero_destination = []; + this.numero_associe = []; if (response.data) { - this.numero_destination = response.data.map(x => x.numero_associe + x.numero_associe_suffixe); + let tmp = response.data; + tmp.forEach(x => { + if (x.numero_relation_type_id === this.numeroRelationTypeId_mutation) { + this.numero_destination.push(x.numero_associe); + } else { + this.numero_associe.push(x.numero_associe + (x.numero_associe_suffixe? "/" + x.numero_associe_suffixe: "")); + } + }); + } + + if (this.numero_destination.length === 0) { + this.numero_destination = "-"; + } else { + this.numero_destination = this.numero_destination.join(", "); + } + if (this.numero_associe.length === 0) { + this.numero_associe = "-"; } else { - this.numero_destination = "-" + this.numero_associe = this.numero_associe.join(", "); } - }).catch(err => { - handleException(err, this); - }); + }).catch(err => handleException(err, this)); }, /* diff --git a/front/src/components/Numeros/numerosHistory.html b/front/src/components/Numeros/numerosHistory.html index 72c5f00e..91ef2123 100644 --- a/front/src/components/Numeros/numerosHistory.html +++ b/front/src/components/Numeros/numerosHistory.html @@ -163,6 +163,22 @@

Consultation d'immeuble

+ +
+
+ + + + +
+
+ + + + +
+
+ diff --git a/front/src/services/exceptionsHandler.js b/front/src/services/exceptionsHandler.js index c3794a05..9c522939 100644 --- a/front/src/services/exceptionsHandler.js +++ b/front/src/services/exceptionsHandler.js @@ -23,12 +23,16 @@ export const handleException = function (error, component) { //Back-end errors: show entire message else if (error && error.response && error.response.data && error.response.data.message) { - component.$root.$emit("ShowError", error.response.data.message); + component.$root.$emit("ShowError", "Une erreur est survenue, contacter l'administrateur. " + error.response.data.message); + } + //Custom error + else if(error){ + component.$root.$emit("ShowError", error); } //All other error codes else { - component.$root.$emit("ShowError", "Une erreur est survenue"); + component.$root.$emit("ShowError", "Une erreur est survenue, contacter l'administrateur."); } };