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

Follow button #963

Merged
merged 25 commits into from
Oct 16, 2017
Merged

Follow button #963

merged 25 commits into from
Oct 16, 2017

Conversation

apradillap
Copy link
Contributor

@apradillap apradillap commented Sep 21, 2017

Connects to #842

What does this PR do?

  • follow a subject:
    • if you click and you are logged in, you start to follow the subject
    • otherwise, the new login modal is opened
  • already following a subject
    • if you click, you stop following a subject

Depending on the context, the button should allow the user to follow:

  • GobiertoParticipation:
    • a process
    • an issue
    • an event
  • GobiertoPeople
    • a person
    • an event

Pending

  • After talking with Alvaro, the notification page has to be redefined because it will grow a lot depending on the people, events, etc. New Issue

captura de pantalla 2017-10-09 a las 9 47 51

@codecov-io
Copy link

codecov-io commented Oct 9, 2017

Codecov Report

Merging #963 into master will increase coverage by 0.08%.
The diff coverage is 79.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #963      +/-   ##
==========================================
+ Coverage   83.06%   83.14%   +0.08%     
==========================================
  Files         411      411              
  Lines       10033    10053      +20     
==========================================
+ Hits         8334     8359      +25     
+ Misses       1699     1694       -5
Impacted Files Coverage Δ
...ollers/user/subscription_preferences_controller.rb 90.9% <ø> (ø) ⬆️
app/forms/user/subscription_preferences_form.rb 92.85% <100%> (ø) ⬆️
app/forms/gobierto_admin/issue_form.rb 100% <100%> (ø) ⬆️
app/extensions/gobierto_common/trackable.rb 100% <100%> (ø) ⬆️
...ierto_admin/gobierto_participation/process_form.rb 88.88% <100%> (+0.93%) ⬆️
app/models/issue.rb 86.2% <50%> (-2.69%) ⬇️
app/controllers/user/subscriptions_controller.rb 90.56% <58.33%> (+16.65%) ⬆️
app/helpers/gobierto_budgets/application_helper.rb 75.34% <0%> (-2.74%) ⬇️
app/models/gobierto_budgets/budget_line_stats.rb 84.5% <0%> (-1.41%) ⬇️
app/forms/user/subscription_form.rb 100% <0%> (+5.71%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ee1599...c6a18d7. Read the comment docs.

@apradillap
Copy link
Contributor Author

@Crashillo I have a problem with Follow button, for example in, http:https://participacion.gobify.net/participacion/p/pacto-social-mujer
captura de pantalla 2017-10-09 a las 9 47 51

Can you help me with the magic of CSS? 😄

@apradillap
Copy link
Contributor Author

I'll check what happens in staging by following a process, which shows another alert. For example: http:https://participacion.gobify.net/participacion/p/jjnlvcebnogn-npp0vusbnoirsvon-vlgdlsjbn

@furilo
Copy link
Member

furilo commented Oct 9, 2017

There you have your CSS. @Crashillo no need to worry.

@apradillap
Copy link
Contributor Author

@furilo
Copy link
Member

furilo commented Oct 10, 2017

@apradillap the CSS issue is fixed.

Btw, the idea was that this button was Ajax (in the sandbox you even had the interaction), but now the whole page is reloading. Any special reason?

@apradillap
Copy link
Contributor Author

apradillap commented Oct 10, 2017

Thanks @furilo for the CSS! I reused another part of the application concerning subscriptions. So I change it to AJAX?

@furilo
Copy link
Member

furilo commented Oct 10, 2017

yes, it its quick

@ferblape
Copy link
Member

I think the new styles broke the button About this process:

screen shot 2017-10-11 at 08 26 37

See in staging: http:https://participacion.gobify.net/participacion/p/presupuestos-participativos-alcobendas

Copy link
Member

@ferblape ferblape left a comment

Choose a reason for hiding this comment

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

I miss tests to follow a Process. Those tests will have shown you the error 500 I caught in the acceptance.

@@ -38,15 +38,16 @@ def create
)
end

redirect_to request.referrer
redirect_to request.referrer if @user_subscription_form.subscribable.class.name == "Site" ||
Copy link
Member

Choose a reason for hiding this comment

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

This piece of code is not working well when I follow a Process, because is raising a 500 error:

NoMethodError (undefined method `name' for #<GobiertoParticipation::Process:0x007fd7f6ec9ed0>):

app/controllers/user/subscriptions_controller.rb:42:in `create'

If you are dealing with HTML and JS requests you should implement a respond_to, and probably redirect to the referer in all HTML requests, and in the JS requests render a create.js.erb partial. In this partial you should render the button in the new state.

So, when a user follows something the button will say "Proceso seguido!"

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the mistake I was telling you yesterday that I had pending, I was aware, I correct it and add the test.

@ferblape
Copy link
Member

Why I can't see in staging the block Participation in my subscription preferences?

screen shot 2017-10-11 at 08 44 08

In which branch is it?

@apradillap
Copy link
Contributor Author

Alvaro commented that we have to redefine the page of subscriptions, which made no sense because it was going to grow a lot.

@apradillap
Copy link
Contributor Author

@furilo Except the new styles broke the button About this process that @ferblape comments, I've added tests and I tested:
GobiertoParticipation:

  • a process
  • an issue

GobiertoPeople

  • a person
  • an event

I have deleted the follow event button within a process.

@apradillap apradillap removed the wip label Oct 11, 2017
@apradillap apradillap changed the title WIP - Follow button Follow button Oct 11, 2017
@@ -27,6 +28,14 @@ class ProcessForm

validates :site, :title_translations, :process_type, presence: true
validates :process_type, inclusion: { in: ::GobiertoParticipation::Process.process_types }
validates_presence_of :starts, :ends, if: :process?
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't add these validations over starts and ends, since they were removed on purpose here to make the process creation flow less restrictive. Applies to both processes and groups.

Please check with @furilo or @ferblape.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, those validations should be removed

@@ -27,6 +28,14 @@ class ProcessForm

validates :site, :title_translations, :process_type, presence: true
validates :process_type, inclusion: { in: ::GobiertoParticipation::Process.process_types }
validates_presence_of :starts, :ends, if: :process?
Copy link
Member

Choose a reason for hiding this comment

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

Yes, those validations should be removed

<a href="#" class="button outline rounded desktop_only follow_process"><i class="fa fa-rss"></i> <span><%= t('.follow_process') %></span></a>
<% end %>
<!-- ./ -->
<span id="subscribable_button">
Copy link
Member

Choose a reason for hiding this comment

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

👍 🆒

@apradillap
Copy link
Contributor Author

Ready to merge

@apradillap apradillap merged commit 671bae8 into master Oct 16, 2017
@apradillap apradillap deleted the 842-follow-button branch October 16, 2017 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants