Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Feature/order episodes in source #155

Merged
merged 10 commits into from
Nov 12, 2024

Conversation

XanderVertegaal
Copy link
Contributor

Closes #122

Implements order_with_respect_to to keep track of the order of episodes within a source and adds buttons in the frontend so users can manually adjust the order.

Copy link
Contributor

@lukavdplas lukavdplas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

This looks good overall; I've added some requests for minor changes.

Comment on lines 25 to 31
corresponding_sources = Source.objects.filter(episode__in=episode_ids)
if corresponding_sources.count() != len(episode_ids):
error = LettercraftErrorType(
field="episode_ids",
messages=["Multiple sources found for given episode IDs."],
messages=["Not every episode has a corresponding source."]
)
return cls(ok=False, errors=[error]) # type: ignore
return cls(ok=False, errors=[error]) # type: ignore
Copy link
Contributor

@lukavdplas lukavdplas Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is hard to understand without a comment since it relies on Django returning duplicate rows for the filter query, which is kind of obscure knowledge. On op of that, it's an indirect test for the thing being validated (invalid IDs), which also makes it less intuitive.

The message here is confusing as well. Strictly speaking, every episode does have a corresponding source, but not every ID has a corresponding episode. Practically, the feedback to the client should be that it's sending non-existent episode IDs, not that there is an issue in the source field of episodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, so basically everything here is bad then 😅

I've made some changes in my last commit, but if this is still not how you want it to be, feel free to push your own commits.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, it was doing the right thing, just confusing to read. Your updated version looks fine!

@XanderVertegaal XanderVertegaal merged commit 7980b4a into develop Nov 12, 2024
2 checks passed
@XanderVertegaal XanderVertegaal deleted the feature/order-episodes-in-source branch November 12, 2024 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Sort episodes by book/chapter/page
2 participants