Skip to content

Commit

Permalink
Remove /teams page (#9331)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljames-dj committed May 1, 2024
1 parent 90a4ee7 commit 52ae67b
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 109 deletions.
5 changes: 0 additions & 5 deletions app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@

class TeamsController < ApplicationController
before_action :authenticate_user!
before_action -> { redirect_to_root_unless_user(:can_manage_teams?) }, except: [:edit, :update]
before_action -> { redirect_to_root_unless_user(:can_edit_team?, team_from_params) }, only: [:edit, :update]

def index
@teams = Team.unscoped.all
end

def edit
@team = team_from_params
end
Expand Down
7 changes: 1 addition & 6 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,9 @@ def can_admin_finances?
admin? || financial_committee?
end

# Returns true if the user can perform every action for teams.
def can_manage_teams?
admin? || board_member? || results_team?
end

# Returns true if the user can edit the given team.
def can_edit_team?(team)
can_manage_teams? ||
can_edit_any_groups? ||
team_leader?(team) ||
# The leader of the WDC can edit the banned competitors list
(team == Team.banned && team_leader?(Team.wdc))
Expand Down
1 change: 0 additions & 1 deletion app/views/admin/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<% [
{ text: "List competitions", path: competitions_view, fa_icon: "list" },
{ text: "Delegates", path: delegates_path(anchor: "all"), fa_icon: "sitemap" },
{ text: "Edit teams", path: teams_path, fa_icon: "users" },
{ text: "Posting Dashboard", path: panel_wrt_path(anchor: PanelController.panel_list['wrt']['postingDashboard']), fa_icon: "user lock" },
{ text: "Run validators", path: admin_check_results_path, fa_icon: "check double" },
{ text: "Create newcomers", path: admin_finish_unfinished_persons_path, fa_icon: "user plus" },
Expand Down
3 changes: 0 additions & 3 deletions app/views/teams/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
</div>

<div class="form-group form-actions">
<%= link_to teams_path, class: "btn btn-default teams-home" do %>
<%= ui_icon("undo") %> Back to Teams
<% end %>
<%= f.button :submit, class: "btn btn-primary" %>
</div>
<% end %>
Expand Down
36 changes: 0 additions & 36 deletions app/views/teams/index.html.erb

This file was deleted.

2 changes: 0 additions & 2 deletions app/webpacker/lib/requests/routes.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ export const subordinateDelegateClaimsUrl = `<%= CGI.unescape(Rails.application.
export const subordinateUpcomingCompetitionsUrl = `<%= CGI.unescape(Rails.application.routes.url_helpers.competitions_for_senior_path) %>`;
export const wfcCompetitionsExportUrl = `<%= CGI.unescape(Rails.application.routes.url_helpers.wfc_competitions_export_path) %>`;

export const teamUrl = (id) => `<%= CGI.unescape(Rails.application.routes.url_helpers.team_path("${id}"))%>`;

export const wfcXeroUsersUrl = `<%= CGI.unescape(Rails.application.routes.url_helpers.api_v0_wfc_xero_users_path) %>`;

export const wfcDuesRedirectsUrl = `<%= CGI.unescape(Rails.application.routes.url_helpers.api_v0_wfc_dues_redirects_path) %>`;
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
get 'polls/:id/vote' => 'votes#vote', as: 'polls_vote'
get 'polls/:id/results' => 'polls#results', as: 'polls_results'

resources :teams, only: [:index, :update, :edit]
resources :teams, only: [:update, :edit]

resources :votes, only: [:create, :update]

Expand Down
29 changes: 0 additions & 29 deletions spec/controllers/teams_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,6 @@
RSpec.describe TeamsController do
let(:team) { FactoryBot.create :team }

describe "GET #index" do
context "when not signed in" do
sign_out

it 'redirects to the sign in page' do
get :index
expect(response).to redirect_to new_user_session_path
end
end

context "when signed in as admin" do
sign_in { FactoryBot.create :admin }

it 'shows the teams index page' do
get :index
expect(response).to render_template :index
end
end

context 'when signed in as a regular user' do
sign_in { FactoryBot.create :user }

it 'does not allow access' do
get :index
expect(response).to redirect_to root_url
end
end
end

describe 'GET #edit' do
context 'when signed in as a team leader without rights to manage all teams' do
let(:team_where_is_leader) { Team.wrc }
Expand Down
26 changes: 0 additions & 26 deletions spec/views/teams/index.html.erb_spec.rb

This file was deleted.

0 comments on commit 52ae67b

Please sign in to comment.