-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from CentreForDigitalHumanities/feature/episodes
Feature/episodes
- Loading branch information
Showing
6 changed files
with
361 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,50 @@ | ||
import pytest | ||
|
||
from . import models | ||
from data.models import ( | ||
CaseStudy, | ||
Letter, | ||
EpistolaryEvent, | ||
LetterAction, | ||
LetterActionCategory, | ||
Person, | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
def letter(db): | ||
letter = models.Letter.objects.create() | ||
letter = Letter.objects.create() | ||
return letter | ||
|
||
|
||
@pytest.fixture() | ||
def epistolary_event(db, letter): | ||
event = models.EpistolaryEvent.objects.create() | ||
def person(db): | ||
person = Person.objects.create() | ||
return person | ||
|
||
|
||
models.EpistolaryEventCategory.objects.create( | ||
value='write', | ||
event=event | ||
@pytest.fixture() | ||
def letter_action(db, letter, person): | ||
letter_action = LetterAction.objects.create() | ||
letter_action.letters.add(letter) | ||
letter_action.actors.add(person) | ||
|
||
LetterActionCategory.objects.create( | ||
letter_action=letter_action, | ||
value="write", | ||
) | ||
|
||
event.letters.add(letter) | ||
return letter_action | ||
|
||
|
||
@pytest.fixture() | ||
def case_study(db): | ||
case_study = CaseStudy.objects.create(name="Test Case Study") | ||
return case_study | ||
|
||
|
||
@pytest.fixture() | ||
def epistolary_event(db, letter, case_study): | ||
epistolary_event = EpistolaryEvent.objects.create( | ||
name="Test Epistolary event", note="Test note", case_studies=[case_study] | ||
) | ||
|
||
return event | ||
return epistolary_event |
123 changes: 123 additions & 0 deletions
123
backend/data/migrations/0002_casestudy_letteraction_letteractioncategory_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Generated by Django 4.2.7 on 2024-01-29 09:35 | ||
|
||
import django.core.validators | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('data', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CaseStudy', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=256)), | ||
], | ||
options={ | ||
'verbose_name': 'case study', | ||
'verbose_name_plural': 'case studies', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='LetterAction', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='LetterActionCategory', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('certainty', models.IntegerField(choices=[(0, 'uncertain'), (1, 'somewhat certain'), (2, 'certain')], default=2, help_text='How certain are you of this value?')), | ||
('note', models.TextField(blank=True, help_text='Additional notes')), | ||
('value', models.CharField(choices=[('write', 'writing'), ('transport', 'transporting'), ('deliver', 'delivering'), ('read', 'reading'), ('sign', 'signing'), ('eat', 'eating')], help_text='The type of event')), | ||
('letter_action', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='categories', to='data.letteraction')), | ||
], | ||
options={ | ||
'verbose_name_plural': 'letter action categories', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='LetterEventDate', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('certainty', models.IntegerField(choices=[(0, 'uncertain'), (1, 'somewhat certain'), (2, 'certain')], default=2, help_text='How certain are you of this value?')), | ||
('note', models.TextField(blank=True, help_text='Additional notes')), | ||
('year_lower', models.IntegerField(default=400, help_text='The earliest possible year for the letter action', validators=[django.core.validators.MinValueValidator(400), django.core.validators.MaxValueValidator(800)])), | ||
('year_upper', models.IntegerField(default=800, help_text='The latest possible year for the letter action', validators=[django.core.validators.MinValueValidator(400), django.core.validators.MaxValueValidator(800)])), | ||
('year_exact', models.IntegerField(blank=True, help_text='The exact year of the letter action (if known)', null=True, validators=[django.core.validators.MinValueValidator(400), django.core.validators.MaxValueValidator(800)])), | ||
('letter_action', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='date', to='data.letteraction')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
), | ||
migrations.RemoveField( | ||
model_name='epistolaryeventdate', | ||
name='event', | ||
), | ||
migrations.RemoveField( | ||
model_name='epistolaryevent', | ||
name='actors', | ||
), | ||
migrations.RemoveField( | ||
model_name='epistolaryevent', | ||
name='letters', | ||
), | ||
migrations.RemoveField( | ||
model_name='role', | ||
name='event', | ||
), | ||
migrations.AddField( | ||
model_name='epistolaryevent', | ||
name='name', | ||
field=models.CharField(default='unnamed event', max_length=256), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='epistolaryevent', | ||
name='note', | ||
field=models.TextField(blank=True, help_text='Additional notes that describe the event and what connects the letter actions it comprises.'), | ||
), | ||
migrations.DeleteModel( | ||
name='EpistolaryEventCategory', | ||
), | ||
migrations.DeleteModel( | ||
name='EpistolaryEventDate', | ||
), | ||
migrations.AddField( | ||
model_name='letteraction', | ||
name='actors', | ||
field=models.ManyToManyField(related_name='events', through='data.Role', to='data.person'), | ||
), | ||
migrations.AddField( | ||
model_name='letteraction', | ||
name='epistolary_events', | ||
field=models.ManyToManyField(help_text='epistolary events this letter action belongs to', related_name='letter_actions', to='data.epistolaryevent'), | ||
), | ||
migrations.AddField( | ||
model_name='letteraction', | ||
name='letters', | ||
field=models.ManyToManyField(help_text='letters involved in this event', related_name='events', to='data.letter'), | ||
), | ||
migrations.AddField( | ||
model_name='epistolaryevent', | ||
name='case_studies', | ||
field=models.ManyToManyField(help_text='case studies this event belongs to', related_name='epistolary_events', to='data.casestudy'), | ||
), | ||
migrations.AddField( | ||
model_name='role', | ||
name='letter_action', | ||
field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.CASCADE, to='data.letteraction'), | ||
preserve_default=False, | ||
), | ||
migrations.AddConstraint( | ||
model_name='letteractioncategory', | ||
constraint=models.UniqueConstraint(models.F('value'), models.F('letter_action'), name='unique_categories_for_letter_action'), | ||
), | ||
] |
Oops, something went wrong.