Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared subtree #53

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Make git subtree available
RUN sudo cp -a /usr/lib/git-core/git-subtree /usr/local/bin/

USER vscode

# pipx is already installed in the base devcontainers Python image
Expand Down
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"postCreateCommand": "poetry install && npm install",
"postStartCommand": "poetry run invoke init-workspace --type codespaces",
"customizations": {
"codespaces": {
"repositories": {
"radexperts/django-shared": {
"permissions": "write-all"
}
}
},
"vscode": {
"extensions": [
"batisteo.vscode-django",
Expand Down
2 changes: 1 addition & 1 deletion adit/batch_query/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def init_db(**kwargs):


def create_group():
from adit.accounts.utils import create_group_with_permissions
from adit.shared.accounts.utils import create_group_with_permissions

create_group_with_permissions(
"batch_query_group",
Expand Down
2 changes: 1 addition & 1 deletion adit/batch_transfer/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def init_db(**kwargs):


def create_group():
from adit.accounts.utils import create_group_with_permissions
from adit.shared.accounts.utils import create_group_with_permissions

create_group_with_permissions(
"batch_transfer_group",
Expand Down
2 changes: 1 addition & 1 deletion adit/batch_transfer/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from django.db import transaction
from django.utils.safestring import mark_safe

from adit.accounts.models import User
from adit.core.errors import BatchFileContentError, BatchFileFormatError, BatchFileSizeError
from adit.core.fields import DicomNodeChoiceField, RestrictedFileField
from adit.shared.accounts.models import User

from .models import BatchTransferJob, BatchTransferTask
from .parsers import BatchTransferFileParser
Expand Down
4 changes: 2 additions & 2 deletions adit/batch_transfer/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import pytest
from django.core.files import File

from adit.accounts.factories import UserFactory
from adit.accounts.models import User
from adit.core.factories import DicomServerFactory
from adit.shared.accounts.factories import UserFactory
from adit.shared.accounts.models import User

from ..forms import BatchTransferJobForm

Expand Down
2 changes: 1 addition & 1 deletion adit/batch_transfer/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from django.urls import reverse
from pytest_django.asserts import assertTemplateUsed

from adit.accounts.factories import UserFactory
from adit.core.factories import DicomServerFactory
from adit.core.models import DicomServer
from adit.shared.accounts.factories import UserFactory

from ..models import BatchTransferJob

Expand Down
4 changes: 2 additions & 2 deletions adit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
from faker import Faker
from playwright.sync_api import Locator, Page, Response

from adit.accounts.factories import InstituteFactory, UserFactory
from adit.accounts.models import Institute, User
from adit.core.factories import (
DicomNodeInstituteAccessFactory,
DicomServerFactory,
DicomWebServerFactory,
)
from adit.core.models import DicomNode, DicomServer
from adit.shared.accounts.factories import InstituteFactory, UserFactory
from adit.shared.accounts.models import Institute, User
from adit.testing import ChannelsLiveServer

fake = Faker()
Expand Down
2 changes: 1 addition & 1 deletion adit/core/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from faker import Faker
from pydicom.uid import generate_uid

from adit.accounts.factories import UserFactory
from adit.shared.accounts.factories import UserFactory

from .models import (
DicomFolder,
Expand Down
2 changes: 1 addition & 1 deletion adit/core/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.forms import ModelChoiceField, fields, forms
from django.template.defaultfilters import filesizeformat

from adit.accounts.models import User
from adit.shared.accounts.models import User

from .models import DicomNode
from .widgets import DicomNodeSelect
Expand Down
2 changes: 1 addition & 1 deletion adit/core/management/commands/create_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.auth.models import UserManager
from django.core.management.base import BaseCommand

from adit.accounts.models import User
from adit.shared.accounts.models import User


class Command(BaseCommand):
Expand Down
4 changes: 2 additions & 2 deletions adit/core/management/commands/populate_dev_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from django.core.management.base import BaseCommand
from faker import Faker

from adit.accounts.factories import AdminUserFactory, InstituteFactory, UserFactory
from adit.accounts.models import Institute, User
from adit.batch_query.factories import (
BatchQueryJobFactory,
BatchQueryResultFactory,
Expand All @@ -27,6 +25,8 @@
SelectiveTransferJobFactory,
SelectiveTransferTaskFactory,
)
from adit.shared.accounts.factories import AdminUserFactory, InstituteFactory, UserFactory
from adit.shared.accounts.models import Institute, User

USER_COUNT = 20
INSTITUTE_COUNT = 3
Expand Down
2 changes: 1 addition & 1 deletion adit/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.db import models
from django.db.models.constraints import UniqueConstraint

from adit.accounts.models import Institute, User
from adit.shared.accounts.models import Institute, User

from .validators import (
no_backslash_char_validator,
Expand Down
2 changes: 1 addition & 1 deletion adit/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.utils import timezone
from sherlock import Lock

from adit.accounts.models import User
from adit.shared.accounts.models import User

from .errors import RetriableError
from .models import AppSettings, DicomFolder, DicomJob, DicomTask
Expand Down
2 changes: 1 addition & 1 deletion adit/core/tests/utils/test_transfer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from celery import Task as CeleryTask
from pydicom import Dataset

from adit.accounts.factories import UserFactory
from adit.core.utils.dicom_dataset import ResultDataset
from adit.shared.accounts.factories import UserFactory

from ...factories import (
DicomFolderFactory,
Expand Down
2 changes: 1 addition & 1 deletion adit/core/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.http import HttpRequest
from rest_framework.request import Request

from adit.accounts.models import User
from adit.shared.accounts.models import User


class AuthenticatedHttpRequest(HttpRequest):
Expand Down
2 changes: 1 addition & 1 deletion adit/core/utils/auth_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.contrib.auth.models import AbstractBaseUser, AnonymousUser

from adit.accounts.models import User
from adit.shared.accounts.models import User


def is_logged_in_user(user: AbstractBaseUser | AnonymousUser) -> TypeGuard[User]:
Expand Down
2 changes: 1 addition & 1 deletion adit/core/utils/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.template.loader import render_to_string
from django.utils.html import strip_tags

from adit.accounts.models import User
from adit.shared.accounts.models import User


def send_mail_to_admins(
Expand Down
2 changes: 1 addition & 1 deletion adit/dicom_explorer/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def register_app():


def init_db(**kwargs):
from adit.accounts.utils import create_group_with_permissions
from adit.shared.accounts.utils import create_group_with_permissions

create_group_with_permissions(
"dicom_explorer_group",
Expand Down
4 changes: 2 additions & 2 deletions adit/dicom_web/tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from django.conf import settings
from django.contrib.auth.models import Group

from adit.accounts.factories import UserFactory
from adit.core.utils.dicom_utils import read_dataset
from adit.token_authentication.factories import TokenFactory
from adit.shared.accounts.factories import UserFactory
from adit.shared.token_authentication.factories import TokenFactory

# Workaround to make playwright work with Django
# see https://github.com/microsoft/playwright-pytest/issues/29#issuecomment-731515676
Expand Down
2 changes: 1 addition & 1 deletion adit/selective_transfer/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def init_db(**kwargs):


def create_group():
from adit.accounts.utils import create_group_with_permissions
from adit.shared.accounts.utils import create_group_with_permissions

create_group_with_permissions(
"selective_transfer_group",
Expand Down
2 changes: 1 addition & 1 deletion adit/selective_transfer/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from django.conf import settings
from django.template.loader import render_to_string

from adit.accounts.models import User
from adit.core.utils.dicom_dataset import ResultDataset
from adit.core.utils.dicom_operator import DicomOperator
from adit.shared.accounts.models import User

from .forms import SelectiveTransferJobForm
from .mixins import SelectiveTransferJobCreateMixin
Expand Down
2 changes: 1 addition & 1 deletion adit/selective_transfer/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

from django.conf import settings

from adit.accounts.models import User
from adit.core.mixins import LockedMixin
from adit.core.utils.dicom_dataset import QueryDataset, ResultDataset
from adit.core.utils.dicom_operator import DicomOperator
from adit.shared.accounts.models import User

from .apps import SECTION_NAME
from .forms import SelectiveTransferJobForm
Expand Down
10 changes: 5 additions & 5 deletions adit/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
INSTALLED_APPS = [
"daphne",
"whitenoise.runserver_nostatic",
"adit.accounts.apps.AccountsConfig",
"adit.shared.accounts.apps.AccountsConfig",
"registration",
"django.contrib.admin",
"django.contrib.auth",
Expand All @@ -68,7 +68,7 @@
"adit.batch_query.apps.BatchQueryConfig",
"adit.batch_transfer.apps.BatchTransferConfig",
"adit.dicom_explorer.apps.DicomExplorerConfig",
"adit.token_authentication.apps.TokenAuthenticationConfig",
"adit.shared.token_authentication.apps.TokenAuthenticationConfig",
"adit.dicom_web.apps.DicomWebConfig",
"channels",
]
Expand All @@ -93,7 +93,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": [BASE_DIR / "adit" / "shared" / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down Expand Up @@ -224,7 +224,7 @@
"rest_framework.permissions.IsAuthenticated",
],
"DEFAULT_AUTHENTICATION_CLASSES": [
"adit.token_authentication.auth.RestTokenAuthentication",
"adit.shared.token_authentication.auth.RestTokenAuthentication",
],
"EXCEPTION_HANDLER": "adit.dicom_web.exceptions.dicom_web_exception_handler",
}
Expand Down Expand Up @@ -280,7 +280,7 @@
]

# Settings for django-registration-redux
REGISTRATION_FORM = "adit.accounts.forms.RegistrationForm"
REGISTRATION_FORM = "adit.shared.accounts.forms.RegistrationForm"
ACCOUNT_ACTIVATION_DAYS = 14
REGISTRATION_OPEN = True

Expand Down
Loading