mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user