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

@@ -55,7 +55,7 @@ def destroy_ctfd(app):
drop_database(app.config['SQLALCHEMY_DATABASE_URI'])
def register_user(app, name="user", email="user@ctfd.io", password="password"):
def register_user(app, name="user", email="user@ctfd.io", password="password", raise_for_error=True):
with app.app_context():
with app.test_client() as client:
r = client.get('/register')
@@ -67,6 +67,13 @@ def register_user(app, name="user", email="user@ctfd.io", password="password"):
"nonce": sess.get('nonce')
}
client.post('/register', data=data)
if raise_for_error:
with client.session_transaction() as sess:
assert sess['id']
assert sess['name'] == name
assert sess['type']
assert sess['email']
assert sess['nonce']
def register_team(app, name="team", password="password"):
@@ -82,7 +89,7 @@ def register_team(app, name="team", password="password"):
client.post('/teams/new', data=data)
def login_as_user(app, name="user", password="password"):
def login_as_user(app, name="user", password="password", raise_for_error=True):
with app.app_context():
with app.test_client() as client:
r = client.get('/login')
@@ -93,6 +100,13 @@ def login_as_user(app, name="user", password="password"):
"nonce": sess.get('nonce')
}
client.post('/login', data=data)
if raise_for_error:
with client.session_transaction() as sess:
assert sess['id']
assert sess['name']
assert sess['type']
assert sess['email']
assert sess['nonce']
return client
@@ -208,7 +222,7 @@ def gen_page(db, title, route, content, draft=False, auth_required=False, **kwar
return page
def gen_notification(db, title, content):
def gen_notification(db, title='title', content='content'):
notif = Notifications(title=title, content=content)
db.session.add(notif)
db.session.commit()