Skip to content

Commit

Permalink
fix(synthese) fix pin not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Narcisi authored and camillemonchicourt committed Sep 15, 2023
1 parent e32d43e commit bc7fc54
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 11 additions & 1 deletion backend/geonature/core/gn_synthese/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,11 +1109,21 @@ def create_report(permissions):
TReport.id_synthese == id_synthese,
TReport.report_type.has(BibReportsTypes.type == type_name),
)

user_pin = TReport.query.filter(
TReport.id_synthese == id_synthese,
TReport.report_type.has(BibReportsTypes.type == "pin"),
TReport.id_role == g.current_user.id_role,
)
# only allow one alert by id_synthese
if type_name in ["alert", "pin"]:
if type_name in ["alert"]:
alert_exists = report_query.one_or_none()
if alert_exists is not None:
raise Conflict("This type already exists for this id")
if type_name in ["pin"]:
pin_exist = user_pin.one_or_none()
if pin_exist is not None:
raise Conflict("This type already exists for this id")
new_entry = TReport(
id_synthese=id_synthese,
id_role=g.current_user.id_role,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges {

loadAllInfo(idSynthese) {
this.isLoading = true;
this.getReport('pin');
this._dataService
.getOneSyntheseObservation(idSynthese)
.pipe(
Expand All @@ -108,7 +109,6 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges {
.subscribe((data) => {
this.selectedObs = data['properties'];
this.alert = find(data.properties.reports, ['report_type.type', 'alert']);
this.pin = find(data.properties.reports, ['report_type.type', 'pin']);
this.selectCdNomenclature = this.selectedObs?.nomenclature_valid_status.cd_nomenclature;
this.selectedGeom = data;
this.selectedObs['municipalities'] = [];
Expand Down Expand Up @@ -341,8 +341,9 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges {
pinSelectedObs() {
if (isEmpty(this.pin)) {
this.addPin();
} else {
this.deletePin();
}
this.deletePin();
}

copyToClipBoard() {
Expand Down

0 comments on commit bc7fc54

Please sign in to comment.