summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-24 17:47:09 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-24 17:47:09 +0200
commitf6c482c06f48449e7dcff34455b5bbdfbd8f6c7b (patch)
tree5524251aeea0ae6f00a4ecb8775fbf542d98eab5 /app
parentd9027df5b55f2eb82f1a71e96412c5e802909090 (diff)
downloadgitlab-ce-f6c482c06f48449e7dcff34455b5bbdfbd8f6c7b.tar.gz
User can create group
Diffstat (limited to 'app')
-rw-r--r--app/controllers/groups_controller.rb26
-rw-r--r--app/helpers/tab_helper.rb7
-rw-r--r--app/models/user.rb2
-rw-r--r--app/views/dashboard/_groups.html.haml2
-rw-r--r--app/views/groups/new.html.haml21
-rw-r--r--app/views/layouts/_head_panel.html.haml2
-rw-r--r--app/views/projects/_new_form.html.haml6
-rw-r--r--app/views/users/_profile.html.haml23
-rw-r--r--app/views/users/show.html.haml28
9 files changed, 87 insertions, 30 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index c25fc32a62c..f95db1af383 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -1,12 +1,30 @@
class GroupsController < ApplicationController
respond_to :html
- layout 'group'
+ layout 'group', except: [:new, :create]
- before_filter :group
- before_filter :projects
+ before_filter :group, except: [:new, :create]
# Authorize
- before_filter :authorize_read_group!
+ before_filter :authorize_read_group!, except: [:new, :create]
+
+ # Load group projects
+ before_filter :projects, except: [:new, :create]
+
+ def new
+ @group = Group.new
+ end
+
+ def create
+ @group = Group.new(params[:group])
+ @group.path = @group.name.dup.parameterize if @group.name
+ @group.owner = current_user
+
+ if @group.save
+ redirect_to @group, notice: 'Group was successfully created.'
+ else
+ render action: "new"
+ end
+ end
def show
@events = Event.in_projects(project_ids).limit(20).offset(params[:offset] || 0)
diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb
index d52d8af6641..5bd6de896ee 100644
--- a/app/helpers/tab_helper.rb
+++ b/app/helpers/tab_helper.rb
@@ -39,7 +39,12 @@ module TabHelper
# Returns a list item element String
def nav_link(options = {}, &block)
if path = options.delete(:path)
- c, a, _ = path.split('#')
+ if path.respond_to?(:each)
+ c = path.map { |p| p.split('#').first }
+ a = path.map { |p| p.split('#').last }
+ else
+ c, a, _ = path.split('#')
+ end
else
c = options.delete(:controller)
a = options.delete(:action)
diff --git a/app/models/user.rb b/app/models/user.rb
index 35a693fdb1c..743d7523bdc 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -220,7 +220,7 @@ class User < ActiveRecord::Base
end
def can_create_group?
- is_admin?
+ can_create_project?
end
def abilities
diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml
index 7f544406761..dc50bffda80 100644
--- a/app/views/dashboard/_groups.html.haml
+++ b/app/views/dashboard/_groups.html.haml
@@ -5,7 +5,7 @@
(#{groups.count})
- if current_user.can_create_group?
%span.right
- = link_to new_admin_group_path, class: "btn very_small info" do
+ = link_to new_group_path, class: "btn very_small info" do
%i.icon-plus
New Group
%ul.well-list
diff --git a/app/views/groups/new.html.haml b/app/views/groups/new.html.haml
new file mode 100644
index 00000000000..b6d5f46507e
--- /dev/null
+++ b/app/views/groups/new.html.haml
@@ -0,0 +1,21 @@
+%h3.page_title New Group
+%hr
+= form_for @group do |f|
+ - if @group.errors.any?
+ .alert-message.block-message.error
+ %span= @group.errors.full_messages.first
+ .clearfix
+ = f.label :name do
+ Group name is
+ .input
+ = f.text_field :name, placeholder: "Ex. OpenSource", class: "xxlarge left"
+ &nbsp;
+ = f.submit 'Create group', class: "btn primary"
+ %hr
+ .padded
+ %ul
+ %li Group is kind of directory for several projects
+ %li All created groups are private
+ %li People within a group see only projects they have access to
+ %li All projects of group will be stored in group directory
+ %li You will be able to move existing projects into group
diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml
index f4b2228a41b..8f4f3d7815f 100644
--- a/app/views/layouts/_head_panel.html.haml
+++ b/app/views/layouts/_head_panel.html.haml
@@ -17,7 +17,7 @@
= link_to new_project_path, title: "Create New Project", class: 'has_bottom_tooltip', 'data-original-title' => 'New project' do
%i.icon-plus
%li
- = link_to profile_path, title: "Your Profile", class: 'has_bottom_tooltip', 'data-original-title' => 'Your profile' do
+ = link_to profile_path, title: "My Profile", class: 'has_bottom_tooltip', 'data-original-title' => 'Your profile' do
%i.icon-user
%li.separator
%li
diff --git a/app/views/projects/_new_form.html.haml b/app/views/projects/_new_form.html.haml
index 2d5f3923e80..ba8f255558a 100644
--- a/app/views/projects/_new_form.html.haml
+++ b/app/views/projects/_new_form.html.haml
@@ -15,6 +15,12 @@
%span Namespace
.input
= f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'chosen'}
+ - elsif current_user.can_create_group?
+ .clearfix
+ .input.light
+ Need a group for several projects?
+ = link_to new_group_path, class: "btn very_small" do
+ Create a group
%hr
%p.padded
New projects are private by default. You choose who can see the project and commit to repository.
diff --git a/app/views/users/_profile.html.haml b/app/views/users/_profile.html.haml
new file mode 100644
index 00000000000..ab6538f083b
--- /dev/null
+++ b/app/views/users/_profile.html.haml
@@ -0,0 +1,23 @@
+.ui-box
+ %h5.title
+ Profile
+ %ul.well-list
+ %li
+ %strong Email
+ %span.right= mail_to @user.email
+ - unless @user.skype.blank?
+ %li
+ %strong Skype
+ %span.right= @user.skype
+ - unless @user.linkedin.blank?
+ %li
+ %strong LinkedIn
+ %span.right= @user.linkedin
+ - unless @user.twitter.blank?
+ %li
+ %strong Twitter
+ %span.right= @user.twitter
+ - unless @user.bio.blank?
+ %li
+ %strong Bio
+ %span.right= @user.bio
diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml
index 2a77c6bfa3d..644826282b8 100644
--- a/app/views/users/show.html.haml
+++ b/app/views/users/show.html.haml
@@ -3,6 +3,11 @@
%h3.page_title
= image_tag gravatar_icon(@user.email, 90), class: "avatar s90"
= @user.name
+ - if @user == current_user
+ .right
+ = link_to profile_path, class: 'btn small' do
+ %i.icon-edit
+ Edit Profile
%br
%small @#{@user.username}
%br
@@ -12,26 +17,5 @@
%h5 Recent events
= render @events
.span4
- .ui-box
- %h5.title Profile
- %ul.well-list
- %li
- %strong Email
- %span.right= mail_to @user.email
- - unless @user.skype.blank?
- %li
- %strong Skype
- %span.right= @user.skype
- - unless @user.linkedin.blank?
- %li
- %strong LinkedIn
- %span.right= @user.linkedin
- - unless @user.twitter.blank?
- %li
- %strong Twitter
- %span.right= @user.twitter
- - unless @user.bio.blank?
- %li
- %strong Bio
- %span.right= @user.bio
+ = render 'profile'
= render 'projects'