From ecd677e827e653b9d9787c2c7b38eaeb2a66bdbc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 00:44:42 +0000 Subject: [PATCH 1/5] Initial plan From c8a0675040a94ce668d5d7b221044cb16e18e4f4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 00:51:34 +0000 Subject: [PATCH 2/5] Create migrations and new Organization models/controllers Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com> --- .../organization_statuses_controller.rb | 68 +++++++++ .../organization_users_controller.rb | 13 ++ app/controllers/organizations_controller.rb | 137 ++++++++++++++++++ app/decorators/organization_decorator.rb | 29 ++++ .../organization_status_decorator.rb | 3 + app/decorators/organization_user_decorator.rb | 5 + app/models/community_news.rb | 2 +- app/models/organization.rb | 107 ++++++++++++++ app/models/organization_obligation.rb | 5 + app/models/organization_status.rb | 7 + app/models/organization_user.rb | 17 +++ app/models/report.rb | 2 +- app/models/story.rb | 2 +- app/models/story_idea.rb | 10 +- app/models/user.rb | 22 +-- app/models/workshop_log.rb | 4 +- config/routes.rb | 5 +- ...004745_rename_projects_to_organizations.rb | 59 ++++++++ 18 files changed, 473 insertions(+), 24 deletions(-) create mode 100644 app/controllers/organization_statuses_controller.rb create mode 100644 app/controllers/organization_users_controller.rb create mode 100644 app/controllers/organizations_controller.rb create mode 100644 app/decorators/organization_decorator.rb create mode 100644 app/decorators/organization_status_decorator.rb create mode 100644 app/decorators/organization_user_decorator.rb create mode 100644 app/models/organization.rb create mode 100644 app/models/organization_obligation.rb create mode 100644 app/models/organization_status.rb create mode 100644 app/models/organization_user.rb create mode 100644 db/migrate/20260120004745_rename_projects_to_organizations.rb diff --git a/app/controllers/organization_statuses_controller.rb b/app/controllers/organization_statuses_controller.rb new file mode 100644 index 000000000..bf7441d60 --- /dev/null +++ b/app/controllers/organization_statuses_controller.rb @@ -0,0 +1,68 @@ +class OrganizationStatusesController < Admin::BaseController + before_action :set_organization_status, only: [ :show, :edit, :update, :destroy ] + + def index + per_page = params[:number_of_items_per_page].presence || 25 + unfiltered = OrganizationStatus.all + @count_display = unfiltered.count + @organization_statuses = unfiltered.paginate(page: params[:page], per_page: per_page).decorate + end + + def show + @organization_status = @organization_status.decorate + end + + def new + @organization_status = OrganizationStatus.new.decorate + set_form_variables + end + + def edit + @organization_status = @organization_status.decorate + set_form_variables + end + + def create + @organization_status = OrganizationStatus.new(organization_status_params) + + if @organization_status.save + redirect_to organization_statuses_path, notice: "Organization status was successfully created." + else + @organization_status = OrganizationStatus.new.decorate + set_form_variables + render :new, status: :unprocessable_content + end + end + + def update + if @organization_status.update(organization_status_params) + redirect_to organization_statuses_path, notice: "Organization status was successfully updated.", status: :see_other + else + @organization_status = OrganizationStatus.new.decorate + set_form_variables + render :edit, status: :unprocessable_content + end + end + + def destroy + @organization_status.destroy! + redirect_to organization_statuses_path, notice: "Organization status was successfully destroyed." + end + + # Optional hooks for setting variables for forms or index + def set_form_variables + end + + private + + def set_organization_status + @organization_status = OrganizationStatus.find(params[:id]) + end + + # Strong parameters + def organization_status_params + params.require(:organization_status).permit( + :name + ) + end +end diff --git a/app/controllers/organization_users_controller.rb b/app/controllers/organization_users_controller.rb new file mode 100644 index 000000000..400a3db27 --- /dev/null +++ b/app/controllers/organization_users_controller.rb @@ -0,0 +1,13 @@ +class OrganizationUsersController < ApplicationController + def destroy + organization_user = OrganizationUser.find(params[:id]) + user = organization_user.user + + if organization_user.destroy + flash[:notice] = "Organization user has been deleted." + else + flash[:alert] = "Unable to delete organization user. Please contact AWBW." + end + redirect_to generate_facilitator_user_path(user) + end +end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb new file mode 100644 index 000000000..179e427a1 --- /dev/null +++ b/app/controllers/organizations_controller.rb @@ -0,0 +1,137 @@ +class OrganizationsController < ApplicationController + before_action :set_organization, only: [ :show, :edit, :update, :destroy ] + + def index + per_page = params[:number_of_items_per_page].presence || 25 + unpaginated = Organization.search_by_params(params).order(:name) + @organizations_count = unpaginated.count + @organizations = unpaginated.paginate(page: params[:page], per_page: per_page) + set_index_variables + end + + def show + @organization.increment_view_count!(session: session, request: request) + + # Reuse WorkshopLogsController#index logic programmatically + workshop_logs_controller = WorkshopLogsController.new + workshop_logs_controller.request = request + workshop_logs_controller.response = response + params[:organization_id] = @organization.id # Inject context so the WorkshopLogsController#index scopes properly + workshop_logs_controller.params = params + workshop_logs_controller.index + + workshop_logs = WorkshopLog.where(organization_id: @organization.id) + @month_year_options = workshop_logs.group("DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m')") + .select("DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m') AS ym, + MAX(COALESCE(date, created_at)) AS max_dt") + .order("max_dt DESC") + .map { |record| [ Date.strptime(record.ym, "%Y-%m").strftime("%B %Y"), record.ym ] } + + @year_options = workshop_logs.pluck( + Arel.sql("DISTINCT EXTRACT(YEAR FROM COALESCE(date, created_at, NOW()))") + ).sort.reverse + @organizations = Organization.where(id: @organization.id) + @per_page = params[:per_page] || 10 + @workshop_logs_unpaginated = workshop_logs + @workshop_logs_count = @workshop_logs_unpaginated.size + @workshop_logs = @workshop_logs_unpaginated.paginate(page: params[:page], per_page: @per_page) + @facilitators = User.active.or(User.where(id: @workshop_logs_unpaginated.pluck(:user_id))) + .joins(:workshop_logs) + .distinct + .order(:last_name, :first_name) + end + + def new + @organization = Organization.new + set_form_variables + end + + def edit + set_form_variables + end + + def create + @organization = Organization.new(organization_params) + + if @organization.save + redirect_to organizations_path, notice: "Organization was successfully created." + else + set_form_variables + render :new, status: :unprocessable_content + end + end + + def update + if @organization.update(organization_params) + redirect_to organizations_path, notice: "Organization was successfully updated.", status: :see_other + else + set_form_variables + render :edit, status: :unprocessable_content + end + end + + def destroy + @organization.destroy! + redirect_to organizations_path, notice: "Organization was successfully destroyed." + end + + # Optional hooks for setting variables for forms or index + def set_form_variables + @organization_statuses = OrganizationStatus.all + @facilitators_array = Facilitator.joins(:user) + .order(:first_name, :last_name) + .map { |f| [ f.name, f.user.id ] } + @organization.organization_users = @organization.organization_users + .includes(:organization) + .sort_by { |ou| ou.user.facilitator&.name.to_s.downcase } + end + + def set_index_variables + @organization_statuses = OrganizationStatus.all + end + + private + + def set_organization + @organization = Organization.find(params[:id]) + end + + # Strong parameters + def organization_params + params.require(:organization).permit( + :name, :description, :start_date, :end_date, :mission_vision_values, :internal_id, + :inactive, :logo, :notes, :agency_type, :agency_type_other, :website_url, + :organization_status_id, :location_id, :windows_type_id, + sectorable_items_attributes: [ + :id, + :sector_id, + :_destroy + ], + organization_users_attributes: [ + :id, + :user_id, + :inactive, + :title, + :_destroy + ], + addresses_attributes: [ + :id, + :address_type, + :inactive, + :phone, + :street_address, + :city, + :state, + :zip_code, + :county, + :country, + :district, + :locality, + :la_city_council_district, + :la_supervisorial_district, + :la_service_planning_area, + :_destroy + ] + ) + end +end diff --git a/app/decorators/organization_decorator.rb b/app/decorators/organization_decorator.rb new file mode 100644 index 000000000..7f8a76095 --- /dev/null +++ b/app/decorators/organization_decorator.rb @@ -0,0 +1,29 @@ +class OrganizationDecorator < ApplicationDecorator + def detail(length: nil) + length ? description&.truncate(length) : description + end + + def default_display_image + return logo if respond_to?(:logo) && logo&.attached? + "theme_default.png" + end + + def title + name + end + + def badges + years = start_date ? (Time.zone.now.year - start_date.year) : 0 + badges = [] + badges << [ "Legacy Organization (10+ years)", "yellow" ] if true || years >= 10 + badges << [ "Seasoned Organization (3-10 years)", "gray" ] if true || start_date.present? && years >= 3 + badges << [ "New Organization (<3 years)", "green" ] if true || start_date.present? && years < 3 + badges << [ "Spotlighted Organization", "gray" ] if true || stories_as_spotlighted_facilitator + badges << [ "Events Hosted", "blue" ] if true || Event.count > 3 + # badges << ["Workshop Author", "gray"] if true || user.workshops.any? # indigo + # badges << ["Story Author", "gray"] if true || user.stories_as_creator.any? # pink + # badges << ["Sector Leader", "purple"] if true || sectorable_items.where(is_leader: true).any? + badges << [ "Blog Contributor", "gray" ] if true # || user.respond_to?(:blogs) && user.blogs.any? # red + badges + end +end diff --git a/app/decorators/organization_status_decorator.rb b/app/decorators/organization_status_decorator.rb new file mode 100644 index 000000000..5c8d0ac80 --- /dev/null +++ b/app/decorators/organization_status_decorator.rb @@ -0,0 +1,3 @@ +class OrganizationStatusDecorator < Draper::Decorator + delegate_all +end diff --git a/app/decorators/organization_user_decorator.rb b/app/decorators/organization_user_decorator.rb new file mode 100644 index 000000000..ff7bd9386 --- /dev/null +++ b/app/decorators/organization_user_decorator.rb @@ -0,0 +1,5 @@ +class OrganizationUserDecorator < ApplicationDecorator + def detail(length: nil) + "#{user.full_name}: #{title.presence || position} - #{organization.name}" + end +end diff --git a/app/models/community_news.rb b/app/models/community_news.rb index d64f35c83..c4a322d60 100644 --- a/app/models/community_news.rb +++ b/app/models/community_news.rb @@ -1,7 +1,7 @@ class CommunityNews < ApplicationRecord include TagFilterable, Trendable, ViewCountable, WindowsTypeFilterable - belongs_to :project, optional: true + belongs_to :organization, optional: true belongs_to :windows_type, optional: true belongs_to :author, class_name: "User", optional: true belongs_to :created_by, class_name: "User" diff --git a/app/models/organization.rb b/app/models/organization.rb new file mode 100644 index 000000000..03ffdf416 --- /dev/null +++ b/app/models/organization.rb @@ -0,0 +1,107 @@ +class Organization < ApplicationRecord + include TagFilterable, Trendable, ViewCountable, WindowsTypeFilterable + + belongs_to :organization_status + belongs_to :organization_obligation, optional: true + belongs_to :location, optional: true # TODO - remove Location if unused + belongs_to :windows_type, optional: true + has_many :addresses, as: :addressable, dependent: :destroy + has_many :bookmarks, as: :bookmarkable, dependent: :destroy + has_many :organization_users, dependent: :restrict_with_error + has_many :users, through: :organization_users + has_many :reports, through: :users + has_many :workshop_logs, through: :users + + has_many :categorizable_items, dependent: :destroy, inverse_of: :categorizable, as: :categorizable + has_many :sectorable_items, as: :sectorable, dependent: :destroy + # has_many through + has_many :categories, through: :categorizable_items + has_many :sectors, through: :sectorable_items + + # Asset associations + has_one_attached :logo + + # Validations + validates :logo, + content_type: %w[image/png image/jpeg image/webp], + size: { less_than: 5.megabytes } + validates :name, presence: true + validates :organization_status_id, presence: true + + # Nested attributes + accepts_nested_attributes_for :addresses, allow_destroy: true, reject_if: :all_blank + accepts_nested_attributes_for :sectorable_items, allow_destroy: true, reject_if: :all_blank + accepts_nested_attributes_for :organization_users, allow_destroy: true, reject_if: :all_blank + + # SearchCop + include SearchCop + search_scope :search do + attributes :name + end + + scope :address, ->(address) do + return all if address.blank? + exact = address.to_s + wildcard = "%#{exact}%" + left_joins(:addresses).where( + <<~SQL, + addresses.street_address LIKE :wildcard OR + addresses.city LIKE :wildcard OR + addresses.state LIKE :wildcard OR + addresses.county LIKE :wildcard OR + addresses.country LIKE :wildcard OR + addresses.district LIKE :wildcard OR + addresses.locality LIKE :wildcard OR + addresses.zip_code LIKE :exact OR + CAST(addresses.la_city_council_district AS CHAR) = :exact OR + CAST(addresses.la_service_planning_area AS CHAR) = :exact OR + CAST(addresses.la_supervisorial_district AS CHAR) = :exact + SQL + wildcard: wildcard, exact: exact) + end + scope :active, ->(active = nil) { active ? where(inactive: !active) : where(inactive: false) } + scope :by_most_viewed, ->(limit = 10) { order(view_count: :desc).limit(limit) } + scope :organization_ids, ->(organization_ids) { where(id: organization_ids.to_s.split("-").map(&:to_i)) } + scope :published, ->(published = nil) { published ? active(published) : active } + scope :category_names, ->(names) { tag_names(:categories, names) } + scope :sector_names, ->(names) { tag_names(:sectors, names) } + + def self.search_by_params(params) + organizations = self.all + organizations = organizations.search(params[:query]) if params[:query].present? + organizations = organizations.sector_names(params[:sector_names]) if params[:sector_names].present? + organizations = organizations.category_names(params[:category_names]) if params[:category_names].present? + organizations = organizations.address(params[:address]) if params[:address].present? + organizations = organizations.windows_type_name(params[:windows_type_name]) if params[:windows_type_name].present? + organizations = organizations.organization_ids(params[:organization_ids]) if params[:organization_ids].present? + organizations + end + + # Methods + def led_by?(user) + return false unless leader + leader.user == user + end + + def type_name + "#{name} #{ " (#{windows_type.short_name})" if windows_type}" + end + + def organization_description + "#{name}, #{organization_locality}" + end + + def organization_locality + addresses.active.first&.locality + end + + def sector_list + sectors.pluck(:name) + end + + private + + def leader + organization_users.find_by(position: 2) + end +end diff --git a/app/models/organization_obligation.rb b/app/models/organization_obligation.rb new file mode 100644 index 000000000..2203d1df7 --- /dev/null +++ b/app/models/organization_obligation.rb @@ -0,0 +1,5 @@ +class OrganizationObligation < ApplicationRecord + OBLIGATION_TYPES = [ "Current Grant Funded", "Previous Grant Funded", + "Voluntary Reporting", "Intermittent Reporting", + "Active Non-Reporting" ] +end diff --git a/app/models/organization_status.rb b/app/models/organization_status.rb new file mode 100644 index 000000000..fde753171 --- /dev/null +++ b/app/models/organization_status.rb @@ -0,0 +1,7 @@ +class OrganizationStatus < ApplicationRecord + ORGANIZATION_STATUSES = [ "Active", "Inactive", "Pending", "Reinstate", "Suspended", "Unknown" ] + + has_many :organizations + + validates :name, presence: true, uniqueness: true +end diff --git a/app/models/organization_user.rb b/app/models/organization_user.rb new file mode 100644 index 000000000..e41e72dee --- /dev/null +++ b/app/models/organization_user.rb @@ -0,0 +1,17 @@ +class OrganizationUser < ApplicationRecord + belongs_to :organization + belongs_to :user + + # Validations + validates_presence_of :organization_id + + # Enum + enum :position, { default: 0, liaison: 1, leader: 2, assistant: 3 } + + scope :active, -> { where(inactive: false) } + + # Methods + def name + "#{user.name}" if user + end +end diff --git a/app/models/report.rb b/app/models/report.rb index a569d5851..3a9c5bf85 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,7 +1,7 @@ class Report < ApplicationRecord belongs_to :owner, polymorphic: true, optional: true belongs_to :user - belongs_to :project + belongs_to :organization belongs_to :windows_type has_one :form, as: :owner has_many :bookmarks, as: :bookmarkable, dependent: :destroy diff --git a/app/models/story.rb b/app/models/story.rb index c7078f1ca..f0b34cb65 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -4,7 +4,7 @@ class Story < ApplicationRecord belongs_to :created_by, class_name: "User" belongs_to :updated_by, class_name: "User" belongs_to :windows_type - belongs_to :project, optional: true + belongs_to :organization, optional: true belongs_to :spotlighted_facilitator, class_name: "Facilitator", foreign_key: "spotlighted_facilitator_id", optional: true belongs_to :story_idea, optional: true diff --git a/app/models/story_idea.rb b/app/models/story_idea.rb index 757b79390..fe37ea1d5 100644 --- a/app/models/story_idea.rb +++ b/app/models/story_idea.rb @@ -7,7 +7,7 @@ class StoryIdea < ApplicationRecord belongs_to :created_by, class_name: "User" belongs_to :updated_by, class_name: "User" - belongs_to :project + belongs_to :organization belongs_to :windows_type belongs_to :workshop, optional: true has_many :bookmarks, as: :bookmarkable, dependent: :destroy @@ -23,7 +23,7 @@ class StoryIdea < ApplicationRecord # Validations validates :created_by_id, presence: true validates :updated_by_id, presence: true - validates :project_id, presence: true + validates :organization_id, presence: true validates :windows_type_id, presence: true validates :body, presence: true validates :permission_given, presence: true @@ -57,14 +57,14 @@ def author_credit end def organization_name - project.name + organization.name end def organization_locality - project&.organization_locality + organization&.organization_locality end def organization_description - project&.organization_description + organization&.organization_description end end diff --git a/app/models/user.rb b/app/models/user.rb index 88526c7da..2ea550354 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,7 +12,7 @@ class User < ApplicationRecord has_many :bookmarks, dependent: :destroy has_many :event_registrations, foreign_key: :registrant_id, dependent: :destroy has_many :notifications, as: :noticeable - has_many :project_users, dependent: :destroy + has_many :organization_users, dependent: :destroy has_many :reports has_many :resources has_many :user_forms, dependent: :destroy @@ -30,20 +30,20 @@ class User < ApplicationRecord has_many :bookmarked_workshops, through: :bookmarks, source: :bookmarkable, source_type: "Workshop" has_many :bookmarked_resources, through: :bookmarks, source: :bookmarkable, source_type: "Resource" has_many :bookmarked_events, through: :bookmarks, source: :bookmarkable, source_type: "Event" - has_many :colleagues, -> { select(:user_id, :position, :project_id).distinct }, - through: :projects, source: :project_users - has_many :communal_reports, through: :projects, source: :reports + has_many :colleagues, -> { select(:user_id, :position, :organization_id).distinct }, + through: :organizations, source: :organization_users + has_many :communal_reports, through: :organizations, source: :reports has_many :events, through: :event_registrations - has_many :projects, through: :project_users + has_many :organizations, through: :organization_users has_many :user_form_form_fields, through: :user_forms, dependent: :destroy - has_many :windows_types, through: :projects + has_many :windows_types, through: :organizations # Images has_one_attached :avatar # Nested attributes accepts_nested_attributes_for :user_forms - accepts_nested_attributes_for :project_users, allow_destroy: true, - reject_if: proc { |attrs| attrs["project_id"].blank? || attrs["title"].blank? } + accepts_nested_attributes_for :organization_users, allow_destroy: true, + reject_if: proc { |attrs| attrs["organization_id"].blank? || attrs["title"].blank? } # Validations validates :email, presence: true, uniqueness: { case_sensitive: false } @@ -52,7 +52,7 @@ class User < ApplicationRecord include SearchCop search_scope :search do attributes [ :email, :first_name, :last_name, :phone ] - attributes user: "projects.name" + attributes user: "organizations.name" end scope :active, -> { where(inactive: false) } @@ -65,8 +65,8 @@ def self.search_by_params(params) results end - def has_liasion_position_for?(project_id) - !project_users.where(project_id: project_id, position: 1).first.nil? + def has_liasion_position_for?(organization_id) + !organization_users.where(organization_id: organization_id, position: 1).first.nil? end def active_for_authentication? diff --git a/app/models/workshop_log.rb b/app/models/workshop_log.rb index 9bab0523a..cb7b80d66 100644 --- a/app/models/workshop_log.rb +++ b/app/models/workshop_log.rb @@ -14,7 +14,7 @@ class WorkshopLog < Report # Scopes scope :workshop_id, ->(workshop_id) { where(workshop_id: workshop_id) if workshop_id.present? } - scope :project_id, ->(project_id) { where(project_id: project_id) if project_id.present? } + scope :organization_id, ->(organization_id) { where(organization_id: organization_id) if organization_id.present? } scope :user_id, ->(user_id) { where(user_id: user_id.to_i) if user_id.present? } scope :month_and_year, ->(month_and_year) { if month_and_year.present? @@ -34,7 +34,7 @@ def self.search(params) logs = logs.month_and_year(params[:month_and_year]) if params[:month_and_year].present? logs = logs.year(params[:year]) if params[:year].present? logs = logs.workshop_id(params[:workshop_id]) if params[:workshop_id].present? - logs = logs.project_id(params[:project_id]) if params[:project_id].present? + logs = logs.organization_id(params[:organization_id]) if params[:organization_id].present? logs.ordered_by_date end diff --git a/config/routes.rb b/config/routes.rb index a888cd316..47b2e9ed5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -60,9 +60,8 @@ resources :faqs resources :notifications, only: [ :index, :show ] resources :organizations - resources :projects - resources :project_statuses - resources :project_users + resources :organization_statuses + resources :organization_users resources :quotes resources :monthly_reports diff --git a/db/migrate/20260120004745_rename_projects_to_organizations.rb b/db/migrate/20260120004745_rename_projects_to_organizations.rb new file mode 100644 index 000000000..c9235f56e --- /dev/null +++ b/db/migrate/20260120004745_rename_projects_to_organizations.rb @@ -0,0 +1,59 @@ +class RenameProjectsToOrganizations < ActiveRecord::Migration[8.1] + def change + # Rename main projects table to organizations + rename_table :projects, :organizations + + # Rename project_statuses table + rename_table :project_statuses, :organization_statuses + + # Rename project_obligations table + rename_table :project_obligations, :organization_obligations + + # Rename project_users table + rename_table :project_users, :organization_users + + # Update foreign key columns + rename_column :organization_users, :project_id, :organization_id + rename_column :organization_users, :agency_id, :organization_agency_id + + # Update foreign key in organizations table + rename_column :organizations, :project_status_id, :organization_status_id + + # Update project_id foreign keys in other tables + rename_column :community_news, :project_id, :organization_id + rename_column :monthly_reports, :project_id, :organization_id + rename_column :reports, :project_id, :organization_id + rename_column :stories, :project_id, :organization_id + rename_column :story_ideas, :project_id, :organization_id + rename_column :workshop_logs, :project_id, :organization_id + + # Rename project_user_id foreign key + rename_column :monthly_reports, :project_user_id, :organization_user_id + + # Rename indexes + rename_index :organization_users, 'index_project_users_on_project_id', 'index_organization_users_on_organization_id' + rename_index :organization_users, 'index_project_users_on_agency_id', 'index_organization_users_on_organization_agency_id' + rename_index :organization_users, 'index_project_users_on_user_id', 'index_organization_users_on_user_id' + + rename_index :organizations, 'index_projects_on_location_id', 'index_organizations_on_location_id' + rename_index :organizations, 'index_projects_on_project_status_id', 'index_organizations_on_organization_status_id' + rename_index :organizations, 'index_projects_on_view_count', 'index_organizations_on_view_count' + rename_index :organizations, 'index_projects_on_windows_type_id', 'index_organizations_on_windows_type_id' + + rename_index :community_news, 'index_community_news_on_project_id', 'index_community_news_on_organization_id' + rename_index :monthly_reports, 'index_monthly_reports_on_project_id', 'index_monthly_reports_on_organization_id' + rename_index :monthly_reports, 'index_monthly_reports_on_project_user_id', 'index_monthly_reports_on_organization_user_id' + rename_index :reports, 'index_reports_on_project_id', 'index_reports_on_organization_id' + rename_index :stories, 'index_stories_on_project_id', 'index_stories_on_organization_id' + rename_index :story_ideas, 'index_story_ideas_on_project_id', 'index_story_ideas_on_organization_id' + rename_index :workshop_logs, 'index_workshop_logs_on_project_id', 'index_workshop_logs_on_organization_id' + + # Rename foreign key constraints + # Note: Rails will handle updating foreign key references automatically when we rename the columns + # However, we need to explicitly update any named foreign key constraints + + # For users table that references projects as agency_id + # The existing foreign key is already named correctly as it references projects.id + # Rails will automatically update this when we rename the table + end +end From 6dc0b8be1f92c0a2ef243fddee9108d866991f8e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 01:03:52 +0000 Subject: [PATCH 3/5] Update view files and controllers for Organization Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com> --- app/controllers/facilitators_controller.rb | 14 ++-- app/controllers/users_controller.rb | 12 ++-- app/views/facilitators/_form.html.erb | 20 +++--- ...erb => _organization_user_fields.html.erb} | 8 +-- .../_form.html.erb | 12 ++-- .../edit.html.erb | 6 +- .../index.html.erb | 26 +++---- .../new.html.erb | 4 +- .../show.html.erb | 22 +++--- .../_address_fields.html.erb | 0 .../_form.html.erb | 42 +++++------ .../_organization_user_fields.html.erb} | 2 +- .../_search_boxes.html.erb | 10 +-- .../_sectorable_item_fields.html.erb | 0 .../_social_media_buttons.html.erb | 22 +++--- .../{projects => organizations}/edit.html.erb | 4 +- .../index.html.erb | 42 +++++------ .../{projects => organizations}/new.html.erb | 2 +- .../{projects => organizations}/show.html.erb | 72 +++++++++---------- ...r.html.erb => _organization_user.html.erb} | 4 +- ...erb => _organization_user_fields.html.erb} | 6 +- 21 files changed, 165 insertions(+), 165 deletions(-) rename app/views/facilitators/{_project_user_fields.html.erb => _organization_user_fields.html.erb} (85%) rename app/views/{project_statuses => organization_statuses}/_form.html.erb (60%) rename app/views/{project_statuses => organization_statuses}/edit.html.erb (75%) rename app/views/{project_statuses => organization_statuses}/index.html.erb (66%) rename app/views/{project_statuses => organization_statuses}/new.html.erb (82%) rename app/views/{project_statuses => organization_statuses}/show.html.erb (66%) rename app/views/{projects => organizations}/_address_fields.html.erb (100%) rename app/views/{projects => organizations}/_form.html.erb (88%) rename app/views/{projects/_project_user_fields.html.erb => organizations/_organization_user_fields.html.erb} (94%) rename app/views/{projects => organizations}/_search_boxes.html.erb (85%) rename app/views/{projects => organizations}/_sectorable_item_fields.html.erb (100%) rename app/views/{projects => organizations}/_social_media_buttons.html.erb (72%) rename app/views/{projects => organizations}/edit.html.erb (84%) rename app/views/{projects => organizations}/index.html.erb (73%) rename app/views/{projects => organizations}/new.html.erb (91%) rename app/views/{projects => organizations}/show.html.erb (72%) rename app/views/shared/{_project_user.html.erb => _organization_user.html.erb} (87%) rename app/views/users/{_project_user_fields.html.erb => _organization_user_fields.html.erb} (91%) diff --git a/app/controllers/facilitators_controller.rb b/app/controllers/facilitators_controller.rb index ad1a27044..60380aaf0 100644 --- a/app/controllers/facilitators_controller.rb +++ b/app/controllers/facilitators_controller.rb @@ -81,14 +81,14 @@ def set_form_variables # @facilitator.build_user if @facilitator.user.blank? # Build a fresh one if missing if @facilitator.user - @facilitator.user.project_users.first || @facilitator.user.project_users.build + @facilitator.user.organization_users.first || @facilitator.user.organization_users.build end - projects = if current_user.super_user? - Project.active + organizations = if current_user.super_user? + Organization.active else - current_user.projects + current_user.organizations end - @projects_array = projects.order(:name).pluck(:name, :id) + @organizations_array = organizations.order(:name).pluck(:name, :id) end @@ -176,9 +176,9 @@ def facilitator_params :state2, :zip2, :notes, - project_users_attributes: [ + organization_users_attributes: [ :id, - :project_id, + :organization_id, :position, :title, :inactive, diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 78102f9c9..43cf7c514 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -110,13 +110,13 @@ def set_facilitator def set_form_variables set_facilitator - @user.project_users.first || @user.project_users.build - projects = if current_user.super_user? - Project.active + @user.organization_users.first || @user.organization_users.build + organizations = if current_user.super_user? + Organization.active else - current_user.projects + current_user.organizations end - @projects_array = projects.order(:name).pluck(:name, :id) + @organizations_array = organizations.order(:name).pluck(:name, :id) end def password_param @@ -135,7 +135,7 @@ def user_params :notes, :primary_address, :avatar, :subscribecode, :agency_id, :facilitator_id, :created_by_id, :updated_by_id, :confirmed, :inactive, :super_user, :legacy, :legacy_id, - project_users_attributes: [ :id, :project_id, :position, :title, :inactive, :_destroy ] + organization_users_attributes: [ :id, :organization_id, :position, :title, :inactive, :_destroy ] ) end end diff --git a/app/views/facilitators/_form.html.erb b/app/views/facilitators/_form.html.erb index 67f09cadb..0bd19227f 100644 --- a/app/views/facilitators/_form.html.erb +++ b/app/views/facilitators/_form.html.erb @@ -149,27 +149,27 @@
<% if current_user.super_user? %>
- <%= u.fields_for :project_users do |project_user_form| %> - <%= render "project_user_fields", - f: project_user_form, - projects: u.object.projects, + <%= u.fields_for :organization_users do |organization_user_form| %> + <%= render "organization_user_fields", + f: organization_user_form, + organizations: u.object.organizations, user: u.object %> <% end %>
<%= link_to_add_association "➕ Add Role", u, - :project_users, - html_options: { locals: { projects: u.object.projects } }, + :organization_users, + html_options: { locals: { organizations: u.object.organizations } }, class: "btn btn-secondary-outline" %>
<% else %> - <% f.object.user && f.object.user.project_users.each do |pu| %> + <% f.object.user && f.object.user.organization_users.each do |ou| %>
-
  • <%= pu.title || pu.position %> - <%= pu.persisted? ? (link_to pu.project&.name, - project_path(pu.project), - class: "underline") : pu.project&.name %>
  • +
  • <%= ou.title || ou.position %> - <%= ou.persisted? ? (link_to ou.organization&.name, + organization_path(ou.organization), + class: "underline") : ou.organization&.name %>
  • <% end %> <% end %> diff --git a/app/views/facilitators/_project_user_fields.html.erb b/app/views/facilitators/_organization_user_fields.html.erb similarity index 85% rename from app/views/facilitators/_project_user_fields.html.erb rename to app/views/facilitators/_organization_user_fields.html.erb index f9b50287d..070276b43 100644 --- a/app/views/facilitators/_project_user_fields.html.erb +++ b/app/views/facilitators/_organization_user_fields.html.erb @@ -2,11 +2,11 @@
    - <%= f.input :project_id, + <%= f.input :organization_id, as: :select, label: "Organization", - collection: @projects_array, - selected: f.object.project_id, + collection: @organizations_array, + selected: f.object.organization_id, input_html: { class: "block w-full rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500" } %> @@ -38,6 +38,6 @@
    <% else %>
    -
  • <%= f.object.project&.name %> (<%= f.object.title || f.object.position %>)
  • +
  • <%= f.object.organization&.name %> (<%= f.object.title || f.object.position %>)
  • <% end %> diff --git a/app/views/project_statuses/_form.html.erb b/app/views/organization_statuses/_form.html.erb similarity index 60% rename from app/views/project_statuses/_form.html.erb rename to app/views/organization_statuses/_form.html.erb index a69ea4067..22afb4ff3 100644 --- a/app/views/project_statuses/_form.html.erb +++ b/app/views/organization_statuses/_form.html.erb @@ -1,12 +1,12 @@ -<%= simple_form_for(@project_status) do |f| %> +<%= simple_form_for(@organization_status) do |f| %>
    <%= f.error_notification %> - <%= render "shared/errors", resource: @project_status if @project_status.errors.any? %> + <%= render "shared/errors", resource: @organization_status if @organization_status.errors.any? %>
    - <% @project_status.attribute_names.reject { |a| ["id", "created_at", "updated_at"].include?(a) }.each do |attr| %> + <% @organization_status.attribute_names.reject { |a| ["id", "created_at", "updated_at"].include?(a) }.each do |attr| %> <% next if ["id", "created_at", "updated_at"].include?(attr) %>
    <%= f.input attr.to_sym, input_html: { class: "form-control" } %> @@ -16,11 +16,11 @@
    - <% if @project_status.persisted? && current_user.super_user? %> - <%= link_to "Delete", @project_status, method: :delete, + <% if @organization_status.persisted? && current_user.super_user? %> + <%= link_to "Delete", @organization_status, method: :delete, class: "btn btn-danger-outline", data: { confirm: "Are you sure?" } %> <% end %> - <%= link_to "Cancel", project_statuses_path, class: "btn btn-secondary-outline" %> + <%= link_to "Cancel", organization_statuses_path, class: "btn btn-secondary-outline" %> <%= f.button :submit, class: "bg-blue-600 text-white px-6 py-2 rounded-lg hover:bg-blue-700 transition-colors duration-150" %> diff --git a/app/views/project_statuses/edit.html.erb b/app/views/organization_statuses/edit.html.erb similarity index 75% rename from app/views/project_statuses/edit.html.erb rename to app/views/organization_statuses/edit.html.erb index a04763e32..afc354d0d 100644 --- a/app/views/project_statuses/edit.html.erb +++ b/app/views/organization_statuses/edit.html.erb @@ -2,14 +2,14 @@
    -

    Edit <%= @project_status.class.model_name.human %>

    - <%= link_to "View", project_status_path(@project_status), +

    Edit <%= @organization_status.class.model_name.human %>

    + <%= link_to "View", organization_status_path(@organization_status), class: "btn btn-secondary-outline" %>
    - <%= render "form", project_status: @project_status %> + <%= render "form" %>
    diff --git a/app/views/project_statuses/index.html.erb b/app/views/organization_statuses/index.html.erb similarity index 66% rename from app/views/project_statuses/index.html.erb rename to app/views/organization_statuses/index.html.erb index f989610e5..60523fce1 100644 --- a/app/views/project_statuses/index.html.erb +++ b/app/views/organization_statuses/index.html.erb @@ -1,17 +1,17 @@
    -
    border border-gray-200 rounded-xl shadow-lg hover:shadow-xl transition-shadow duration-200 p-6">

    - <%= ProjectStatus.model_name.human.pluralize %> (<%= @count_display %>) + <%= OrganizationStatus.model_name.human.pluralize %> (<%= @count_display %>)

    - <%= link_to("New #{ ProjectStatus.model_name.human.downcase }", - new_project_status_path, + <%= link_to("New #{ OrganizationStatus.model_name.human.downcase }", + new_organization_status_path, class: "btn btn-primary-outline") %>
    @@ -27,24 +27,24 @@ - <% @project_statuses.each do |project_status| %> + <% @organization_statuses.each do |organization_status| %> - <%= project_status.name %> + <%= organization_status.name %> - <%= link_to project_status.projects.count, - projects_path(project_status_id: project_status.id, - project_ids: project_status.projects.pluck(:id).join("-")), + <%= link_to organization_status.organizations.count, + organizations_path(organization_status_id: organization_status.id, + organization_ids: organization_status.organizations.pluck(:id).join("-")), class: "btn btn-secondary-default" %>
    <%= link_to "Edit", - edit_project_status_path(project_status), + edit_organization_status_path(organization_status), class: "btn btn-secondary-outline" %>
    @@ -55,15 +55,15 @@
    - <% unless @project_statuses.any? %> + <% unless @organization_statuses.any? %>

    - No <%= ProjectStatus.model_name.human.pluralize.downcase %> found. + No <%= OrganizationStatus.model_name.human.pluralize.downcase %> found.

    <% end %>
    diff --git a/app/views/project_statuses/new.html.erb b/app/views/organization_statuses/new.html.erb similarity index 82% rename from app/views/project_statuses/new.html.erb rename to app/views/organization_statuses/new.html.erb index c90d575ec..8d68d638f 100644 --- a/app/views/project_statuses/new.html.erb +++ b/app/views/organization_statuses/new.html.erb @@ -2,14 +2,14 @@
    -

    New <%= @project_status.class.model_name.human %>

    +

    New <%= @organization_status.class.model_name.human %>

    - <%= render "form", project_status: @project_status %> + <%= render "form" %>
    diff --git a/app/views/project_statuses/show.html.erb b/app/views/organization_statuses/show.html.erb similarity index 66% rename from app/views/project_statuses/show.html.erb rename to app/views/organization_statuses/show.html.erb index c3300f580..4eb1cdf39 100644 --- a/app/views/project_statuses/show.html.erb +++ b/app/views/organization_statuses/show.html.erb @@ -4,14 +4,14 @@

    - <%= @project_status.class.model_name.human %> Details + <%= @organization_status.class.model_name.human %> Details

    - <%= link_to("Index", project_statuses_path, class: "btn btn-secondary-outline") %> + <%= link_to("Index", organization_statuses_path, class: "btn btn-secondary-outline") %> <% if current_user.super_user? %> - <%= link_to("Edit", edit_project_status_path(@project_status), class: "btn btn-primary-outline") %> + <%= link_to("Edit", edit_organization_status_path(@organization_status), class: "btn btn-primary-outline") %> <% end %>
    @@ -21,37 +21,37 @@

    Name:

    -

    <%= @project_status.name %>

    +

    <%= @organization_status.name %>

    - +

    - Associated Projects + Associated Organizations

    - <% if @project_status.projects.any? %> + <% if @organization_status.organizations.any? %>
      - <% @project_status.projects.order(:name).each do |project| %> + <% @organization_status.organizations.order(:name).each do |organization| %>
    • - <%= project.name %> + <%= organization.name %> <%= link_to "View", - project_path(project), + organization_path(organization), class: "text-sm text-indigo-600 hover:underline" %>
    • <% end %>
    <% else %>

    - No projects are currently associated with this status. + No organizations are currently associated with this status.

    <% end %>
    diff --git a/app/views/projects/_address_fields.html.erb b/app/views/organizations/_address_fields.html.erb similarity index 100% rename from app/views/projects/_address_fields.html.erb rename to app/views/organizations/_address_fields.html.erb diff --git a/app/views/projects/_form.html.erb b/app/views/organizations/_form.html.erb similarity index 88% rename from app/views/projects/_form.html.erb rename to app/views/organizations/_form.html.erb index bd8316059..a895d025e 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/organizations/_form.html.erb @@ -1,15 +1,15 @@ -<%= simple_form_for(@project) do |f| %> - <%= render 'shared/errors', resource: @project if @project.errors.any? %> +<%= simple_form_for(@organization) do |f| %> + <%= render 'shared/errors', resource: @organization if @organization.errors.any? %>
    - +
    <%= f.input :name, - label: "Project Name", + label: "Organization Name", as: :text, required: true, input_html: { @@ -21,12 +21,12 @@
    - <%= f.input :project_status_id, - label: "Project status", + <%= f.input :organization_status_id, + label: "Organization status", as: :select, required: true, - collection: @project_statuses, - selected: f.object.project_status_id, + collection: @organization_statuses, + selected: f.object.organization_status_id, input_html: { class: "w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500" @@ -113,9 +113,9 @@ <% if current_user.super_user? %>
    - <%= f.input :project_status_id, + <%= f.input :organization_status_id, as: :select, - collection: @project_statuses, + collection: @organization_statuses, include_blank: true, label: "Status", required: true, @@ -125,9 +125,9 @@
    <% else %>
    - Project status: + Organization status:
    - <%= f.object.project_status&.name %> + <%= f.object.organization_status&.name %> <% end %>
    @@ -179,7 +179,7 @@ <% if current_user.super_user? %>
    <%= f.input :internal_id, - label: "Internal Project ID", + label: "Internal Organization ID", input_html: { class: "rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500" } %> @@ -247,20 +247,20 @@
    <% if current_user.super_user? %>
    - <%= f.fields_for :project_users do |project_user_form| %> - <%= render "project_user_fields", - f: project_user_form %> + <%= f.fields_for :organization_users do |organization_user_form| %> + <%= render "organization_user_fields", + f: organization_user_form %> <% end %>
    <%= link_to_add_association "➕ Add Role", f, - :project_users, + :organization_users, class: "btn btn-secondary-outline" %>
    <% else %> - <% f.object.user && f.object.user.project_users.each do |pu| %> + <% f.object.user && f.object.user.organization_users.each do |pu| %>
  • <%= pu.title || pu.position %> - <%= facilitator_profile_button(pu.user.facilitator) if pu.persisted? && pu.user.facilitator %> @@ -273,11 +273,11 @@
    - <% if @project.persisted? && current_user.super_user? %> - <%= link_to "Delete", @project, class: "btn btn-danger-outline", + <% if @organization.persisted? && current_user.super_user? %> + <%= link_to "Delete", @organization, class: "btn btn-danger-outline", method: :delete, data: { confirm: "Are you sure?" } %> <% end %> - <%= link_to "Cancel", projects_path, class: "btn btn-utility-outline" %> + <%= link_to "Cancel", organizations_path, class: "btn btn-utility-outline" %> <%= f.button :submit, class: "btn btn-primary" %>
    <% end %> diff --git a/app/views/projects/_project_user_fields.html.erb b/app/views/organizations/_organization_user_fields.html.erb similarity index 94% rename from app/views/projects/_project_user_fields.html.erb rename to app/views/organizations/_organization_user_fields.html.erb index 424ed1913..18a19dc9c 100644 --- a/app/views/projects/_project_user_fields.html.erb +++ b/app/views/organizations/_organization_user_fields.html.erb @@ -39,6 +39,6 @@
  • <% else %>
    -
  • <%= f.object.project&.name %> (<%= f.object.title || f.object.position %>)
  • +
  • <%= f.object.organization&.name %> (<%= f.object.title || f.object.position %>)
  • <% end %> diff --git a/app/views/projects/_search_boxes.html.erb b/app/views/organizations/_search_boxes.html.erb similarity index 85% rename from app/views/projects/_search_boxes.html.erb rename to app/views/organizations/_search_boxes.html.erb index 18f5c2d94..9610ca72c 100644 --- a/app/views/projects/_search_boxes.html.erb +++ b/app/views/organizations/_search_boxes.html.erb @@ -1,5 +1,5 @@
    - <%= form_with url: projects_path, method: :get, local: true, class: "flex flex-wrap items-end gap-3" do %> + <%= form_with url: organizations_path, method: :get, local: true, class: "flex flex-wrap items-end gap-3" do %>
    <%= label_tag :query, "Name", class: "text-sm font-medium text-gray-700 mb-1 block" %> <%= text_field_tag :query, params[:query], @@ -28,9 +28,9 @@ <% if current_user.super_user? %>
    <%= label_tag :status, "Status", class: "text-sm font-medium text-gray-700 mb-1 block" %> - <%= select_tag :project_status, - options_for_select(@project_statuses.map { |ps| [ps.name, ps.id] }, - params[:project_status_id].to_s), + <%= select_tag :organization_status, + options_for_select(@organization_statuses.map { |ps| [ps.name, ps.id] }, + params[:organization_status_id].to_s), include_blank: "All statuses", class: "w-40 rounded-md border border-gray-300 px-3 py-2 text-gray-800 shadow-sm focus:border-blue-500 focus:ring focus:ring-blue-200 focus:outline-none", @@ -38,7 +38,7 @@
    <% end %> - <%= link_to "Clear filters", projects_path, + <%= link_to "Clear filters", organizations_path, class: "btn btn-utility-outline w-full sm:w-auto" %> <% end %>
    \ No newline at end of file diff --git a/app/views/projects/_sectorable_item_fields.html.erb b/app/views/organizations/_sectorable_item_fields.html.erb similarity index 100% rename from app/views/projects/_sectorable_item_fields.html.erb rename to app/views/organizations/_sectorable_item_fields.html.erb diff --git a/app/views/projects/_social_media_buttons.html.erb b/app/views/organizations/_social_media_buttons.html.erb similarity index 72% rename from app/views/projects/_social_media_buttons.html.erb rename to app/views/organizations/_social_media_buttons.html.erb index 36fe6a7fb..465319f12 100644 --- a/app/views/projects/_social_media_buttons.html.erb +++ b/app/views/organizations/_social_media_buttons.html.erb @@ -1,8 +1,8 @@ -<% return if project.blank? %> +<% return if organization.blank? %>
    - <% if project.linked_in_url.present? %> - <%= link_to project.linked_in_url, target: "_blank", rel: "noopener noreferrer", + <% if organization.linked_in_url.present? %> + <%= link_to organization.linked_in_url, target: "_blank", rel: "noopener noreferrer", class: "group inline-flex items-center justify-center w-6 h-6 rounded-md bg-gray-100 hover:bg-[#0A66C2] transition-colors duration-200" do %> @@ -10,8 +10,8 @@ <% end %> <% end %> - <% if project.instagram_url.present? %> - <%= link_to project.instagram_url, target: "_blank", rel: "noopener noreferrer", + <% if organization.instagram_url.present? %> + <%= link_to organization.instagram_url, target: "_blank", rel: "noopener noreferrer", class: "group inline-flex items-center justify-center w-6 h-6 rounded-md bg-gray-100 hover:bg-gradient-to-tr hover:from-[#F58529] hover:via-[#DD2A7B] hover:to-[#8134AF] @@ -20,8 +20,8 @@ <% end %> <% end %> - <% if project.facebook_url.present? %> - <%= link_to project.facebook_url, target: "_blank", rel: "noopener noreferrer", + <% if organization.facebook_url.present? %> + <%= link_to organization.facebook_url, target: "_blank", rel: "noopener noreferrer", class: "group inline-flex items-center justify-center w-6 h-6 rounded-md bg-gray-100 hover:bg-[#1877F2] transition-colors duration-200" do %> @@ -29,8 +29,8 @@ <% end %> <% end %> - <% if project.twitter_url.present? %> - <%= link_to project.twitter_url, target: "_blank", rel: "noopener noreferrer", + <% if organization.twitter_url.present? %> + <%= link_to organization.twitter_url, target: "_blank", rel: "noopener noreferrer", class: "group inline-flex items-center justify-center w-6 h-6 rounded-md bg-gray-100 hover:bg-[#1DA1F2] transition-colors duration-200" do %> @@ -38,8 +38,8 @@ <% end %> <% end %> - <% if project.youtube_url.present? %> - <%= link_to project.youtube_url, target: "_blank", rel: "noopener noreferrer", + <% if organization.youtube_url.present? %> + <%= link_to organization.youtube_url, target: "_blank", rel: "noopener noreferrer", class: "group inline-flex items-center justify-center w-6 h-6 rounded-md bg-gray-100 hover:bg-[#FF0000] text-gray-600 hover:text-white diff --git a/app/views/projects/edit.html.erb b/app/views/organizations/edit.html.erb similarity index 84% rename from app/views/projects/edit.html.erb rename to app/views/organizations/edit.html.erb index aa1f2637a..20188a4a9 100644 --- a/app/views/projects/edit.html.erb +++ b/app/views/organizations/edit.html.erb @@ -3,13 +3,13 @@

    Edit Organization

    - <%= link_to 'View', project_path(@project), + <%= link_to 'View', organization_path(@organization), class: "btn btn-secondary-outline" %>
    - <%= render "form", project: @project %> + <%= render "form" %>
    diff --git a/app/views/projects/index.html.erb b/app/views/organizations/index.html.erb similarity index 73% rename from app/views/projects/index.html.erb rename to app/views/organizations/index.html.erb index b30eb889a..eee6b1a3e 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/organizations/index.html.erb @@ -1,14 +1,14 @@
    -
    +

    - Organizations (<%= number_with_delimiter(@projects_count) %>) + Organizations (<%= number_with_delimiter(@organizations_count) %>)

    <% if current_user.super_user? %> <%= link_to "New Organization", - new_project_path, + new_organization_path, class: "admin-only bg-blue-100 btn btn-primary-outline" %> <% end %>
    @@ -16,7 +16,7 @@ <%= render "search_boxes" %> - +
    @@ -34,17 +34,17 @@ - <% @projects.each do |project| %> + <% @organizations.each do |organization| %> @@ -112,7 +112,7 @@
    diff --git a/app/views/projects/new.html.erb b/app/views/organizations/new.html.erb similarity index 91% rename from app/views/projects/new.html.erb rename to app/views/organizations/new.html.erb index ff157e229..d7a4cf0c0 100644 --- a/app/views/projects/new.html.erb +++ b/app/views/organizations/new.html.erb @@ -9,7 +9,7 @@
    - <%= render "form", project: @project %> + <%= render "form" %>
    diff --git a/app/views/projects/show.html.erb b/app/views/organizations/show.html.erb similarity index 72% rename from app/views/projects/show.html.erb rename to app/views/organizations/show.html.erb index 8796ec645..e74476f89 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -4,12 +4,12 @@
    - <%= link_to "Organizations", projects_path, class: "btn btn-secondary-outline" %> + <%= link_to "Organizations", organizations_path, class: "btn btn-secondary-outline" %> - <%= render "bookmarks/editable_bookmark_button", resource: @project %> + <%= render "bookmarks/editable_bookmark_button", resource: @organization %> <% if current_user.super_user? %> - <%= link_to "Edit", edit_project_path(@project), + <%= link_to "Edit", edit_organization_path(@organization), class: "admin-only bg-green-100 btn btn-primary-outline" %> <% end %>
    @@ -17,8 +17,8 @@
    - <% if @project.logo&.attached? %> - <%= image_tag url_for(@project.logo), + <% if @organization.logo&.attached? %> + <%= image_tag url_for(@organization.logo), class: "w-32 h-32 rounded-full object-cover border border-gray-200 shadow-sm" %> <% else %> <%= image_tag "missing.png", @@ -28,10 +28,10 @@

    - <%= @project.name %> + <%= @organization.name %>

    - <% @project.addresses.each do |address| %> + <% @organization.addresses.each do |address| %>

    <% if address.locality.present? %>
    @@ -54,22 +54,22 @@

    <% end %> - <% if @project.start_date.present? %> + <% if @organization.start_date.present? %>

    Affiliated since - <%= @project.start_date.year %> + <%= @organization.start_date.year %>

    <% end %>
    - <%= render "projects/social_media_buttons", project: @project if false %> + <%= render "organizations/social_media_buttons", organization: @organization if false %>
    - <% @project.decorate.badges.each do |(label, color)| %> + <% @organization.decorate.badges.each do |(label, color)| %> <%= label %> @@ -85,9 +85,9 @@

    Windows facilitators

    - <% if @project.project_users.active.any? %> + <% if @organization.organization_users.active.any? %>
      - <% @project.project_users.active.each do |pu| %> + <% @organization.organization_users.active.each do |pu| %>
    • <%= pu.user.facilitator ? facilitator_profile_button(pu.user.facilitator) : pu.user.name %> <% if pu.position.present? %> @@ -102,13 +102,13 @@
    - <% if true || @project.profile_show_sectors? %> + <% if true || @organization.profile_show_sectors? %>

    Service Populations

    - <% if @project.sectorable_items.any? %> + <% if @organization.sectorable_items.any? %>

    - <% @project.sectorable_items.joins(:sector).order("sectors.name").map do |si| %> + <% @organization.sectorable_items.joins(:sector).order("sectors.name").map do |si| %> <%= render "sectors/tagging_label", sector: si.sector, display_leader: true, @@ -124,23 +124,23 @@
    - <% if true || @project.profile_show_email? || @project.profile_show_phone? %> + <% if true || @organization.profile_show_email? || @organization.profile_show_phone? %>

    Contact Information

    - <% if true || @project.profile_show_email? %> + <% if true || @organization.profile_show_email? %>

    - 📧 <%#= mail_to @project.email, @project.email, + 📧 <%#= mail_to @organization.email, @organization.email, class: "text-blue-600 hover:underline" %>

    <% end %> - <% if true || @project.profile_show_phone? && @project.phone.present? %> + <% if true || @organization.profile_show_phone? && @organization.phone.present? %>

    - 📞 <%#= link_to @project.phone, "tel:#{@project.phone}", + 📞 <%#= link_to @organization.phone, "tel:#{@organization.phone}", class: "text-blue-600 hover:underline" %>

    <% end %> - <% if true || @project.profile_show_website? && @project.website_url.present? %> + <% if true || @organization.profile_show_website? && @organization.website_url.present? %>

    - 🌎 <%#= link_to @project.website_url, + 🌎 <%#= link_to @organization.website_url, class: "text-blue-600 hover:underline" %>

    <% end %> @@ -151,18 +151,18 @@
    - <% if true || @project.profile_show_description? && @project.description.present? %> + <% if true || @organization.profile_show_description? && @organization.description.present? %>

    Description

    - <%= sanitize(@project.description, tags: %w[p br strong em a ul ol li b i], attributes: %w[href]) %> + <%= sanitize(@organization.description, tags: %w[p br strong em a ul ol li b i], attributes: %w[href]) %>
    <% end %> - <% if true || @project.profile_show_workshops? %> + <% if true || @organization.profile_show_workshops? %>

    Workshops authored

    - <% if false && @project.workshops.any? %> - <% @project.workshops.each do |workshop| %> + <% if false && @organization.workshops.any? %> + <% @organization.workshops.each do |workshop| %> <%= link_to workshop.name, workshop_path(workshop), class: "btn btn-secondary-outline" %> <% end %> <% else %> @@ -172,10 +172,10 @@ <% end %> - <% if true || @project.profile_show_stories? %> + <% if true || @organization.profile_show_stories? %>

    Stories

    - <%# stories = @project.stories_as_creator + @project.stories_as_spotlighted_project %> + <%# stories = @organization.stories_as_creator + @organization.stories_as_spotlighted_organization %> <%# if stories.any? %> <%# stories.each do |story| %> <%#= link_to story.title, story_path(story), class: "btn btn-secondary-outline" %> @@ -187,7 +187,7 @@ <% end %> - <% if true || @project.profile_show_events_registered? %> + <% if true || @organization.profile_show_events_registered? %>

    Events hosted

    <%# if Event.all.any? %> @@ -203,14 +203,14 @@
    - <% if current_user.super_user || @project.project_users.pluck(:user_id).include?(current_user.id) %> -
    + <% if current_user.super_user || @organization.organization_users.pluck(:user_id).include?(current_user.id) %> +
    - <% if true || @project.profile_show_workshop_logs? %> + <% if true || @organization.profile_show_workshop_logs? %>

    Workshop Logs submitted

    - <% if false && @project.workshop_logs.any? %> - <% @project.workshop_logs.order(date: :desc, created_at: :desc).each do |workshop_log| %> + <% if false && @organization.workshop_logs.any? %> + <% @organization.workshop_logs.order(date: :desc, created_at: :desc).each do |workshop_log| %> <%= link_to workshop_log.full_name, workshop_log_path(workshop_log), class: "btn btn-secondary-outline" %> <% end %> diff --git a/app/views/shared/_project_user.html.erb b/app/views/shared/_organization_user.html.erb similarity index 87% rename from app/views/shared/_project_user.html.erb rename to app/views/shared/_organization_user.html.erb index a5f40f6e4..98288bf6a 100644 --- a/app/views/shared/_project_user.html.erb +++ b/app/views/shared/_organization_user.html.erb @@ -1,4 +1,4 @@ -<% user = project_user.user.decorate %> +<% user = organization_user.user.decorate %> <% unless user == current_user %> <%= link_to user_path(user) do %>
    - <%= link_to project_path(project) do %> - <% if project.logo.attached? %> + <%= link_to organization_path(organization) do %> + <% if organization.logo.attached? %> <%= image_tag( - project.logo, + organization.logo, class: "w-10 h-10 rounded-full object-cover border border-gray-300 shadow-sm mx-auto" ) %> <% else %> - <%= link_to project_path(project) do %> + <%= link_to organization_path(organization) do %> - <%= link_to project.name, project_path(project), class: "hover:underline" %> + <%= link_to organization.name, organization_path(organization), class: "hover:underline" %> - <%= project.windows_type&.short_name&.titleize %> + <%= organization.windows_type&.short_name&.titleize %> - <%= project.addresses.active.map(&:locality).join("
    ") %> + <%= organization.addresses.active.map(&:locality).join("
    ") %>
    - <% if project.start_date || project.end_date %> - <%= project.start_date&.strftime("%b %Y") %> – - <%= project.end_date&.strftime("%b %Y") || "Present" %> + <% if organization.start_date || organization.end_date %> + <%= organization.start_date&.strftime("%b %Y") %> – + <%= organization.end_date&.strftime("%b %Y") || "Present" %> <% end %> "> - <%= project.project_status&.name %> + <%= organization.organization_status&.name %> - <% if project.inactive? %> + <% if organization.inactive? %> <% else %> @@ -96,10 +96,10 @@ <% if current_user.super_user? %> - <%= link_to "Edit", edit_project_path(project), + <%= link_to "Edit", edit_organization_path(organization), class: "admin-only bg-blue-100 btn btn-secondary-outline text-xs px-2 py-1" %> <% end %> - <%= link_to "Profile", project_path(project), + <%= link_to "Profile", organization_path(organization), class: "btn btn-secondary-outline text-xs px-2 py-1" %>