Admins can see all of the modlog, everyone else can only see public entries #21

This commit is contained in:
rimu 2024-07-07 16:09:50 +08:00
parent 557e73d6a2
commit bfdb8749e5

View file

@ -358,7 +358,14 @@ def modlog():
page = request.args.get('page', 1, type=int) page = request.args.get('page', 1, type=int)
low_bandwidth = request.cookies.get('low_bandwidth', '0') == '1' low_bandwidth = request.cookies.get('low_bandwidth', '0') == '1'
modlog_entries = ModLog.query.filter(ModLog.public == True).order_by(desc(ModLog.created_at)) # Admins can see all of the modlog, everyone else can only see public entries
if current_user.is_authenticated:
if current_user.is_admin() or current_user.is_staff():
modlog_entries = ModLog.query.order_by(desc(ModLog.created_at))
else:
modlog_entries = ModLog.query.filter(ModLog.public == True).order_by(desc(ModLog.created_at))
else:
modlog_entries = ModLog.query.filter(ModLog.public == True).order_by(desc(ModLog.created_at))
# Pagination # Pagination
modlog_entries = modlog_entries.paginate(page=page, per_page=100 if not low_bandwidth else 50, error_out=False) modlog_entries = modlog_entries.paginate(page=page, per_page=100 if not low_bandwidth else 50, error_out=False)