Add user to team he creates
This commit is contained in:
parent
020078663e
commit
01a7250ba5
4 changed files with 22 additions and 6 deletions
|
@ -9,13 +9,11 @@ class TeamsController < ApplicationController
|
|||
layout 'user_team', except: [:new, :create]
|
||||
|
||||
def show
|
||||
user_team
|
||||
projects
|
||||
@events = Event.in_projects(user_team.project_ids).limit(20).offset(params[:offset] || 0)
|
||||
end
|
||||
|
||||
def edit
|
||||
user_team
|
||||
end
|
||||
|
||||
def update
|
||||
|
@ -41,6 +39,9 @@ class TeamsController < ApplicationController
|
|||
@team.path = @team.name.dup.parameterize if @team.name
|
||||
|
||||
if @team.save
|
||||
# Add current user as Master to the team
|
||||
@team.add_members([current_user.id], UsersProject::MASTER, true)
|
||||
|
||||
redirect_to team_path(@team)
|
||||
else
|
||||
render action: :new
|
||||
|
|
|
@ -123,7 +123,7 @@ class Ability
|
|||
def user_team_abilities user, team
|
||||
rules = []
|
||||
|
||||
# Only group owner and administrators can manage group
|
||||
# Only group owner and administrators can manage team
|
||||
if team.owner == user || team.admin?(user) || user.admin?
|
||||
rules << [ :manage_user_team ]
|
||||
end
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
= f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium project-access-select span2"
|
||||
.left.span2
|
||||
%span
|
||||
= check_box_tag :group_admin, true, @team.admin?(user)
|
||||
Admin access
|
||||
- if @team.admin?(user)
|
||||
%i.icon-check
|
||||
Admin access
|
||||
.pull-right
|
||||
- if current_user == user
|
||||
%span.btn.disabled This is you!
|
||||
- if @team.owner == user
|
||||
%span.btn.disabled.btn-success Owner
|
||||
%span.btn.disabled Owner
|
||||
- elsif user.blocked
|
||||
%span.btn.disabled.blocked Blocked
|
||||
- elsif allow_admin
|
||||
|
|
|
@ -17,3 +17,17 @@
|
|||
%li All created teams are public (users can view who enter into team and which project are assigned for this team)
|
||||
%li People within a team see only projects they have access to
|
||||
%li You will be able to assign existing projects for team
|
||||
%hr
|
||||
|
||||
- if current_user.can_create_group?
|
||||
.clearfix
|
||||
.input.light
|
||||
Need a group for several dependent projects?
|
||||
= link_to new_group_path, class: "btn btn-tiny" do
|
||||
Create a group
|
||||
- if current_user.can_create_project?
|
||||
.clearfix
|
||||
.input.light
|
||||
Want to create a project?
|
||||
= link_to new_project_path, class: "btn btn-tiny" do
|
||||
Create a project
|
||||
|
|
Loading…
Reference in a new issue