-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this 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.
frontend/src/app/shared/order-button-group/order-button-group.component.ts
Show resolved
Hide resolved
frontend/src/app/shared/order-button-group/order-button-group.component.ts
Outdated
Show resolved
Hide resolved
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
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.