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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
552b3105
Commit
552b3105
authored
Nov 23, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed admin area. Create project only from one place
parent
2b683b0d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
101 deletions
+42
-101
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+12
-33
app/models/project.rb
app/models/project.rb
+4
-1
app/views/admin/projects/_form.html.haml
app/views/admin/projects/_form.html.haml
+9
-9
app/views/admin/projects/_new_form.html.haml
app/views/admin/projects/_new_form.html.haml
+0
-29
app/views/admin/projects/edit.html.haml
app/views/admin/projects/edit.html.haml
+2
-2
app/views/admin/projects/index.html.haml
app/views/admin/projects/index.html.haml
+3
-3
app/views/admin/projects/new.html.haml
app/views/admin/projects/new.html.haml
+0
-12
app/views/admin/projects/show.html.haml
app/views/admin/projects/show.html.haml
+11
-11
config/routes.rb
config/routes.rb
+1
-1
No files found.
app/controllers/admin/projects_controller.rb
View file @
552b3105
class
Admin::ProjectsController
<
AdminController
class
Admin::ProjectsController
<
AdminController
before_filter
:
admin_
project
,
only:
[
:edit
,
:show
,
:update
,
:destroy
,
:team_update
]
before_filter
:project
,
only:
[
:edit
,
:show
,
:update
,
:destroy
,
:team_update
]
def
index
def
index
@
admin_
projects
=
Project
.
scoped
@projects
=
Project
.
scoped
@
admin_projects
=
@admin_
projects
.
search
(
params
[
:name
])
if
params
[
:name
].
present?
@
projects
=
@
projects
.
search
(
params
[
:name
])
if
params
[
:name
].
present?
@
admin_projects
=
@admin_
projects
.
order
(
"name ASC"
).
page
(
params
[
:page
]).
per
(
20
)
@
projects
=
@
projects
.
order
(
"name ASC"
).
page
(
params
[
:page
]).
per
(
20
)
end
end
def
show
def
show
@users
=
User
.
scoped
@users
=
User
.
scoped
@users
=
@users
.
not_in_project
(
@
admin_project
)
if
@admin_
project
.
users
.
present?
@users
=
@users
.
not_in_project
(
@
project
)
if
@
project
.
users
.
present?
@users
=
@users
.
all
@users
=
@users
.
all
end
end
def
new
@admin_project
=
Project
.
new
end
def
edit
def
edit
end
end
def
team_update
def
team_update
@admin_project
.
add_users_ids_to_team
(
params
[
:user_ids
],
params
[
:project_access
])
@project
.
add_users_ids_to_team
(
params
[
:user_ids
],
params
[
:project_access
])
redirect_to
[
:admin
,
@admin_project
],
notice:
'Project was successfully updated.'
end
def
create
@admin_project
=
Project
.
new
(
params
[
:project
])
@admin_project
.
owner
=
current_user
if
@admin_project
.
save
redirect_to
[
:admin
,
@project
],
notice:
'Project was successfully updated.'
redirect_to
[
:admin
,
@admin_project
],
notice:
'Project was successfully created.'
else
render
action:
"new"
end
end
end
def
update
def
update
owner_id
=
params
[
:project
].
delete
(
:owner_id
)
owner_id
=
params
[
:project
].
delete
(
:owner_id
)
if
owner_id
if
owner_id
@
admin_
project
.
owner
=
User
.
find
(
owner_id
)
@project
.
owner
=
User
.
find
(
owner_id
)
end
end
if
@
admin_project
.
update_attributes
(
params
[
:project
]
)
if
@
project
.
update_attributes
(
params
[
:project
],
as: :admin
)
redirect_to
[
:admin
,
@
admin_
project
],
notice:
'Project was successfully updated.'
redirect_to
[
:admin
,
@project
],
notice:
'Project was successfully updated.'
else
else
render
action:
"edit"
render
action:
"edit"
end
end
end
end
def
destroy
def
destroy
@admin_project
.
destroy
@project
.
destroy
redirect_to
admin_projects_url
,
notice:
'Project was successfully deleted.'
end
private
def
admin_project
redirect_to
projects_url
,
notice:
'Project was successfully deleted.'
@admin_project
=
Project
.
find_by_code
(
params
[
:id
])
end
end
end
end
app/models/project.rb
View file @
552b3105
...
@@ -28,7 +28,10 @@ class Project < ActiveRecord::Base
...
@@ -28,7 +28,10 @@ class Project < ActiveRecord::Base
include
Team
include
Team
attr_accessible
:name
,
:path
,
:description
,
:code
,
:default_branch
,
:issues_enabled
,
attr_accessible
:name
,
:path
,
:description
,
:code
,
:default_branch
,
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:wiki_enabled
:wall_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
as:
[
:default
,
:admin
]
attr_accessible
:namespace_id
,
as: :admin
attr_accessor
:error_code
attr_accessor
:error_code
# Relations
# Relations
...
...
app/views/admin/projects/_form.html.haml
View file @
552b3105
...
@@ -11,16 +11,13 @@
...
@@ -11,16 +11,13 @@
.input
.input
=
f
.
text_field
:name
,
placeholder:
"Example Project"
,
class:
"xxlarge"
=
f
.
text_field
:name
,
placeholder:
"Example Project"
,
class:
"xxlarge"
%hr
%fieldset
.adv_settings
.adv_settings
%legend
Advanced settings:
%h6
Advanced settings:
.clearfix
.clearfix
=
f
.
label
:path
do
=
f
.
label
:path
do
Path
Path
.input
.input
.input-prepend
=
text_field_tag
:ppath
,
@project
.
path_to_repo
,
class:
"xlarge"
,
disabled:
true
%strong
=
text_field_tag
:ppath
,
@admin_project
.
path_to_repo
,
class:
"xlarge"
,
disabled:
true
.clearfix
.clearfix
=
f
.
label
:code
do
=
f
.
label
:code
do
URL
URL
...
@@ -30,6 +27,10 @@
...
@@ -30,6 +27,10 @@
=
f
.
text_field
:code
,
placeholder:
"example"
=
f
.
text_field
:code
,
placeholder:
"example"
-
unless
project
.
new_record?
-
unless
project
.
new_record?
.clearfix
=
f
.
label
:namespace_id
.input
=
f
.
select
:namespace_id
,
namespaces_options
,
{},
{
class:
'chosen'
}
.clearfix
.clearfix
=
f
.
label
:owner_id
=
f
.
label
:owner_id
.input
=
f
.
select
:owner_id
,
User
.
all
.
map
{
|
user
|
[
user
.
name
,
user
.
id
]
},
{},
{
class:
'chosen'
}
.input
=
f
.
select
:owner_id
,
User
.
all
.
map
{
|
user
|
[
user
.
name
,
user
.
id
]
},
{},
{
class:
'chosen'
}
...
@@ -40,9 +41,8 @@
...
@@ -40,9 +41,8 @@
.input
=
f
.
select
(
:default_branch
,
project
.
heads
.
map
(
&
:name
),
{},
style:
"width:210px;"
)
.input
=
f
.
select
(
:default_branch
,
project
.
heads
.
map
(
&
:name
),
{},
style:
"width:210px;"
)
-
unless
project
.
new_record?
-
unless
project
.
new_record?
%hr
%fieldset
.adv_settings
.adv_settings
%legend
Features:
%h6
Features:
.clearfix
.clearfix
=
f
.
label
:issues_enabled
,
"Issues"
=
f
.
label
:issues_enabled
,
"Issues"
...
...
app/views/admin/projects/_new_form.html.haml
deleted
100644 → 0
View file @
2b683b0d
=
form_for
[
:admin
,
@admin_project
]
do
|
f
|
-
if
@admin_project
.
errors
.
any?
.alert-message.block-message.error
%span
=
@admin_project
.
errors
.
full_messages
.
first
.clearfix.project_name_holder
=
f
.
label
:name
do
Project name is
.input
=
f
.
text_field
:name
,
placeholder:
"Example Project"
,
class:
"xxlarge"
=
f
.
submit
'Create project'
,
class:
"btn primary project-submit"
%hr
%div
.adv_settings
%h6
Advanced settings:
.clearfix
=
f
.
label
:path
do
Git Clone
.input
.input-prepend
%span
.add-on
=
Gitlab
.
config
.
ssh_path
=
f
.
text_field
:path
,
placeholder:
"example_project"
,
disabled:
!
@admin_project
.
new_record?
%span
.add-on
=
".git"
.clearfix
=
f
.
label
:code
do
URL
.input
.input-prepend
%span
.add-on
=
web_app_url
=
f
.
text_field
:code
,
placeholder:
"example"
app/views/admin/projects/edit.html.haml
View file @
552b3105
%h3
.page_title
#{
@
admin_project
.
name
}
→
Edit project
%h3
.page_title
#{
@
project
.
name
}
→
Edit project
%hr
%hr
=
render
'form'
,
project:
@
admin_
project
=
render
'form'
,
project:
@project
app/views/admin/projects/index.html.haml
View file @
552b3105
=
render
'admin/shared/projects_head'
=
render
'admin/shared/projects_head'
%h3
.page_title
%h3
.page_title
Projects
Projects
=
link_to
'New Project'
,
new_
admin_
project_path
,
class:
"btn small right"
=
link_to
'New Project'
,
new_project_path
,
class:
"btn small right"
%br
%br
=
form_tag
admin_projects_path
,
method: :get
,
class:
'form-inline'
do
=
form_tag
admin_projects_path
,
method: :get
,
class:
'form-inline'
do
=
text_field_tag
:name
,
params
[
:name
],
class:
"xlarge"
=
text_field_tag
:name
,
params
[
:name
],
class:
"xlarge"
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
%th
Edit
%th
Edit
%th
.cred
Danger Zone!
%th
.cred
Danger Zone!
-
@
admin_
projects
.
each
do
|
project
|
-
@projects
.
each
do
|
project
|
%tr
%tr
%td
=
link_to
project
.
name
,
[
:admin
,
project
]
%td
=
link_to
project
.
name
,
[
:admin
,
project
]
%td
=
project
.
path
%td
=
project
.
path
...
@@ -24,4 +24,4 @@
...
@@ -24,4 +24,4 @@
%td
=
last_commit
(
project
)
%td
=
last_commit
(
project
)
%td
=
link_to
'Edit'
,
edit_admin_project_path
(
project
),
id:
"edit_
#{
dom_id
(
project
)
}
"
,
class:
"btn small"
%td
=
link_to
'Edit'
,
edit_admin_project_path
(
project
),
id:
"edit_
#{
dom_id
(
project
)
}
"
,
class:
"btn small"
%td
.bgred
=
link_to
'Destroy'
,
[
:admin
,
project
],
confirm:
"REMOVE
#{
project
.
name
}
? Are you sure?"
,
method: :delete
,
class:
"btn small danger"
%td
.bgred
=
link_to
'Destroy'
,
[
:admin
,
project
],
confirm:
"REMOVE
#{
project
.
name
}
? Are you sure?"
,
method: :delete
,
class:
"btn small danger"
=
paginate
@
admin_
projects
,
theme:
"admin"
=
paginate
@projects
,
theme:
"admin"
app/views/admin/projects/new.html.haml
deleted
100644 → 0
View file @
2b683b0d
.project_new_holder
%h3
.page_title
New Project
%hr
=
render
'new_form'
%div
.save-project-loader.hide
%center
=
image_tag
"ajax_loader.gif"
%h3
Creating project
&
repository. Please wait a few minutes
:javascript
$
(
function
(){
new
Projects
();
});
app/views/admin/projects/show.html.haml
View file @
552b3105
=
render
'admin/shared/projects_head'
=
render
'admin/shared/projects_head'
%h3
.page_title
%h3
.page_title
Project:
#{
@
admin_
project
.
name
}
Project:
#{
@project
.
name
}
=
link_to
edit_admin_project_path
(
@
admin_
project
),
class:
"btn right"
do
=
link_to
edit_admin_project_path
(
@project
),
class:
"btn right"
do
%i
.icon-edit
%i
.icon-edit
Edit
Edit
-
if
!
@
admin_project
.
has_post_receive_file?
&&
@admin_
project
.
has_commits?
-
if
!
@
project
.
has_post_receive_file?
&&
@
project
.
has_commits?
%br
%br
.alert.alert-error
.alert.alert-error
%span
%span
...
@@ -25,36 +25,36 @@
...
@@ -25,36 +25,36 @@
%b
%b
Name:
Name:
%td
%td
=
@
admin_
project
.
name
=
@project
.
name
%tr
%tr
%td
%td
%b
%b
Code:
Code:
%td
%td
=
@
admin_
project
.
code
=
@project
.
code
%tr
%tr
%td
%td
%b
%b
Path:
Path:
%td
%td
=
@admin_project
.
path
%code
=
@project
.
path_to_repo
%tr
%tr
%td
%td
%b
%b
Owner:
Owner:
%td
%td
=
@
admin_
project
.
owner_name
||
'(deleted)'
=
@project
.
owner_name
||
'(deleted)'
%tr
%tr
%td
%td
%b
%b
Post Receive File:
Post Receive File:
%td
%td
=
check_box_tag
:post_receive_file
,
1
,
@
admin_
project
.
has_post_receive_file?
,
disabled:
true
=
check_box_tag
:post_receive_file
,
1
,
@project
.
has_post_receive_file?
,
disabled:
true
%br
%br
%h3
%h3
Team
Team
%small
%small
(
#{
@
admin_
project
.
users_projects
.
count
}
)
(
#{
@project
.
users_projects
.
count
}
)
%br
%br
%table
.zebra-striped
%table
.zebra-striped
%thead
%thead
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
%th
Repository Access
%th
Repository Access
%th
%th
-
@
admin_
project
.
users_projects
.
each
do
|
tm
|
-
@project
.
users_projects
.
each
do
|
tm
|
%tr
%tr
%td
%td
=
link_to
tm
.
user_name
,
admin_user_path
(
tm
.
user
)
=
link_to
tm
.
user_name
,
admin_user_path
(
tm
.
user
)
...
@@ -75,7 +75,7 @@
...
@@ -75,7 +75,7 @@
%br
%br
%h3
Add new team member
%h3
Add new team member
%br
%br
=
form_tag
team_update_admin_project_path
(
@
admin_
project
),
class:
"bulk_import"
,
method: :put
do
=
form_tag
team_update_admin_project_path
(
@project
),
class:
"bulk_import"
,
method: :put
do
%table
.zebra-striped
%table
.zebra-striped
%thead
%thead
%tr
%tr
...
...
config/routes.rb
View file @
552b3105
...
@@ -49,7 +49,7 @@ Gitlab::Application.routes.draw do
...
@@ -49,7 +49,7 @@ Gitlab::Application.routes.draw do
delete
:remove_project
delete
:remove_project
end
end
end
end
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.\/0-9_\-]+/
}
do
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.\/0-9_\-]+/
}
,
except:
[
:new
,
:create
]
do
member
do
member
do
get
:team
get
:team
put
:team_update
put
:team_update
...
...
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