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

Show stage extras to teacher if enabled for any section #17558

Merged
merged 2 commits into from
Sep 8, 2017

Conversation

balderdash
Copy link
Contributor

No description provided.

@balderdash balderdash changed the base branch from route-to-extras to staging September 7, 2017 21:22
@balderdash balderdash assigned Hamms and balderdash and unassigned balderdash Sep 7, 2017
enabled_for_stage = !script_level.end_of_script?
enabled_for_user = current_user && current_user.section_for_script(script_level.script) &&
current_user.section_for_script(script_level.script).stage_extras
if enabled_for_stage && enabled_for_user
enabled_for_teacher = current_user.try(:teacher?) &&
current_user.sections.any? do |section|
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think you could do current_user.sections.where(script_id: script_level.script_id).any? to make this a bit cheaper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out stage_extras is a column too, not a serialized property, so the query can take care of both.

@balderdash balderdash merged commit a9f394b into staging Sep 8, 2017
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.

None yet

2 participants