Skip to content

Commit

Permalink
Move glossary related actions out of AdminController...
Browse files Browse the repository at this point in the history
... into GlossaryController, and consolidate views.

Note two important loose ends:
1. The edit/update actions need to be secured with pundit.
2. The current glossary was hardcoded in /glossary/show.html.erb. Since
this commit changes that to be dynamic, we'll want to put the static
contents into a seed file or similar.
  • Loading branch information
solebared committed Jan 22, 2021
1 parent 7c6cf57 commit e5ae91f
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 170 deletions.
29 changes: 1 addition & 28 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,5 @@
class AdminController < ApplicationController
include NotUsingPunditYet

before_action :authenticate_user!, except: %i[new create]
before_action :set_system_settings, only: [:glossary_edit, :glossary_index, :glossary_update]

# FIXME: extract glossary related code into their own controller
def glossary_edit
@system_settings = SystemSetting.current_settings
render 'admin/glossary/form'
end

def glossary_index
@glossary_content = @system_settings.glossary_content
render 'admin/glossary/index'
end

def glossary_update
@system_settings.update(glossary_content: glossary_params[:glossary_content])
redirect_to glossary_admin_path
end

private

def glossary_params
params.require(:system_setting).permit(:glossary_content)
end

def set_system_settings
@system_settings = SystemSetting.current_settings
end
before_action :authenticate_user!
end
18 changes: 18 additions & 0 deletions app/controllers/glossary_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
class GlossaryController < PublicController
include NotUsingPunditYet

before_action :set_system_settings

def show; end
def edit; end

def update
@system_settings.update!(glossary_params)
redirect_to glossary_path
end

private

def glossary_params
params.require(:system_setting).permit(:glossary_content)
end

def set_system_settings
@system_settings = SystemSetting.current_settings
end
end
4 changes: 0 additions & 4 deletions app/views/admin/glossary/index.html.erb

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<%= render partial: 'admin/glossary/header' %>
<%= link_to "View Glossary", glossary_admin_path %>
<%= render partial: 'glossary/header' %>
<%= link_to "View Glossary", glossary_path %>
<hr>
<div class="glossary_form">
<%= form_with model: @system_settings, url: glossary_admin_edit_path, local: true do |f| %>
<%= form_with model: @system_settings, url: glossary_path, local: true do |f| %>
<div class="field">
<%= f.rich_text_area :glossary_content %>
</div>
Expand Down
97 changes: 4 additions & 93 deletions app/views/glossary/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,93 +1,4 @@
<div class="columns">
<div class="column is-12">
<div class="title">Glossary</div>
<hr>
</div>
</div>

<div class="row columns">
<div class="columns column is-12">
<div class="column is-12">
<%= link_to "Contributions", contributions_path %>: All public-generated content, like, Asks, Offers, Community Resources, Announcements

<hr>

<%= link_to "Community Resources", community_resources_path(is_approved: false) %>: Local offerings and organizations that are always available, e.g. Food Pantry, Diaper Bank. Can be links or videos
<br>
<%= link_to "Announcements", announcements_path(is_approved: false) %>: References and notes to share with the public about specific events and offerings, e.g. food drive Jun 12

<hr>


<%= link_to "Asks", listings_path(contribution_type: "Ask") %>: Request for support/exchange from the public
<br>
<%= link_to "Offers", listings_path(contribution_type: "Offer") %> Offer of support/exchange from the public
<br>
<%= link_to "Donations", donations_path %>: Log of Donations to the mutual aid group, but this form could connect to Stripe, etc, later

<hr>

<%= link_to "Locations", locations_path %>: Address-related info submitted by People or Organizations when they fill out Forms. Also used to store Service Area info
<br>
<%= link_to "Location Types", location_types_path %>: Kind of Location, so, home, business, cross street, etc
<br>
<%= link_to "Submissions", submissions_path %>: Form "responses" (This is a log of all results from all Forms: Ask, Offer, (CommunityResource, Annoucement, Volunteer), etc)
<br>
<%= link_to "Form Questions", custom_form_questions_path %>: Questions you want to be on your Forms
<br>
<%= link_to "Submission Responses", submission_responses_path %>: People's answers to specific Form Questions

<hr>


<%= link_to "Matches", matches_path %>: Connection between a receiver (Ask/Profile) and a provider (Offer/Community Resource/Profile) (Profile matches are TBD)
<br>
<%= link_to "Feedback", feedbacks_path %>: Each Match will generate an email request to receivers and providers to request Feedback about their experience. (We are considering showing stats on Profiles re thumbsup/starts/rating, TBD)
<br>
<%= link_to "Communication Log", communication_logs_path %>: Log of all phone calls, texts, etc, to People. Any system-generated emails will be saved as such.

<hr>

<%= link_to "People", people_path %>: All the human People in the system -- receiver/provider/leadership team member/partner organization point of contact/etc
<br>
<%= link_to "Volunteers", volunteer_admin_path %>: People who are part of the group (different than Providers who submit Offers)
<br>
<%= link_to "Positions", positions_path %>: Title/Role/Membership a Person has within an Organization, e.g. Leadership Team member/Dispatch Team member/Point of Contact

<hr>

<%= link_to "User accounts", users_path %>: For People who log in to this system. People will still have Profiles even if they don't have a User Account. (Still need to decide depending on login status.)
<br>
<%= link_to "Shared Accounts", shared_accounts_path %>: List of accounts the mutual aid group keeps, along w descriptions (but NOT passwords!), so there's one list of all the gmail addresses, payment gateways, etc. (Again, NOT the actual passwords!)
<br>
<%= link_to "Software Feedback", software_feedbacks_path %>: Place for Users (Admins only?) to store ideas/feedback for this system. (Y'all can decide which of these you want to request of coders...)
<br>

<%= link_to "Categories", categories_path %>: Services offered/facilitated by the mutual aid group. Can be nested. Categories will appear on Form checkboxes and dropdowns, and Contribution page filters
<br>
<%= link_to "Service Areas", service_areas_path %>: Geographic "areas" served by the mutual aid group. Can be nested. Can start at state, and drill down to Pods. Service Areas will appear on Form checkboxes and dropdowns, and Contribution page filters
<br>
<%= link_to "Contact Methods", contact_methods_path %>: Mechanism for contacting People, e.g. Text, Call, Email, WhatsApp. Contact Methods will appear on Form checkboxes and dropdowns, and on Contribution page filters

<hr>
<%= link_to "Translations", mobility_string_translations_path %>: Working up to multilanguage support
<br>
<%= link_to "System Locales", system_locales_path %>: Languages your group supports. We populated this list, but you can change it to whatever you want!

<hr>

<%= link_to "Yearbook", yearbook_path %>: List of everyone who has a Position. (Later we can have Profile photos.)

<hr>

<%= link_to "Respond", respond_contribution_path(Listing.first) %>: Preview a Contribution and prepare to "Respond" to the person by adding a Tentative Match
<br>
<%= link_to "Triage", triage_contribution_path(Listing.first) %>: Update Contribution -- Add short summary, change description, indicate if 'Inexhaustible'
<br>
<span class="has-text-weight-bold">Tentative Match:</span> This is a real Match. The first point of contact is to choose a potential match, and then to contact both parties.
<br>
<span class="has-text-weight-bold">Inexhaustible:</span> This Contribution can be matched many times, will continue to show up in dropdowns, etc

</div>
</div>
</div>
<%= render partial: 'glossary/header' %>
<%= link_to "Edit Glossary", edit_glossary_path, class: "btn" %>
<hr>
<%= @system_settings.glossary_content %>
6 changes: 1 addition & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
resource :yearbook, only: [:show], controller: :yearbook
end

get '/admin/glossary', to: 'admin#glossary_index', as: 'glossary_admin'
get '/admin/glossary_edit', to: 'admin#glossary_edit', as: 'glossary_admin_edit'
patch '/admin/glossary_edit', to: 'admin#glossary_update', as: 'glossary_admin_update'

get '/public', to: 'public_pages#landing_page', as: 'landing_page_public'
get '/about', to: 'public_pages#about', as: 'about_public'
get '/announcements_list', to: 'public_pages#announcements', as: 'announcements_public'
Expand Down Expand Up @@ -80,7 +76,7 @@
resources :teams
resources :users

resource :glossary, controller: :glossary, only: [:show]
resource :glossary, controller: :glossary, only: [:show, :edit, :update]

root :to => 'public_pages#landing_page'
end
37 changes: 0 additions & 37 deletions spec/requests/admin_spec.rb

This file was deleted.

35 changes: 35 additions & 0 deletions spec/requests/glossary_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'rails_helper'

describe '/glossary', type: :request do
let!(:system_setting) { FactoryBot.create :system_setting, glossary_content: 'Original text' }

before do
sign_in create(:user, :admin)
end

describe 'GET /glossary' do
it 'renders a successful response with the current content' do
get glossary_url
expect(response).to be_successful
expect(response.body).to include 'Original text'
end
end

describe 'GET /glossary/edit' do
it 'renders a successful response with the current content' do
get edit_glossary_url
expect(response).to be_successful
expect(response.body).to include 'Original text'
end
end

describe 'PATCH /glossary' do
let(:new_html) { "<b>Word</b>: Definition" }

it 'updates glossary_content of the system_setting object' do
patch glossary_url, params: { system_setting: { glossary_content: new_html } }
expect(response.status).to eq 302
expect(system_setting.reload.glossary_content.to_s).to include new_html
end
end
end

0 comments on commit e5ae91f

Please sign in to comment.