-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load plugins from Serveradmin apps for Servershell
- Loading branch information
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.apps import apps | ||
from django.contrib.staticfiles import finders | ||
|
||
|
||
def servershell_plugins(): | ||
"""Find $app.servershell.plugin.js files from Serveradmin apps | ||
Scans all apps beginning with serveradmin_ for files that follow the pattern | ||
$app.servershell.plugin.js and return them. This allows apps to add | ||
commands to the Servershell. | ||
@return: | ||
""" | ||
js_files = list() | ||
app_names = [app.name for app in apps.get_app_configs() if app.name.startswith("serveradmin_")] | ||
for app_name in app_names: | ||
path = f"js/{app_name}.servershell.plugin.js" | ||
js_file = finders.find(path) | ||
if js_file: | ||
js_files.append(path) | ||
|
||
return js_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters