From fce1f9fb072092f1986f123652679488a496fafa Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Sat, 27 Mar 2021 02:02:25 +0100 Subject: [PATCH 1/5] delete ability to create orgs from public part, the superadmin can do it easily in the /admin section --- app/controllers/organizations_controller.rb | 18 ----- app/policies/organization_policy.rb | 4 -- app/views/organizations/index.html.erb | 67 ++++++++----------- app/views/organizations/show.html.erb | 8 --- app/views/users/manage.html.erb | 2 +- config/routes.rb | 4 +- .../organizations_controller_spec.rb | 10 --- 7 files changed, 32 insertions(+), 81 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index ea52cbe98..cbc12109b 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,12 +1,6 @@ class OrganizationsController < ApplicationController before_action :load_resource, only: [:show, :edit, :update, :set_current] - def new - @organization = Organization.new - - authorize @organization - end - def index @organizations = Organization.all.page(params[:page]).per(25) end @@ -20,18 +14,6 @@ def show per(10) end - def create - @organization = Organization.new(organization_params) - - authorize @organization - - if @organization.save - redirect_to @organization - else - render action: :new, status: :unprocessable_entity - end - end - def update if @organization.update(organization_params) redirect_to @organization diff --git a/app/policies/organization_policy.rb b/app/policies/organization_policy.rb index 532fdda78..1081ee5ca 100644 --- a/app/policies/organization_policy.rb +++ b/app/policies/organization_policy.rb @@ -5,10 +5,6 @@ def index? true end - def create? - user&.superadmin? - end - def update? user&.superadmin? || user&.admins?(organization) end diff --git a/app/views/organizations/index.html.erb b/app/views/organizations/index.html.erb index bc255c7ac..20090cac9 100644 --- a/app/views/organizations/index.html.erb +++ b/app/views/organizations/index.html.erb @@ -2,41 +2,32 @@ <%= Organization.model_name.human(count: :many) %> - - - - - - - - - - - - <% @organizations.each do |org| %> - - - - - - <% end %> - -
<%= Organization.model_name.human(count: :one) %><%= t '.member_count' %>
<%= link_to org.name, org %><%= org.users.count %> - <% if current_user&.admins?(org) %> - <%= link_to edit_organization_path(org), class: 'action' do %> - <%= glyph :pencil %> - <%= t 'global.edit' %> - <% end %> - <% end %> -
- -<%= paginate @organizations %> +
+
+ + + + + + + + + + + + <% @organizations.each do |org| %> + + + + + + + + <% end %> + +
<%= t '.city' %><%= t '.neighborhood' %><%= t '.web' %><%= t '.member_count' %>
<%= link_to(org.name, org) %><%= org.city %><%= org.neighborhood %><%= link_to(org.web, org.web) if org.web.present? %><%= org.members.count %>
+
+ <%= paginate @organizations %> +
+
+
diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index d5e16dce3..d14dca13d 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -84,14 +84,6 @@