Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(synthese) fix pin not working #2702

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1106,11 +1106,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