remove before_filter from controllers
This commit is contained in:
parent
f87b76a805
commit
dcea52203d
4 changed files with 34 additions and 33 deletions
|
@ -1,9 +1,4 @@
|
|||
class Admin::TeamsController < Admin::ApplicationController
|
||||
before_filter :user_team,
|
||||
only: [ :edit, :show, :update, :destroy,
|
||||
:delegate_projects, :relegate_project,
|
||||
:add_members, :remove_member ]
|
||||
|
||||
def index
|
||||
@teams = UserTeam.order('name ASC')
|
||||
@teams = @teams.search(params[:name]) if params[:name].present?
|
||||
|
@ -12,11 +7,11 @@ class Admin::TeamsController < Admin::ApplicationController
|
|||
|
||||
def show
|
||||
@projects = Project.scoped
|
||||
@projects = @projects.without_team(@team) if @team.projects.any?
|
||||
@projects = @projects.without_team(user_team) if user_team.projects.any?
|
||||
#@projects.reject!(&:empty_repo?)
|
||||
|
||||
@users = User.active
|
||||
@users = @users.not_in_team(@team) if @team.members.any?
|
||||
@users = @users.not_in_team(user_team) if user_team.members.any?
|
||||
@users = UserDecorator.decorate @users
|
||||
end
|
||||
|
||||
|
@ -25,15 +20,16 @@ class Admin::TeamsController < Admin::ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
user_team
|
||||
end
|
||||
|
||||
def create
|
||||
@team = UserTeam.new(params[:user_team])
|
||||
@team.path = @team.name.dup.parameterize if @team.name
|
||||
@team.owner = current_user
|
||||
user_team = UserTeam.new(params[:user_team])
|
||||
user_team.path = user_team.name.dup.parameterize if user_team.name
|
||||
user_team.owner = current_user
|
||||
|
||||
if @team.save
|
||||
redirect_to admin_team_path(@team), notice: 'UserTeam was successfully created.'
|
||||
if user_team.save
|
||||
redirect_to admin_team_path(user_team), notice: 'UserTeam was successfully created.'
|
||||
else
|
||||
render action: "new"
|
||||
end
|
||||
|
@ -44,26 +40,26 @@ class Admin::TeamsController < Admin::ApplicationController
|
|||
owner_id = user_team_params.delete(:owner_id)
|
||||
|
||||
if owner_id
|
||||
@team.owner = User.find(owner_id)
|
||||
user_team.owner = User.find(owner_id)
|
||||
end
|
||||
|
||||
if @team.update_attributes(user_team_params)
|
||||
redirect_to admin_team_path(@team), notice: 'UserTeam was successfully updated.'
|
||||
if user_team.update_attributes(user_team_params)
|
||||
redirect_to admin_team_path(user_team), notice: 'UserTeam was successfully updated.'
|
||||
else
|
||||
render action: "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@team.destroy
|
||||
user_team.destroy
|
||||
|
||||
redirect_to admin_user_teams_path, notice: 'UserTeam was successfully deleted.'
|
||||
end
|
||||
|
||||
private
|
||||
protected
|
||||
|
||||
def user_team
|
||||
@team = UserTeam.find_by_path(params[:id])
|
||||
@team ||= UserTeam.find_by_path(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue