Skip to content

Commit

Permalink
log history: corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Feb 13, 2023
1 parent 1510cca commit d928a61
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion backend/geonature/core/gn_synthese/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def filter_by_scope(self, scope, user=None):
)
return self


def filter_by_params(self, params: MultiDict = None):
model = Synthese
and_list = []
Expand All @@ -150,6 +149,7 @@ def sort(self, label: str, direction: str):

return self.order_by(order_by)


@serializable
class CorAreaSynthese(DB.Model):
__tablename__ = "cor_area_synthese"
Expand Down
11 changes: 4 additions & 7 deletions backend/geonature/core/gn_synthese/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
from geojson import FeatureCollection, Feature
import sqlalchemy as sa

from utils_flask_sqla.generic import serializeQuery, GenericTable, GenericQuery
from utils_flask_sqla.generic import serializeQuery, GenericTable
from utils_flask_sqla.response import to_csv_resp, to_json_resp, json_resp
from utils_flask_sqla_geo.generic import GenericTableGeo

from geonature.utils import filemanager
from geonature.utils.config import config
from geonature.utils.env import DB
from geonature.utils.errors import GeonatureApiError
from geonature.utils.utilsgeometrytools import export_as_geo_file
Expand All @@ -43,8 +42,6 @@
VColorAreaTaxon,
TReport,
SyntheseLogEntry,
SyntheseQuery,

)
from geonature.core.gn_synthese.synthese_config import MANDATORY_COLUMNS

Expand Down Expand Up @@ -1195,8 +1192,6 @@ def delete_report(id_report):
DB.session.commit()




@routes.route("/log", methods=["get"])
@permissions.check_cruved_scope("R", True, module_code="SYNTHESE")
@json_resp
Expand Down Expand Up @@ -1227,7 +1222,9 @@ def list_synthese_log_entries(info_role) -> dict:
q2 = Synthese.query.with_entities(
Synthese.id_synthese,
Synthese.last_action,
func.coalesce(Synthese.meta_update_date, Synthese.meta_create_date),
func.coalesce(Synthese.meta_update_date, Synthese.meta_create_date).label(
"meta_last_action_date"
),
)

q3 = q1.union(q2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.sql.expression import null


# revision identifiers, used by Alembic.
Expand All @@ -28,7 +26,7 @@ def upgrade():
)
op.execute(
"""
CREATE OR REPLACE FUNCTION gn_synthese.fct_tri_log_delete_on_synthese() RETURNS TRIGGER AS
CREATE FUNCTION gn_synthese.fct_tri_log_delete_on_synthese() RETURNS TRIGGER AS
$BODY$
DECLARE
BEGIN
Expand All @@ -47,13 +45,12 @@ def upgrade():
END;
$BODY$ LANGUAGE plpgsql COST 100
;
DROP TRIGGER IF EXISTS tri_log_delete_synthese ON gn_synthese.synthese;
CREATE TRIGGER tri_log_delete_synthese
AFTER DELETE
ON gn_synthese.synthese
REFERENCING OLD TABLE AS old_table
FOR EACH STATEMENT
EXECUTE FUNCTION gn_synthese.fct_tri_log_delete_on_synthese()
EXECUTE FUNCTION gn_synthese.fct_tri_log_delete_on_synthese()
;
"""
)
Expand Down

0 comments on commit d928a61

Please sign in to comment.