added a lot of logging
This commit is contained in:
@@ -4,6 +4,7 @@ from models import db, Room, User, RoomMemberPermission, RoomFile
|
||||
from forms import RoomForm
|
||||
from routes.room_files import user_has_permission
|
||||
from routes.auth import require_password_change
|
||||
from utils import log_event
|
||||
|
||||
rooms_bp = Blueprint('rooms', __name__, url_prefix='/rooms')
|
||||
|
||||
@@ -53,6 +54,17 @@ def create_room():
|
||||
db.session.add(creator_permission)
|
||||
db.session.commit()
|
||||
|
||||
log_event(
|
||||
event_type='room_create',
|
||||
details={
|
||||
'room_id': room.id,
|
||||
'room_name': room.name,
|
||||
'description': room.description,
|
||||
'created_by': f"{current_user.username} {current_user.last_name}"
|
||||
},
|
||||
user_id=current_user.id
|
||||
)
|
||||
|
||||
flash('Room created successfully!', 'success')
|
||||
return redirect(url_for('rooms.rooms'))
|
||||
return render_template('rooms/create_room.html', form=form)
|
||||
@@ -74,6 +86,17 @@ def room(room_id):
|
||||
can_rename = user_has_permission(room, 'can_rename')
|
||||
can_move = user_has_permission(room, 'can_move')
|
||||
can_share = user_has_permission(room, 'can_share')
|
||||
|
||||
log_event(
|
||||
event_type='room_open',
|
||||
details={
|
||||
'room_id': room_id,
|
||||
'room_name': room.name,
|
||||
'accessed_by': f"{current_user.username} {current_user.last_name}"
|
||||
},
|
||||
user_id=current_user.id
|
||||
)
|
||||
|
||||
return render_template('rooms/room.html', room=room, can_download=can_download, can_upload=can_upload, can_delete=can_delete, can_rename=can_rename, can_move=can_move, can_share=can_share)
|
||||
|
||||
@rooms_bp.route('/<int:room_id>/members')
|
||||
@@ -183,9 +206,26 @@ def edit_room(room_id):
|
||||
form = RoomForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
old_name = room.name
|
||||
old_description = room.description
|
||||
|
||||
room.name = form.name.data
|
||||
room.description = form.description.data
|
||||
db.session.commit()
|
||||
|
||||
log_event(
|
||||
event_type='room_update',
|
||||
details={
|
||||
'room_id': room.id,
|
||||
'old_name': old_name,
|
||||
'new_name': room.name,
|
||||
'old_description': old_description,
|
||||
'new_description': room.description,
|
||||
'updated_by': f"{current_user.username} {current_user.last_name}"
|
||||
},
|
||||
user_id=current_user.id
|
||||
)
|
||||
|
||||
flash('Room updated successfully!', 'success')
|
||||
return redirect(url_for('rooms.rooms'))
|
||||
|
||||
@@ -214,6 +254,16 @@ def delete_room(room_id):
|
||||
db.session.commit()
|
||||
print("Room deleted successfully")
|
||||
|
||||
log_event(
|
||||
event_type='room_delete',
|
||||
details={
|
||||
'room_id': room_id,
|
||||
'room_name': room_name,
|
||||
'deleted_by': f"{current_user.username} {current_user.last_name}"
|
||||
},
|
||||
user_id=current_user.id
|
||||
)
|
||||
|
||||
flash(f'Room "{room_name}" has been deleted.', 'success')
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
|
||||
Reference in New Issue
Block a user