-
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 branch 'develop' into feature/user-permissions
- Loading branch information
Showing
116 changed files
with
3,545 additions
and
478 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
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
38 changes: 38 additions & 0 deletions
38
backend/event/migrations/0028_alter_episode_source_mention_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,38 @@ | ||
# Generated by Django 4.2.7 on 2024-10-23 12:38 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('event', '0027_alter_episode_agents_alter_episode_gifts_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='episode', | ||
name='source_mention', | ||
field=models.CharField(blank=True, choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], help_text='How is this entity presented in the text?', max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='episodeagent', | ||
name='source_mention', | ||
field=models.CharField(choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], default='direct', help_text='How is this information presented in the text?', max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='episodegift', | ||
name='source_mention', | ||
field=models.CharField(choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], default='direct', help_text='How is this information presented in the text?', max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='episodeletter', | ||
name='source_mention', | ||
field=models.CharField(choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], default='direct', help_text='How is this information presented in the text?', max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='episodespace', | ||
name='source_mention', | ||
field=models.CharField(choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], default='direct', help_text='How is this information presented in the text?', max_length=32), | ||
), | ||
] |
17 changes: 17 additions & 0 deletions
17
backend/event/migrations/0029_alter_episode_order_with_respect_to.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,17 @@ | ||
# Generated by Django 4.2.7 on 2024-10-30 13:39 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('event', '0028_alter_episode_source_mention_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterOrderWithRespectTo( | ||
name='episode', | ||
order_with_respect_to='source', | ||
), | ||
] |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from graphene import Mutation, Boolean, List, NonNull, ID, ResolveInfo | ||
|
||
from event.models import Episode | ||
from graphql_app.types.LettercraftErrorType import LettercraftErrorType | ||
from source.models import Source | ||
|
||
|
||
class UpdateEpisodeOrderMutation(Mutation): | ||
ok = Boolean(required=True) | ||
errors = List(NonNull(LettercraftErrorType), required=True) | ||
|
||
class Arguments: | ||
episode_ids = List( | ||
NonNull(ID), required=True, description="Ordered list of episode IDs" | ||
) | ||
|
||
@classmethod | ||
def mutate(cls, root: None, info: ResolveInfo, episode_ids: list[str]): | ||
if len(episode_ids) == 0: | ||
error = LettercraftErrorType( | ||
field="episode_ids", messages=["No episode IDs provided."] | ||
) | ||
return cls(ok=False, errors=[error]) # type: ignore | ||
|
||
# Check if all episode IDs are valid. | ||
episodes = Episode.objects.filter(id__in=episode_ids).prefetch_related("source") | ||
if episodes.count() != len(episode_ids): | ||
error = LettercraftErrorType( | ||
field="episode_ids", | ||
messages=["Not every provided episode ID is valid."], | ||
) | ||
return cls(ok=False, errors=[error]) # type: ignore | ||
|
||
corresponding_sources: set[Source] = {episode.source for episode in episodes} | ||
|
||
# Check if there is at least one source for the provided episode IDs. | ||
# (There should always be.) | ||
if len(corresponding_sources) == 0: | ||
error = LettercraftErrorType( | ||
field="episode_ids", messages=["No source found for given episode IDs."] | ||
) | ||
return cls(ok=False, errors=[error]) # type: ignore | ||
|
||
# Check if all provided episode IDs belong to the same source. | ||
if len(corresponding_sources) > 1: | ||
error = LettercraftErrorType( | ||
field="episode_ids", | ||
messages=["The provided episode IDs belong to more than one source."], | ||
) | ||
return cls(ok=False, errors=[error]) # type: ignore | ||
|
||
source = corresponding_sources.pop() | ||
|
||
source.set_episode_order(episode_ids) # type: ignore | ||
|
||
return cls(ok=True, errors=[]) # type: ignore |
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,29 @@ | ||
from django.db.models.query import QuerySet | ||
|
||
|
||
def test_episode_order_mutation(graphql_client, episode, episode_2): | ||
result = graphql_client.execute( | ||
f""" | ||
mutation TestMutation {{ | ||
updateEpisodeOrder( | ||
episodeIds: [ | ||
{episode_2.pk}, {episode.pk} | ||
] | ||
) {{ | ||
ok | ||
errors {{ | ||
field | ||
messages | ||
}} | ||
}} | ||
}} | ||
""" | ||
) | ||
|
||
assert result["data"]["updateEpisodeOrder"]["ok"] == True | ||
assert result["data"]["updateEpisodeOrder"]["errors"] == [] | ||
|
||
order_queryset = episode.source.get_episode_order() # type: QuerySet | ||
ids_list = list(order_queryset.values_list("id", flat=True)) | ||
|
||
assert ids_list == [episode_2.pk, episode.pk] |
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
33 changes: 33 additions & 0 deletions
33
backend/letter/migrations/0021_alter_giftdescription_source_mention_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,33 @@ | ||
# Generated by Django 4.2.7 on 2024-10-23 12:38 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('letter', '0020_remove_giftdescription_designators_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='giftdescription', | ||
name='source_mention', | ||
field=models.CharField(blank=True, choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], help_text='How is this entity presented in the text?', max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='giftdescriptioncategory', | ||
name='source_mention', | ||
field=models.CharField(choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], default='direct', help_text='How is this information presented in the text?', max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='letterdescription', | ||
name='source_mention', | ||
field=models.CharField(blank=True, choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], help_text='How is this entity presented in the text?', max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='letterdescriptioncategory', | ||
name='source_mention', | ||
field=models.CharField(choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], default='direct', help_text='How is this information presented in the text?', max_length=32), | ||
), | ||
] |
21 changes: 21 additions & 0 deletions
21
backend/letter/migrations/0022_alter_giftdescription_order_with_respect_to_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,21 @@ | ||
# Generated by Django 4.2.7 on 2024-10-30 13:39 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('letter', '0021_alter_giftdescription_source_mention_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterOrderWithRespectTo( | ||
name='giftdescription', | ||
order_with_respect_to='source', | ||
), | ||
migrations.AlterOrderWithRespectTo( | ||
name='letterdescription', | ||
order_with_respect_to='source', | ||
), | ||
] |
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
28 changes: 28 additions & 0 deletions
28
backend/person/migrations/0024_alter_agentdescription_source_mention_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,28 @@ | ||
# Generated by Django 4.2.7 on 2024-10-23 12:38 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('person', '0023_remove_agentdescription_designators'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='agentdescription', | ||
name='source_mention', | ||
field=models.CharField(blank=True, choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], help_text='How is this entity presented in the text?', max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='agentdescriptiongender', | ||
name='source_mention', | ||
field=models.CharField(choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], default='direct', help_text='How is this information presented in the text?', max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='agentdescriptionlocation', | ||
name='source_mention', | ||
field=models.CharField(choices=[('direct', 'directly mentioned'), ('implied', 'implied'), ('up_for_debate', 'up for debate')], default='direct', help_text='How is this information presented in the text?', max_length=32), | ||
), | ||
] |
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
Oops, something went wrong.