Skip to content

Commit

Permalink
Merge branch 'plugin-loading-apps' into 'main'
Browse files Browse the repository at this point in the history
Rename plugin app.py to apps.py to be consistent with django

See merge request reportcreator/reportcreator!830
  • Loading branch information
MWedl committed Jan 16, 2025
2 parents 19ee927 + 4df2f05 commit 7a1274c
Show file tree
Hide file tree
Showing 16 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions api/src/reportcreator_api/conf/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ def load_plugins(plugin_dirs: list[Path], enabled_plugins: list[str]):
continue

init_file = module_dir / '__init__.py'
app_file = module_dir / 'app.py'
if not init_file.is_file() or not app_file.is_file():
apps_file = module_dir / 'apps.py'
if not init_file.is_file() or not apps_file.is_file():
continue

module_name = f"sysreptor_plugins.{module_dir.name}"
try:
plugin_app_module = import_module(module_name + '.app')
plugin_app_module = import_module(module_name + '.apps')
except ImportError:
continue
plugin_config_class = next(filter(lambda c: issubclass(c, PluginConfig) and c != PluginConfig, map(lambda c: getattr(plugin_app_module, c), dir(plugin_app_module))), None)
Expand Down
6 changes: 3 additions & 3 deletions api/src/reportcreator_api/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
def enable_demoplugin():
# Import config to check if plugin exists
try:
from sysreptor_plugins.demoplugin.app import DemoPluginConfig # type: ignore
from sysreptor_plugins.demoplugin.apps import DemoPluginConfig # type: ignore
except ImportError:
pytest.skip('DemoPlugin not found')

Expand All @@ -45,7 +45,7 @@ def enable_demoplugin():
def disable_demoplugin():
with override_settings(
ENABLED_PLUGINS=[plugin for plugin in settings.ENABLED_PLUGINS if plugin not in ['demoplugin', DEMOPLUGIN_ID]],
INSTALLED_APPS=[app for app in settings.INSTALLED_APPS if app != 'sysreptor_plugins.demoplugin.app.DemoPluginConfig'],
INSTALLED_APPS=[app for app in settings.INSTALLED_APPS if app != 'sysreptor_plugins.demoplugin.apps.DemoPluginConfig'],
):
yield

Expand Down Expand Up @@ -89,7 +89,7 @@ def test_plugin_loading(self):
assert omit_keys(demoplugin_config, ['frontend_entry']) == {'id': DEMOPLUGIN_ID, 'name': 'demoplugin', 'frontend_settings': {}}

def test_load_professional_only(self):
from sysreptor_plugins.demoplugin.app import DemoPluginConfig # type: ignore
from sysreptor_plugins.demoplugin.apps import DemoPluginConfig # type: ignore

try:
DemoPluginConfig.professional_only = True
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion plugins/demoplugin/tests/test_plugin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
websocket_client,
)

from ..app import DemoPluginConfig
from ..apps import DemoPluginConfig
from ..models import DemoPluginModel

PLUGIN_ID = DemoPluginConfig.plugin_id
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion plugins/projectnumber/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ReportSection,
)

from .app import ProjectNumberPluginConfig
from .apps import ProjectNumberPluginConfig
from .models import ProjectNumber

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion plugins/projectnumber/tests/test_plugin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
create_user,
)

from ..app import ProjectNumberPluginConfig
from ..apps import ProjectNumberPluginConfig
from ..management.commands import resetprojectnumber
from ..models import ProjectNumber

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion plugins/renderfindings/tests/test_renderfindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
create_user,
)

from ..app import RenderFindingsPluginConfig
from ..apps import RenderFindingsPluginConfig

URL_NAMESPACE = RenderFindingsPluginConfig.label

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion plugins/webhooks/tests/test_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from reportcreator_api.tests.mock import create_finding, create_project, create_user
from reportcreator_api.utils import utils

from ..app import WebhooksPluginConfig
from ..apps import WebhooksPluginConfig
from ..models import WebhookEventType


Expand Down
2 changes: 1 addition & 1 deletion plugins/webhooks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.apps import apps
from reportcreator_api.utils.utils import run_in_background

from .app import WebhooksPluginConfig
from .apps import WebhooksPluginConfig
from .models import WebhookEventType


Expand Down

0 comments on commit 7a1274c

Please sign in to comment.