Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
d6363e93
Commit
d6363e93
authored
Oct 02, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Admin Group scaffold -> new, show, index
parent
d683ce5c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
175 additions
and
1 deletion
+175
-1
app/controllers/admin/groups_controller.rb
app/controllers/admin/groups_controller.rb
+66
-0
app/models/group.rb
app/models/group.rb
+6
-0
app/models/project.rb
app/models/project.rb
+4
-1
app/views/admin/groups/_form.html.haml
app/views/admin/groups/_form.html.haml
+19
-0
app/views/admin/groups/index.html.haml
app/views/admin/groups/index.html.haml
+24
-0
app/views/admin/groups/new.html.haml
app/views/admin/groups/new.html.haml
+3
-0
app/views/admin/groups/show.html.haml
app/views/admin/groups/show.html.haml
+48
-0
config/routes.rb
config/routes.rb
+5
-0
No files found.
app/controllers/admin/groups_controller.rb
0 → 100644
View file @
d6363e93
class
Admin::GroupsController
<
AdminController
before_filter
:group
,
only:
[
:edit
,
:show
,
:update
,
:destroy
,
:project_update
]
def
index
@groups
=
Group
.
scoped
@groups
=
@groups
.
search
(
params
[
:name
])
if
params
[
:name
].
present?
@groups
=
@groups
.
page
(
params
[
:page
]).
per
(
20
)
end
def
show
@projects
=
Project
.
scoped
@projects
=
@projects
.
not_in_group
(
@group
)
if
@group
.
projects
.
present?
@projects
=
@projects
.
all
end
def
new
@group
=
Group
.
new
end
def
edit
end
def
create
@group
=
Group
.
new
(
params
[
:group
])
@group
.
owner
=
current_user
if
@group
.
save
redirect_to
[
:admin
,
@group
],
notice:
'Group was successfully created.'
else
render
action:
"new"
end
end
def
update
owner_id
=
params
[
:group
].
delete
(
:owner_id
)
if
owner_id
@group
.
owner
=
User
.
find
(
owner_id
)
end
if
@group
.
update_attributes
(
params
[
:group
])
redirect_to
[
:admin
,
@group
],
notice:
'Group was successfully updated.'
else
render
action:
"edit"
end
end
def
project_update
project_ids
=
params
[
:project_ids
]
Project
.
where
(
id:
project_ids
).
update_all
(
group_id:
@group
.
id
)
redirect_to
:back
,
notice:
'Group was successfully updated.'
end
def
destroy
@group
.
destroy
redirect_to
groups_url
,
notice:
'Group was successfully deleted.'
end
private
def
group
@group
=
Group
.
find_by_code
(
params
[
:id
])
end
end
app/models/group.rb
View file @
d6363e93
...
@@ -19,4 +19,10 @@ class Group < ActiveRecord::Base
...
@@ -19,4 +19,10 @@ class Group < ActiveRecord::Base
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:name
,
presence:
true
,
uniqueness:
true
validates
:code
,
presence:
true
,
uniqueness:
true
validates
:code
,
presence:
true
,
uniqueness:
true
validates
:owner_id
,
presence:
true
validates
:owner_id
,
presence:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
def
to_param
code
end
end
end
app/models/project.rb
View file @
d6363e93
...
@@ -26,9 +26,12 @@ class Project < ActiveRecord::Base
...
@@ -26,9 +26,12 @@ class Project < ActiveRecord::Base
has_many
:wikis
,
dependent: :destroy
has_many
:wikis
,
dependent: :destroy
has_many
:protected_branches
,
dependent: :destroy
has_many
:protected_branches
,
dependent: :destroy
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
# Scopes
# Scopes
scope
:public_only
,
where
(
private_flag:
false
)
scope
:public_only
,
where
(
private_flag:
false
)
scope
:without_user
,
lambda
{
|
user
|
where
(
"id not in (:ids)"
,
ids:
user
.
projects
.
map
(
&
:id
)
)
}
scope
:without_user
,
->
(
user
)
{
where
(
"id not in (:ids)"
,
ids:
user
.
projects
.
map
(
&
:id
)
)
}
scope
:not_in_group
,
->
(
group
)
{
where
(
"id not in (:ids)"
,
ids:
group
.
project_ids
)
}
def
self
.
active
def
self
.
active
joins
(
:issues
,
:notes
,
:merge_requests
).
order
(
"issues.created_at, notes.created_at, merge_requests.created_at DESC"
)
joins
(
:issues
,
:notes
,
:merge_requests
).
order
(
"issues.created_at, notes.created_at, merge_requests.created_at DESC"
)
...
...
app/views/admin/groups/_form.html.haml
0 → 100644
View file @
d6363e93
=
form_for
[
:admin
,
@group
]
do
|
f
|
-
if
@group
.
errors
.
any?
.alert-message.block-message.error
%span
=
@group
.
errors
.
full_messages
.
first
.clearfix.group_name_holder
=
f
.
label
:name
do
Group name is
.input
=
f
.
text_field
:name
,
placeholder:
"Example Group"
,
class:
"xxlarge"
.clearfix
=
f
.
label
:code
do
URL
.input
.input-prepend
%span
.add-on
=
web_app_url
=
f
.
text_field
:code
,
placeholder:
"example"
.form-actions
=
f
.
submit
'Create group'
,
class:
"btn primary"
app/views/admin/groups/index.html.haml
0 → 100644
View file @
d6363e93
%h3
.page_title
Groups
=
link_to
'New Group'
,
new_admin_group_path
,
class:
"btn small right"
%br
=
form_tag
admin_groups_path
,
method: :get
,
class:
'form-inline'
do
=
text_field_tag
:name
,
params
[
:name
],
class:
"xlarge"
=
submit_tag
"Search"
,
class:
"btn submit primary"
%table
%thead
%th
Name
%th
Path
%th
Projects
%th
Edit
%th
.cred
Danger Zone!
-
@groups
.
each
do
|
group
|
%tr
%td
=
link_to
group
.
name
,
[
:admin
,
group
]
%td
=
group
.
path
%td
=
group
.
projects
.
count
%td
=
link_to
'Edit'
,
edit_admin_group_path
(
group
),
id:
"edit_
#{
dom_id
(
group
)
}
"
,
class:
"btn small"
%td
.bgred
=
link_to
'Destroy'
,
[
:admin
,
group
],
confirm:
"REMOVE
#{
group
.
name
}
? Are you sure?"
,
method: :delete
,
class:
"btn small danger"
=
paginate
@groups
,
theme:
"admin"
app/views/admin/groups/new.html.haml
0 → 100644
View file @
d6363e93
%h3
.page_title
New Group
%br
=
render
'form'
app/views/admin/groups/show.html.haml
0 → 100644
View file @
d6363e93
%h3
.page_title
Group:
#{
@group
.
name
}
=
link_to
edit_admin_group_path
(
@group
),
class:
"btn right"
do
%i
.icon-edit
Edit
%br
%table
.zebra-striped
%thead
%tr
%th
Group
%th
%tr
%td
%b
Name:
%td
=
@group
.
name
%tr
%td
%b
Code:
%td
=
@group
.
code
%tr
%td
%b
Owner:
%td
=
@group
.
owner_name
.ui-box
%h5
Projects
%small
(
#{
@group
.
projects
.
count
}
)
%ul
.unstyled
-
@group
.
projects
.
each
do
|
project
|
%li
.wll
%strong
=
link_to
project
.
name
,
[
:admin
,
project
]
%br
%h3
Add new project
%br
=
form_tag
project_update_admin_group_path
(
@group
),
class:
"bulk_import"
,
method: :put
do
=
select_tag
:project_ids
,
options_from_collection_for_select
(
@projects
,
:id
,
:name
),
multiple:
true
,
data:
{
placeholder:
'Select projects'
},
class:
'chosen span5'
.form-actions
=
submit_tag
'Add'
,
class:
"btn primary"
config/routes.rb
View file @
d6363e93
...
@@ -43,6 +43,11 @@ Gitlab::Application.routes.draw do
...
@@ -43,6 +43,11 @@ Gitlab::Application.routes.draw do
put
:unblock
put
:unblock
end
end
end
end
resources
:groups
,
constraints:
{
id:
/[^\/]+/
}
do
member
do
put
:project_update
end
end
resources
:projects
,
constraints:
{
id:
/[^\/]+/
}
do
resources
:projects
,
constraints:
{
id:
/[^\/]+/
}
do
member
do
member
do
get
:team
get
:team
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment