-
Notifications
You must be signed in to change notification settings - Fork 5
Exchange Creation, Events Enhancements, i18n & Docs/CI Upgrades #1051
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
cdd02c3
Allow person to create a request directly in response to an offer
rsmithlal 48c7392
Notifiy offer creators of a match when someone makes a request linked…
rsmithlal 25e0e0c
Restrict the offer and request list results to exclude requests and o…
rsmithlal 13509d6
If person has responded to an offer, prevent them from responding aga…
rsmithlal 9e5ad4b
If request was created in response to an offer, show the offer that i…
rsmithlal 4b2699f
Clearly identify offers and requests created by current-person or in …
rsmithlal aeaadeb
Filter requests and offers to exclude those that were creared in resp…
rsmithlal 07a52d3
Rubocop fixes
rsmithlal 97011e0
Allow person to directly create an offer or request in response to a …
rsmithlal a142ba5
She the offer/request creator on the show view
rsmithlal 5b71f5a
Show source offer or request in the top of the form when responding t…
rsmithlal 8146cf1
Show and allow setting offer and request status and urgency
rsmithlal f3b40a9
Restricts responses to open/matched sources; marks matched status
rsmithlal 15f89cc
Update specs
rsmithlal caafc61
Rubocop Fixes
rsmithlal 9c87d8a
Add posts url to navigation item route names
rsmithlal 947bba4
Adjust offers and requests list sidebar to move add button to the sea…
rsmithlal b68463e
Rubocop fixes
rsmithlal c29afc0
Add diagram and docs for exchange system
rsmithlal cd23661
Update agent instructions to generate and maintain docs and diagrams
rsmithlal 6574547
Add pull request template and contributing guidelines
rsmithlal b146f74
Enhance agreement and response link handling
rsmithlal 4c0db86
Refactor notification handling in controllers and add NotificationRea…
rsmithlal bafc0ed
Add docs and flow diagram for notifications system
rsmithlal df0fafd
Update diagrams
rsmithlal 49a2b60
Add docs to readmes
rsmithlal f1f0dbf
Add docs and diagrams for user accounts and invitation flows
rsmithlal 10d0c89
Enhance diagram rendering script with force option and improved outpu…
rsmithlal c575e44
Add invitation requirement details to registration forms and document…
rsmithlal 3e39f51
Update docs developer guides to explain rendering diagrams
rsmithlal 6de2b6e
Update robot instructions to raise awareness of platform registrartio…
rsmithlal 3923b0d
Update robot instructions to use i18n-tasks to ensure translation health
rsmithlal 498e6ae
Add coverage report upload step to CI workflow
rsmithlal 3810019
Refactor flash messages to use I18n translations across controllers a…
rsmithlal 15e006b
Add docs and flow diagram for Role Based Access Control (RBAC)
rsmithlal 8a709cf
Add docs and diagrams of the content management and navigation systems
rsmithlal c41e212
Add privacy practices and metrics documentation to enhance data handl…
rsmithlal 9097f23
Add democratic-by-design docs
rsmithlal db789ef
Adjust i18n-health job to use ruby 3.4.4
rsmithlal a701242
feat: Implement event RSVP functionality with ICS export
rsmithlal 8f96fbd
Update coverage report generation for GH action
rsmithlal 33a39ad
feat: Implement source type validation in Joatu controllers and enhan…
rsmithlal f45e2c3
chore: Remove unnecessary whitespace in JoatuController
rsmithlal d921f33
feat: Enhance security guidelines in documentation for code generatio…
rsmithlal de3c632
Add event reminder functionality with associated tests and mailer
rsmithlal a233dac
feat: Enhance event reminder and update mailers with new templates an…
rsmithlal 161c728
feat: Refactor event reminder job and notifier to use params for even…
rsmithlal fb62b95
chore: Remove test_person.rb file as it is no longer needed
rsmithlal 333ed2f
refactor: Simplify error handling tests in EventReminderJob spec
rsmithlal e7939cf
Add notifications queue to dummy app
rsmithlal 71b9e47
feat: Enhance event and notification systems with comprehensive remin…
rsmithlal b0b810b
Normalize existing translations
rsmithlal 9e43d2e
Add missing translations
rsmithlal 9359464
fix: Update notification titles to include conversation context in En…
rsmithlal f236bab
fix: Simplify new message notification title in French locale
rsmithlal fdd1618
fix: Update time-related translations for improved clarity in English…
rsmithlal e0052ed
Merge branch 'main' into feature/exchange
rsmithlal 14860ad
refactor: Update event flow and documentation to enhance event hostin…
rsmithlal e2ea8af
refactor: Organize event host spec to improve clarity and structure
rsmithlal 7b6c579
feat: Add better_together_event_hosts table to schema
rsmithlal b15d50c
test: Add validation trigger for event host defaulting to creator
rsmithlal 7cd9c12
update i18n check
rsmithlal 86d6134
ci(i18n): install dev/test gems and use bundler-cache; add bin/i18n h…
rsmithlal f6326bf
ci(i18n): ensure bundler uses dev/test groups during cache; add i18n-…
rsmithlal da26be1
ci(i18n): make bin/i18n compatible across i18n-tasks versions (fallba…
rsmithlal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
app/controllers/better_together/joatu/response_links_controller.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module BetterTogether | ||
| module Joatu | ||
| class ResponseLinksController < JoatuController # rubocop:todo Style/Documentation | ||
| before_action :authenticate_user! | ||
| # This controller doesn't call Pundit's `authorize` in the create flow | ||
| # because it builds responses from an existing source. The global | ||
| # `after_action :verify_authorized` from ResourceController would raise | ||
| # an AuthorizationNotPerformedError after a redirect which can lead to a | ||
| # DoubleRenderError (redirect then error render). Skip the check here. | ||
| skip_after_action :verify_authorized | ||
|
|
||
| def create # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity | ||
| # Create a request from offer or offer from request, linking them via ResponseLink | ||
| source_type = params[:source_type] | ||
| source_id = params[:source_id] | ||
|
|
||
| unless source_type && source_id | ||
| return redirect_back fallback_location: joatu_hub_path, | ||
| alert: 'Invalid source' | ||
| end | ||
|
|
||
| source = source_type.constantize.find_by(id: source_id) | ||
|
||
| return redirect_back fallback_location: joatu_hub_path, alert: 'Source not found' unless source | ||
|
|
||
| # Only allow creating responses against sources that are open or already matched | ||
| if source.respond_to?(:status) && !%w[open matched].include?(source.status) | ||
| return redirect_back fallback_location: joatu_hub_path, | ||
| alert: 'Cannot respond to a source that is not open or matched.' | ||
| end | ||
|
|
||
| if source.is_a?(BetterTogether::Joatu::Offer) | ||
| # Build a new Request from offer details | ||
| request = BetterTogether::Joatu::Request.new | ||
| request.name = source.name | ||
| request.description = source.description | ||
| request.creator_id = helpers.current_person&.id | ||
| request.target_type = source.target_type if source.respond_to?(:target_type) | ||
| request.target_id = source.target_id if source.respond_to?(:target_id) | ||
| request.urgency = source.urgency if source.respond_to?(:urgency) | ||
| request.address_id = source.address_id if source.respond_to?(:address_id) | ||
| request.category_ids = source.categories.pluck(:id) if source.respond_to?(:categories) | ||
|
|
||
| if request.save | ||
| rl = ResponseLink.create(source: source, response: request, creator_id: helpers.current_person&.id) | ||
| if rl.persisted? | ||
| # mark_source_matched is handled in model callback | ||
| else | ||
| Rails.logger.error("Failed to create ResponseLink: #{rl.errors.full_messages.join(', ')}") | ||
| end | ||
| redirect_to joatu_request_path(request), notice: 'Request created in response to offer.' | ||
| else | ||
| redirect_back fallback_location: joatu_offer_path(source), | ||
| alert: request.errors.full_messages.to_sentence | ||
| end | ||
| elsif source.is_a?(BetterTogether::Joatu::Request) | ||
| offer = BetterTogether::Joatu::Offer.new | ||
| offer.name = source.name | ||
| offer.description = source.description | ||
| offer.creator_id = helpers.current_person&.id | ||
| offer.target_type = source.target_type if source.respond_to?(:target_type) | ||
| offer.target_id = source.target_id if source.respond_to?(:target_id) | ||
| offer.urgency = source.urgency if source.respond_to?(:urgency) | ||
| offer.address_id = source.address_id if source.respond_to?(:address_id) | ||
| offer.category_ids = source.categories.pluck(:id) if source.respond_to?(:categories) | ||
|
|
||
| if offer.save | ||
| rl = ResponseLink.create(source: source, response: offer, creator_id: helpers.current_person&.id) | ||
| unless rl.persisted? | ||
| Rails.logger.error("Failed to create ResponseLink: #{rl.errors.full_messages.join(', ')}") | ||
| end | ||
| redirect_to joatu_offer_path(offer), notice: 'Offer created in response to request.' | ||
| else | ||
| redirect_back fallback_location: joatu_request_path(source), | ||
| alert: offer.errors.full_messages.to_sentence | ||
| end | ||
| else | ||
| redirect_back fallback_location: joatu_hub_path, alert: 'Unsupported source type' | ||
| end | ||
| rescue StandardError => e | ||
| # Log full backtrace to surface errors during tests | ||
| Rails.logger.error( | ||
| "ResponseLinksController#create failed: #{e.class} - #{e.message}\n#{e.backtrace.join("\n")}" | ||
| ) | ||
| raise | ||
| end | ||
| end | ||
| end | ||
| end | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.