mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-24 09:14:20 +01:00
Update admin notification UI and allow for deleting notifications (#803)
* Show notification titles on the notification list page * Allow for deleting notifications * Update notification UI in admin panel * Make /api/v1/notifications/<id> accessible to all * Default `login_as_user()` and `register_user()` to fail on invalid credentials
This commit is contained in:
@@ -50,3 +50,33 @@ class NotificantionList(Resource):
|
||||
'success': True,
|
||||
'data': response.data
|
||||
}
|
||||
|
||||
|
||||
@notifications_namespace.route('/<notification_id>')
|
||||
@notifications_namespace.param('notification_id', 'A Notification ID')
|
||||
class Notification(Resource):
|
||||
def get(self, notification_id):
|
||||
notif = Notifications.query.filter_by(id=notification_id).first_or_404()
|
||||
schema = NotificationSchema()
|
||||
response = schema.dump(notif)
|
||||
if response.errors:
|
||||
return {
|
||||
'success': False,
|
||||
'errors': response.errors
|
||||
}, 400
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
'data': response.data
|
||||
}
|
||||
|
||||
@admins_only
|
||||
def delete(self, notification_id):
|
||||
notif = Notifications.query.filter_by(id=notification_id).first_or_404()
|
||||
db.session.delete(notif)
|
||||
db.session.commit()
|
||||
db.session.close()
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user