Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas committed Jun 10, 2024
2 parents 5a73ecb + b38d87d commit 7426cda
Show file tree
Hide file tree
Showing 98 changed files with 4,334 additions and 1,896 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ authors:
website: 'https://cdh.uu.nl/rsl/'
repository-code: 'https://github.com/CentreForDigitalHumanities/lettercraft'
license: BSD-3-Clause
version: 0.3.0
date-released: '2024-04-24'
version: 0.4.0
date-released: '2024-06-10'
39 changes: 37 additions & 2 deletions backend/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
from allauth.account.models import EmailAddress
import pytest

from case_study.models import CaseStudy
from letter.models import LetterDescription

from person.models import HistoricalPerson, AgentDescription
from source.models import Source
from event.models import EventDescription
from user.models import User


@pytest.fixture()
def user_data():
return {
"username": "JohnDoe",
"email": "[email protected]",
"password": "secretpassword",
"first_name": "John",
"last_name": "Doe",
}


@pytest.fixture()
def user(db, user_data):
user = User.objects.create(
username=user_data["username"],
email=user_data["email"],
password=user_data["password"],
first_name=user_data["first_name"],
last_name=user_data["last_name"],
)
EmailAddress.objects.create(
user=user, email=user.email, verified=True, primary=True
)
return user


@pytest.fixture
def user_client(client, user):
client.force_login(user)
yield client
client.logout()


@pytest.fixture()
Expand All @@ -13,12 +49,11 @@ def source(db):


@pytest.fixture()
def letter_description(db, source, agent_description):
def letter_description(db, source):
letter = LetterDescription.objects.create(
name="Bert's letter",
source=source,
)
letter.senders.add(agent_description)
return letter


Expand Down
8 changes: 1 addition & 7 deletions backend/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
"Source information",
{
"description": "Information about the source from which this description is taken.",
"fields": [
"source",
"source_location",
"source_mention",
],
"fields": ["source", "source_mention", "designators", "book", "chapter", "page"],
},
)

Expand All @@ -26,8 +22,6 @@

description_field_fields = [
"source_mention",
"source_location",
"source_terminology",
] + field_fields


Expand Down
47 changes: 28 additions & 19 deletions backend/core/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.db import models
from django.core.validators import MinValueValidator, MaxValueValidator
from source.models import Source
from django.contrib.postgres.fields import ArrayField

