Commit 01a7250ba502c63681bf0060b2cbf1b2a28afac6

Authored by Dmitriy Zaporozhets
1 parent 02007866

Add user to team he creates

app/controllers/teams_controller.rb
... ... @@ -9,13 +9,11 @@ class TeamsController < ApplicationController
9 9 layout 'user_team', except: [:new, :create]
10 10  
11 11 def show
12   - user_team
13 12 projects
14 13 @events = Event.in_projects(user_team.project_ids).limit(20).offset(params[:offset] || 0)
15 14 end
16 15  
17 16 def edit
18   - user_team
19 17 end
20 18  
21 19 def update
... ... @@ -41,6 +39,9 @@ class TeamsController < ApplicationController
41 39 @team.path = @team.name.dup.parameterize if @team.name
42 40  
43 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 45 redirect_to team_path(@team)
45 46 else
46 47 render action: :new
... ...
app/models/ability.rb
... ... @@ -123,7 +123,7 @@ class Ability
123 123 def user_team_abilities user, team
124 124 rules = []
125 125  
126   - # Only group owner and administrators can manage group
  126 + # Only group owner and administrators can manage team
127 127 if team.owner == user || team.admin?(user) || user.admin?
128 128 rules << [ :manage_user_team ]
129 129 end
... ...
app/views/teams/members/_show.html.haml
... ... @@ -17,13 +17,14 @@
17 17 = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium project-access-select span2"
18 18 .left.span2
19 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 23 .pull-right
23 24 - if current_user == user
24 25 %span.btn.disabled This is you!
25 26 - if @team.owner == user
26   - %span.btn.disabled.btn-success Owner
  27 + %span.btn.disabled Owner
27 28 - elsif user.blocked
28 29 %span.btn.disabled.blocked Blocked
29 30 - elsif allow_admin
... ...
app/views/teams/new.html.haml
... ... @@ -17,3 +17,17 @@
17 17 %li All created teams are public (users can view who enter into team and which project are assigned for this team)
18 18 %li People within a team see only projects they have access to
19 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
... ...