Skip to content

Commit

Permalink
Merge pull request #643 from rufener/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
rufener authored Feb 9, 2022
2 parents a74bd12 + ee2de57 commit 7765d8b
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 57 deletions.
1 change: 1 addition & 0 deletions back/infolica/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,7 @@ class VEtapesAffaires(Base):
next_operateur_initiales = Column(Text)
next_remarque = Column(Text)
next_datetime = Column(DateTime)
next_etape_id = Column(DateTime)


class VAffairesPreavis(Base):
Expand Down
5 changes: 2 additions & 3 deletions back/infolica/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def includeme(config):
config.add_route('modification_affaire_by_affaire_fille', '/infolica/api/modification_affaire_by_affaire_fille/{id}')
config.add_route('affaires_cockpit', '/infolica/api/affaires_cockpit')
config.add_route('abandon_affaire_reopen_parent_affaire', '/infolica/api/abandon_affaire_reopen_parent_affaire')
config.add_route('affaire_attribution_change_state', '/infolica/api/affaire_attribution_change_state')
#Factures
config.add_route('factures', '/infolica/api/factures')
config.add_route('factures_s', '/infolica/api/factures/')
Expand Down Expand Up @@ -121,7 +122,7 @@ def includeme(config):
config.add_route('affaire_preavis_by_affaire_id','/infolica/api/affaire_preavis/{id}')
#Documents affaire
config.add_route('affaire_dossier_by_affaire_id', '/infolica/api/affaire_dossier/{id}')
config.add_route('affaire_documents_by_affaire_id','/infolica/api/affaire_documents/{id}')
config.add_route('affaire_documents_by_affaire_id','/infolica/api/affaire_documents')
config.add_route('types_documents', '/infolica/api/types_documents')
config.add_route('types_documents_s', '/infolica/api/types_documents/')
config.add_route('upload_affaire_document', '/infolica/api/upload_affaire_document')
Expand Down Expand Up @@ -178,8 +179,6 @@ def includeme(config):
#Numéro MO next available
config.add_route('numero_mo_next', '/infolica/api/numero_mo_next')
config.add_route('types_numeros_mo', '/infolica/api/types_numeros_mo')
#Open Folder
config.add_route('open_folder', '/infolica/api/open_folder')
#Notes de mise à jour
config.add_route('notes_maj', '/infolica/api/notes_maj')
config.add_route('version', '/infolica/api/version')
Expand Down
24 changes: 24 additions & 0 deletions back/infolica/views/affaire.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,30 @@ def affaire_spatial(request):
return affaires


@view_config(route_name="affaire_attribution_change_state", request_method="PUT", renderer='json')
def affaire_attribution_change_state_update_view(request):
"""
Update attribution of affaire
"""
# Check connected
if not check_connected(request):
raise exc.HTTPForbidden()

affaire_id = request.params['affaire_id'] if "affaire_id" in request.params else None
attribution = request.params['attribution'] if ("attribution" in request.params and request.params['attribution'] != "null") else None

if affaire_id is None:
raise CustomError(CustomError.INCOMPLETE_REQUEST)

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

affaire.attribution = attribution

return Utils.get_data_save_response(Constant.SUCCESS_SAVE.format(Affaire.__tablename__))


