Skip to content

Commit

Permalink
Move CAS signal to common app
Browse files Browse the repository at this point in the history
This commit also adds a custom AppConfig in the common app, which
ensures that the Django signal receivers in the app work as expected.
  • Loading branch information
tw4l committed Aug 24, 2020
1 parent aa1a7c7 commit 6bf42f0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions storage_service/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = "common.apps.CommonAppConfig"
11 changes: 11 additions & 0 deletions storage_service/common/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from django.apps import AppConfig


class CommonAppConfig(AppConfig):
name = "common"

def ready(self):
import common.signals # noqa: F401
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def cas_user_authenticated_callback(sender, **kwargs):
if not settings.CAS_CHECK_ADMIN_ATTRIBUTES:
return

LOGGER.debug("cas_user_authenticated signal received")

username = kwargs.get("user")
attributes = kwargs.get("attributes")

Expand Down
2 changes: 1 addition & 1 deletion storage_service/storage_service/tests/test_cas.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from unittest import mock

from common.backends import CustomCASBackend
from storage_service.signals import _cas_user_is_administrator
from common.signals import _cas_user_is_administrator

TEST_CAS_USER = "casuser"
TEST_CAS_ADMIN_ATTRIBUTE = "usertype"
Expand Down

0 comments on commit 6bf42f0

Please sign in to comment.