Commit 01a7250ba502c63681bf0060b2cbf1b2a28afac6
1 parent
02007866
Exists in
master
and in
4 other branches
Add user to team he creates
Showing
4 changed files
with
22 additions
and
6 deletions
Show diff stats
app/controllers/teams_controller.rb
| @@ -9,13 +9,11 @@ class TeamsController < ApplicationController | @@ -9,13 +9,11 @@ class TeamsController < ApplicationController | ||
| 9 | layout 'user_team', except: [:new, :create] | 9 | layout 'user_team', except: [:new, :create] |
| 10 | 10 | ||
| 11 | def show | 11 | def show |
| 12 | - user_team | ||
| 13 | projects | 12 | projects |
| 14 | @events = Event.in_projects(user_team.project_ids).limit(20).offset(params[:offset] || 0) | 13 | @events = Event.in_projects(user_team.project_ids).limit(20).offset(params[:offset] || 0) |
| 15 | end | 14 | end |
| 16 | 15 | ||
| 17 | def edit | 16 | def edit |
| 18 | - user_team | ||
| 19 | end | 17 | end |
| 20 | 18 | ||
| 21 | def update | 19 | def update |
| @@ -41,6 +39,9 @@ class TeamsController < ApplicationController | @@ -41,6 +39,9 @@ class TeamsController < ApplicationController | ||
| 41 | @team.path = @team.name.dup.parameterize if @team.name | 39 | @team.path = @team.name.dup.parameterize if @team.name |
| 42 | 40 | ||
| 43 | if @team.save | 41 | if @team.save |
| 42 | + # Add current user as Master to the team | ||
| 43 | + @team.add_members([current_user.id], UsersProject::MASTER, true) | ||
| 44 | + | ||
| 44 | redirect_to team_path(@team) | 45 | redirect_to team_path(@team) |
| 45 | else | 46 | else |
| 46 | render action: :new | 47 | render action: :new |
app/models/ability.rb
| @@ -123,7 +123,7 @@ class Ability | @@ -123,7 +123,7 @@ class Ability | ||
| 123 | def user_team_abilities user, team | 123 | def user_team_abilities user, team |
| 124 | rules = [] | 124 | rules = [] |
| 125 | 125 | ||
| 126 | - # Only group owner and administrators can manage group | 126 | + # Only group owner and administrators can manage team |
| 127 | if team.owner == user || team.admin?(user) || user.admin? | 127 | if team.owner == user || team.admin?(user) || user.admin? |
| 128 | rules << [ :manage_user_team ] | 128 | rules << [ :manage_user_team ] |
| 129 | end | 129 | end |
app/views/teams/members/_show.html.haml
| @@ -17,13 +17,14 @@ | @@ -17,13 +17,14 @@ | ||
| 17 | = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium project-access-select span2" | 17 | = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium project-access-select span2" |
| 18 | .left.span2 | 18 | .left.span2 |
| 19 | %span | 19 | %span |
| 20 | - = check_box_tag :group_admin, true, @team.admin?(user) | ||
| 21 | - Admin access | 20 | + - if @team.admin?(user) |
| 21 | + %i.icon-check | ||
| 22 | + Admin access | ||
| 22 | .pull-right | 23 | .pull-right |
| 23 | - if current_user == user | 24 | - if current_user == user |
| 24 | %span.btn.disabled This is you! | 25 | %span.btn.disabled This is you! |
| 25 | - if @team.owner == user | 26 | - if @team.owner == user |
| 26 | - %span.btn.disabled.btn-success Owner | 27 | + %span.btn.disabled Owner |
| 27 | - elsif user.blocked | 28 | - elsif user.blocked |
| 28 | %span.btn.disabled.blocked Blocked | 29 | %span.btn.disabled.blocked Blocked |
| 29 | - elsif allow_admin | 30 | - elsif allow_admin |
app/views/teams/new.html.haml
| @@ -17,3 +17,17 @@ | @@ -17,3 +17,17 @@ | ||
| 17 | %li All created teams are public (users can view who enter into team and which project are assigned for this team) | 17 | %li All created teams are public (users can view who enter into team and which project are assigned for this team) |
| 18 | %li People within a team see only projects they have access to | 18 | %li People within a team see only projects they have access to |
| 19 | %li You will be able to assign existing projects for team | 19 | %li You will be able to assign existing projects for team |
| 20 | + %hr | ||
| 21 | + | ||
| 22 | + - if current_user.can_create_group? | ||
| 23 | + .clearfix | ||
| 24 | + .input.light | ||
| 25 | + Need a group for several dependent projects? | ||
| 26 | + = link_to new_group_path, class: "btn btn-tiny" do | ||
| 27 | + Create a group | ||
| 28 | + - if current_user.can_create_project? | ||
| 29 | + .clearfix | ||
| 30 | + .input.light | ||
| 31 | + Want to create a project? | ||
| 32 | + = link_to new_project_path, class: "btn btn-tiny" do | ||
| 33 | + Create a project |