From 0bc2d48d539cd4bab87d9ed91a3db9246c3af952 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Setni=C4=8Dka?= <setnicka@seznam.cz>
Date: Thu, 31 Dec 2020 17:36:50 +0100
Subject: [PATCH] =?UTF-8?q?Opravy=20logov=C3=A1n=C3=AD=20p=C5=99i=20vytv?=
=?UTF-8?q?=C3=A1=C5=99en=C3=AD/editaci=20a=20maz=C3=A1n=C3=AD=20m=C3=ADst?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
mo/web/org.py | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/mo/web/org.py b/mo/web/org.py
index 7fd69de5..b702ba18 100644
--- a/mo/web/org.py
+++ b/mo/web/org.py
@@ -112,7 +112,7 @@ def org_place_edit(id: int):
# School record removed
mo.util.log(
type=db.LogType.place,
- what=g.user.user_id,
+ what=school.place_id,
details={'action': 'school-delete', 'school': db.row2dict(school)},
)
app.logger.info(f"Deleting school record for place {place.place_id}")
@@ -122,15 +122,15 @@ def org_place_edit(id: int):
schoolChanges = db.get_object_changes(school)
elif request.form.get('type') == 'school':
# School record created
- newSchool = db.School()
- newSchool.place_id = place.place_id
+ new_school = db.School()
+ new_school.place_id = place.place_id
mo.util.log(
type=db.LogType.place,
- what=g.user.user_id,
- details={'action': 'school-add', 'place_id': place.place_id},
+ what=new_school.place_id,
+ details={'action': 'school-add'},
)
app.logger.info(f"Creating new school for place {place.place_id}")
- db.get_session().add(newSchool)
+ db.get_session().add(new_school)
# Take org directly to the school edit to fill the data
msg = 'Záznam o škole vytvořen, vyplňte prosím všechna data'
redirectURL = url_for('org_place_edit', id=id)
@@ -139,7 +139,7 @@ def org_place_edit(id: int):
app.logger.info(f"Place {id} modified, changes: {changes}")
mo.util.log(
type=db.LogType.place,
- what=g.user.user_id,
+ what=id,
details={'action': 'edit', 'changes': changes},
)
db.get_session().commit()
@@ -253,8 +253,21 @@ def org_place_delete(id: int):
if place.type == db.PlaceType.school:
school = sess.query(db.School).get(place.place_id)
+ mo.util.log(
+ type=db.LogType.place,
+ what=school.place_id,
+ details={'action': 'school-delete', 'school': db.row2dict(school)},
+ )
+ app.logger.info(f"Deleting school record for place {id}")
db.get_session().delete(school)
+ mo.util.log(
+ type=db.LogType.place,
+ what=id,
+ details={'action': 'delete', 'place': db.row2dict(place)},
+ )
+ app.logger.info(f"Deleting place {id}")
+
parent = place.parent
db.get_session().delete(place)
db.get_session().commit()
@@ -286,12 +299,13 @@ def org_place_new_child(id: int):
form.populate_obj(new_place)
new_place.parent = parent_place.place_id
new_place.level = parent_place.level + 1
- db.get_session().add(new_place)
+ sess.add(new_place)
+ sess.flush()
app.logger.info(f"New place created: {db.row2dict(new_place)}")
mo.util.log(
type=db.LogType.place,
- what=g.user.user_id,
+ what=new_place.place_id,
details={'action': 'new', 'place': db.row2dict(new_place)},
)
db.get_session().commit()
--
GitLab