Skip to content
Snippets Groups Projects
Commit 0bc2d48d authored by Jiří Setnička's avatar Jiří Setnička
Browse files

Opravy logování při vytváření/editaci a mazání míst

parent 5f58f6cd
No related branches found
No related tags found
1 merge request!4Dodělávky manipulace s places
...@@ -112,7 +112,7 @@ def org_place_edit(id: int): ...@@ -112,7 +112,7 @@ def org_place_edit(id: int):
# School record removed # School record removed
mo.util.log( mo.util.log(
type=db.LogType.place, type=db.LogType.place,
what=g.user.user_id, what=school.place_id,
details={'action': 'school-delete', 'school': db.row2dict(school)}, details={'action': 'school-delete', 'school': db.row2dict(school)},
) )
app.logger.info(f"Deleting school record for place {place.place_id}") app.logger.info(f"Deleting school record for place {place.place_id}")
...@@ -122,15 +122,15 @@ def org_place_edit(id: int): ...@@ -122,15 +122,15 @@ def org_place_edit(id: int):
schoolChanges = db.get_object_changes(school) schoolChanges = db.get_object_changes(school)
elif request.form.get('type') == 'school': elif request.form.get('type') == 'school':
# School record created # School record created
newSchool = db.School() new_school = db.School()
newSchool.place_id = place.place_id new_school.place_id = place.place_id
mo.util.log( mo.util.log(
type=db.LogType.place, type=db.LogType.place,
what=g.user.user_id, what=new_school.place_id,
details={'action': 'school-add', 'place_id': place.place_id}, details={'action': 'school-add'},
) )
app.logger.info(f"Creating new school for place {place.place_id}") 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 # 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' msg = 'Záznam o škole vytvořen, vyplňte prosím všechna data'
redirectURL = url_for('org_place_edit', id=id) redirectURL = url_for('org_place_edit', id=id)
...@@ -139,7 +139,7 @@ def org_place_edit(id: int): ...@@ -139,7 +139,7 @@ def org_place_edit(id: int):
app.logger.info(f"Place {id} modified, changes: {changes}") app.logger.info(f"Place {id} modified, changes: {changes}")
mo.util.log( mo.util.log(
type=db.LogType.place, type=db.LogType.place,
what=g.user.user_id, what=id,
details={'action': 'edit', 'changes': changes}, details={'action': 'edit', 'changes': changes},
) )
db.get_session().commit() db.get_session().commit()
...@@ -253,8 +253,21 @@ def org_place_delete(id: int): ...@@ -253,8 +253,21 @@ def org_place_delete(id: int):
if place.type == db.PlaceType.school: if place.type == db.PlaceType.school:
school = sess.query(db.School).get(place.place_id) 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) 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 parent = place.parent
db.get_session().delete(place) db.get_session().delete(place)
db.get_session().commit() db.get_session().commit()
...@@ -286,12 +299,13 @@ def org_place_new_child(id: int): ...@@ -286,12 +299,13 @@ def org_place_new_child(id: int):
form.populate_obj(new_place) form.populate_obj(new_place)
new_place.parent = parent_place.place_id new_place.parent = parent_place.place_id
new_place.level = parent_place.level + 1 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)}") app.logger.info(f"New place created: {db.row2dict(new_place)}")
mo.util.log( mo.util.log(
type=db.LogType.place, type=db.LogType.place,
what=g.user.user_id, what=new_place.place_id,
details={'action': 'new', 'place': db.row2dict(new_place)}, details={'action': 'new', 'place': db.row2dict(new_place)},
) )
db.get_session().commit() db.get_session().commit()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment