diff --git a/castellum_core/MANIFEST.in b/castellum_core/MANIFEST.in new file mode 100644 index 0000000000000000000000000000000000000000..3c92a62c794287c07270b92bf10249309cd66c57 --- /dev/null +++ b/castellum_core/MANIFEST.in @@ -0,0 +1,5 @@ +recursive-include castellum_core/static * +recursive-include castellum_core/*/static * +recursive-include castellum_core/templates * +recursive-include castellum_core/*/templates * +recursive-include castellum_core/locale * diff --git a/castellum_core/castellum_core/castellum_auth/__init__.py b/castellum_core/castellum_core/castellum_auth/__init__.py index f643c010e1dd0750e5d725ac352e4dc3cc2a6a4f..02a9271b01e2770bc67da36038ef22be108a66e4 100644 --- a/castellum_core/castellum_core/castellum_auth/__init__.py +++ b/castellum_core/castellum_core/castellum_auth/__init__.py @@ -1 +1 @@ -default_app_config = 'castellum_auth.apps.CastellumAuthConfig' +default_app_config = 'castellum_core.castellum_auth.apps.CastellumAuthConfig' diff --git a/castellum_core/castellum_core/castellum_auth/apps.py b/castellum_core/castellum_core/castellum_auth/apps.py index 41ffd0a3a0d1e56a8fc53c79874ce3bacbea13bc..a9f6a999f12a4a0b4bc575e154d73095ee13fb94 100644 --- a/castellum_core/castellum_core/castellum_auth/apps.py +++ b/castellum_core/castellum_core/castellum_auth/apps.py @@ -23,4 +23,4 @@ from django.apps import AppConfig class CastellumAuthConfig(AppConfig): - name = 'castellum_auth' + name = 'castellum_core.castellum_auth' diff --git a/castellum_core/castellum_core/castellum_auth/management/commands/create_castellum_admin.py b/castellum_core/castellum_core/castellum_auth/management/commands/create_castellum_admin.py index 8f71474f456b492446b511e8ba91afdec03d7de7..3952137540a800280697c2845016aa5741305525 100644 --- a/castellum_core/castellum_core/castellum_auth/management/commands/create_castellum_admin.py +++ b/castellum_core/castellum_core/castellum_auth/management/commands/create_castellum_admin.py @@ -1,7 +1,7 @@ from django.core.management.base import BaseCommand from django.utils import timezone -from castellum_auth.models import User +from castellum_core.castellum_auth.models import User class Command(BaseCommand): diff --git a/castellum_core/castellum_core/castellum_core/__init__.py b/castellum_core/castellum_core/main/__init__.py similarity index 100% rename from castellum_core/castellum_core/castellum_core/__init__.py rename to castellum_core/castellum_core/main/__init__.py diff --git a/castellum_core/castellum_core/castellum_core/settings/__init__.py b/castellum_core/castellum_core/main/settings/__init__.py similarity index 100% rename from castellum_core/castellum_core/castellum_core/settings/__init__.py rename to castellum_core/castellum_core/main/settings/__init__.py diff --git a/castellum_core/castellum_core/castellum_core/settings/default.py b/castellum_core/castellum_core/main/settings/default.py similarity index 93% rename from castellum_core/castellum_core/castellum_core/settings/default.py rename to castellum_core/castellum_core/main/settings/default.py index 5b80953ff2a1b1c982a9389aa7d7c65ca37cb831..0c18b01dae5c7926055e1ea470bafab1697cb520 100644 --- a/castellum_core/castellum_core/castellum_core/settings/default.py +++ b/castellum_core/castellum_core/main/settings/default.py @@ -20,9 +20,9 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'bootstrap4', - 'castellum_auth', - 'studies', - 'subject_management', + 'castellum_core.castellum_auth', + 'castellum_core.studies', + 'castellum_core.subject_management', ] MIDDLEWARE = [ @@ -35,11 +35,11 @@ MIDDLEWARE = [ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'castellum_auth.middlewares.UserExpirationMiddleware', - 'castellum_auth.middlewares.AutoLogoutMiddleware', + 'castellum_core.castellum_auth.middlewares.UserExpirationMiddleware', + 'castellum_core.castellum_auth.middlewares.AutoLogoutMiddleware', ] -ROOT_URLCONF = 'castellum_core.urls' +ROOT_URLCONF = 'castellum_core.main.urls' TEMPLATES = [ @@ -60,11 +60,11 @@ TEMPLATES = [ }, ] -WSGI_APPLICATION = 'castellum_core.wsgi.application' +WSGI_APPLICATION = 'castellum_core.main.wsgi.application' DATABASE_ROUTERS = [ - 'subject_management.routers.SubjectManagementRouter', + 'castellum_core.subject_management.routers.SubjectManagementRouter', ] # Password validation diff --git a/castellum_core/castellum_core/castellum_core/settings/development.py b/castellum_core/castellum_core/main/settings/development.py similarity index 100% rename from castellum_core/castellum_core/castellum_core/settings/development.py rename to castellum_core/castellum_core/main/settings/development.py diff --git a/castellum_core/castellum_core/castellum_core/urls.py b/castellum_core/castellum_core/main/urls.py similarity index 96% rename from castellum_core/castellum_core/castellum_core/urls.py rename to castellum_core/castellum_core/main/urls.py index 72663950c1450502ac8eeac580d20c775099f75f..1ac5d46f845e506fdd5f6874d20ad9f59804c4b9 100644 --- a/castellum_core/castellum_core/castellum_core/urls.py +++ b/castellum_core/castellum_core/main/urls.py @@ -41,5 +41,5 @@ urlpatterns = [ path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'), path('admin/', admin.site.urls), - path('studies/', include('studies.urls')), + path('studies/', include('castellum_core.studies.urls')), ] diff --git a/castellum_core/castellum_core/castellum_core/wsgi.py b/castellum_core/castellum_core/main/wsgi.py similarity index 91% rename from castellum_core/castellum_core/castellum_core/wsgi.py rename to castellum_core/castellum_core/main/wsgi.py index d1fa17d67c5e84d8cb58d80cd5efa1884c055e7d..34e0f3dbd58723351120b0630ac6e99ea6e8f2e6 100644 --- a/castellum_core/castellum_core/castellum_core/wsgi.py +++ b/castellum_core/castellum_core/main/wsgi.py @@ -3,6 +3,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "castellum_core.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "castellum_core.main.settings") application = get_wsgi_application() diff --git a/castellum_core/castellum_core/manage.py b/castellum_core/castellum_core/manage.py index 3ffcc2d0b0f3fde0140a6929679cad010ed7b963..68e5195170df34ee3ad38dee49969d1296df6445 100755 --- a/castellum_core/castellum_core/manage.py +++ b/castellum_core/castellum_core/manage.py @@ -3,7 +3,7 @@ import os import sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "castellum_core.settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "castellum_core.main.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/castellum_core/castellum_core/studies/__init__.py b/castellum_core/castellum_core/studies/__init__.py index a2055a094defdbb65d9e7f9ebe9fa041284baaf4..29e2a691e5da683a75da8b86389cd65e1cd0036c 100644 --- a/castellum_core/castellum_core/studies/__init__.py +++ b/castellum_core/castellum_core/studies/__init__.py @@ -1 +1 @@ -default_app_config = 'studies.apps.StudiesConfig' +default_app_config = 'castellum_core.studies.apps.StudiesConfig' diff --git a/castellum_core/castellum_core/studies/apps.py b/castellum_core/castellum_core/studies/apps.py index 5f605c0c19faec452cc9924d943672e715c4e1ca..6e2e4944c9941c96f7cf1c5dac194969c7da1277 100644 --- a/castellum_core/castellum_core/studies/apps.py +++ b/castellum_core/castellum_core/studies/apps.py @@ -23,4 +23,4 @@ from django.apps import AppConfig class StudiesConfig(AppConfig): - name = 'studies' + name = 'castellum_core.studies' diff --git a/castellum_core/castellum_core/subject_management/__init__.py b/castellum_core/castellum_core/subject_management/__init__.py index 6e59d7160d19057527329a8a868faa4188e50563..8e17ca51bc146a7defe88db0a1b1330f8ebe07fc 100644 --- a/castellum_core/castellum_core/subject_management/__init__.py +++ b/castellum_core/castellum_core/subject_management/__init__.py @@ -1 +1 @@ -default_app_config = 'subject_management.apps.SubjectManagementConfig' +default_app_config = 'castellum_core.subject_management.apps.SubjectManagementConfig' diff --git a/castellum_core/castellum_core/subject_management/apps.py b/castellum_core/castellum_core/subject_management/apps.py index 778ea66e54b5074704b29c542e5ef5d3813525b4..24591d082adc47325c6e142808d9ba92c62350c0 100644 --- a/castellum_core/castellum_core/subject_management/apps.py +++ b/castellum_core/castellum_core/subject_management/apps.py @@ -23,4 +23,4 @@ from django.apps import AppConfig class SubjectManagementConfig(AppConfig): - name = 'subject_management' + name = 'castellum_core.subject_management' diff --git a/castellum_core/setup.py b/castellum_core/setup.py index 6b3210175e3ac5ac3d9694a171eeee0f7ed436d7..0226aa51c776042c276ea93ab9cef934d8f8bdbd 100644 --- a/castellum_core/setup.py +++ b/castellum_core/setup.py @@ -9,6 +9,7 @@ setup( license="AGPL-3.0-or-later", packages=find_packages(), + include_package_data=True, install_requires=[ "Django==2.0.4", diff --git a/castellum_core/tests/castellum_auth/admin/test_user_admin.py b/castellum_core/tests/castellum_auth/admin/test_user_admin.py index 45395b602d0f0a77d33b79418a11c8a6b6dd37e4..d18ec9886ba1991e8a0f7d5026e01f040f5c4303 100644 --- a/castellum_core/tests/castellum_auth/admin/test_user_admin.py +++ b/castellum_core/tests/castellum_auth/admin/test_user_admin.py @@ -4,8 +4,8 @@ from django.utils.timezone import datetime from freezegun import freeze_time from model_mommy import mommy -from castellum_auth.admin import expiration_date -from castellum_auth.models import User +from castellum_core.castellum_auth.admin import expiration_date +from castellum_core.castellum_auth.models import User def test_no_expiration_date_is_set(): diff --git a/castellum_core/tests/castellum_auth/conftest.py b/castellum_core/tests/castellum_auth/conftest.py index d9913f728b85872e3f85ae5b0d247c264180f74c..339f24603e982492047e9ed9620d83ad7a548434 100644 --- a/castellum_core/tests/castellum_auth/conftest.py +++ b/castellum_core/tests/castellum_auth/conftest.py @@ -1,7 +1,7 @@ import pytest from django.utils import timezone -from castellum_auth.models import User +from castellum_core.castellum_auth.models import User @pytest.fixture diff --git a/castellum_core/tests/castellum_auth/management_commands/test_clear_sessions.py b/castellum_core/tests/castellum_auth/management_commands/test_clear_sessions.py index 401f7f9465bd9a7b5ae2a0494f37b9667c483ab3..6db0ce8d600b78ef93014914f9da8028ff9643ba 100644 --- a/castellum_core/tests/castellum_auth/management_commands/test_clear_sessions.py +++ b/castellum_core/tests/castellum_auth/management_commands/test_clear_sessions.py @@ -1,6 +1,6 @@ import pytest -from castellum_auth.management.commands.clear_sessions import Command +from castellum_core.castellum_auth.management.commands.clear_sessions import Command @pytest.mark.django_db diff --git a/castellum_core/tests/castellum_auth/management_commands/test_create_castellum_admin.py b/castellum_core/tests/castellum_auth/management_commands/test_create_castellum_admin.py index 1f666395c51a09f16707ccf2bb63d8c64e08a4df..12f47c4fcb9aef000943d8eb4f9b9a879e9ffae1 100644 --- a/castellum_core/tests/castellum_auth/management_commands/test_create_castellum_admin.py +++ b/castellum_core/tests/castellum_auth/management_commands/test_create_castellum_admin.py @@ -1,7 +1,7 @@ import pytest -from castellum_auth.models import User -from castellum_auth.management.commands.create_castellum_admin import Command +from castellum_core.castellum_auth.models import User +from castellum_core.castellum_auth.management.commands.create_castellum_admin import Command @pytest.mark.django_db diff --git a/castellum_core/tests/castellum_auth/test_middlewares.py b/castellum_core/tests/castellum_auth/test_middlewares.py index b954f352840111af3d57e568720ba41ec9c2d2bf..9de4e9bdd141dcd154ba60b16650c87ca2500db7 100644 --- a/castellum_core/tests/castellum_auth/test_middlewares.py +++ b/castellum_core/tests/castellum_auth/test_middlewares.py @@ -3,7 +3,7 @@ from freezegun import freeze_time from django.utils import timezone -from castellum_auth.models import User +from castellum_core.castellum_auth.models import User @pytest.mark.django_db diff --git a/castellum_core/tests/castellum_auth/test_user_model.py b/castellum_core/tests/castellum_auth/test_user_model.py index affc8dfdd7acd3ecc587c9e65b4f4b48f3477cce..97c530a31544e0db9afe8072c44cc02bbb35d7d2 100644 --- a/castellum_core/tests/castellum_auth/test_user_model.py +++ b/castellum_core/tests/castellum_auth/test_user_model.py @@ -32,7 +32,7 @@ def test_user_get_all_permission_objects_unique(user): assert len(user.get_all_permission_objects()) == 1 -@patch('castellum_auth.models.send_mail') +@patch('castellum_core.castellum_auth.models.send_mail') def test_lock_notification(send_mail, user): user.is_active = True user.save() @@ -43,7 +43,7 @@ def test_lock_notification(send_mail, user): assert send_mail.called -@patch('castellum_auth.models.send_mail') +@patch('castellum_core.castellum_auth.models.send_mail') def test_unlock_no_notification(send_mail, user): user.is_active = False user.save() diff --git a/castellum_core/tests/subject_management/models/conftest.py b/castellum_core/tests/subject_management/models/conftest.py index a1d5cb7d169cdc60349bbadbd2a298c5bed654fd..89935ebcfce4dd08b1db7127402a27c9306de478 100644 --- a/castellum_core/tests/subject_management/models/conftest.py +++ b/castellum_core/tests/subject_management/models/conftest.py @@ -1,6 +1,6 @@ import pytest -from subject_management.models import Address, City, Country +from castellum_core.subject_management.models import Address, City, Country @pytest.fixture diff --git a/castellum_core/tests/subject_management/test_router.py b/castellum_core/tests/subject_management/test_router.py index 909103125d93778e5cc36cf5d697126e1d5ee122..e003542b388da9eab1f8bd91866bb2586c5da686 100644 --- a/castellum_core/tests/subject_management/test_router.py +++ b/castellum_core/tests/subject_management/test_router.py @@ -2,9 +2,9 @@ import pytest from model_mommy import mommy -from castellum_auth.models import User -from subject_management.models import Subject -from subject_management.routers import APP_LABEL, SubjectManagementRouter +from castellum_core.castellum_auth.models import User +from castellum_core.subject_management.models import Subject +from castellum_core.subject_management.routers import APP_LABEL, SubjectManagementRouter @pytest.fixture diff --git a/castellum_core/tox.ini b/castellum_core/tox.ini index dbc898005c5071e658187709680b3a7c904c2bf4..0c8ee27776eb0552f3dc9eb45e4a06764c84e266 100644 --- a/castellum_core/tox.ini +++ b/castellum_core/tox.ini @@ -4,7 +4,7 @@ envlist = py35,flake8 [pytest] addopts = - --ds=castellum_core.settings + --ds=castellum_core.main.settings --cov=castellum_core --cov-branch --cov-report term-missing:skip-covered diff --git a/castellum_core/uwsgi.ini b/castellum_core/uwsgi.ini index c36d850c77af336916637c2b5f04c3e88bf41f02..3b2c1bafef9e273abfdcf80e1929c2d0b79416d1 100644 --- a/castellum_core/uwsgi.ini +++ b/castellum_core/uwsgi.ini @@ -9,5 +9,5 @@ socket=0.0.0.0:8000 protocol=http static-map=/static=/code/castellum_core/collected_static -wsgi-file=castellum_core/wsgi.py +wsgi-file=main/wsgi.py plugin=python3 diff --git a/foo/bootstrap.sh b/foo/bootstrap.sh new file mode 100755 index 0000000000000000000000000000000000000000..bc85be7152cba68d4ca7514125fb393177f5e865 --- /dev/null +++ b/foo/bootstrap.sh @@ -0,0 +1,7 @@ +#!/bin/sh -e + +python3 -m venv .env +. .env/bin/activate +pip install ../castellum_core +python manage.py migrate +python manage.py runserver diff --git a/foo/manage.py b/foo/manage.py new file mode 100755 index 0000000000000000000000000000000000000000..2fb39583a055aef7ced32d3ec969885578ae239c --- /dev/null +++ b/foo/manage.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) diff --git a/foo/settings.py b/foo/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..f6c3f7ceca209439e7d6d51a0aeeace57c24a908 --- /dev/null +++ b/foo/settings.py @@ -0,0 +1,23 @@ +from castellum_core.main.settings.default import * + +FOO_DIR = os.path.dirname(__file__) + +SECRET_KEY = 'i#$kwk(s24ysn+l%+c!*z9u4+45)oex!-s#!bux#wf2pv2cc0d' + +DEBUG = True + + +# Database + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(FOO_DIR, 'db.sqlite3'), + }, + 'subject_management': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(FOO_DIR, 'subject_management.sqlite3'), + }, +} + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'