summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-23 07:31:09 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-23 07:31:09 +0300
commit552b3105fba11493d25575ee9220631a816141f6 (patch)
tree6b15a865db2e90bab9a71221be51a4d8ead4fedb /app
parent2b683b0d0bf90c84b33ec4ed5c70e3bc787094e2 (diff)
downloadgitlab-ce-552b3105fba11493d25575ee9220631a816141f6.tar.gz
Fixed admin area. Create project only from one place
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/projects_controller.rb45
-rw-r--r--app/models/project.rb5
-rw-r--r--app/views/admin/projects/_form.html.haml18
-rw-r--r--app/views/admin/projects/_new_form.html.haml29
-rw-r--r--app/views/admin/projects/edit.html.haml4
-rw-r--r--app/views/admin/projects/index.html.haml6
-rw-r--r--app/views/admin/projects/new.html.haml12
-rw-r--r--app/views/admin/projects/show.html.haml22
8 files changed, 41 insertions, 100 deletions
diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb
index d27b657de3a..7829cc9315c 100644
--- a/app/controllers/admin/projects_controller.rb
+++ b/app/controllers/admin/projects_controller.rb
@@ -1,65 +1,44 @@
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
- @admin_projects = Project.scoped
- @admin_projects = @admin_projects.search(params[:name]) if params[:name].present?
- @admin_projects = @admin_projects.order("name ASC").page(params[:page]).per(20)
+ @projects = Project.scoped
+ @projects = @projects.search(params[:name]) if params[:name].present?
+ @projects = @projects.order("name ASC").page(params[:page]).per(20)
end
def show
@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
end
- def new
- @admin_project = Project.new
- end
-
def edit
end
def team_update
- @admin_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
+ @project.add_users_ids_to_team(params[:user_ids], params[:project_access])
- if @admin_project.save
- redirect_to [:admin, @admin_project], notice: 'Project was successfully created.'
- else
- render action: "new"
- end
+ redirect_to [:admin, @project], notice: 'Project was successfully updated.'
end
def update
owner_id = params[:project].delete(:owner_id)
if owner_id
- @admin_project.owner = User.find(owner_id)
+ @project.owner = User.find(owner_id)
end
- if @admin_project.update_attributes(params[:project])
- redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.'
+ if @project.update_attributes(params[:project], as: :admin)
+ redirect_to [:admin, @project], notice: 'Project was successfully updated.'
else
render action: "edit"
end
end
def destroy
- @admin_project.destroy
-
- redirect_to admin_projects_url, notice: 'Project was successfully deleted.'
- end
-
- private
+ @project.destroy
- def admin_project
- @admin_project = Project.find_by_code(params[:id])
+ redirect_to projects_url, notice: 'Project was successfully deleted.'
end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index eb3b1b3d113..07697b1315f 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -28,7 +28,10 @@ class Project < ActiveRecord::Base
include Team
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
# Relations
diff --git a/app/views/admin/projects/_form.html.haml b/app/views/admin/projects/_form.html.haml
index 4848e7391a3..a238d938076 100644
--- a/app/views/admin/projects/_form.html.haml
+++ b/app/views/admin/projects/_form.html.haml
@@ -11,16 +11,13 @@
.input
= f.text_field :name, placeholder: "Example Project", class: "xxlarge"
- %hr
- .adv_settings
- %h6 Advanced settings:
+ %fieldset.adv_settings
+ %legend Advanced settings:
.clearfix
= f.label :path do
Path
.input
- .input-prepend
- %strong
- = text_field_tag :ppath, @admin_project.path_to_repo, class: "xlarge", disabled: true
+ = text_field_tag :ppath, @project.path_to_repo, class: "xlarge", disabled: true
.clearfix
= f.label :code do
URL
@@ -31,6 +28,10 @@
- unless project.new_record?
.clearfix
+ = f.label :namespace_id
+ .input= f.select :namespace_id, namespaces_options, {}, {class: 'chosen'}
+
+ .clearfix
= f.label :owner_id
.input= f.select :owner_id, User.all.map { |user| [user.name, user.id] }, {}, {class: 'chosen'}
@@ -40,9 +41,8 @@
.input= f.select(:default_branch, project.heads.map(&:name), {}, style: "width:210px;")
- unless project.new_record?
- %hr
- .adv_settings
- %h6 Features:
+ %fieldset.adv_settings
+ %legend Features:
.clearfix
= f.label :issues_enabled, "Issues"
diff --git a/app/views/admin/projects/_new_form.html.haml b/app/views/admin/projects/_new_form.html.haml
deleted file mode 100644
index d793b6f3aff..00000000000
--- a/app/views/admin/projects/_new_form.html.haml
+++ /dev/null
@@ -1,29 +0,0 @@
-= 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"
diff --git a/app/views/admin/projects/edit.html.haml b/app/views/admin/projects/edit.html.haml
index b5255671154..7b59a0cc753 100644
--- a/app/views/admin/projects/edit.html.haml
+++ b/app/views/admin/projects/edit.html.haml
@@ -1,3 +1,3 @@
-%h3.page_title #{@admin_project.name} &rarr; Edit project
+%h3.page_title #{@project.name} &rarr; Edit project
%hr
-= render 'form', project: @admin_project
+= render 'form', project: @project
diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml
index 3335fce0078..7239794a812 100644
--- a/app/views/admin/projects/index.html.haml
+++ b/app/views/admin/projects/index.html.haml
@@ -1,7 +1,7 @@
= render 'admin/shared/projects_head'
%h3.page_title
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
= form_tag admin_projects_path, method: :get, class: 'form-inline' do
= text_field_tag :name, params[:name], class: "xlarge"
@@ -16,7 +16,7 @@
%th Edit
%th.cred Danger Zone!
- - @admin_projects.each do |project|
+ - @projects.each do |project|
%tr
%td= link_to project.name, [:admin, project]
%td= project.path
@@ -24,4 +24,4 @@
%td= last_commit(project)
%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"
-= paginate @admin_projects, theme: "admin"
+= paginate @projects, theme: "admin"
diff --git a/app/views/admin/projects/new.html.haml b/app/views/admin/projects/new.html.haml
deleted file mode 100644
index 933cb671142..00000000000
--- a/app/views/admin/projects/new.html.haml
+++ /dev/null
@@ -1,12 +0,0 @@
-.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 &amp; repository. Please wait a few minutes
-
-:javascript
- $(function(){ new Projects(); });
diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml
index 78df8f2d2e9..ae5da372e1a 100644
--- a/app/views/admin/projects/show.html.haml
+++ b/app/views/admin/projects/show.html.haml
@@ -1,11 +1,11 @@
= render 'admin/shared/projects_head'
%h3.page_title
- Project: #{@admin_project.name}
- = link_to edit_admin_project_path(@admin_project), class: "btn right" do
+ Project: #{@project.name}
+ = link_to edit_admin_project_path(@project), class: "btn right" do
%i.icon-edit
Edit
-- if !@admin_project.has_post_receive_file? && @admin_project.has_commits?
+- if !@project.has_post_receive_file? && @project.has_commits?
%br
.alert.alert-error
%span
@@ -25,36 +25,36 @@
%b
Name:
%td
- = @admin_project.name
+ = @project.name
%tr
%td
%b
Code:
%td
- = @admin_project.code
+ = @project.code
%tr
%td
%b
Path:
%td
- = @admin_project.path
+ %code= @project.path_to_repo
%tr
%td
%b
Owner:
%td
- = @admin_project.owner_name || '(deleted)'
+ = @project.owner_name || '(deleted)'
%tr
%td
%b
Post Receive File:
%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
%h3
Team
%small
- (#{@admin_project.users_projects.count})
+ (#{@project.users_projects.count})
%br
%table.zebra-striped
%thead
@@ -64,7 +64,7 @@
%th Repository Access
%th
- - @admin_project.users_projects.each do |tm|
+ - @project.users_projects.each do |tm|
%tr
%td
= link_to tm.user_name, admin_user_path(tm.user)
@@ -75,7 +75,7 @@
%br
%h3 Add new team member
%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
%thead
%tr