-
Notifications
You must be signed in to change notification settings - Fork 81
Auto-update signature count on petition page. #482
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
Conversation
188601b to
3ac2ddd
Compare
app/helpers/application_helper.rb
Outdated
|
|
||
| def open_petition_page? | ||
| # XXX What should go here? Same as petition_page? plus petition.open? Is that allowed here? | ||
| true |
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.
The method petition_page? is just a check for the controller and action name but we know that if it's true then the @petition instance variable is set so just use the Petition#open? method to achieve what you need, e.g:
petition_page? && @petition.open?
Hopefully that's clearer?
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.
Ah, great, thanks, I still don't get my head around where variables are magically available in ruby :)
|
The reason that |
This also updates the progress bar.
3ac2ddd to
106f77f
Compare
|
Ah, of course, makes sense, thanks. Think only thing I don't understand now is the |
That's just a simple decorator around the template context so that we can return the values in the way that we need. Mostly it's simple delegations but some are slightly more complicated. It then creates the cache key for each item in the list of dependencies. |
|
@dracos one more thing - I think creating a signature count API would be useful - there's no need to pull all of the JSON data just to get the signature count. |
This fetches the JSON of the petition every 10 seconds and updates the count, and progress bar, accordingly, with a pretty counting animation.