diff options
author | gitlabhq <m@gitlabhq.com> | 2011-10-15 01:05:41 +0400 |
---|---|---|
committer | gitlabhq <m@gitlabhq.com> | 2011-10-15 01:05:41 +0400 |
commit | 53421e060a3b96a63206d39205193bfdea0eeaba (patch) | |
tree | 67c0b16b4b5b0523a83b27825cf67117bd448799 | |
parent | 5f8255ac67e26d8d7dc98cff37ecae5eab4ab3cf (diff) |
clean controllers
-rw-r--r-- | app/controllers/commits_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/keys_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 128 | ||||
-rw-r--r-- | app/controllers/team_members_controller.rb | 5 | ||||
-rw-r--r-- | app/views/notes/_notes.html.haml | 1 | ||||
-rw-r--r-- | app/views/projects/_list.html.haml | 3 | ||||
-rw-r--r-- | app/views/projects/_projects_top_menu.html.haml | 3 |
7 files changed, 60 insertions, 88 deletions
diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index fe46ddcefb7..af82b1cd901 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -21,7 +21,6 @@ class CommitsController < ApplicationController respond_to do |format| format.html # index.html.erb format.js - format.json { render json: @commits } end end @@ -33,7 +32,6 @@ class CommitsController < ApplicationController respond_to do |format| format.html # show.html.erb format.js - format.json { render json: @commit } end end end diff --git a/app/controllers/keys_controller.rb b/app/controllers/keys_controller.rb index 003de6b301a..b2cf1c08882 100644 --- a/app/controllers/keys_controller.rb +++ b/app/controllers/keys_controller.rb @@ -3,11 +3,6 @@ class KeysController < ApplicationController def index @keys = current_user.keys.all - - respond_to do |format| - format.html # index.html.erb - format.json { render json: @keys } - end end def new @@ -32,7 +27,6 @@ class KeysController < ApplicationController respond_to do |format| format.html { redirect_to keys_url } format.js { render :nothing => true } - format.json { head :ok } end end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 7dd6eefc313..1cc2fd63faa 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -8,10 +8,52 @@ class ProjectsController < ApplicationController def index @projects = current_user.projects.all + end + + def new + @project = Project.new + end + + def edit + end + + def create + @project = Project.new(params[:project]) + @project.owner = current_user + + Project.transaction do + @project.save! + @project.users_projects.create!(:admin => true, :read => true, :write => true, :user => current_user) + end + + respond_to do |format| + if @project.valid? + format.html { redirect_to @project, notice: 'Project was successfully created.' } + format.js + else + format.html { render action: "new" } + format.js + end + end + rescue Gitosis::AccessDenied + render :js => "location.href = '#{errors_gitosis_path}'" and return + rescue StandardError => ex + @project.errors.add(:base, "Cant save project. Please try again later") + respond_to do |format| + format.html { render action: "new" } + format.js + end + end + def update respond_to do |format| - format.html # index.html.erb - format.json { render json: @projects } + if project.update_attributes(params[:project]) + format.html { redirect_to project, notice: 'Project was successfully updated.' } + format.js + else + format.html { render action: "edit" } + format.js + end end end @@ -21,20 +63,27 @@ class ProjectsController < ApplicationController @tree = @commit.tree @tree = @tree / params[:path] if params[:path] - respond_to do |format| - format.html # show.html.erb - format.json { render json: project } - end rescue Grit::NoSuchPathError => ex respond_to do |format| format.html {render "projects/empty"} end end - def tree - load_refs # load @branch, @tag & @ref + # + # Wall + # + def wall + @notes = @project.common_notes + @note = Note.new + end + # + # Repository preview + # + + def tree + load_refs # load @branch, @tag & @ref @repo = project.repo @@ -74,77 +123,14 @@ class ProjectsController < ApplicationController return render_404 end - def new - @project = Project.new - - respond_to do |format| - format.html # new.html.erb - format.json { render json: @project } - end - end - - def edit - end - - def create - @project = Project.new(params[:project]) - @project.owner = current_user - - Project.transaction do - @project.save! - @project.users_projects.create!(:admin => true, :read => true, :write => true, :user => current_user) - end - - respond_to do |format| - if @project.valid? - format.html { redirect_to @project, notice: 'Project was successfully created.' } - format.js - format.json { render json: @project, status: :created, location: @project } - else - format.html { render action: "new" } - format.js - format.json { render json: @project.errors, status: :unprocessable_entity } - end - end - rescue Gitosis::AccessDenied - render :js => "location.href = '#{errors_gitosis_path}'" and return - rescue StandardError => ex - @project.errors.add(:base, "Cant save project. Please try again later") - respond_to do |format| - format.html { render action: "new" } - format.js - format.json { render json: @project.errors, status: :unprocessable_entity } - end - end - - def update - respond_to do |format| - if project.update_attributes(params[:project]) - format.html { redirect_to project, notice: 'Project was successfully updated.' } - format.js - format.json { head :ok } - else - format.html { render action: "edit" } - format.js - format.json { render json: project.errors, status: :unprocessable_entity } - end - end - end - def destroy project.destroy respond_to do |format| format.html { redirect_to projects_url } - format.json { head :ok } end end - def wall - @notes = @project.common_notes - @note = Note.new - end - protected def project diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index fd3c944b289..e00cc36c0eb 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -12,7 +12,6 @@ class TeamMembersController < ApplicationController respond_to do |format| format.html # show.html.erb format.js - format.json { render json: @team_member } end end @@ -22,7 +21,6 @@ class TeamMembersController < ApplicationController respond_to do |format| format.html # new.html.erb format.js - format.json { render json: @team_member } end end @@ -34,11 +32,9 @@ class TeamMembersController < ApplicationController if @team_member.save format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } format.js - format.json { render json: @team_member, status: :created, location: @team_member } else format.html { render action: "new" } format.js - format.json { render json: @team_member.errors, status: :unprocessable_entity } end end end @@ -59,7 +55,6 @@ class TeamMembersController < ApplicationController respond_to do |format| format.html { redirect_to root_path } - format.json { head :ok } format.js { render :nothing => true } end end diff --git a/app/views/notes/_notes.html.haml b/app/views/notes/_notes.html.haml index 457bb8db763..9d1d4b941c8 100644 --- a/app/views/notes/_notes.html.haml +++ b/app/views/notes/_notes.html.haml @@ -1,5 +1,6 @@ %ul#notes-list - @notes.each do |note| + - next unless note.author = render :partial => "notes/show", :locals => {:note => note} %br diff --git a/app/views/projects/_list.html.haml b/app/views/projects/_list.html.haml index 82e1948c757..aec61ffbbe1 100644 --- a/app/views/projects/_list.html.haml +++ b/app/views/projects/_list.html.haml @@ -1,6 +1,3 @@ --#- if current_user.can_create_project? - = link_to 'New Project', new_project_path, :class => "lbutton vm" - %table.round-borders#projects-list %tr %th Name diff --git a/app/views/projects/_projects_top_menu.html.haml b/app/views/projects/_projects_top_menu.html.haml index be04c57e842..f80f28a8bbb 100644 --- a/app/views/projects/_projects_top_menu.html.haml +++ b/app/views/projects/_projects_top_menu.html.haml @@ -1,6 +1,7 @@ %div.top_project_menu %span= link_to 'All', projects_path, :class => current_page?(projects_path) ? "current" : nil - %span= link_to "New Project", new_project_path, :class => current_page?(:controller => "projects", :action => "new") ? "current" : nil + - if current_user.can_create_project? + %span= link_to "New Project", new_project_path, :class => current_page?(:controller => "projects", :action => "new") ? "current" : nil %span.right = link_to_function(image_tag("list_view_icon.jpg"), "switchProjectView()", :style => "border:none;box-shadow:none;") |