Skip to content

Add Flashs + Contribute to composts

Charlotte Flament requested to merge development into staging

Part 1 : Flash for user profile completion

Encourage user to fill-in his profile

  • when the user opens the website and his profile is not complete, a message appears to encourage to complete the profile

Changes

  • app/models/user.rb : added a private method calculating profile completion
  • app/helpers/users_helper.rb : added a profile_completed?(level) helper returning a boolean if the profile is completed up to a certain level
  • app/controllers/composts_controller.rb : added a callback for welcome page sending a flash if the condition profile_completion is below 50%

Tests

  • created a user with just an email and the password and the flash appears on the welcome page : PASSED
  • created a user with just an email and the password and the flash does not appear on the other pages : PASSED
  • edited a user with all useful data and the message no longer appears on the welcome page : PASSED

Links

Part 2 : Enable a authenticated user to add a contribution to a compost

Enable a user to do direct contributions

Changes

  • app/views/composts/_contribute.html.erb : create a partial with the contribution form
  • app/views/composts/show.html.erb : render the contribute partial
  • app/controllers/contributions_controller.rb : created a controller for contributions with new and create methods
  • config/routes.rb : created all resources routes for contributions
  • app/helpers/contributions_helper : the contribution_default_quantity` is defined in the helper

Tests

  • as a logged user, I can see a form on the page show of a compost : PASSED
  • as a logged user, I can click the button "contribuer" and a contribution is created and related to the right user and compost (I verify it in console) + I get a flash success message: PASSED
  • when a contribution is created, the filling attribute of the compost is incremented of the contribution_default_quantity: PASSED
  • as a unlogged user, I can access the compost show view : FAILED

Links

Side notes

  • still need to manage access to page show for simple visitor
  • no notion of contribution status or validation
  • no possibility to add a message to contribution for now
Edited by Ghost User

Merge request reports