@view_config(route_name="guichet_rf_saisie_pm", request_method="GET", renderer='jsonp')
def guichet_rf_saisie_pm_view(request):
"""
Expand Down
29 changes: 6 additions & 23 deletions back/infolica/views/affaire_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def affaire_documents_view(request):
if not check_connected(request):
raise exc.HTTPForbidden()

affaire_id = request.matchdict['id']
affaire_id = request.params['affaire_id'] if 'affaire_id' in request.params else None
affaire_chemin = request.dbsession.query(Affaire).filter(Affaire.id == affaire_id).first().chemin

documents = []
Expand All @@ -63,10 +63,12 @@ def affaire_documents_view(request):
file_i = {}
file_i['relpath'] = os.path.relpath(root, affaire_path).replace('\\', '/')
file_i['filename'] = name
file_i['creation'] = datetime.fromtimestamp(os.path.getctime(os.path.join(root, name))).strftime("%d.%m.%Y")
file_i['modification'] = datetime.fromtimestamp(os.path.getmtime(os.path.join(root, name))).strftime("%d.%m.%Y")
file_i['creation_sort'] = os.path.getctime(os.path.join(root, name))
file_i['modification_sort'] = os.path.getmtime(os.path.join(root, name))
file_i['creation'] = datetime.fromtimestamp(file_i['creation_sort']).strftime("%d.%m.%Y")
file_i['modification'] = datetime.fromtimestamp(file_i['modification_sort']).strftime("%d.%m.%Y")
documents.append(file_i)

return documents


Expand Down Expand Up @@ -99,22 +101,3 @@ def download_affaire_document_view(request):
headers['Accept-Ranges'] = 'bite'
headers['Content-Disposition'] = 'attachment;filename=' + urllib.parse.quote(filename)
return response


@view_config(route_name='open_folder', request_method='GET', renderer='json')
def save_document_view(request):
"""
open folder (affaire)
"""
basepath = request.registry.settings['affaires_directory_full_path']

affaire_id = request.params['affaire_id'] if 'affaire_id' in request.params else None
relpath = request.dbsession.query(Affaire).filter(Affaire.id == affaire_id).first().chemin

path = os.path.join(basepath, relpath)

if os.path.exists(path):
# subprocess.Popen('explorer ' + path)
return {'affaire_path': path.replace('\\', '/')}

return {'affaire_path': basepath.replace('\\', '/')}
1 change: 1 addition & 0 deletions back/infolica/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def test_error(exc, request):
@view_config(route_name='emolument', request_method='OPTIONS', renderer='json')
@view_config(route_name='emolument_affaire_freeze', request_method='OPTIONS', renderer='json')
@view_config(route_name='emolument_affaire_repartiton', request_method='OPTIONS', renderer='json')
@view_config(route_name='affaire_attribution_change_state', request_method='OPTIONS', renderer='json')
def options_response_view(request):
"""
Common OPTION RESPONSE
Expand Down
6 changes: 2 additions & 4 deletions front/.env
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ VUE_APP_TYPES_AFFAIRES_ENDPOINT = "/types_affaires"
VUE_APP_RECHERCHE_AFFAIRES_ENDPOINT = "/recherche_affaires"
VUE_APP_AFFAIRE_NUMEROS_ENDPOINT = "/affaire_numeros"
VUE_APP_DESACTIVER_AFFAIRE_NUMEROS_ENDPOINT = "/desactiver_numeros_affaires/"
VUE_APP_AFFAIRE_DOCUMENTS_ENDPOINT = "/affaire_documents/"
VUE_APP_AFFAIRE_DOCUMENTS_ENDPOINT = "/affaire_documents"
VUE_APP_AFFAIRE_TYPES_DOCUMENTS_ENDPOINT = "/types_documents"
VUE_APP_AFFAIRE_TYPES_MODIF_AFFAIRE_ENDPOINT = "/types_modification_affaire"
VUE_APP_AFFAIRE_UPLOAD_DOCUMENTS_ENDPOINT = "/upload_affaire_document"
Expand All @@ -76,6 +76,7 @@ VUE_APP_MODIFICATION_AFFAIRE_BY_AFFAIRE_MERE_ENDPOINT = "/modification_affaire_b
VUE_APP_MODIFICATION_AFFAIRE_BY_AFFAIRE_FILLE_ENDPOINT = "/modification_affaire_by_affaire_fille/"
VUE_APP_AFFAIRES_COCKPIT_ENDPOINT = "/affaires_cockpit"
VUE_APP_ABANDON_AFFAIRE_REOUVERTURE_AFFAIRE_PARENT_ENDPOINT = "/abandon_affaire_reopen_parent_affaire"
VUE_APP_AFFAIRE_ATTRIBUTION_CHANGE_STATE_ENDPOINT = "/affaire_attribution_change_state"

#Preavis
VUE_APP_PREAVIS_ENDPOINT = "/preavis"
Expand Down Expand Up @@ -130,9 +131,6 @@ VUE_APP_TYPES_NUMEROS_MO_ENDPOINT = "/types_numeros_mo"
#Plans de la MO
VUE_APP_PLANS_MO_ENDPOINT = "/plans_mo"

#Open folder
VUE_APP_OPEN_FOLDER_ENDPOINT = "/open_folder"

#Permissions
VUE_APP_FONCTION_ADMIN = "fonction_admin"
VUE_APP_AFFAIRE_EDITION = "affaire_edition"
Expand Down
6 changes: 3 additions & 3 deletions front/src/components/Affaires/AffairesDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,14 @@ export default {
async affaireAttributionChangeState() {
let formData = new FormData();
if (this.affaireAttribution.checked) {
formData.append("id_affaire", this.affaire.id);
formData.append("affaire_id", this.affaire.id);
formData.append("attribution", JSON.parse(localStorage.getItem("infolica_user")).initiales);
} else {
formData.append("id_affaire", this.affaire.id);
formData.append("affaire_id", this.affaire.id);
formData.append("attribution", null);
}
this.$http.put(
process.env.VUE_APP_API_URL + process.env.VUE_APP_AFFAIRES_ENDPOINT,
process.env.VUE_APP_API_URL + process.env.VUE_APP_AFFAIRE_ATTRIBUTION_CHANGE_STATE_ENDPOINT,
formData,
{
withCredentials: true,
Expand Down
42 changes: 23 additions & 19 deletions front/src/components/Affaires/Documents/Documents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default {
types_documents_list: null,
showEditAffairePathBtn: false,
showUploadDocBtn: false,
showUploadDocsDialog: false,
tableSort_by: 'relpath',
tableSort_order: 'desc'
}),
methods: {
Expand All @@ -58,28 +59,21 @@ export default {
* SEARCH AFFAIRE DOCUMENTS
*/
async searchAffaireDocuments() {
this.$http
.get(
this.$http.get(
process.env.VUE_APP_API_URL +
process.env.VUE_APP_AFFAIRE_DOCUMENTS_ENDPOINT +
this.$route.params.id,
process.env.VUE_APP_AFFAIRE_DOCUMENTS_ENDPOINT +
"?affaire_id=" + this.affaire.id,
{
withCredentials: true,
headers: { Accept: "application/json" }
}
)
.then(response => {
if (response.data) {
let tmp = response.data;
tmp.forEach(x => x.modification_sort = new Date(x.modification).getTime());
this.documents = tmp;
).then(response => {
if (response && response.data) {
this.documents = response.data;
}
})
.catch(err => {
}).catch(err => {
handleException(err, this);
});
this.showUploadDocsDialog = false;
},
/**
Expand Down Expand Up @@ -186,18 +180,28 @@ export default {
this.searchAffaireDossier();
},
sortAffaireDocuments(value) {
return value.sort((a, b) => {
const sortBy = this.tableSort_by;
if (this.tableSort_order === 'desc') {
return String(a[sortBy]).localeCompare(b[sortBy]);
}
return String(b[sortBy]).localeCompare(a[sortBy]);
})
}
},
mounted: function() {
this.searchAffaireDocuments();
this.searchAffaireDossier();
this.searchAffaireDocuments();
this.$root.$on("searchAffaireDocuments", () => {
this.searchAffaireDossier()
this.searchAffaireDocuments()
})
this.searchAffaireDossier();
this.searchAffaireDocuments();
});
// show edit affaire path
if(checkPermission(process.env.VUE_APP_FONCTION_ADMIN)) {
Expand Down
7 changes: 2 additions & 5 deletions front/src/components/Affaires/Documents/documents.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
</md-button>
</md-card-expand-trigger>
Documents
<md-button class="md-primary uploadDocBtn" v-on:click="showUploadDocsDialog = true" v-if="showUploadDocBtn && false">
Charger des documents
</md-button>
</div>
</md-card-header>

Expand Down Expand Up @@ -47,8 +44,8 @@
</div>
</div>

<div v-if="documents[0]">
<md-table v-model="documents" md-sort="relpath" md-sort-order="asc" md-fixed-header md-card>
<div v-if="documents && documents.length > 0">
<md-table v-model="documents" :md-sort.sync="tableSort_by" :md-sort-order.sync="tableSort_order" :md-sort-fn="sortAffaireDocuments" md-fixed-header md-card>
<md-table-row slot="md-table-row" slot-scope="{ item }">
<md-table-cell md-label="Dossier" md-sort-by="relpath">{{ item.relpath }}</md-table-cell>
<md-table-cell md-label="Fichier" md-sort-by="filename">{{ item.filename }}</md-table-cell>
Expand Down

0 comments on commit 7765d8b

Please sign in to comment.