Skip to content

Commit

Permalink
Merge pull request #544 from rufener/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
rufener authored Jul 16, 2021
2 parents d495861 + 2e88382 commit bef6d07
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 46 deletions.
2 changes: 2 additions & 0 deletions back/infolica/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
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
2 changes: 1 addition & 1 deletion front/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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__"


#======================================
Expand Down
8 changes: 4 additions & 4 deletions front/src/components/Affaires/AffairesDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
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
2 changes: 1 addition & 1 deletion front/src/components/Affaires/affairesDashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h1 style="margin-bottom: 0px;">
</div>
<div style="text-align: right;" class="md-layout-item">
<md-button style="background-color: lightgray;" class="md-raised" @click="openSitnTheme('cadastre')">Cadastre</md-button>
<md-button style="background-color: lightgray;" class="md-raised" @click="openSitnTheme('environnement')">Sites Pollués</md-button>
<md-button style="background-color: lightgray;" class="md-raised" @click="openSitnTheme('sites_pollues')">Sites Pollués</md-button>
<md-button style="background-color: lightgray;" class="md-raised" @click="openSitnTheme('amenagement_territoire')">Aménagement du territoire</md-button>
</div>
<div class="md-layout-item md-size-100" v-if="showMovePointComment">
Expand Down
79 changes: 54 additions & 25 deletions front/src/components/Numeros/NumerosHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ 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: {
/**
* 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);
},
/*
Expand All @@ -54,9 +57,7 @@ export default {
this.numero.suffixe = "-"
}
}
}).catch(err => {
handleException(err, this);
});
}).catch(err => handleException(err, this));
},
Expand All @@ -71,9 +72,7 @@ export default {
return obj.nom;
});
}
}).catch(err => {
handleException(err, this);
});
}).catch(err => handleException(err, this));
},
Expand All @@ -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));
},
Expand All @@ -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));
},
Expand All @@ -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));
},
/*
Expand Down
16 changes: 16 additions & 0 deletions front/src/components/Numeros/numerosHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ <h1 style="flex: 1;">Consultation d'immeuble</h1>
</div>
</div>

<!-- Immeuble de base et associé -->
<div class="md-layout md-gutter">
<div class="md-layout-item md-small-size-30">
<md-field>
<label>Immeuble de base</label>
<md-textarea v-model="numero_base" md-autogrow readonly></md-textarea>
</md-field>
</div>
<div class="md-layout-item md-small-size-30">
<md-field>
<label>Immeuble(s) associé(s)</label>
<md-textarea v-model="numero_associe" md-autogrow readonly></md-textarea>
</md-field>
</div>
</div>

</md-card-content>

</md-card>
Expand Down
8 changes: 6 additions & 2 deletions front/src/services/exceptionsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
};

0 comments on commit bef6d07

Please sign in to comment.