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

Improve podcast handling #330

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open

Improve podcast handling #330

wants to merge 6 commits into from

Conversation

MattWindsor91
Copy link
Member

Predominantly an attempt to fix #269, but I've also done a few minor changes (mostly DRY) round the edges.

In ascending order of potential controversy:

  • The model code now performs the check to see if podcasts are published, so all endpoints depending on the model now only see published podcasts.
  • The podcast player uses the Go builtin http.NotFound if it 404s, so at least there's an error thrown, even if it's ugly as sin. (I presumed that using the normal URY 404 would be silly - it won't render well in an embed.)
  • The podcast controller eagerly constructs a model in its constructor, since all of its endpoints depend on having the model around.
  • I've pulled out 404 handling code from both the not-found and podcasts controllers into one bit of code, which is currently in controllers but can be moved.
  • I've also pulled out the idea of handling a template using the page context of a controller into a private method of Controller, which might be useful, or it might be overly coupling templates and controllers, comments welcome.

I'd love to do more to improve the error handling here, but I think I need more structured error information from myradio-go.

This is a fairly conservative change; I think a lot of this can be pushed
up into the Controller logic.
The check occurs at the model level,
so anything that retrieves podcasts will now ignore unpublished ones.

This commit doesn't implement 404 handling for missing podcasts in the player,
so this currently just triggers a 200 and a blank screen.

Fixes #269.
There was a missing return - harmless but inefficient, I think?
This is better than nothing.
This might be a bit controversial, so I've left it til the end.
The general idea here is that podcasts and not_found should agree
on 404 error handling, and the template rendering helper I wrote
earlier is generalisable to other controllers, so
into controller.go they go.

Comments and feedback welcomed.
It seems strange to construct the model afresh every request,
when we have everything needed to construct it available in the ctor.
Copy link
Member

@markspolakovs markspolakovs left a comment

Choose a reason for hiding this comment

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

Seems sane, modulo one possible change - I'd really like to not use 404 for non-"this doesn't exist" errors, but I know that's a far bigger effort.

controllers/controller.go Show resolved Hide resolved

// we should not show unpublished podcasts, regardless of situation
// (https://github.com/UniversityRadioYork/2016-site/issues/269)
if pod.Status != "Published" {
Copy link
Member

Choose a reason for hiding this comment

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

Do we also want to make this change (i.e. invert the conditional) in GetAllPodcasts, or is the conditional there sufficient?

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.

/podcast/:id/player ignores suspended flag
2 participants