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:
Kevin Chung
2018-12-14 23:23:02 -05:00
committed by GitHub
parent 0c14f6ff0f
commit 367110969e
11 changed files with 147 additions and 33 deletions

View File

@@ -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,
}