mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
Adds plugin functions to register javascript and CSS in the admin panel. Move global plugin script/stylesheet lists into application factory specific lists. Closes #804 (#805)
* Adds plugin functions to register javascript and CSS in the admin panel * Move global plugin script/stylesheet lists into application factory specific lists * Closes #804
This commit is contained in:
@@ -7,6 +7,8 @@ from CTFd.plugins import (
|
||||
register_plugin_asset,
|
||||
register_plugin_script,
|
||||
register_plugin_stylesheet,
|
||||
register_admin_plugin_script,
|
||||
register_admin_plugin_stylesheet,
|
||||
override_template,
|
||||
register_admin_plugin_menu_bar,
|
||||
get_admin_plugin_menu_bar,
|
||||
@@ -77,7 +79,7 @@ def test_admin_override_template():
|
||||
|
||||
|
||||
def test_register_plugin_script():
|
||||
'''Test that register_plugin_script adds script paths to the core theme when used from a plugin'''
|
||||
"""Test that register_plugin_script adds script paths to the core theme when used from a plugin"""
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
register_plugin_script('/fake/script/path.js')
|
||||
@@ -91,7 +93,7 @@ def test_register_plugin_script():
|
||||
|
||||
|
||||
def test_register_plugin_stylesheet():
|
||||
'''Test that register_plugin_stylesheet adds stylesheet paths to the core theme when used from a plugin'''
|
||||
"""Test that register_plugin_stylesheet adds stylesheet paths to the core theme when used from a plugin"""
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
register_plugin_script('/fake/stylesheet/path.css')
|
||||
@@ -104,6 +106,34 @@ def test_register_plugin_stylesheet():
|
||||
destroy_ctfd(app)
|
||||
|
||||
|
||||
def test_register_admin_plugin_script():
|
||||
"""Test that register_admin_plugin_script adds script paths to the admin theme when used from a plugin"""
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
register_admin_plugin_script('/fake/script/path.js')
|
||||
register_admin_plugin_script('http://ctfd.io/fake/script/path.js')
|
||||
with login_as_user(app, name="admin") as client:
|
||||
r = client.get('/admin/statistics')
|
||||
output = r.get_data(as_text=True)
|
||||
assert '/fake/script/path.js' in output
|
||||
assert 'http://ctfd.io/fake/script/path.js' in output
|
||||
destroy_ctfd(app)
|
||||
|
||||
|
||||
def test_register_admin_plugin_stylesheet():
|
||||
"""Test that register_admin_plugin_stylesheet adds stylesheet paths to the admin theme when used from a plugin"""
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
register_admin_plugin_stylesheet('/fake/stylesheet/path.css')
|
||||
register_admin_plugin_stylesheet('http://ctfd.io/fake/stylesheet/path.css')
|
||||
with login_as_user(app, name="admin") as client:
|
||||
r = client.get('/admin/statistics')
|
||||
output = r.get_data(as_text=True)
|
||||
assert '/fake/stylesheet/path.css' in output
|
||||
assert 'http://ctfd.io/fake/stylesheet/path.css' in output
|
||||
destroy_ctfd(app)
|
||||
|
||||
|
||||
def test_register_admin_plugin_menu_bar():
|
||||
"""
|
||||
Test that register_admin_plugin_menu_bar() properly inserts into HTML and get_admin_plugin_menu_bar()
|
||||
|
||||
Reference in New Issue
Block a user