From 01a7250ba502c63681bf0060b2cbf1b2a28afac6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Date: Mon, 18 Feb 2013 14:35:38 +0200 Subject: [PATCH] Add user to team he creates --- app/controllers/teams_controller.rb | 5 +++-- app/models/ability.rb | 2 +- app/views/teams/members/_show.html.haml | 7 ++++--- app/views/teams/new.html.haml | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index ef66b77e23..4861892d36 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -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 diff --git a/app/models/ability.rb b/app/models/ability.rb index 6d087a959a..6fda2e52c7 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 diff --git a/app/views/teams/members/_show.html.haml b/app/views/teams/members/_show.html.haml index 6cddb8e482..4a0287dee4 100644 --- a/app/views/teams/members/_show.html.haml +++ b/app/views/teams/members/_show.html.haml @@ -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 diff --git a/app/views/teams/new.html.haml b/app/views/teams/new.html.haml index 38f61c11c0..7089f79155 100644 --- a/app/views/teams/new.html.haml +++ b/app/views/teams/new.html.haml @@ -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 -- 2.30.9