Commit 01a7250b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add user to team he creates

parent 02007866
...@@ -9,13 +9,11 @@ class TeamsController < ApplicationController ...@@ -9,13 +9,11 @@ class TeamsController < ApplicationController
layout 'user_team', except: [:new, :create] layout 'user_team', except: [:new, :create]
def show def show
user_team
projects projects
@events = Event.in_projects(user_team.project_ids).limit(20).offset(params[:offset] || 0) @events = Event.in_projects(user_team.project_ids).limit(20).offset(params[:offset] || 0)
end end
def edit def edit
user_team
end end
def update def update
...@@ -41,6 +39,9 @@ class TeamsController < ApplicationController ...@@ -41,6 +39,9 @@ class TeamsController < ApplicationController
@team.path = @team.name.dup.parameterize if @team.name @team.path = @team.name.dup.parameterize if @team.name
if @team.save 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) redirect_to team_path(@team)
else else
render action: :new render action: :new
......
...@@ -123,7 +123,7 @@ class Ability ...@@ -123,7 +123,7 @@ class Ability
def user_team_abilities user, team def user_team_abilities user, team
rules = [] 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? if team.owner == user || team.admin?(user) || user.admin?
rules << [ :manage_user_team ] rules << [ :manage_user_team ]
end end
......
...@@ -17,13 +17,14 @@ ...@@ -17,13 +17,14 @@
= f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium project-access-select span2" = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium project-access-select span2"
.left.span2 .left.span2
%span %span
= check_box_tag :group_admin, true, @team.admin?(user) - if @team.admin?(user)
Admin access %i.icon-check
Admin access
.pull-right .pull-right
- if current_user == user - if current_user == user
%span.btn.disabled This is you! %span.btn.disabled This is you!
- if @team.owner == user - if @team.owner == user
%span.btn.disabled.btn-success Owner %span.btn.disabled Owner
- elsif user.blocked - elsif user.blocked
%span.btn.disabled.blocked Blocked %span.btn.disabled.blocked Blocked
- elsif allow_admin - elsif allow_admin
......
...@@ -17,3 +17,17 @@ ...@@ -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 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 People within a team see only projects they have access to
%li You will be able to assign existing projects for team %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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment