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 | 21 | respond_to do |format| |
22 | 22 | format.html # index.html.erb |
23 | 23 | format.js |
24 | - format.json { render json: @commits } | |
25 | 24 | end |
26 | 25 | end |
27 | 26 | |
... | ... | @@ -33,7 +32,6 @@ class CommitsController < ApplicationController |
33 | 32 | respond_to do |format| |
34 | 33 | format.html # show.html.erb |
35 | 34 | format.js |
36 | - format.json { render json: @commit } | |
37 | 35 | end |
38 | 36 | end |
39 | 37 | end | ... | ... |
app/controllers/keys_controller.rb
... | ... | @@ -3,11 +3,6 @@ class KeysController < ApplicationController |
3 | 3 | |
4 | 4 | def index |
5 | 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 | 6 | end |
12 | 7 | |
13 | 8 | def new |
... | ... | @@ -32,7 +27,6 @@ class KeysController < ApplicationController |
32 | 27 | respond_to do |format| |
33 | 28 | format.html { redirect_to keys_url } |
34 | 29 | format.js { render :nothing => true } |
35 | - format.json { head :ok } | |
36 | 30 | end |
37 | 31 | end |
38 | 32 | end | ... | ... |
app/controllers/projects_controller.rb
... | ... | @@ -8,10 +8,52 @@ class ProjectsController < ApplicationController |
8 | 8 | |
9 | 9 | def index |
10 | 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 | 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 | 57 | end |
16 | 58 | end |
17 | 59 | |
... | ... | @@ -21,20 +63,27 @@ class ProjectsController < ApplicationController |
21 | 63 | @tree = @commit.tree |
22 | 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 | 66 | rescue Grit::NoSuchPathError => ex |
29 | 67 | respond_to do |format| |
30 | 68 | format.html {render "projects/empty"} |
31 | 69 | end |
32 | 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 | 88 | @repo = project.repo |
40 | 89 | |
... | ... | @@ -74,77 +123,14 @@ class ProjectsController < ApplicationController |
74 | 123 | return render_404 |
75 | 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 | 126 | def destroy |
135 | 127 | project.destroy |
136 | 128 | |
137 | 129 | respond_to do |format| |
138 | 130 | format.html { redirect_to projects_url } |
139 | - format.json { head :ok } | |
140 | 131 | end |
141 | 132 | end |
142 | 133 | |
143 | - def wall | |
144 | - @notes = @project.common_notes | |
145 | - @note = Note.new | |
146 | - end | |
147 | - | |
148 | 134 | protected |
149 | 135 | |
150 | 136 | def project | ... | ... |
app/controllers/team_members_controller.rb
... | ... | @@ -12,7 +12,6 @@ class TeamMembersController < ApplicationController |
12 | 12 | respond_to do |format| |
13 | 13 | format.html # show.html.erb |
14 | 14 | format.js |
15 | - format.json { render json: @team_member } | |
16 | 15 | end |
17 | 16 | end |
18 | 17 | |
... | ... | @@ -22,7 +21,6 @@ class TeamMembersController < ApplicationController |
22 | 21 | respond_to do |format| |
23 | 22 | format.html # new.html.erb |
24 | 23 | format.js |
25 | - format.json { render json: @team_member } | |
26 | 24 | end |
27 | 25 | end |
28 | 26 | |
... | ... | @@ -34,11 +32,9 @@ class TeamMembersController < ApplicationController |
34 | 32 | if @team_member.save |
35 | 33 | format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } |
36 | 34 | format.js |
37 | - format.json { render json: @team_member, status: :created, location: @team_member } | |
38 | 35 | else |
39 | 36 | format.html { render action: "new" } |
40 | 37 | format.js |
41 | - format.json { render json: @team_member.errors, status: :unprocessable_entity } | |
42 | 38 | end |
43 | 39 | end |
44 | 40 | end |
... | ... | @@ -59,7 +55,6 @@ class TeamMembersController < ApplicationController |
59 | 55 | |
60 | 56 | respond_to do |format| |
61 | 57 | format.html { redirect_to root_path } |
62 | - format.json { head :ok } | |
63 | 58 | format.js { render :nothing => true } |
64 | 59 | end |
65 | 60 | end | ... | ... |
app/views/notes/_notes.html.haml
app/views/projects/_list.html.haml
app/views/projects/_projects_top_menu.html.haml
1 | 1 | %div.top_project_menu |
2 | 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 | 5 | %span.right |
5 | 6 | = link_to_function(image_tag("list_view_icon.jpg"), "switchProjectView()", :style => "border:none;box-shadow:none;") |
6 | 7 | ... | ... |