- {{ domain|display:'key' }}
- {{ domain|display:'name' }}
+ {{ coding_list|display:'key' }}
+ {{ coding_list|display:'name' }}
-
+
{% translate 'get pseudonym' %}
diff --git a/castellum/execution/templates/execution/study_export.html b/castellum/execution/templates/execution/study_export.html
index d1ff65109e4aa48032b8814381190935ab3b6ceb..afd8ea8ed0101a3c25ee31e947ab2ac613083993 100644
--- a/castellum/execution/templates/execution/study_export.html
+++ b/castellum/execution/templates/execution/study_export.html
@@ -6,7 +6,7 @@
{% block content %}
{% endblock %}
diff --git a/castellum/execution/templates/execution/study_resolve.html b/castellum/execution/templates/execution/study_resolve.html
index 71b27716d3b12e5ac67c41f02329e67df115ed85..7f7da3f346099071398d87cd97e96c1b7da2ba81 100644
--- a/castellum/execution/templates/execution/study_resolve.html
+++ b/castellum/execution/templates/execution/study_resolve.html
@@ -6,10 +6,10 @@
{% include 'utils/form_errors.html' with form=form %}
{% csrf_token %}
- {% if form.domain.field.choices|length != 1 %}
- {% bootstrap_field form.domain %}
+ {% if form.coding_list.field.choices|length != 1 %}
+ {% bootstrap_field form.coding_list %}
{% else %}
- {{ form.domain.as_hidden }}
+ {{ form.coding_list.as_hidden }}
{% endif %}
{% bootstrap_field form.pseudonym %}
diff --git a/castellum/execution/urls.py b/castellum/execution/urls.py
index bbe9c6426427740c996103c93d80fae3728df600..d904b0eee3acf24525c93a69fa2029672d3d016a 100644
--- a/castellum/execution/urls.py
+++ b/castellum/execution/urls.py
@@ -22,7 +22,7 @@ from django.conf import settings
from django.urls import path
from .api import APIAttributesView
-from .api import APIDomainsView
+from .api import APICodingListsView
from .api import APIPseudonymsView
from .api import APIResolveView
from .api import APIValidateView
@@ -74,7 +74,7 @@ urlpatterns = [
name='participation-pseudonyms',
),
path(
- '//pseudonyms//',
+ '//pseudonyms//',
ParticipationPseudonymView.as_view(),
name='participation-pseudonym',
),
@@ -127,15 +127,34 @@ urlpatterns = [
if settings.CASTELLUM_API_ENABLED:
urlpatterns += [
- path('api/studies//domains/', APIDomainsView.as_view()),
- path('api/studies//domains//', APIPseudonymsView.as_view()),
- path('api/studies//domains///', APIValidateView.as_view()),
+ path('api/studies//coding-lists/', APICodingListsView.as_view()),
+ path('api/studies//coding-lists//', APIPseudonymsView.as_view()),
path(
- 'api/studies//domains///attributes/',
+ 'api/studies//coding-lists///',
+ APIValidateView.as_view(),
+ ),
+ path(
+ 'api/studies//coding-lists///attributes/',
+ APIAttributesView.as_view(),
+ ),
+ path(
+ 'api/studies//coding-lists////', # noqa
+ APIResolveView.as_view(),
+ ),
+
+ # deprecated aliases
+ path('api/studies//domains/', APICodingListsView.as_view()),
+ path('api/studies//domains//', APIPseudonymsView.as_view()),
+ path(
+ 'api/studies//domains///',
+ APIValidateView.as_view(),
+ ),
+ path(
+ 'api/studies//domains///attributes/',
APIAttributesView.as_view(),
),
path(
- 'api/studies//domains////',
+ 'api/studies//domains////', # noqa
APIResolveView.as_view(),
),
]
diff --git a/castellum/execution/views.py b/castellum/execution/views.py
index c2a6b3f07711956ed39c86149b680e8ea2989c2d..96516344fed68c8c8a9deca651443ca9d20db048 100644
--- a/castellum/execution/views.py
+++ b/castellum/execution/views.py
@@ -46,11 +46,11 @@ from castellum.appointments.mixins import BaseCalendarView
from castellum.appointments.mixins import SchedulerFetchStudyMixin
from castellum.castellum_auth.mixins import PermissionRequiredMixin
from castellum.contacts.mixins import BaseContactUpdateView
-from castellum.pseudonyms.forms import DomainForm
+from castellum.pseudonyms.forms import CodingListForm
from castellum.pseudonyms.forms import PseudonymForm
from castellum.pseudonyms.helpers import get_pseudonym
from castellum.pseudonyms.helpers import get_subject
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.recruitment.attribute_exporters import get_exporter
from castellum.recruitment.mixins import BaseAttributesUpdateView
from castellum.recruitment.mixins import ParticipationMixin
@@ -112,10 +112,10 @@ class ExportView(StudyMixin, PermissionRequiredMixin, DetailView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
- context['form'] = DomainForm(context=self.study)
+ context['form'] = CodingListForm(context=self.study)
return context
- def export(self, domain):
+ def export(self, coding_list):
exporter = get_exporter()
descriptions = self.study.exportable_attributes.all()
response = HttpResponse(content_type='application/zip')
@@ -127,7 +127,7 @@ class ExportView(StudyMixin, PermissionRequiredMixin, DetailView):
.filter(status=Participation.INVITED)
.select_related('subject')
):
- pseudonym = get_pseudonym(participation.subject, domain.key)
+ pseudonym = get_pseudonym(participation.subject, coding_list.key)
subjects.append((pseudonym, participation.subject))
filename = exporter.get_schema_filename()
@@ -152,12 +152,14 @@ class ExportView(StudyMixin, PermissionRequiredMixin, DetailView):
self.study.get_exportable_attributes_max_privacy_level(),
)):
raise PermissionDenied
- if 'domain' in self.request.GET:
- domain = get_object_or_404(self.study.domains.all(), key=self.request.GET['domain'])
- return self.export(domain)
- elif self.study.domains.count() == 1:
- domain = self.study.domains.get()
- return self.export(domain)
+ if 'coding_list' in self.request.GET:
+ coding_list = get_object_or_404(
+ self.study.coding_lists.all(), key=self.request.GET['coding_list']
+ )
+ return self.export(coding_list)
+ elif self.study.coding_lists.count() == 1:
+ coding_list = self.study.coding_lists.get()
+ return self.export(coding_list)
else:
return super().get(request, **kwargs)
@@ -178,9 +180,9 @@ class ParticipationDetailView(ParticipationDetailMixin, DetailView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
- context['domains'] = [
- *self.study.domains.all(),
- *self.study.general_domains.filter(managers=self.request.user),
+ context['coding_lists'] = [
+ *self.study.coding_lists.all(),
+ *self.study.general_coding_lists.filter(managers=self.request.user),
]
return context
@@ -205,7 +207,7 @@ class ParticipationPseudonymsView(ParticipationDetailMixin, DetailView):
context['subject'] = None
context['participation'] = None
- context['domains'] = self.study.domains.all()
+ context['coding_lists'] = self.study.coding_lists.all()
return context
@@ -221,15 +223,15 @@ class ParticipationPseudonymView(ParticipationDetailMixin, View):
)
def get(self, request, *args, **kwargs):
- qs = Domain.objects.filter(
- models.Q(pk__in=self.study.domains.all())
- | models.Q(pk__in=self.study.general_domains.filter(managers=request.user))
+ qs = CodingList.objects.filter(
+ models.Q(pk__in=self.study.coding_lists.all())
+ | models.Q(pk__in=self.study.general_coding_lists.filter(managers=request.user))
)
- domain = get_object_or_404(qs, key=kwargs['domain'])
- pseudonym = get_pseudonym(self.subject, domain.key)
+ coding_list = get_object_or_404(qs, key=kwargs['coding_list'])
+ pseudonym = get_pseudonym(self.subject, coding_list.key)
- monitoring_logger.info('Pseudonym access: domain {} by {}'.format(
- domain.key, self.request.user.pk
+ monitoring_logger.info('Pseudonym access: coding_list {} by {}'.format(
+ coding_list.key, self.request.user.pk
))
return HttpResponse(pseudonym)
@@ -326,7 +328,7 @@ class ResolveView(StudyMixin, PermissionRequiredMixin, FormView):
def form_valid(self, form):
try:
- subject = get_subject(form.cleaned_data['domain'], form.cleaned_data['pseudonym'])
+ subject = get_subject(form.cleaned_data['coding_list'], form.cleaned_data['pseudonym'])
participation = Participation.objects.filter(
study=self.study,
subject=subject,
diff --git a/castellum/pseudonyms/admin.py b/castellum/pseudonyms/admin.py
index 7da5b3139d87a3f937205ae42e7c5e90e0220ab9..3d4203ca7776765b508bb7520f41a043a03af949 100644
--- a/castellum/pseudonyms/admin.py
+++ b/castellum/pseudonyms/admin.py
@@ -23,10 +23,10 @@ from django.contrib import admin
from . import models
-class DomainAdmin(admin.ModelAdmin):
+class CodingListAdmin(admin.ModelAdmin):
readonly_fields = ['key']
search_fields = ['name', 'key']
-admin.site.register(models.Domain, DomainAdmin)
+admin.site.register(models.CodingList, CodingListAdmin)
admin.site.register(models.Pseudonym)
diff --git a/castellum/pseudonyms/forms.py b/castellum/pseudonyms/forms.py
index 800e2406782c72e3c104b745a608df54348c1303..5f9c9441e997008761a8c8fd9ff1a21ac83abee4 100644
--- a/castellum/pseudonyms/forms.py
+++ b/castellum/pseudonyms/forms.py
@@ -33,20 +33,20 @@ class PseudonymField(forms.CharField):
raise ValidationError(_('Invalid pseudonym'), code='invalid')
-class DomainForm(forms.Form):
- domain = forms.ChoiceField(label=_('Domain'))
+class CodingListForm(forms.Form):
+ coding_list = forms.ChoiceField(label=_('Coding list'))
def __init__(self, *args, context, **kwargs):
super().__init__(*args, **kwargs)
- self.fields['domain'].choices = [(d.key, str(d)) for d in context.domains.all()]
- if self.fields['domain'].choices:
- self.fields['domain'].initial = self.fields['domain'].choices[0][0]
+ self.fields['coding_list'].choices = [(d.key, str(d)) for d in context.coding_lists.all()]
+ if self.fields['coding_list'].choices:
+ self.fields['coding_list'].initial = self.fields['coding_list'].choices[0][0]
else:
- self.fields['domain'].disabled = True
+ self.fields['coding_list'].disabled = True
self.cleaned_data = {}
- self.add_error(None, _('All pseudonym domains have been deleted.'))
+ self.add_error(None, _('All coding lists have been deleted.'))
-class PseudonymForm(DomainForm):
+class PseudonymForm(CodingListForm):
pseudonym = PseudonymField(label=_('Pseudonym'))
diff --git a/castellum/pseudonyms/helpers.py b/castellum/pseudonyms/helpers.py
index e79527fe54a0e632fbb2c6fccfe27698e26deed4..792a316288a5412d1bb4de5119597e48d57670b9 100644
--- a/castellum/pseudonyms/helpers.py
+++ b/castellum/pseudonyms/helpers.py
@@ -22,7 +22,7 @@ from django.db.utils import IntegrityError
from castellum.subjects.models import Subject
-from .models import Domain
+from .models import CodingList
from .models import Pseudonym
@@ -35,27 +35,30 @@ def attempt(fn, attempts=10):
return attempt(fn, attempts=attempts - 1)
-def get_subject(domain_key, pseudonym):
- return Subject.objects.get(pseudonym__domain__key=domain_key, pseudonym__pseudonym=pseudonym)
+def get_subject(coding_list_key, pseudonym):
+ return Subject.objects.get(
+ pseudonym__coding_list__key=coding_list_key,
+ pseudonym__pseudonym=pseudonym,
+ )
-def get_pseudonym(subject, target_domain_key):
- target_domain = Domain.objects.get(key=target_domain_key)
+def get_pseudonym(subject, target_coding_list_key):
+ target_coding_list = CodingList.objects.get(key=target_coding_list_key)
target, __ = attempt(
- lambda: Pseudonym.objects.get_or_create(subject=subject, domain=target_domain)
+ lambda: Pseudonym.objects.get_or_create(subject=subject, coding_list=target_coding_list)
)
return target.pseudonym
-def get_pseudonym_if_exists(subject, target_domain_key):
+def get_pseudonym_if_exists(subject, target_coding_list_key):
# You should use ``get_pseudonym()`` in most cases as it does not
# leak whether a pseudony exists.
- target_domain = Domain.objects.get(key=target_domain_key)
- target = Pseudonym.objects.filter(subject=subject, domain=target_domain).first()
+ target_coding_list = CodingList.objects.get(key=target_coding_list_key)
+ target = Pseudonym.objects.filter(subject=subject, coding_list=target_coding_list).first()
return target.pseudonym if target else None
-def delete_pseudonym(domain_key, pseudonym):
- p = Pseudonym.objects.get(domain__key=domain_key, pseudonym=pseudonym)
+def delete_pseudonym(coding_list_key, pseudonym):
+ p = Pseudonym.objects.get(coding_list__key=coding_list_key, pseudonym=pseudonym)
p.subject = None
p.save()
diff --git a/castellum/pseudonyms/migrations/0009_rename_domain_coding_list.py b/castellum/pseudonyms/migrations/0009_rename_domain_coding_list.py
new file mode 100644
index 0000000000000000000000000000000000000000..c8b736d86092b56dce12bd0f5c62a2b1f5046c8d
--- /dev/null
+++ b/castellum/pseudonyms/migrations/0009_rename_domain_coding_list.py
@@ -0,0 +1,32 @@
+# Generated by Django 3.2.12 on 2022-03-22 16:22
+
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('subjects', '0037_alter_subject_privacy_level'),
+ ('pseudonyms', '0008_domain_managers'),
+ ('studies', '0047_rename_domain_conding_list'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='pseudonym',
+ old_name='domain',
+ new_name='coding_list',
+ ),
+ migrations.AlterUniqueTogether(
+ name='pseudonym',
+ unique_together={('coding_list', 'pseudonym'), ('coding_list', 'subject')},
+ ),
+ migrations.RenameModel('Domain', 'CodingList'),
+ migrations.AlterField(
+ model_name='codinglist',
+ name='managers',
+ field=models.ManyToManyField(blank=True, related_name='general_coding_lists', to=settings.AUTH_USER_MODEL, verbose_name='Users who can access this coding list'),
+ ),
+ ]
diff --git a/castellum/pseudonyms/models.py b/castellum/pseudonyms/models.py
index 0880304b44ccb3fe899071b709c5588fdb910b1e..4423fcdd74fcdc9f82b303e7dba3dda6b28bb904 100644
--- a/castellum/pseudonyms/models.py
+++ b/castellum/pseudonyms/models.py
@@ -29,7 +29,7 @@ from castellum.subjects.models import Subject
from castellum.utils import uuid_str
-class Domain(models.Model):
+class CodingList(models.Model):
key = models.CharField(max_length=64, default=uuid_str, unique=True, editable=False)
name = models.CharField(max_length=64, blank=True)
bits = models.PositiveIntegerField(default=40)
@@ -40,8 +40,8 @@ class Domain(models.Model):
managers = models.ManyToManyField(
User,
- verbose_name=_('Users who can access this domain'),
- related_name='general_domains',
+ verbose_name=_('Users who can access this coding list'),
+ related_name='general_coding_lists',
blank=True,
)
exportable_attributes = models.ManyToManyField(
@@ -65,13 +65,13 @@ class Domain(models.Model):
class Pseudonym(models.Model):
subject = models.ForeignKey(Subject, on_delete=models.SET_NULL, blank=True, null=True)
- domain = models.ForeignKey(Domain, on_delete=models.CASCADE)
+ coding_list = models.ForeignKey(CodingList, on_delete=models.CASCADE)
pseudonym = models.CharField(max_length=64, default=None)
class Meta:
unique_together = [
- ['domain', 'pseudonym'],
- ['domain', 'subject'],
+ ['coding_list', 'pseudonym'],
+ ['coding_list', 'subject'],
]
def __str__(self):
@@ -79,5 +79,5 @@ class Pseudonym(models.Model):
def save(self, *args, **kwargs):
if not self.pseudonym:
- self.pseudonym = settings.CASTELLUM_PSEUDONYM_GENERATE(self.domain.bits)
+ self.pseudonym = settings.CASTELLUM_PSEUDONYM_GENERATE(self.coding_list.bits)
super().save(*args, **kwargs)
diff --git a/castellum/recruitment/management/commands/create_demo_content.py b/castellum/recruitment/management/commands/create_demo_content.py
index 199b1055b9e32b499d136d02385b46e576199975..fbba8b637dac01ca4fee88b27c2ffb1580f29e70 100644
--- a/castellum/recruitment/management/commands/create_demo_content.py
+++ b/castellum/recruitment/management/commands/create_demo_content.py
@@ -33,7 +33,7 @@ from castellum.contacts.models import Address
from castellum.contacts.models import Contact
from castellum.contacts.models import Street
from castellum.contacts.models import phonetic
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.recruitment.models import AttributeChoice
from castellum.studies.models import Study
from castellum.studies.models import StudySession
@@ -219,8 +219,8 @@ def generate_studies(count, stdout):
continue
i += 1
- Domain.objects.create(
- bits=settings.CASTELLUM_STUDY_DOMAIN_BITS,
+ CodingList.objects.create(
+ bits=settings.CASTELLUM_STUDY_PSEUDONYM_BITS,
context=study,
)
diff --git a/castellum/recruitment/signals.py b/castellum/recruitment/signals.py
index 88c9bc68aea4ff6a86a3fcda5b30d93a41d26884..76eaef1ba98d1b8ca12f3f65d1cf78c248536515 100644
--- a/castellum/recruitment/signals.py
+++ b/castellum/recruitment/signals.py
@@ -28,7 +28,7 @@ def delete_participation_pseudonyms(sender, instance, using, **kwargs):
if sender is Participation:
Pseudonym.objects.filter(
- domain__in=instance.study.domains.all(), subject=instance.subject
+ coding_list__in=instance.study.coding_lists.all(), subject=instance.subject
).update(subject=None)
diff --git a/castellum/settings/default/__init__.py b/castellum/settings/default/__init__.py
index 1b69830fab45906bdc4aae78e42cbeb27eb9ecae..9a74685cb24b6b54386efbda2e1a3c055dcae113 100644
--- a/castellum/settings/default/__init__.py
+++ b/castellum/settings/default/__init__.py
@@ -126,8 +126,8 @@ CASTELLUM_PSEUDONYM_GENERATE = castellum_pseudonyms.generate
# See also https://docs.djangoproject.com/en/stable/ref/forms/fields/#django.forms.Field.clean
CASTELLUM_PSEUDONYM_CLEAN = castellum_pseudonyms.clean
-CASTELLUM_STUDY_DOMAIN_BITS = 20
-CASTELLUM_SESSION_DOMAIN_BITS = 20
+CASTELLUM_STUDY_PSEUDONYM_BITS = 20
+CASTELLUM_SESSION_PSEUDONYM_BITS = 20
# Path to a cover letter template
# Must be in .docx format
@@ -157,18 +157,18 @@ CASTELLUM_ATTRIBUTE_EXPORTER = 'castellum.recruitment.attribute_exporters.JSONEx
# /studies/api/studies/?status=
# basic metadata of a study
# /studies/api/studies//
-# list of study domains:
-# /execution/api/studies//domains/
-# list of pseudonyms in a domain:
-# /execution/api/studies//domains//
+# list of study coding lists:
+# /execution/api/studies//coding-lists/
+# list of pseudonyms in a coding list:
+# /execution/api/studies//coding-lists//
# validate a single pseudonym
-# /execution/api/studies//domains///
+# /execution/api/studies//coding-lists///
# get exportable attributes:
-# /execution/api/studies//domains///attributes/
-# resolve pseudonym to a target domain (can also be a general domain):
-# /execution/api/studies//domains////
-# get exportable attributes for general domains
-# /subjects/api/subjects///attributes/
+# /execution/api/studies//coding-lists///attributes/
+# resolve pseudonym to a target coding list (can also be a general coding list):
+# /execution/api/studies//coding-lists////
+# get exportable attributes for general coding lists
+# /subjects/api/subjects///attributes/
CASTELLUM_API_ENABLED = False
# If you want to allow external services to automatically add subjects
diff --git a/castellum/studies/apps.py b/castellum/studies/apps.py
index 4d9c19b5218297414d4b2a5977699b7a4f73f930..118a11f2a8cf516f0b2ba89c4fbe3638e138fa2f 100644
--- a/castellum/studies/apps.py
+++ b/castellum/studies/apps.py
@@ -29,7 +29,7 @@ class StudiesConfig(AppConfig):
name = 'castellum.studies'
def ready(self):
- pre_delete.connect(signals.delete_study_domain)
+ pre_delete.connect(signals.delete_study_coding_list)
- post_save.connect(signals.create_session_domain)
- pre_delete.connect(signals.delete_session_domain)
+ post_save.connect(signals.create_session_coding_list)
+ pre_delete.connect(signals.delete_session_coding_list)
diff --git a/castellum/studies/migrations/0047_rename_domain_conding_list.py b/castellum/studies/migrations/0047_rename_domain_conding_list.py
new file mode 100644
index 0000000000000000000000000000000000000000..82f7e99635bee45d648365b7131553eb02085c1f
--- /dev/null
+++ b/castellum/studies/migrations/0047_rename_domain_conding_list.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.2.12 on 2022-03-22 16:22
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('studies', '0046_rename_study_is_onetime_invitation'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='study',
+ old_name='general_domains',
+ new_name='general_coding_lists',
+ ),
+ migrations.AlterField(
+ model_name='study',
+ name='general_coding_lists',
+ field=models.ManyToManyField(blank=True, limit_choices_to={'object_id': None}, to='pseudonyms.Domain', verbose_name='General coding lists'),
+ ),
+ ]
diff --git a/castellum/studies/models.py b/castellum/studies/models.py
index a784afc613a73cf36c6a0d87803db77594cf093a..193a71be940cf9009c8a6f3bed64ecf2ce04ef1c 100644
--- a/castellum/studies/models.py
+++ b/castellum/studies/models.py
@@ -35,7 +35,7 @@ from parler.models import TranslatableModel
from parler.models import TranslatedFields
from castellum.castellum_auth.models import User
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.utils.fields import ColorField
from castellum.utils.fields import DateField
from castellum.utils.fields import PhoneNumberField
@@ -116,10 +116,10 @@ class Study(models.Model):
snapshot = models.TextField(_('Snapshot'), blank=True, editable=False)
members = models.ManyToManyField(User, through='StudyMembership')
- domains = GenericRelation(Domain)
- general_domains = models.ManyToManyField(
- Domain,
- verbose_name=_('General pseudonym domains'),
+ coding_lists = GenericRelation(CodingList)
+ general_coding_lists = models.ManyToManyField(
+ CodingList,
+ verbose_name=_('General coding lists'),
blank=True,
limit_choices_to={'object_id': None},
)
@@ -413,7 +413,7 @@ class StudySession(models.Model):
duration = models.PositiveIntegerField(_('Duration of a session in minutes'))
type = models.ManyToManyField(StudyType, verbose_name=_('Type'), blank=True)
resources = models.ManyToManyField(Resource, verbose_name=_('Resources'), blank=True)
- domains = GenericRelation(Domain)
+ coding_lists = GenericRelation(CodingList)
reminder_text = models.TextField(_('Additional text for reminder emails'), blank=True)
schedule_id = models.CharField(
_('External schedule ID'), max_length=64, blank=True, null=True, unique=True
@@ -424,10 +424,10 @@ class StudySession(models.Model):
return '{} - {}'.format(self.study, self.name)
@property
- def domain(self):
- domain = self.domains.first()
- if domain:
- return domain.key
+ def coding_list_key(self):
+ coding_list = self.coding_lists.first()
+ if coding_list:
+ return coding_list.key
class StudyTag(models.Model):
diff --git a/castellum/studies/signals.py b/castellum/studies/signals.py
index 108685d2999710ebc7e8dfd2e0fcaa640a79918b..824daec5c71ddf9d3218777f8f24de8809934210 100644
--- a/castellum/studies/signals.py
+++ b/castellum/studies/signals.py
@@ -21,26 +21,26 @@
from django.conf import settings
-def delete_study_domain(sender, instance, using, **kwargs):
+def delete_study_coding_list(sender, instance, using, **kwargs):
from castellum.studies.models import Study
if sender is Study:
- instance.domains.all().delete()
+ instance.coding_lists.all().delete()
-def create_session_domain(sender, instance, using, **kwargs):
- from castellum.pseudonyms.models import Domain
+def create_session_coding_list(sender, instance, using, **kwargs):
+ from castellum.pseudonyms.models import CodingList
from castellum.studies.models import StudySession
- if sender is StudySession and not instance.domains.exists():
- Domain.objects.create(
- bits=settings.CASTELLUM_SESSION_DOMAIN_BITS,
+ if sender is StudySession and not instance.coding_lists.exists():
+ CodingList.objects.create(
+ bits=settings.CASTELLUM_SESSION_PSEUDONYM_BITS,
context=instance,
)
-def delete_session_domain(sender, instance, using, **kwargs):
+def delete_session_coding_list(sender, instance, using, **kwargs):
from castellum.studies.models import StudySession
if sender is StudySession:
- instance.domains.all().delete()
+ instance.coding_lists.all().delete()
diff --git a/castellum/studies/templates/studies/domain_confirm_delete.html b/castellum/studies/templates/studies/coding_list_confirm_delete.html
similarity index 62%
rename from castellum/studies/templates/studies/domain_confirm_delete.html
rename to castellum/studies/templates/studies/coding_list_confirm_delete.html
index 6ac74f557dcc3103593053361a473b5000906bd7..c74ccca1a5551d6343f36a0c60f884e5d0f26dc9 100644
--- a/castellum/studies/templates/studies/domain_confirm_delete.html
+++ b/castellum/studies/templates/studies/coding_list_confirm_delete.html
@@ -1,21 +1,21 @@
-{% extends "studies/study_domains_base.html" %}
+{% extends "studies/study_coding_lists_base.html" %}
{% load i18n auth django_bootstrap5 utils %}
-{% block title %}{% translate "Delete" %} · {% translate "Study domains" %} · {{ block.super }}{% endblock %}
+{% block title %}{% translate "Delete" %} · {% translate "Study coding lists" %} · {{ block.super }}{% endblock %}
{% block content %}
diff --git a/castellum/studies/templates/studies/study_base.html b/castellum/studies/templates/studies/study_base.html
index c04a10b257ffc0345443ed3df1435faadb38c50c..f77d9d20c205a2d6dc815022eb125ede348a38b0 100644
--- a/castellum/studies/templates/studies/study_base.html
+++ b/castellum/studies/templates/studies/study_base.html
@@ -128,7 +128,7 @@
{% translate 'Member management' %}
- {% translate 'Pseudonym domains' %}
+ {% translate 'Coding lists' %}
{% translate 'Sessions' %}
diff --git a/castellum/studies/templates/studies/study_domains_base.html b/castellum/studies/templates/studies/study_coding_lists_base.html
similarity index 53%
rename from castellum/studies/templates/studies/study_domains_base.html
rename to castellum/studies/templates/studies/study_coding_lists_base.html
index 21cd0395dc4f7b2e5fc85250e872174f65380ca6..6bbbb84942e8cbab7b7e2741e00f4aa623624a86 100644
--- a/castellum/studies/templates/studies/study_domains_base.html
+++ b/castellum/studies/templates/studies/study_coding_lists_base.html
@@ -1,15 +1,15 @@
{% extends "studies/study_base.html" %}
{% load i18n auth django_bootstrap5 utils %}
-{% block container_class %}{% if general_domains_exist %}container-lg{% else %}container{% endif %}{% endblock %}
+{% block container_class %}{% if general_coding_lists_exist %}container-lg{% else %}container{% endif %}{% endblock %}
{% block content_with_messages %}
- {% if general_domains_exist %}
+ {% if general_coding_lists_exist %}
diff --git a/castellum/studies/templates/studies/study_coding_lists_general.html b/castellum/studies/templates/studies/study_coding_lists_general.html
new file mode 100644
index 0000000000000000000000000000000000000000..2d81e16ef6c486a6c33373a50b81732a0904b787
--- /dev/null
+++ b/castellum/studies/templates/studies/study_coding_lists_general.html
@@ -0,0 +1,14 @@
+{% extends "studies/study_coding_lists_base.html" %}
+{% load i18n auth django_bootstrap5 utils %}
+
+{% block title %}{% translate "General coding lists" %} · {{ block.super }}{% endblock %}
+
+{% block content %}
+
+{% endblock %}
diff --git a/castellum/studies/templates/studies/study_domains_study.html b/castellum/studies/templates/studies/study_coding_lists_study.html
similarity index 55%
rename from castellum/studies/templates/studies/study_domains_study.html
rename to castellum/studies/templates/studies/study_coding_lists_study.html
index 6b1afc7acb0d921da40fd345d1b5e367054c183f..af53a8af55ea5b19ea58ee7478617513c7dcccef 100644
--- a/castellum/studies/templates/studies/study_domains_study.html
+++ b/castellum/studies/templates/studies/study_coding_lists_study.html
@@ -1,29 +1,29 @@
-{% extends "studies/study_domains_base.html" %}
+{% extends "studies/study_coding_lists_base.html" %}
{% load i18n auth django_bootstrap5 utils %}
-{% block title %}{% translate "Study domains" %} · {{ block.super }}{% endblock %}
+{% block title %}{% translate "Study coding lists" %} · {{ block.super }}{% endblock %}
{% block content %}
-
{% translate 'Pseudonyms allow you to store data about subjects without their names and other identifying data. Often it is sufficient to have one pseudonym per subject and study. However, if you need more than that you can create additional pseudonym domains. Note that a pseudonym is only meaningful in combination with its domain.' %}
+
{% translate 'Pseudonyms allow you to store data about subjects without their names and other identifying data. Often it is sufficient to have one pseudonym per subject and study. However, if you need more than that you can create additional coding lists. Note that a pseudonym is only meaningful in combination with its coding list.' %}
- {% for domain in study.domains.all %}
+ {% for coding_list in study.coding_lists.all %}
@@ -43,6 +43,6 @@
{% endblock %}
diff --git a/castellum/studies/templates/studies/study_diff.html b/castellum/studies/templates/studies/study_diff.html
index c17853c47007d35ffae7b198e1363f15d6984920..cba86dbda147a06114cede0bc965cf2a4ba347a6 100644
--- a/castellum/studies/templates/studies/study_diff.html
+++ b/castellum/studies/templates/studies/study_diff.html
@@ -49,11 +49,11 @@
{% translate 'Tags' %}
{% diff_get study 'studytag_set' as items %}{% diff_list items %}
-
{% translate 'Domains' %}
-
{% diff_get study 'domains' as items %}{% diff_list items %}
+
{% translate 'Coding lists' %}
+
{% diff_get study 'coding_lists' as items %}{% diff_list items %}
-
{{ study|verbose_name:'general_domains' }}
-
{% diff_get study 'general_domains' as items %}{% diff_list items %}
+
{{ study|verbose_name:'general_coding_lists' }}
+
{% diff_get study 'general_coding_lists' as items %}{% diff_list items %}
{{ study|verbose_name:'exportable_attributes' }}
{% diff_get study 'exportable_attributes' as items %}{% diff_list items %}
diff --git a/castellum/studies/templates/studies/study_domains_general.html b/castellum/studies/templates/studies/study_domains_general.html
deleted file mode 100644
index fc3fa2f14e3ceeb54aff86215fcfac9b345fccea..0000000000000000000000000000000000000000
--- a/castellum/studies/templates/studies/study_domains_general.html
+++ /dev/null
@@ -1,14 +0,0 @@
-{% extends "studies/study_domains_base.html" %}
-{% load i18n auth django_bootstrap5 utils %}
-
-{% block title %}{% translate "General domains" %} · {{ block.super }}{% endblock %}
-
-{% block content %}
-
-{% endblock %}
diff --git a/castellum/studies/urls/__init__.py b/castellum/studies/urls/__init__.py
index 9e54a76ae6f3057d0c015d922919f41781140f61..f8c6ea32b02220dc4c3fb561044df4eeea5ccbf2 100644
--- a/castellum/studies/urls/__init__.py
+++ b/castellum/studies/urls/__init__.py
@@ -26,13 +26,13 @@ from ..views.api import APIStudyDetailView
from ..views.api import APIStudyListView
from ..views.recruitment import AnonymousInvitationMailRecruitmentView
from ..views.studies import FilterTrialCreateView
+from ..views.studies import StudyCodingListDeleteView
+from ..views.studies import StudyCodingListsGeneralView
+from ..views.studies import StudyCodingListsView
from ..views.studies import StudyCreateView
from ..views.studies import StudyDeleteView
from ..views.studies import StudyDetailView
from ..views.studies import StudyDiffView
-from ..views.studies import StudyDomainDeleteView
-from ..views.studies import StudyDomainsGeneralView
-from ..views.studies import StudyDomainsView
from ..views.studies import StudyExportView
from ..views.studies import StudyFinishRecruitmentView
from ..views.studies import StudyImportView
@@ -51,12 +51,16 @@ urlpatterns = [
path('
/', StudyDetailView.as_view(), name='detail'),
path('/update/', StudyUpdateView.as_view(), name='update'),
path('/delete/', StudyDeleteView.as_view(), name='delete'),
- path('/domains/', StudyDomainsView.as_view(), name='domains'),
- path('/domains/general/', StudyDomainsGeneralView.as_view(), name='domains-general'),
+ path('/coding-lists/', StudyCodingListsView.as_view(), name='coding-lists'),
path(
- '/domains//',
- StudyDomainDeleteView.as_view(),
- name='domain-delete',
+ '/coding-lists/general/',
+ StudyCodingListsGeneralView.as_view(),
+ name='coding-lists-general',
+ ),
+ path(
+ '/coding-lists//',
+ StudyCodingListDeleteView.as_view(),
+ name='coding-list-delete',
),
path('/start/', StudyStartRecruitmentView.as_view(), name='start'),
path('/finish/', StudyFinishRecruitmentView.as_view(), name='finish'),
diff --git a/castellum/studies/views/studies.py b/castellum/studies/views/studies.py
index 4a362f30bea1840034fa4a75e4c7a281ad7e4cd5..a1adce8841bff64634f553863c12e3e89b3d7474 100644
--- a/castellum/studies/views/studies.py
+++ b/castellum/studies/views/studies.py
@@ -46,7 +46,7 @@ from django.views.generic import TemplateView
from django.views.generic import UpdateView
from castellum.castellum_auth.mixins import PermissionRequiredMixin
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.recruitment import filter_queries
from castellum.recruitment.models import Participation
from castellum.recruitment.models import SubjectFilter
@@ -113,8 +113,8 @@ def take_snapshot(study):
study.snapshot = serializers.serialize('json', [
study,
*study.studymembership_set.all(),
- *study.domains.all(),
- *study.general_domains.all(),
+ *study.coding_lists.all(),
+ *study.general_coding_lists.all(),
*study.studytag_set.all(),
*study.studysession_set.all(),
*study.subjectfiltergroup_set.all(),
@@ -235,13 +235,13 @@ class StudyCreateView(PermissionRequiredMixin, CreateView):
self.object.mail_body = self.duplicate.mail_body
self.object.save()
- self.object.general_domains.set(self.duplicate.general_domains.all())
+ self.object.general_coding_lists.set(self.duplicate.general_coding_lists.all())
- for domain in self.duplicate.domains.all():
- Domain.objects.create(
- name=domain.name,
- bits=domain.bits,
- content_type=domain.content_type,
+ for coding_list in self.duplicate.coding_lists.all():
+ CodingList.objects.create(
+ name=coding_list.name,
+ bits=coding_list.bits,
+ content_type=coding_list.content_type,
object_id=self.object.pk,
)
@@ -257,8 +257,8 @@ class StudyCreateView(PermissionRequiredMixin, CreateView):
for tag in self.duplicate.executiontag_set.all():
self.object.executiontag_set.create(name=tag.name)
else:
- Domain.objects.create(
- bits=settings.CASTELLUM_STUDY_DOMAIN_BITS,
+ CodingList.objects.create(
+ bits=settings.CASTELLUM_STUDY_PSEUDONYM_BITS,
context=self.object,
)
@@ -413,40 +413,42 @@ class StudyFinishRecruitmentView(StudyMixin, PermissionRequiredMixin, View):
return redirect(get_next_url(request, reverse('studies:detail', args=[self.study.pk])))
-class StudyDomainsMixin(StudyMixin, PermissionRequiredMixin):
+class StudyCodingListsMixin(StudyMixin, PermissionRequiredMixin):
permission_required = 'studies.change_study'
is_anonymous_invitation = False
is_filter_trial = False
- tab = 'domains'
+ tab = 'coding-lists'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
- context['general_domains_exist'] = Domain.objects.filter(object_id=None).exists()
+ context['general_coding_lists_exist'] = CodingList.objects.filter(object_id=None).exists()
return context
-class StudyDomainsView(StudyDomainsMixin, TemplateView):
- template_name = 'studies/study_domains_study.html'
- subtab = 'domains-study'
+class StudyCodingListsView(StudyCodingListsMixin, TemplateView):
+ template_name = 'studies/study_coding_lists_study.html'
+ subtab = 'coding-lists-study'
def post(self, request, *args, **kwargs):
if self.request.POST.get('action') == 'add':
- self.study.domains.create(bits=settings.CASTELLUM_STUDY_DOMAIN_BITS)
+ self.study.coding_lists.create(bits=settings.CASTELLUM_STUDY_PSEUDONYM_BITS)
elif self.request.POST.get('action') == 'name':
- domain = get_object_or_404(self.study.domains.all(), key=self.request.POST['domain'])
- form_cls = modelform_factory(Domain, fields=['name'])
- form = form_cls(data=self.request.POST, instance=domain)
+ coding_list = get_object_or_404(
+ self.study.coding_lists.all(), key=self.request.POST['coding_list']
+ )
+ form_cls = modelform_factory(CodingList, fields=['name'])
+ form = form_cls(data=self.request.POST, instance=coding_list)
if form.is_valid():
form.save()
return redirect(self.request.path)
-class StudyDomainsGeneralView(StudyDomainsMixin, UpdateView):
+class StudyCodingListsGeneralView(StudyCodingListsMixin, UpdateView):
model = Study
- fields = ['general_domains']
- template_name = 'studies/study_domains_general.html'
- subtab = 'domains-general'
+ fields = ['general_coding_lists']
+ template_name = 'studies/study_coding_lists_general.html'
+ subtab = 'coding-lists-general'
def get_success_url(self):
return self.request.path
@@ -457,16 +459,16 @@ class StudyDomainsGeneralView(StudyDomainsMixin, UpdateView):
return super().form_valid(form)
-class StudyDomainDeleteView(StudyDomainsMixin, DeleteView):
- model = Domain
- template_name = 'studies/domain_confirm_delete.html'
- subtab = 'domains-study'
+class StudyCodingListDeleteView(StudyCodingListsMixin, DeleteView):
+ model = CodingList
+ template_name = 'studies/coding_list_confirm_delete.html'
+ subtab = 'coding-lists-study'
def get_object(self):
- return get_object_or_404(self.study.domains.all(), key=self.kwargs['key'])
+ return get_object_or_404(self.study.coding_lists.all(), key=self.kwargs['key'])
def get_success_url(self):
- return reverse('studies:domains', args=[self.study.pk])
+ return reverse('studies:coding-lists', args=[self.study.pk])
class StudyImportView(PermissionRequiredMixin, FormView):
diff --git a/castellum/subjects/api.py b/castellum/subjects/api.py
index e23d519c2b17fddbfd355e4fd959e83eddb0bdd6..cc30bcae49d6dcc4a29ee69339f2fed712c13d4a 100644
--- a/castellum/subjects/api.py
+++ b/castellum/subjects/api.py
@@ -46,26 +46,28 @@ class APIAttributesView(APIAuthMixin, PermissionRequiredMixin, View):
except ValueError:
raise Http404
- domain = get_object_or_404(request.user.general_domains, key=self.kwargs['domain'])
+ coding_list = get_object_or_404(
+ request.user.general_coding_lists, key=self.kwargs['coding_list']
+ )
try:
- subject = get_subject(domain.key, pseudonym)
+ subject = get_subject(coding_list.key, pseudonym)
except Subject.DoesNotExist:
raise Http404
if not self.request.user.has_privacy_level(max(
subject.privacy_level,
- domain.get_exportable_attributes_max_privacy_level(),
+ coding_list.get_exportable_attributes_max_privacy_level(),
)):
raise PermissionDenied
exporter = JSONExporter()
- descriptions = domain.exportable_attributes.all()
+ descriptions = coding_list.exportable_attributes.all()
attrs = exporter.get_subject_attributes(descriptions, subject)
- monitoring_logger.info('Attribute export: domain {} subject {} by {}'.format(
- domain.key, subject.pk, request.user.pk
+ monitoring_logger.info('Attribute export: coding_list {} subject {} by {}'.format(
+ coding_list.key, subject.pk, request.user.pk
))
return JsonResponse(attrs)
diff --git a/castellum/subjects/templates/subjects/subject_confirm_delete.html b/castellum/subjects/templates/subjects/subject_confirm_delete.html
index 1bccaaf95590b75df6550b96421668126252c752..5290e033931c25dc3cf000013d78448ecc46ad55 100644
--- a/castellum/subjects/templates/subjects/subject_confirm_delete.html
+++ b/castellum/subjects/templates/subjects/subject_confirm_delete.html
@@ -17,9 +17,9 @@
{% translate "This subject cannot be deleted because there still is data about them in studies." %}
- {% elif has_pseudonym_in_general_domain %}
+ {% elif has_pseudonym_in_general_coding_list %}
- {% translate "This subject may still have data in general domains." %}
+ {% translate "This subject may still have data in general coding lists." %}
{% else %}
@@ -27,7 +27,7 @@
{% endif %}
- {% if has_participations or has_pseudonym_in_general_domain %}
+ {% if has_participations or has_pseudonym_in_general_coding_list %}
{% if has_participations %}
@@ -60,10 +60,10 @@
{% endfor %}
- {% if has_pseudonym_in_general_domain %}
+ {% if has_pseudonym_in_general_coding_list %}
-
{% translate "General pseudonym domains" %}
+
{% translate "General coding lists" %}
{% translate 'Pseudonyms' %}
@@ -76,7 +76,7 @@
{% endif %}
{% translate "Are you sure you want to permanently delete this subject and all related data?" %}
- {% if not has_participations and has_pseudonym_in_general_domain %}
+ {% if not has_participations and has_pseudonym_in_general_coding_list %}
{% translate "I have made sure that all external data related to this subject has been destroyed" %}
@@ -84,7 +84,7 @@
{% endif %}
{% endblock %}
diff --git a/castellum/subjects/templates/subjects/subject_export.html b/castellum/subjects/templates/subjects/subject_export.html
index 36f37605e0dbba2213905a7e585b863618b3b605..e34950e706ae62a10f7cba6703d223dbe4974c87 100644
--- a/castellum/subjects/templates/subjects/subject_export.html
+++ b/castellum/subjects/templates/subjects/subject_export.html
@@ -28,7 +28,7 @@
{% endif %}
- {% if has_participations or general_domains_exist %}
+ {% if has_participations or general_coding_lists_exist %}
{% translate 'Remember to also gather information from the following external sources:' %}
@@ -55,10 +55,10 @@
{% endfor %}
- {% if general_domains_exist %}
+ {% if general_coding_lists_exist %}
-
{% translate "General pseudonym domains" %}
+
{% translate "General coding lists" %}
{% translate 'Pseudonyms' %}
diff --git a/castellum/subjects/templates/subjects/subject_pseudonyms.html b/castellum/subjects/templates/subjects/subject_pseudonyms.html
index e015019e3827dca4287c2cd2ebf89bd561c14258..02163e76354247bfde334100104d5fe58c1d8f9e 100644
--- a/castellum/subjects/templates/subjects/subject_pseudonyms.html
+++ b/castellum/subjects/templates/subjects/subject_pseudonyms.html
@@ -7,18 +7,18 @@
- {% translate 'Domain key' %}
- {% translate 'Domain name' %}
+ {% translate 'Coding list key' %}
+ {% translate 'Coding list name' %}
{% translate 'Pseudonym' %}
- {% for domain in domains %}
+ {% for coding_list in coding_lists %}
- {{ domain|display:'key' }}
- {{ domain|display:'name' }}
+ {{ coding_list|display:'key' }}
+ {{ coding_list|display:'name' }}
-
+
{% translate 'get pseudonym' %}
diff --git a/castellum/subjects/urls.py b/castellum/subjects/urls.py
index 782d2b7af952bf2d5cf7e996fdd173cf521561cc..1e850e1f82193186d6b3cfb3fa2bfecc6fae4d88 100644
--- a/castellum/subjects/urls.py
+++ b/castellum/subjects/urls.py
@@ -94,7 +94,7 @@ urlpatterns = [
path('maintenance/notes/', MaintenanceNotesView.as_view(), name='maintenance-notes'),
path('/', SubjectDetailView.as_view(), name='detail'),
path('/pseudonyms/', SubjectPseudonymsView.as_view(), name='pseudonyms'),
- path('/pseudonyms//', SubjectPseudonymView.as_view(), name='pseudonym'),
+ path('/pseudonyms//', SubjectPseudonymView.as_view(), name='pseudonym'),
path('/delete/', SubjectDeleteView.as_view(), name='delete'),
path('/export/', SubjectExportView.as_view(), name='export'),
path('/contact/', ContactUpdateView.as_view(), name='contact'),
@@ -139,5 +139,8 @@ urlpatterns = [
if settings.CASTELLUM_API_ENABLED:
urlpatterns += [
- path('api/subjects///attributes/', APIAttributesView.as_view()),
+ path(
+ 'api/subjects///attributes/',
+ APIAttributesView.as_view(),
+ ),
]
diff --git a/castellum/subjects/views.py b/castellum/subjects/views.py
index 9d5026f99468e085dc2b4d8d9390bf66334e6dde..d182c0406ebe3ace64297eab71d921b06b2b8e80 100644
--- a/castellum/subjects/views.py
+++ b/castellum/subjects/views.py
@@ -55,7 +55,7 @@ from castellum.contacts.mixins import BaseContactUpdateView
from castellum.contacts.models import Address
from castellum.contacts.models import Contact
from castellum.pseudonyms.helpers import get_pseudonym_if_exists
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.recruitment import filter_queries
from castellum.recruitment.mixins import BaseAttributesUpdateView
from castellum.recruitment.models import AttributeDescription
@@ -247,7 +247,7 @@ class SubjectPseudonymsView(SubjectMixin, PermissionRequiredMixin, DetailView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
- context['domains'] = Domain.objects.filter(object_id=None)
+ context['coding_lists'] = CodingList.objects.filter(object_id=None)
return context
@@ -262,11 +262,11 @@ class SubjectPseudonymView(SubjectMixin, PermissionRequiredMixin, View):
)
def get(self, request, *args, **kwargs):
- domain = get_object_or_404(Domain, key=kwargs['domain'], object_id=None)
- pseudonym = get_pseudonym_if_exists(self.subject, domain.key)
+ coding_list = get_object_or_404(CodingList, key=kwargs['coding_list'], object_id=None)
+ pseudonym = get_pseudonym_if_exists(self.subject, coding_list.key)
- monitoring_logger.info('Pseudonym access: domain {} by {}'.format(
- domain.key, self.request.user.pk
+ monitoring_logger.info('Pseudonym access: coding_list {} by {}'.format(
+ coding_list.key, self.request.user.pk
))
return HttpResponse(pseudonym or '—')
@@ -289,8 +289,8 @@ class SubjectDeleteView(SubjectMixin, PermissionRequiredMixin, DeleteView):
context = super().get_context_data(**kwargs)
context['has_participations'] = self.object.participation_set.exists()
context['is_last_legal_representative'] = self.is_last_legal_representative()
- context['has_pseudonym_in_general_domain'] = (
- self.subject.pseudonym_set.filter(domain__object_id=None).exists()
+ context['has_pseudonym_in_general_coding_list'] = (
+ self.subject.pseudonym_set.filter(coding_list__object_id=None).exists()
)
return context
@@ -320,7 +320,11 @@ class SubjectExportView(SubjectMixin, PermissionRequiredMixin, DetailView):
if self.object.export_requested:
context['has_participations'] = self.object.participation_set.exists()
- context['general_domains_exist'] = Domain.objects.filter(object_id=None).exists()
+ context['general_coding_lists_exist'] = (
+ CodingList.objects
+ .filter(object_id=None)
+ .exists()
+ )
context['appointments'] = Appointment.objects.filter(participation__subject=self.object)
context['notes'] = self.object.subjectnote_set.all()
diff --git a/docs/API.md b/docs/API.md
index 2db04a63f625e3ae73c0e04a4c3208b727584944..87259d62124c185c8bc3f5f7d6820816ac2f4172 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -8,12 +8,12 @@ The following API endpoints can be enabled with the
- `/studies/api/studies/?status=`
- `/studies/api/studies//`
-- `/execution/api/studies//domains/`
-- `/execution/api/studies//domains//`
-- `/execution/api/studies//domains///`
-- `/execution/api/studies//domains///attributes/`
-- `/execution/api/studies//domains////`
-- `/subjects/api/subjects///attributes/`
+- `/execution/api/studies//coding-lists/`
+- `/execution/api/studies//coding-lists//`
+- `/execution/api/studies//coding-lists///`
+- `/execution/api/studies//coding-lists///attributes/`
+- `/execution/api/studies//coding-lists////`
+- `/subjects/api/subjects///attributes/`
## Authentication
diff --git a/docs/pseudonyms.md b/docs/pseudonyms.md
index 1fd5e8048ae12157ba0f3c7fbb48fbe09bd05fab..f34c6268289cb94447db3834ef6aa980db0899d0 100644
--- a/docs/pseudonyms.md
+++ b/docs/pseudonyms.md
@@ -4,26 +4,26 @@ Castellum allows you to keep the subject's contact information in a
central place and use pseudonyms everywhere else.
Subjects can have multiple pseudonyms. To know which is which, each
-pseudonym is tied to a *pseudonym domain*. There can be only one
-pseudonym for a subject in each domain.
+pseudonym is tied to a *coding list*. There can be only one
+pseudonym for a subject in each coding list.
-## General domains
+## General coding lists
-Most domains are linked to an object in Castellum, usually a study. But
-there can also be so called *general domains* which are not linked to
+Most coding lists are linked to an object in Castellum, usually a study. But
+there can also be so called *general coding lists* which are not linked to
anything in Castellum. These can be useful to provide pseudonyms for
external databases that are used accross studies, e.g. for blood samples
or IQ scores.
-In order to use a general domain you need to perform these steps:
+In order to use a general coding list you need to perform these steps:
-- In the admin UI, create a domain that has a blank `content_type`
+- In the admin UI, create a coding list that has a blank `content_type`
and `object_id`.
- In the same UI, select which users need to be able to access this
- general domain.
+ general coding list.
- Also in the same UI, select which attributes need to be accessible
- for this domain via the API.
-- Study coordinators can then select which general domain they need to
+ for this coding list via the API.
+- Study coordinators can then select which general coding list they need to
access in their study.
## Legacy pseudonyms
@@ -35,21 +35,21 @@ how those legacy pseudonyms can be imported into Castellum.
### Import data
-To import legacy pseudonyms you first need to create such a domain.
+To import legacy pseudonyms you first need to create such a coding list.
After that you can create the pseudonyms themselves:
- from castellum.pseudonyms.models import Domain
+ from castellum.pseudonyms.models import CodingList
from castellum.pseudonyms.models import Pseudonym
mydata = […]
- mydomain = Domain.objects.create()
- print(mydomain.key)
+ my_coding_list = CodingList.objects.create()
+ print(my_coding_list.key)
for subject, legacy_pseudonym in mydata:
Pseudonym.objects.create(
subject=subject,
- domain=mydomain
+ coding_list=my_coding_list
pseudonym=legacy_pseudonym,
)
diff --git a/tests/appointments/test_fetch_scheduler_appointments.py b/tests/appointments/test_fetch_scheduler_appointments.py
index 094cd83416c535e69dc4fa8f766f8cdb4b85308b..4dd3d25afb2435c4964201bf6db6b9d98709d35f 100644
--- a/tests/appointments/test_fetch_scheduler_appointments.py
+++ b/tests/appointments/test_fetch_scheduler_appointments.py
@@ -15,7 +15,7 @@ def test_fetch_scheduler_appointments(participation):
participation.save()
session = baker.make(StudySession, study=participation.study, schedule_id='test_scheduler')
- pseudonym = get_pseudonym(participation.subject, session.domain)
+ pseudonym = get_pseudonym(participation.subject, session.coding_list_key)
scheduler_data = {pseudonym: timezone.now()}
with patch('castellum.utils.scheduler.get_bulk', return_value=scheduler_data) as mock:
diff --git a/tests/execution/views/test_api_attributes_view.py b/tests/execution/views/test_api_attributes_view.py
index 44d545c3c1d879b6737b141a727f3cdc0058777c..c1d73c63769a9fef96177ac6135ded0952162f25 100644
--- a/tests/execution/views/test_api_attributes_view.py
+++ b/tests/execution/views/test_api_attributes_view.py
@@ -1,7 +1,7 @@
from model_bakery import baker
from castellum.pseudonyms.helpers import get_pseudonym
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.recruitment.models import Participation
@@ -10,12 +10,12 @@ def test_apiattributesview(
):
study = study_in_execution_status
study.exportable_attributes.add(attribute_description)
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/attributes/'.format(
- study.pk, domain.key, pseudonym
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/attributes/'.format(
+ study.pk, coding_list.key, pseudonym
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
@@ -26,12 +26,12 @@ def test_apiattributesview(
def test_participation_status(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.NOT_CONTACTED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/attributes/'.format(
- study.pk, domain.key, pseudonym
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/attributes/'.format(
+ study.pk, coding_list.key, pseudonym
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
@@ -43,26 +43,26 @@ def test_privacy_level(client, conductor, study_in_execution_status, subject):
subject.save()
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/attributes/'.format(
- study.pk, domain.key, pseudonym
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/attributes/'.format(
+ study.pk, coding_list.key, pseudonym
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 403
-def test_unrelated_domain(client, conductor, study_in_execution_status, subject):
+def test_unrelated_coding_list(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain)
+ coding_list = baker.make(CodingList)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/attributes/'.format(
- study.pk, domain.key, pseudonym
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/attributes/'.format(
+ study.pk, coding_list.key, pseudonym
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
diff --git a/tests/execution/views/test_api_coding_lists_view.py b/tests/execution/views/test_api_coding_lists_view.py
new file mode 100644
index 0000000000000000000000000000000000000000..9673fb9f55ceb38fc3b582dfe0b790645c09b3c3
--- /dev/null
+++ b/tests/execution/views/test_api_coding_lists_view.py
@@ -0,0 +1,41 @@
+from model_bakery import baker
+
+from castellum.pseudonyms.models import CodingList
+
+
+def test_api_coding_lists_view(client, conductor, study_in_execution_status):
+ baker.make(CodingList, context=study_in_execution_status)
+ baker.make(CodingList, context=study_in_execution_status)
+
+ url = '/execution/api/studies/{}/coding-lists/'.format(study_in_execution_status.pk)
+ response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
+
+ assert response.status_code == 200
+ data = response.json()
+ assert len(data['coding_lists']) == 2
+
+
+def test_no_general_coding_lists(client, conductor, study_in_execution_status):
+ coding_list = baker.make(CodingList)
+ study_in_execution_status.general_coding_lists.add(coding_list)
+ conductor.general_coding_lists.add(coding_list)
+
+ url = '/execution/api/studies/{}/coding-lists/'.format(study_in_execution_status.pk)
+ response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
+
+ assert response.status_code == 200
+ data = response.json()
+ assert len(data['coding_lists']) == 0
+
+
+def test_permission(client, recruiter, study_in_execution_status):
+ url = '/execution/api/studies/{}/coding-lists/'.format(study_in_execution_status.pk)
+ response = client.get(url, HTTP_AUTHORIZATION='token ' + recruiter.token)
+ assert response.status_code == 403
+
+
+def test_only_token_auth(client, conductor, study_in_execution_status):
+ client.force_login(conductor)
+ url = '/execution/api/studies/{}/coding-lists/'.format(study_in_execution_status.pk)
+ response = client.get(url)
+ assert response.status_code == 403
diff --git a/tests/execution/views/test_api_domains_view.py b/tests/execution/views/test_api_domains_view.py
deleted file mode 100644
index bfe499ed1c3f087fcf6a6fa7417e3bda73b7ff9b..0000000000000000000000000000000000000000
--- a/tests/execution/views/test_api_domains_view.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from model_bakery import baker
-
-from castellum.pseudonyms.models import Domain
-
-
-def test_apidomainsview(client, conductor, study_in_execution_status):
- baker.make(Domain, context=study_in_execution_status)
- baker.make(Domain, context=study_in_execution_status)
-
- url = '/execution/api/studies/{}/domains/'.format(study_in_execution_status.pk)
- response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
-
- assert response.status_code == 200
- data = response.json()
- assert len(data['domains']) == 2
-
-
-def test_no_general_domains(client, conductor, study_in_execution_status):
- domain = baker.make(Domain)
- study_in_execution_status.general_domains.add(domain)
- conductor.general_domains.add(domain)
-
- url = '/execution/api/studies/{}/domains/'.format(study_in_execution_status.pk)
- response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
-
- assert response.status_code == 200
- data = response.json()
- assert len(data['domains']) == 0
-
-
-def test_permission(client, recruiter, study_in_execution_status):
- url = '/execution/api/studies/{}/domains/'.format(study_in_execution_status.pk)
- response = client.get(url, HTTP_AUTHORIZATION='token ' + recruiter.token)
- assert response.status_code == 403
-
-
-def test_only_token_auth(client, conductor, study_in_execution_status):
- client.force_login(conductor)
- url = '/execution/api/studies/{}/domains/'.format(study_in_execution_status.pk)
- response = client.get(url)
- assert response.status_code == 403
diff --git a/tests/execution/views/test_api_pseudonyms_view.py b/tests/execution/views/test_api_pseudonyms_view.py
index df05b61efc820b99fce8e04176bc8dcca6dac989..c1c3f6ababd60c72cce0a6a97f51c7de74b8fc2c 100644
--- a/tests/execution/views/test_api_pseudonyms_view.py
+++ b/tests/execution/views/test_api_pseudonyms_view.py
@@ -1,15 +1,15 @@
from model_bakery import baker
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.recruitment.models import Participation
def test_apipseudonymsview(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- url = '/execution/api/studies/{}/domains/{}/'.format(study.pk, domain.key)
+ url = '/execution/api/studies/{}/coding-lists/{}/'.format(study.pk, coding_list.key)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 200
@@ -19,10 +19,10 @@ def test_apipseudonymsview(client, conductor, study_in_execution_status, subject
def test_participation_status(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.NOT_CONTACTED)
- url = '/execution/api/studies/{}/domains/{}/'.format(study.pk, domain.key)
+ url = '/execution/api/studies/{}/coding-lists/{}/'.format(study.pk, coding_list.key)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 200
@@ -35,10 +35,10 @@ def test_privacy_level(client, conductor, study_in_execution_status, subject):
subject.save()
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- url = '/execution/api/studies/{}/domains/{}/'.format(study.pk, domain.key)
+ url = '/execution/api/studies/{}/coding-lists/{}/'.format(study.pk, coding_list.key)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 200
@@ -46,12 +46,12 @@ def test_privacy_level(client, conductor, study_in_execution_status, subject):
assert len(data['pseudonyms']) == 1
-def test_unrelated_domain(client, conductor, study_in_execution_status, subject):
+def test_unrelated_coding_list(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain)
+ coding_list = baker.make(CodingList)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- url = '/execution/api/studies/{}/domains/{}/'.format(study.pk, domain.key)
+ url = '/execution/api/studies/{}/coding-lists/{}/'.format(study.pk, coding_list.key)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 404
diff --git a/tests/execution/views/test_api_resolve_view.py b/tests/execution/views/test_api_resolve_view.py
index ff433b2f2b215b274bc3bef24341b207abba5327..22796b207e1b23781d491844c1c69407df9bf019 100644
--- a/tests/execution/views/test_api_resolve_view.py
+++ b/tests/execution/views/test_api_resolve_view.py
@@ -4,21 +4,21 @@ from freezegun import freeze_time
from model_bakery import baker
from castellum.pseudonyms.helpers import get_pseudonym
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.recruitment.models import Participation
from castellum.studies.models import Study
def test_apiresolveview(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
- target_domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
- target_pseudonym = get_pseudonym(subject, target_domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
+ target_pseudonym = get_pseudonym(subject, target_coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
@@ -28,13 +28,13 @@ def test_apiresolveview(client, conductor, study_in_execution_status, subject):
def test_token_required(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
- target_domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url) # no token
@@ -43,17 +43,17 @@ def test_token_required(client, conductor, study_in_execution_status, subject):
def test_user_expired(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
- target_domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
with freeze_time('2000-01-01'):
conductor.expiration_date = timezone.now()
conductor.save()
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
with freeze_time('2000-01-02'):
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
@@ -63,13 +63,13 @@ def test_user_expired(client, conductor, study_in_execution_status, subject):
def test_token_required_logged_in(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
- target_domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
client.force_login(conductor)
response = client.get(url) # no token
@@ -79,13 +79,13 @@ def test_token_required_logged_in(client, conductor, study_in_execution_status,
def test_permission_required(client, recruiter, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
- target_domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + recruiter.token)
@@ -97,13 +97,13 @@ def test_privacy_level(client, conductor, study_in_execution_status, subject):
subject.save()
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
- target_domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
@@ -111,13 +111,13 @@ def test_privacy_level(client, conductor, study_in_execution_status, subject):
def test_study_status(client, conductor, study, subject):
- domain = baker.make(Domain, context=study)
- target_domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
@@ -126,88 +126,88 @@ def test_study_status(client, conductor, study, subject):
def test_participation_status(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
- target_domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.NOT_CONTACTED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 404
-def test_source_domain_wrong_study(client, conductor, study_in_execution_status, subject):
+def test_source_coding_list_wrong_study(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
other_study = baker.make(Study)
- domain = baker.make(Domain, context=other_study)
+ coding_list = baker.make(CodingList, context=other_study)
- target_domain = baker.make(Domain, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 404
-def test_source_domain_general(client, conductor, study_in_execution_status, subject):
+def test_source_coding_list_general(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain)
- study.general_domains.add(domain)
- conductor.general_domains.add(domain)
+ coding_list = baker.make(CodingList)
+ study.general_coding_lists.add(coding_list)
+ conductor.general_coding_lists.add(coding_list)
- target_domain = baker.make(Domain, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 404
-def test_target_domain_other_study(client, conductor, study_in_execution_status, subject):
+def test_target_coding_list_other_study(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
other_study = baker.make(Study)
- target_domain = baker.make(Domain, context=other_study)
+ target_coding_list = baker.make(CodingList, context=other_study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 404
-def test_target_domain_general(client, conductor, study_in_execution_status, subject):
+def test_target_coding_list_general(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
- target_domain = baker.make(Domain)
- study.general_domains.add(target_domain)
- conductor.general_domains.add(target_domain)
+ target_coding_list = baker.make(CodingList)
+ study.general_coding_lists.add(target_coding_list)
+ conductor.general_coding_lists.add(target_coding_list)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
- target_pseudonym = get_pseudonym(subject, target_domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
+ target_pseudonym = get_pseudonym(subject, target_coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
@@ -215,36 +215,38 @@ def test_target_domain_general(client, conductor, study_in_execution_status, sub
assert response.json() == {'pseudonym': target_pseudonym}
-def test_target_domain_general_bad_user(client, conductor, study_in_execution_status, subject):
+def test_target_coding_list_general_bad_user(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
- target_domain = baker.make(Domain)
- study.general_domains.add(target_domain)
+ target_coding_list = baker.make(CodingList)
+ study.general_coding_lists.add(target_coding_list)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 404
-def test_source_domain_general_bad_study(client, conductor, study_in_execution_status, subject):
+def test_source_coding_list_general_bad_study(
+ client, conductor, study_in_execution_status, subject
+):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
- target_domain = baker.make(Domain)
- conductor.general_domains.add(target_domain)
+ target_coding_list = baker.make(CodingList)
+ conductor.general_coding_lists.add(target_coding_list)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym, target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym, target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
@@ -253,14 +255,14 @@ def test_source_domain_general_bad_study(client, conductor, study_in_execution_s
def test_normalize_pseudonym(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
- target_domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
+ target_coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
- target_pseudonym = get_pseudonym(subject, target_domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
+ target_pseudonym = get_pseudonym(subject, target_coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/{}/'.format(
- study.pk, domain.key, pseudonym.lower(), target_domain.key
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym.lower(), target_coding_list.key
)
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
diff --git a/tests/execution/views/test_api_validate_view.py b/tests/execution/views/test_api_validate_view.py
index e9339f78da75c4ffbb8de0f65c92102d09fbb2bc..9df6035f6b43e5760aa796b0634f7ee6f014c5b9 100644
--- a/tests/execution/views/test_api_validate_view.py
+++ b/tests/execution/views/test_api_validate_view.py
@@ -1,17 +1,19 @@
from model_bakery import baker
from castellum.pseudonyms.helpers import get_pseudonym
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.recruitment.models import Participation
def test_apivalidateview(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/'.format(study.pk, domain.key, pseudonym)
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym
+ )
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 200
@@ -20,24 +22,28 @@ def test_apivalidateview(client, conductor, study_in_execution_status, subject):
def test_normalize_pseudonym(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/'.format(study.pk, domain.key, pseudonym.lower())
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym.lower()
+ )
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 200
assert response.json() == {'pseudonym': pseudonym}
-def test_unrelated_domain(client, conductor, study_in_execution_status, subject):
+def test_unrelated_coding_list(client, conductor, study_in_execution_status, subject):
study = study_in_execution_status
- domain = baker.make(Domain)
+ coding_list = baker.make(CodingList)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/'.format(study.pk, domain.key, pseudonym)
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym
+ )
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 404
@@ -48,11 +54,13 @@ def test_ignore_privacylevel(client, conductor, study_in_execution_status, subje
subject.save()
study = study_in_execution_status
- domain = baker.make(Domain, context=study)
+ coding_list = baker.make(CodingList, context=study)
baker.make(Participation, study=study, subject=subject, status=Participation.INVITED)
- pseudonym = get_pseudonym(subject, domain.key)
+ pseudonym = get_pseudonym(subject, coding_list.key)
- url = '/execution/api/studies/{}/domains/{}/{}/'.format(study.pk, domain.key, pseudonym)
+ url = '/execution/api/studies/{}/coding-lists/{}/{}/'.format(
+ study.pk, coding_list.key, pseudonym
+ )
response = client.get(url, HTTP_AUTHORIZATION='token ' + conductor.token)
assert response.status_code == 200
diff --git a/tests/execution/views/test_export_view.py b/tests/execution/views/test_export_view.py
index 32a26d55c18fd13b2027d86889d5b16bb57bbb3e..f9088e4598b088fe50a0ede0b0d1e330ccbc84ea 100644
--- a/tests/execution/views/test_export_view.py
+++ b/tests/execution/views/test_export_view.py
@@ -1,13 +1,13 @@
from model_bakery import baker
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.pseudonyms.models import Pseudonym
from castellum.recruitment.models import Participation
from castellum.studies.models import Study
-def test_single_domain(client, conductor, study_in_execution_status):
- baker.make(Domain, context=study_in_execution_status)
+def test_single_coding_list(client, conductor, study_in_execution_status):
+ baker.make(CodingList, context=study_in_execution_status)
client.force_login(conductor)
url = '/execution/{}/export/'.format(study_in_execution_status.pk)
@@ -17,19 +17,19 @@ def test_single_domain(client, conductor, study_in_execution_status):
assert response['Content-Type'] == 'application/zip'
-def test_no_domain(client, conductor, study_in_execution_status):
+def test_no_coding_list(client, conductor, study_in_execution_status):
client.force_login(conductor)
url = '/execution/{}/export/'.format(study_in_execution_status.pk)
response = client.get(url)
assert response.status_code == 200
assert response['Content-Type'] == 'text/html; charset=utf-8'
- assert b'All pseudonym domains have been deleted.' in response.content
+ assert b'All coding lists have been deleted.' in response.content
-def test_multi_domain(client, conductor, study_in_execution_status):
- baker.make(Domain, context=study_in_execution_status)
- baker.make(Domain, context=study_in_execution_status)
+def test_multi_coding_list(client, conductor, study_in_execution_status):
+ baker.make(CodingList, context=study_in_execution_status)
+ baker.make(CodingList, context=study_in_execution_status)
client.force_login(conductor)
url = '/execution/{}/export/'.format(study_in_execution_status.pk)
@@ -39,41 +39,43 @@ def test_multi_domain(client, conductor, study_in_execution_status):
assert response['Content-Type'] == 'text/html; charset=utf-8'
-def test_multi_domain_given(client, conductor, study_in_execution_status):
+def test_multi_coding_list_given(client, conductor, study_in_execution_status):
baker.make(Participation, study=study_in_execution_status, status=Participation.INVITED)
- baker.make(Domain, context=study_in_execution_status)
- domain2 = baker.make(Domain, context=study_in_execution_status)
+ baker.make(CodingList, context=study_in_execution_status)
+ coding_list2 = baker.make(CodingList, context=study_in_execution_status)
client.force_login(conductor)
- url = '/execution/{}/export/?domain={}'.format(study_in_execution_status.pk, domain2.key)
+ url = '/execution/{}/export/?coding_list={}'.format(
+ study_in_execution_status.pk, coding_list2.key
+ )
response = client.get(url)
assert response.status_code == 200
assert response['Content-Type'] == 'application/zip'
- # use existence of pseudonym as indicator which domain was used
- assert domain2.pseudonym_set.count() == 1
+ # use existence of pseudonym as indicator which coding_list was used
+ assert coding_list2.pseudonym_set.count() == 1
assert Pseudonym.objects.count() == 1
-def test_multi_domain_given_invalid(client, conductor, study_in_execution_status):
- baker.make(Domain, context=study_in_execution_status)
- baker.make(Domain, context=study_in_execution_status)
+def test_multi_coding_list_given_invalid(client, conductor, study_in_execution_status):
+ baker.make(CodingList, context=study_in_execution_status)
+ baker.make(CodingList, context=study_in_execution_status)
client.force_login(conductor)
- url = '/execution/{}/export/?domain={}'.format(study_in_execution_status.pk, 'invalid')
+ url = '/execution/{}/export/?coding_list={}'.format(study_in_execution_status.pk, 'invalid')
response = client.get(url)
assert response.status_code == 404
-def test_multi_domain_given_wrong_study(client, conductor, study_in_execution_status):
+def test_multi_coding_list_given_wrong_study(client, conductor, study_in_execution_status):
study2 = baker.make(Study)
- baker.make(Domain, context=study_in_execution_status)
- domain2 = baker.make(Domain, context=study_in_execution_status)
+ baker.make(CodingList, context=study_in_execution_status)
+ coding_list2 = baker.make(CodingList, context=study_in_execution_status)
client.force_login(conductor)
- url = '/execution/{}/export/?domain={}'.format(study2.pk, domain2.key)
+ url = '/execution/{}/export/?coding_list={}'.format(study2.pk, coding_list2.key)
response = client.get(url)
assert response.status_code == 404
diff --git a/tests/execution/views/test_pseudonyms_view.py b/tests/execution/views/test_pseudonyms_view.py
index 0981f0a4136019352a7f7a20a657963c85c6ab57..933d5bf8fc652af83ac25906e1663858c09c202e 100644
--- a/tests/execution/views/test_pseudonyms_view.py
+++ b/tests/execution/views/test_pseudonyms_view.py
@@ -22,7 +22,7 @@ def test_200(request, client, study, user_fixture):
def test_lists_all_pseudonyms(client, conductor, study):
participation = baker.make(Participation, study=study, status=Participation.INVITED)
- study.domains.create()
+ study.coding_lists.create()
client.force_login(conductor)
response = client.get('/execution/{}/{}/pseudonyms/'.format(
study.pk, participation.pk
@@ -35,7 +35,7 @@ def test_no_name(client, conductor, study, subject):
participation = baker.make(
Participation, subject=subject, study=study, status=Participation.INVITED
)
- study.domains.create()
+ study.coding_lists.create()
client.force_login(conductor)
response = client.get('/execution/{}/{}/pseudonyms/'.format(
study.pk, participation.pk
diff --git a/tests/execution/views/test_views.py b/tests/execution/views/test_views.py
index 00d4c30ff472fc863df1bde9bb99159a5b543763..3e32de0bb2d8c0e377ed5571504392b4379adfd9 100644
--- a/tests/execution/views/test_views.py
+++ b/tests/execution/views/test_views.py
@@ -3,7 +3,7 @@ from model_bakery import baker
from castellum.appointments.models import Appointment
from castellum.pseudonyms.helpers import get_pseudonym
-from castellum.pseudonyms.models import Domain
+from castellum.pseudonyms.models import CodingList
from castellum.recruitment.models import ExecutionTag
from castellum.recruitment.models import Participation
from castellum.studies.models import StudySession
@@ -105,7 +105,7 @@ def test_participation_detail_view_tags(client, subject, conductor, study_in_exe
def test_resolve_view(client, member, study_in_execution_status, subject):
client.force_login(member)
- domain = baker.make(Domain, context=study_in_execution_status)
+ coding_list = baker.make(CodingList, context=study_in_execution_status)
participation = baker.make(
Participation,
study=study_in_execution_status,
@@ -116,12 +116,12 @@ def test_resolve_view(client, member, study_in_execution_status, subject):
url = '/execution/{}/resolve/'.format(study_in_execution_status.pk)
response = client.get(url)
- assert b'