Skip to content

add content warning field to book #1564

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

Merged
merged 6 commits into from
Jun 27, 2024
Merged

add content warning field to book #1564

merged 6 commits into from
Jun 27, 2024

Conversation

jivey
Copy link
Member

@jivey jivey commented Jun 25, 2024

https://openstax.atlassian.net/browse/DISCO-342

I originally planned for this to be a snippet, but as far as I can tell, there's not a way to limit the association to a single snippet. I'm also unsure where on the form this should live... next to description seemed to make some sense, but I can move it around.

@jivey jivey marked this pull request as ready for review June 25, 2024 20:30
@jivey jivey requested a review from mwvolo June 25, 2024 20:30
@mwvolo
Copy link
Member

mwvolo commented Jun 26, 2024

To limit the association to one snippet, you'd want to do something like this on the book model.

Also, create the model for the snippet, like this.

This solution work, but it means that we need to ensure the content is the same across all books (bigger content management lift).

Another option is to update the required books in the save method. I imagine this would look something like a filter for books that require the content warning and updating them all on save. (untested code example: Book.filter(subject__in=Subject.objects.get(name='Nursing').all())

I'd say it comes down to how many books this will be used on and the expectations of the behavior of this field.

@jivey jivey force-pushed the content-warning branch from 7e1ea48 to e9c65b8 Compare June 26, 2024 18:38
@jivey
Copy link
Member Author

jivey commented Jun 26, 2024

@mwvolo Thanks for the links, that was a lot easier than I thought. I think this is ready for another look.

I noticed some of the snippets have an endpoint to return all (like http://127.0.0.1:8000/apps/cms/api/snippets/amazonbookblurb/?format=json) do you think I should add that for this as well?

@mwvolo
Copy link
Member

mwvolo commented Jun 26, 2024

@jivey I think you'll only need to do that if @RoyEJohnson is going to need to pull the warnings for some reason (to show on REX, for e.g.)

Copy link
Member

@mwvolo mwvolo left a comment

Choose a reason for hiding this comment

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

Looks good!
Can always add the endpoint for the snippet later if required.

@jivey jivey merged commit 410b416 into main Jun 27, 2024
2 checks passed
@jivey jivey deleted the content-warning branch June 27, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants