Commit 53421e060a3b96a63206d39205193bfdea0eeaba
1 parent
5f8255ac
Exists in
master
and in
4 other branches
clean controllers
Showing
7 changed files
with
60 additions
and
88 deletions
Show diff stats
app/controllers/commits_controller.rb
@@ -21,7 +21,6 @@ class CommitsController < ApplicationController | @@ -21,7 +21,6 @@ class CommitsController < ApplicationController | ||
21 | respond_to do |format| | 21 | respond_to do |format| |
22 | format.html # index.html.erb | 22 | format.html # index.html.erb |
23 | format.js | 23 | format.js |
24 | - format.json { render json: @commits } | ||
25 | end | 24 | end |
26 | end | 25 | end |
27 | 26 | ||
@@ -33,7 +32,6 @@ class CommitsController < ApplicationController | @@ -33,7 +32,6 @@ class CommitsController < ApplicationController | ||
33 | respond_to do |format| | 32 | respond_to do |format| |
34 | format.html # show.html.erb | 33 | format.html # show.html.erb |
35 | format.js | 34 | format.js |
36 | - format.json { render json: @commit } | ||
37 | end | 35 | end |
38 | end | 36 | end |
39 | end | 37 | end |
app/controllers/keys_controller.rb
@@ -3,11 +3,6 @@ class KeysController < ApplicationController | @@ -3,11 +3,6 @@ class KeysController < ApplicationController | ||
3 | 3 | ||
4 | def index | 4 | def index |
5 | @keys = current_user.keys.all | 5 | @keys = current_user.keys.all |
6 | - | ||
7 | - respond_to do |format| | ||
8 | - format.html # index.html.erb | ||
9 | - format.json { render json: @keys } | ||
10 | - end | ||
11 | end | 6 | end |
12 | 7 | ||
13 | def new | 8 | def new |
@@ -32,7 +27,6 @@ class KeysController < ApplicationController | @@ -32,7 +27,6 @@ class KeysController < ApplicationController | ||
32 | respond_to do |format| | 27 | respond_to do |format| |
33 | format.html { redirect_to keys_url } | 28 | format.html { redirect_to keys_url } |
34 | format.js { render :nothing => true } | 29 | format.js { render :nothing => true } |
35 | - format.json { head :ok } | ||
36 | end | 30 | end |
37 | end | 31 | end |
38 | end | 32 | end |
app/controllers/projects_controller.rb
@@ -8,10 +8,52 @@ class ProjectsController < ApplicationController | @@ -8,10 +8,52 @@ class ProjectsController < ApplicationController | ||
8 | 8 | ||
9 | def index | 9 | def index |
10 | @projects = current_user.projects.all | 10 | @projects = current_user.projects.all |
11 | + end | ||
12 | + | ||
13 | + def new | ||
14 | + @project = Project.new | ||
15 | + end | ||
16 | + | ||
17 | + def edit | ||
18 | + end | ||
19 | + | ||
20 | + def create | ||
21 | + @project = Project.new(params[:project]) | ||
22 | + @project.owner = current_user | ||
23 | + | ||
24 | + Project.transaction do | ||
25 | + @project.save! | ||
26 | + @project.users_projects.create!(:admin => true, :read => true, :write => true, :user => current_user) | ||
27 | + end | ||
28 | + | ||
29 | + respond_to do |format| | ||
30 | + if @project.valid? | ||
31 | + format.html { redirect_to @project, notice: 'Project was successfully created.' } | ||
32 | + format.js | ||
33 | + else | ||
34 | + format.html { render action: "new" } | ||
35 | + format.js | ||
36 | + end | ||
37 | + end | ||
38 | + rescue Gitosis::AccessDenied | ||
39 | + render :js => "location.href = '#{errors_gitosis_path}'" and return | ||
40 | + rescue StandardError => ex | ||
41 | + @project.errors.add(:base, "Cant save project. Please try again later") | ||
42 | + respond_to do |format| | ||
43 | + format.html { render action: "new" } | ||
44 | + format.js | ||
45 | + end | ||
46 | + end | ||
11 | 47 | ||
48 | + def update | ||
12 | respond_to do |format| | 49 | respond_to do |format| |
13 | - format.html # index.html.erb | ||
14 | - format.json { render json: @projects } | 50 | + if project.update_attributes(params[:project]) |
51 | + format.html { redirect_to project, notice: 'Project was successfully updated.' } | ||
52 | + format.js | ||
53 | + else | ||
54 | + format.html { render action: "edit" } | ||
55 | + format.js | ||
56 | + end | ||
15 | end | 57 | end |
16 | end | 58 | end |
17 | 59 | ||
@@ -21,20 +63,27 @@ class ProjectsController < ApplicationController | @@ -21,20 +63,27 @@ class ProjectsController < ApplicationController | ||
21 | @tree = @commit.tree | 63 | @tree = @commit.tree |
22 | @tree = @tree / params[:path] if params[:path] | 64 | @tree = @tree / params[:path] if params[:path] |
23 | 65 | ||
24 | - respond_to do |format| | ||
25 | - format.html # show.html.erb | ||
26 | - format.json { render json: project } | ||
27 | - end | ||
28 | rescue Grit::NoSuchPathError => ex | 66 | rescue Grit::NoSuchPathError => ex |
29 | respond_to do |format| | 67 | respond_to do |format| |
30 | format.html {render "projects/empty"} | 68 | format.html {render "projects/empty"} |
31 | end | 69 | end |
32 | end | 70 | end |
33 | 71 | ||
34 | - def tree | ||
35 | - load_refs # load @branch, @tag & @ref | 72 | + # |
73 | + # Wall | ||
74 | + # | ||
36 | 75 | ||
76 | + def wall | ||
77 | + @notes = @project.common_notes | ||
78 | + @note = Note.new | ||
79 | + end | ||
37 | 80 | ||
81 | + # | ||
82 | + # Repository preview | ||
83 | + # | ||
84 | + | ||
85 | + def tree | ||
86 | + load_refs # load @branch, @tag & @ref | ||
38 | 87 | ||
39 | @repo = project.repo | 88 | @repo = project.repo |
40 | 89 | ||
@@ -74,77 +123,14 @@ class ProjectsController < ApplicationController | @@ -74,77 +123,14 @@ class ProjectsController < ApplicationController | ||
74 | return render_404 | 123 | return render_404 |
75 | end | 124 | end |
76 | 125 | ||
77 | - def new | ||
78 | - @project = Project.new | ||
79 | - | ||
80 | - respond_to do |format| | ||
81 | - format.html # new.html.erb | ||
82 | - format.json { render json: @project } | ||
83 | - end | ||
84 | - end | ||
85 | - | ||
86 | - def edit | ||
87 | - end | ||
88 | - | ||
89 | - def create | ||
90 | - @project = Project.new(params[:project]) | ||
91 | - @project.owner = current_user | ||
92 | - | ||
93 | - Project.transaction do | ||
94 | - @project.save! | ||
95 | - @project.users_projects.create!(:admin => true, :read => true, :write => true, :user => current_user) | ||
96 | - end | ||
97 | - | ||
98 | - respond_to do |format| | ||
99 | - if @project.valid? | ||
100 | - format.html { redirect_to @project, notice: 'Project was successfully created.' } | ||
101 | - format.js | ||
102 | - format.json { render json: @project, status: :created, location: @project } | ||
103 | - else | ||
104 | - format.html { render action: "new" } | ||
105 | - format.js | ||
106 | - format.json { render json: @project.errors, status: :unprocessable_entity } | ||
107 | - end | ||
108 | - end | ||
109 | - rescue Gitosis::AccessDenied | ||
110 | - render :js => "location.href = '#{errors_gitosis_path}'" and return | ||
111 | - rescue StandardError => ex | ||
112 | - @project.errors.add(:base, "Cant save project. Please try again later") | ||
113 | - respond_to do |format| | ||
114 | - format.html { render action: "new" } | ||
115 | - format.js | ||
116 | - format.json { render json: @project.errors, status: :unprocessable_entity } | ||
117 | - end | ||
118 | - end | ||
119 | - | ||
120 | - def update | ||
121 | - respond_to do |format| | ||
122 | - if project.update_attributes(params[:project]) | ||
123 | - format.html { redirect_to project, notice: 'Project was successfully updated.' } | ||
124 | - format.js | ||
125 | - format.json { head :ok } | ||
126 | - else | ||
127 | - format.html { render action: "edit" } | ||
128 | - format.js | ||
129 | - format.json { render json: project.errors, status: :unprocessable_entity } | ||
130 | - end | ||
131 | - end | ||
132 | - end | ||
133 | - | ||
134 | def destroy | 126 | def destroy |
135 | project.destroy | 127 | project.destroy |
136 | 128 | ||
137 | respond_to do |format| | 129 | respond_to do |format| |
138 | format.html { redirect_to projects_url } | 130 | format.html { redirect_to projects_url } |
139 | - format.json { head :ok } | ||
140 | end | 131 | end |
141 | end | 132 | end |
142 | 133 | ||
143 | - def wall | ||
144 | - @notes = @project.common_notes | ||
145 | - @note = Note.new | ||
146 | - end | ||
147 | - | ||
148 | protected | 134 | protected |
149 | 135 | ||
150 | def project | 136 | def project |
app/controllers/team_members_controller.rb
@@ -12,7 +12,6 @@ class TeamMembersController < ApplicationController | @@ -12,7 +12,6 @@ class TeamMembersController < ApplicationController | ||
12 | respond_to do |format| | 12 | respond_to do |format| |
13 | format.html # show.html.erb | 13 | format.html # show.html.erb |
14 | format.js | 14 | format.js |
15 | - format.json { render json: @team_member } | ||
16 | end | 15 | end |
17 | end | 16 | end |
18 | 17 | ||
@@ -22,7 +21,6 @@ class TeamMembersController < ApplicationController | @@ -22,7 +21,6 @@ class TeamMembersController < ApplicationController | ||
22 | respond_to do |format| | 21 | respond_to do |format| |
23 | format.html # new.html.erb | 22 | format.html # new.html.erb |
24 | format.js | 23 | format.js |
25 | - format.json { render json: @team_member } | ||
26 | end | 24 | end |
27 | end | 25 | end |
28 | 26 | ||
@@ -34,11 +32,9 @@ class TeamMembersController < ApplicationController | @@ -34,11 +32,9 @@ class TeamMembersController < ApplicationController | ||
34 | if @team_member.save | 32 | if @team_member.save |
35 | format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } | 33 | format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } |
36 | format.js | 34 | format.js |
37 | - format.json { render json: @team_member, status: :created, location: @team_member } | ||
38 | else | 35 | else |
39 | format.html { render action: "new" } | 36 | format.html { render action: "new" } |
40 | format.js | 37 | format.js |
41 | - format.json { render json: @team_member.errors, status: :unprocessable_entity } | ||
42 | end | 38 | end |
43 | end | 39 | end |
44 | end | 40 | end |
@@ -59,7 +55,6 @@ class TeamMembersController < ApplicationController | @@ -59,7 +55,6 @@ class TeamMembersController < ApplicationController | ||
59 | 55 | ||
60 | respond_to do |format| | 56 | respond_to do |format| |
61 | format.html { redirect_to root_path } | 57 | format.html { redirect_to root_path } |
62 | - format.json { head :ok } | ||
63 | format.js { render :nothing => true } | 58 | format.js { render :nothing => true } |
64 | end | 59 | end |
65 | end | 60 | end |
app/views/notes/_notes.html.haml
app/views/projects/_list.html.haml
app/views/projects/_projects_top_menu.html.haml
1 | %div.top_project_menu | 1 | %div.top_project_menu |
2 | %span= link_to 'All', projects_path, :class => current_page?(projects_path) ? "current" : nil | 2 | %span= link_to 'All', projects_path, :class => current_page?(projects_path) ? "current" : nil |
3 | - %span= link_to "New Project", new_project_path, :class => current_page?(:controller => "projects", :action => "new") ? "current" : nil | 3 | + - if current_user.can_create_project? |
4 | + %span= link_to "New Project", new_project_path, :class => current_page?(:controller => "projects", :action => "new") ? "current" : nil | ||
4 | %span.right | 5 | %span.right |
5 | = link_to_function(image_tag("list_view_icon.jpg"), "switchProjectView()", :style => "border:none;box-shadow:none;") | 6 | = link_to_function(image_tag("list_view_icon.jpg"), "switchProjectView()", :style => "border:none;box-shadow:none;") |
6 | 7 |