class Field(models.Model):
Expand Down Expand Up @@ -117,20 +116,44 @@ class EntityDescription(Named, models.Model):
"""

source = models.ForeignKey(
to=Source,
to='source.Source',
on_delete=models.PROTECT,
help_text="Source text containing this description",
)

source_mention = models.CharField(
max_length=32,
blank=True,
choices=[("direct", "directly mentioned"), ("implied", "implied")],
help_text="How is this entity presented in the text?",
)
source_location = models.CharField(
max_length=200,

designators = ArrayField(
models.CharField(
max_length=200,
),
default=list,
blank=True,
size=5,
help_text="Relevant (Latin) terminology used to describe this entity in the source text",
)

book = models.CharField(
max_length=255,
blank=True,
help_text="The book in the source"
)

chapter = models.CharField(
max_length=255,
blank=True,
help_text="Specific location(s) where the entity is mentioned or described in the source text",
help_text="The chapter or chapters in the source"
)

page = models.CharField(
max_length=255,
blank=True,
help_text="The page number or page range in the source"
)

class Meta:
Expand All @@ -154,20 +177,6 @@ class DescriptionField(Field, models.Model):
choices=[("direct", "directly mentioned"), ("implied", "implied")],
help_text="How is this information presented in the text?",
)
source_location = models.CharField(
max_length=200,
blank=True,
help_text="Specific location of the information in the source text",
)
source_terminology = ArrayField(
models.CharField(
max_length=200,
),
default=list,
blank=True,
size=5,
help_text="Relevant terminology used in the source text",
)

class Meta:
abstract = True
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Generated by Django 4.2.7 on 2024-04-25 10:13

from django.db import migrations, models


def migrate_source_location_to_page(apps, schema_editor):
EventDescription = apps.get_model("event", "EventDescription")
for event_description in EventDescription.objects.all():
if event_description.source_location:
event_description.page = event_description.source_location
event_description.save()


def migrate_page_to_source_location(apps, schema_editor):
EventDescription = apps.get_model("event", "EventDescription")
for event_description in EventDescription.objects.all():
if event_description.page:
event_description.source_location = event_description.page
event_description.save()


class Migration(migrations.Migration):

dependencies = [
("event", "0015_alter_eventcategory_options_episode"),
]

operations = [
migrations.AddField(
model_name="eventdescription",
name="book",
field=models.CharField(
blank=True, help_text="The book in the source", max_length=255
),
),
migrations.AddField(
model_name="eventdescription",
name="chapter",
field=models.CharField(
blank=True,
help_text="The chapter or chapters in the source",
max_length=255,
),
),
migrations.AddField(
model_name="eventdescription",
name="page",
field=models.CharField(
blank=True,
help_text="The page number or page range in the source",
max_length=255,
),
),
migrations.RunPython(
code=migrate_source_location_to_page,
reverse_code=migrate_page_to_source_location,
),
migrations.RemoveField(
model_name="eventdescription",
name="source_location",
),
migrations.RemoveField(
model_name="eventdescriptionagent",
name="source_location",
),
migrations.RemoveField(
model_name="eventdescriptiongift",
name="source_location",
),
migrations.RemoveField(
model_name="eventdescriptionletter",
name="source_location",
),
migrations.RemoveField(
model_name="eventdescriptionspace",
name="source_location",
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 4.2.7 on 2024-05-17 13:15

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("event", "0016_remove_eventdescription_source_location_and_more"),
]

operations = [
migrations.RemoveField(
model_name="eventdescriptionagent",
name="source_terminology",
),
migrations.RemoveField(
model_name="eventdescriptiongift",
name="source_terminology",
),
migrations.RemoveField(
model_name="eventdescriptionletter",
name="source_terminology",
),
migrations.RemoveField(
model_name="eventdescriptionspace",
name="source_terminology",
),
migrations.AddField(
model_name="eventdescription",
name="designators",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(max_length=200),
blank=True,
default=list,
help_text="Relevant (Latin) terminology used to describe this entity in the source text",
size=5,
),
),
]
38 changes: 2 additions & 36 deletions backend/letter/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,10 @@ class GiftDescriptionCategoryAdmin(admin.StackedInline):
verbose_name_plural = "categories"


class GiftDescriptionSenderAdmin(admin.StackedInline):
model = models.GiftDescriptionSender
fields = ["agent"] + core_admin.description_field_fields
extra = 0
verbose_name = "sender"


class GiftDescriptionAddresseeAdmin(admin.StackedInline):
model = models.GiftDescriptionAddressee
fields = ["agent"] + core_admin.description_field_fields
extra = 0
verbose_name = "addressee"


@admin.register(models.GiftDescription)
class GiftDescriptionAdmin(core_admin.EntityDescriptionAdmin, admin.ModelAdmin):
inlines = [
GiftDescriptionCategoryAdmin,
GiftDescriptionSenderAdmin,
GiftDescriptionAddresseeAdmin,
GiftDescriptionCategoryAdmin
]


Expand All @@ -52,27 +36,9 @@ class LetterDescriptionCategoryAdmin(admin.StackedInline):
verbose_name_plural = "categories"


class LetterDescriptionSenderAdmin(admin.StackedInline):
model = models.LetterDescriptionSender
fields = ["agent"] + core_admin.description_field_fields
extra = 0
verbose_name = "sender"


class LetterDescriptionAddresseeAdmin(admin.StackedInline):
model = models.LetterDescriptionAddressee
fields = ["agent"] + core_admin.description_field_fields
extra = 0
verbose_name = "addressee"


@admin.register(models.LetterDescription)
class LetterDescriptionAdmin(core_admin.EntityDescriptionAdmin, admin.ModelAdmin):
inlines = [
LetterDescriptionCategoryAdmin,
LetterDescriptionSenderAdmin,
LetterDescriptionAddresseeAdmin,
]
inlines = [LetterDescriptionCategoryAdmin]


class PreservedLetterRoleAdmin(admin.StackedInline):
Expand Down
Loading

0 comments on commit 7426cda

Please sign in to comment.