##// END OF EJS Templates
custom field tags...
Jean-Philippe Lang -
r18:54aeec7b5fcf
parent child
Show More
@@ -1,305 +1,305
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class ProjectsController < ApplicationController
18 class ProjectsController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
20 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
21 before_filter :require_admin, :only => [ :add, :destroy ]
21 before_filter :require_admin, :only => [ :add, :destroy ]
22
22
23 helper :sort
23 helper :sort
24 include SortHelper
24 include SortHelper
25 helper :search_filter
25 helper :search_filter
26 include SearchFilterHelper
26 include SearchFilterHelper
27 helper :custom_fields
27 helper :custom_fields
28 include CustomFieldsHelper
28 include CustomFieldsHelper
29
29
30 def index
30 def index
31 list
31 list
32 render :action => 'list'
32 render :action => 'list'
33 end
33 end
34
34
35 # Lists public projects
35 # Lists public projects
36 def list
36 def list
37 sort_init 'name', 'asc'
37 sort_init 'name', 'asc'
38 sort_update
38 sort_update
39 @project_count = Project.count(["is_public=?", true])
39 @project_count = Project.count(["is_public=?", true])
40 @project_pages = Paginator.new self, @project_count,
40 @project_pages = Paginator.new self, @project_count,
41 15,
41 15,
42 @params['page']
42 @params['page']
43 @projects = Project.find :all, :order => sort_clause,
43 @projects = Project.find :all, :order => sort_clause,
44 :conditions => ["is_public=?", true],
44 :conditions => ["is_public=?", true],
45 :limit => @project_pages.items_per_page,
45 :limit => @project_pages.items_per_page,
46 :offset => @project_pages.current.offset
46 :offset => @project_pages.current.offset
47 end
47 end
48
48
49 # Add a new project
49 # Add a new project
50 def add
50 def add
51 @custom_fields = IssueCustomField.find(:all)
51 @custom_fields = IssueCustomField.find(:all)
52 @root_projects = Project.find(:all, :conditions => "parent_id is null")
52 @root_projects = Project.find(:all, :conditions => "parent_id is null")
53 @project = Project.new(params[:project])
53 @project = Project.new(params[:project])
54 if request.get?
54 if request.get?
55 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
55 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
56 else
56 else
57 @project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
57 @project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
58 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
58 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
59 @project.custom_values = @custom_values
59 @project.custom_values = @custom_values
60 if @project.save
60 if @project.save
61 flash[:notice] = l(:notice_successful_create)
61 flash[:notice] = l(:notice_successful_create)
62 redirect_to :controller => 'admin', :action => 'projects'
62 redirect_to :controller => 'admin', :action => 'projects'
63 end
63 end
64 end
64 end
65 end
65 end
66
66
67 # Show @project
67 # Show @project
68 def show
68 def show
69 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
69 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
70 @members = @project.members.find(:all, :include => [:user, :role])
70 @members = @project.members.find(:all, :include => [:user, :role])
71 @subprojects = @project.children if @project.children_count > 0
71 @subprojects = @project.children if @project.children_count > 0
72 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
72 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
73 @trackers = Tracker.find(:all)
73 @trackers = Tracker.find(:all)
74 end
74 end
75
75
76 def settings
76 def settings
77 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
77 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
78 @custom_fields = IssueCustomField::find_all
78 @custom_fields = IssueCustomField::find_all
79 @issue_category ||= IssueCategory.new
79 @issue_category ||= IssueCategory.new
80 @member ||= @project.members.new
80 @member ||= @project.members.new
81 @roles = Role.find_all
81 @roles = Role.find_all
82 @users = User.find_all - @project.members.find(:all, :include => :user).collect{|m| m.user }
82 @users = User.find_all - @project.members.find(:all, :include => :user).collect{|m| m.user }
83 @custom_values = ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
83 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
84 end
84 end
85
85
86 # Edit @project
86 # Edit @project
87 def edit
87 def edit
88 if request.post?
88 if request.post?
89 @project.custom_fields = IssueCustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
89 @project.custom_fields = IssueCustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
90 if params[:custom_fields]
90 if params[:custom_fields]
91 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
91 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
92 @project.custom_values = @custom_values
92 @project.custom_values = @custom_values
93 end
93 end
94 if @project.update_attributes(params[:project])
94 if @project.update_attributes(params[:project])
95 flash[:notice] = l(:notice_successful_update)
95 flash[:notice] = l(:notice_successful_update)
96 redirect_to :action => 'settings', :id => @project
96 redirect_to :action => 'settings', :id => @project
97 else
97 else
98 settings
98 settings
99 render :action => 'settings'
99 render :action => 'settings'
100 end
100 end
101 end
101 end
102 end
102 end
103
103
104 # Delete @project
104 # Delete @project
105 def destroy
105 def destroy
106 if request.post? and params[:confirm]
106 if request.post? and params[:confirm]
107 @project.destroy
107 @project.destroy
108 redirect_to :controller => 'admin', :action => 'projects'
108 redirect_to :controller => 'admin', :action => 'projects'
109 end
109 end
110 end
110 end
111
111
112 # Add a new issue category to @project
112 # Add a new issue category to @project
113 def add_issue_category
113 def add_issue_category
114 if request.post?
114 if request.post?
115 @issue_category = @project.issue_categories.build(params[:issue_category])
115 @issue_category = @project.issue_categories.build(params[:issue_category])
116 if @issue_category.save
116 if @issue_category.save
117 flash[:notice] = l(:notice_successful_create)
117 flash[:notice] = l(:notice_successful_create)
118 redirect_to :action => 'settings', :id => @project
118 redirect_to :action => 'settings', :id => @project
119 else
119 else
120 settings
120 settings
121 render :action => 'settings'
121 render :action => 'settings'
122 end
122 end
123 end
123 end
124 end
124 end
125
125
126 # Add a new version to @project
126 # Add a new version to @project
127 def add_version
127 def add_version
128 @version = @project.versions.build(params[:version])
128 @version = @project.versions.build(params[:version])
129 if request.post? and @version.save
129 if request.post? and @version.save
130 flash[:notice] = l(:notice_successful_create)
130 flash[:notice] = l(:notice_successful_create)
131 redirect_to :action => 'settings', :id => @project
131 redirect_to :action => 'settings', :id => @project
132 end
132 end
133 end
133 end
134
134
135 # Add a new member to @project
135 # Add a new member to @project
136 def add_member
136 def add_member
137 @member = @project.members.build(params[:member])
137 @member = @project.members.build(params[:member])
138 if request.post?
138 if request.post?
139 if @member.save
139 if @member.save
140 flash[:notice] = l(:notice_successful_create)
140 flash[:notice] = l(:notice_successful_create)
141 redirect_to :action => 'settings', :id => @project
141 redirect_to :action => 'settings', :id => @project
142 else
142 else
143 settings
143 settings
144 render :action => 'settings'
144 render :action => 'settings'
145 end
145 end
146 end
146 end
147 end
147 end
148
148
149 # Show members list of @project
149 # Show members list of @project
150 def list_members
150 def list_members
151 @members = @project.members
151 @members = @project.members
152 end
152 end
153
153
154 # Add a new document to @project
154 # Add a new document to @project
155 def add_document
155 def add_document
156 @categories = Enumeration::get_values('DCAT')
156 @categories = Enumeration::get_values('DCAT')
157 @document = @project.documents.build(params[:document])
157 @document = @project.documents.build(params[:document])
158 if request.post?
158 if request.post?
159 # Save the attachment
159 # Save the attachment
160 if params[:attachment][:file].size > 0
160 if params[:attachment][:file].size > 0
161 @attachment = @document.attachments.build(params[:attachment])
161 @attachment = @document.attachments.build(params[:attachment])
162 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
162 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
163 end
163 end
164 if @document.save
164 if @document.save
165 flash[:notice] = l(:notice_successful_create)
165 flash[:notice] = l(:notice_successful_create)
166 redirect_to :action => 'list_documents', :id => @project
166 redirect_to :action => 'list_documents', :id => @project
167 end
167 end
168 end
168 end
169 end
169 end
170
170
171 # Show documents list of @project
171 # Show documents list of @project
172 def list_documents
172 def list_documents
173 @documents = @project.documents
173 @documents = @project.documents
174 end
174 end
175
175
176 # Add a new issue to @project
176 # Add a new issue to @project
177 def add_issue
177 def add_issue
178 @tracker = Tracker.find(params[:tracker_id])
178 @tracker = Tracker.find(params[:tracker_id])
179 @priorities = Enumeration::get_values('IPRI')
179 @priorities = Enumeration::get_values('IPRI')
180 @issue = Issue.new(:project => @project, :tracker => @tracker)
180 @issue = Issue.new(:project => @project, :tracker => @tracker)
181 if request.get?
181 if request.get?
182 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
182 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
183 else
183 else
184 @issue.attributes = params[:issue]
184 @issue.attributes = params[:issue]
185 @issue.author_id = self.logged_in_user.id if self.logged_in_user
185 @issue.author_id = self.logged_in_user.id if self.logged_in_user
186 # Create the document if a file was sent
186 # Create the document if a file was sent
187 if params[:attachment][:file].size > 0
187 if params[:attachment][:file].size > 0
188 @attachment = @issue.attachments.build(params[:attachment])
188 @attachment = @issue.attachments.build(params[:attachment])
189 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
189 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
190 end
190 end
191 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
191 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
192 @issue.custom_values = @custom_values
192 @issue.custom_values = @custom_values
193 if @issue.save
193 if @issue.save
194 flash[:notice] = l(:notice_successful_create)
194 flash[:notice] = l(:notice_successful_create)
195 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
195 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
196 redirect_to :action => 'list_issues', :id => @project
196 redirect_to :action => 'list_issues', :id => @project
197 end
197 end
198 end
198 end
199 end
199 end
200
200
201 # Show filtered/sorted issues list of @project
201 # Show filtered/sorted issues list of @project
202 def list_issues
202 def list_issues
203 sort_init 'issues.id', 'desc'
203 sort_init 'issues.id', 'desc'
204 sort_update
204 sort_update
205
205
206 search_filter_init_list_issues
206 search_filter_init_list_issues
207 search_filter_update if params[:set_filter] or request.post?
207 search_filter_update if params[:set_filter] or request.post?
208
208
209 @issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause)
209 @issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause)
210 @issue_pages = Paginator.new self, @issue_count, 15, @params['page']
210 @issue_pages = Paginator.new self, @issue_count, 15, @params['page']
211 @issues = Issue.find :all, :order => sort_clause,
211 @issues = Issue.find :all, :order => sort_clause,
212 :include => [ :author, :status, :tracker, :project ],
212 :include => [ :author, :status, :tracker, :project ],
213 :conditions => search_filter_clause,
213 :conditions => search_filter_clause,
214 :limit => @issue_pages.items_per_page,
214 :limit => @issue_pages.items_per_page,
215 :offset => @issue_pages.current.offset
215 :offset => @issue_pages.current.offset
216 end
216 end
217
217
218 # Export filtered/sorted issues list to CSV
218 # Export filtered/sorted issues list to CSV
219 def export_issues_csv
219 def export_issues_csv
220 sort_init 'issues.id', 'desc'
220 sort_init 'issues.id', 'desc'
221 sort_update
221 sort_update
222
222
223 search_filter_init_list_issues
223 search_filter_init_list_issues
224
224
225 @issues = Issue.find :all, :order => sort_clause,
225 @issues = Issue.find :all, :order => sort_clause,
226 :include => [ :author, :status, :tracker, :project ],
226 :include => [ :author, :status, :tracker, :project ],
227 :conditions => search_filter_clause
227 :conditions => search_filter_clause
228
228
229 export = StringIO.new
229 export = StringIO.new
230 CSV::Writer.generate(export, ',') do |csv|
230 CSV::Writer.generate(export, ',') do |csv|
231 csv << %w(Id Status Tracker Subject Author Created Updated)
231 csv << %w(Id Status Tracker Subject Author Created Updated)
232 @issues.each do |issue|
232 @issues.each do |issue|
233 csv << [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
233 csv << [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
234 end
234 end
235 end
235 end
236 export.rewind
236 export.rewind
237 send_data(export.read,
237 send_data(export.read,
238 :type => 'text/csv; charset=utf-8; header=present',
238 :type => 'text/csv; charset=utf-8; header=present',
239 :filename => 'export.csv')
239 :filename => 'export.csv')
240 end
240 end
241
241
242 # Add a news to @project
242 # Add a news to @project
243 def add_news
243 def add_news
244 @news = News.new(:project => @project)
244 @news = News.new(:project => @project)
245 if request.post?
245 if request.post?
246 @news.attributes = params[:news]
246 @news.attributes = params[:news]
247 @news.author_id = self.logged_in_user.id if self.logged_in_user
247 @news.author_id = self.logged_in_user.id if self.logged_in_user
248 if @news.save
248 if @news.save
249 flash[:notice] = l(:notice_successful_create)
249 flash[:notice] = l(:notice_successful_create)
250 redirect_to :action => 'list_news', :id => @project
250 redirect_to :action => 'list_news', :id => @project
251 end
251 end
252 end
252 end
253 end
253 end
254
254
255 # Show news list of @project
255 # Show news list of @project
256 def list_news
256 def list_news
257 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
257 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
258 end
258 end
259
259
260 def add_file
260 def add_file
261 if request.post?
261 if request.post?
262 # Save the attachment
262 # Save the attachment
263 if params[:attachment][:file].size > 0
263 if params[:attachment][:file].size > 0
264 @attachment = @project.versions.find(params[:version_id]).attachments.build(params[:attachment])
264 @attachment = @project.versions.find(params[:version_id]).attachments.build(params[:attachment])
265 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
265 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
266 if @attachment.save
266 if @attachment.save
267 flash[:notice] = l(:notice_successful_create)
267 flash[:notice] = l(:notice_successful_create)
268 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
268 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
269 end
269 end
270 end
270 end
271 end
271 end
272 @versions = @project.versions
272 @versions = @project.versions
273 end
273 end
274
274
275 def list_files
275 def list_files
276 @versions = @project.versions
276 @versions = @project.versions
277 end
277 end
278
278
279 # Show changelog for @project
279 # Show changelog for @project
280 def changelog
280 def changelog
281 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
281 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
282 if request.get?
282 if request.get?
283 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
283 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
284 else
284 else
285 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
285 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
286 end
286 end
287 @selected_tracker_ids ||= []
287 @selected_tracker_ids ||= []
288 @fixed_issues = @project.issues.find(:all,
288 @fixed_issues = @project.issues.find(:all,
289 :include => [ :fixed_version, :status, :tracker ],
289 :include => [ :fixed_version, :status, :tracker ],
290 :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
290 :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
291 :order => "versions.effective_date DESC, issues.id DESC"
291 :order => "versions.effective_date DESC, issues.id DESC"
292 ) unless @selected_tracker_ids.empty?
292 ) unless @selected_tracker_ids.empty?
293 @fixed_issues ||= []
293 @fixed_issues ||= []
294 end
294 end
295
295
296 private
296 private
297 # Find project of id params[:id]
297 # Find project of id params[:id]
298 # if not found, redirect to project list
298 # if not found, redirect to project list
299 # Used as a before_filter
299 # Used as a before_filter
300 def find_project
300 def find_project
301 @project = Project.find(params[:id])
301 @project = Project.find(params[:id])
302 rescue
302 rescue
303 redirect_to :action => 'list'
303 redirect_to :action => 'list'
304 end
304 end
305 end
305 end
@@ -1,97 +1,107
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module ApplicationHelper
18 module ApplicationHelper
19
19
20 # return current logged in user or nil
20 # Return current logged in user or nil
21 def loggedin?
21 def loggedin?
22 @logged_in_user
22 @logged_in_user
23 end
23 end
24
24
25 # return true if user is loggend in and is admin, otherwise false
25 # Return true if user is logged in and is admin, otherwise false
26 def admin_loggedin?
26 def admin_loggedin?
27 @logged_in_user and @logged_in_user.admin?
27 @logged_in_user and @logged_in_user.admin?
28 end
28 end
29
29
30 # Return true if user is authorized for controller/action, otherwise false
30 def authorize_for(controller, action)
31 def authorize_for(controller, action)
31 # check if action is allowed on public projects
32 # check if action is allowed on public projects
32 if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ controller, action ]
33 if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ controller, action ]
33 return true
34 return true
34 end
35 end
35 # check if user is authorized
36 # check if user is authorized
36 if @logged_in_user and (@logged_in_user.admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], @logged_in_user.role_for_project(@project.id) ) )
37 if @logged_in_user and (@logged_in_user.admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], @logged_in_user.role_for_project(@project.id) ) )
37 return true
38 return true
38 end
39 end
39 return false
40 return false
40 end
41 end
41
42
42 # Display a link if user is authorized
43 # Display a link if user is authorized
43 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
44 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
44 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action])
45 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action])
45 end
46 end
46
47
47 # Display a link to user's account page
48 # Display a link to user's account page
48 def link_to_user(user)
49 def link_to_user(user)
49 link_to user.display_name, :controller => 'account', :action => 'show', :id => user
50 link_to user.display_name, :controller => 'account', :action => 'show', :id => user
50 end
51 end
51
52
52 def format_date(date)
53 def format_date(date)
53 l_date(date) if date
54 l_date(date) if date
54 end
55 end
55
56
56 def format_time(time)
57 def format_time(time)
57 l_datetime(time) if time
58 l_datetime(time) if time
58 end
59 end
59
60
60 def pagination_links_full(paginator, options={}, html_options={})
61 def pagination_links_full(paginator, options={}, html_options={})
61 html =''
62 html =''
62 html << link_to(('&#171; ' + l(:label_previous) ), { :page => paginator.current.previous }) + ' ' if paginator.current.previous
63 html << link_to(('&#171; ' + l(:label_previous) ), { :page => paginator.current.previous }) + ' ' if paginator.current.previous
63 html << (pagination_links(paginator, options, html_options) || '')
64 html << (pagination_links(paginator, options, html_options) || '')
64 html << ' ' + link_to((l(:label_next) + ' &#187;'), { :page => paginator.current.next }) if paginator.current.next
65 html << ' ' + link_to((l(:label_next) + ' &#187;'), { :page => paginator.current.next }) if paginator.current.next
65 html
66 html
66 end
67 end
67
68
68 def error_messages_for(object_name, options = {})
69 def error_messages_for(object_name, options = {})
69 options = options.symbolize_keys
70 options = options.symbolize_keys
70 object = instance_variable_get("@#{object_name}")
71 object = instance_variable_get("@#{object_name}")
71 if object && !object.errors.empty?
72 if object && !object.errors.empty?
72 # build full_messages here with controller current language
73 # build full_messages here with controller current language
73 full_messages = []
74 full_messages = []
74 object.errors.each do |attr, msg|
75 object.errors.each do |attr, msg|
75 next if msg.nil?
76 next if msg.nil?
76 if attr == "base"
77 if attr == "base"
77 full_messages << l(msg)
78 full_messages << l(msg)
78 else
79 else
79 full_messages << "&#171; " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " &#187; " + l(msg)
80 full_messages << "&#171; " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " &#187; " + l(msg) unless attr == "custom_values"
80 end
81 end
81 end
82 end
83 # retrieve custom values error messages
84 if object.errors[:custom_values]
85 object.custom_values.each do |v|
86 v.errors.each do |attr, msg|
87 next if msg.nil?
88 full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(msg)
89 end
90 end
91 end
82 content_tag("div",
92 content_tag("div",
83 content_tag(
93 content_tag(
84 options[:header_tag] || "h2", lwr(:gui_validation_error, object.errors.count) + " :"
94 options[:header_tag] || "h2", lwr(:gui_validation_error, full_messages.length) + " :"
85 ) +
95 ) +
86 content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
96 content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
87 "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
97 "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
88 )
98 )
89 else
99 else
90 ""
100 ""
91 end
101 end
92 end
102 end
93
103
94 def lang_options_for_select
104 def lang_options_for_select
95 (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]}
105 (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]}
96 end
106 end
97 end
107 end
@@ -1,67 +1,70
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module CustomFieldsHelper
18 module CustomFieldsHelper
19
19
20 # Return custom field html tag corresponding to its format
20 def custom_field_tag(custom_value)
21 def custom_field_tag(custom_value)
21 custom_field = custom_value.custom_field
22 custom_field = custom_value.custom_field
22 field_name = "custom_fields[#{custom_field.id}]"
23 field_name = "custom_fields[#{custom_field.id}]"
23 field_id = "custom_fields_#{custom_field.id}"
24 field_id = "custom_fields_#{custom_field.id}"
24
25
25 case custom_field.field_format
26 case custom_field.field_format
26 when "string", "int", "date"
27 when "string", "int", "date"
27 text_field_tag field_name, custom_value.value, :id => field_id
28 text_field 'custom_value', 'value', :name => field_name, :id => field_id
28 when "text"
29 when "text"
29 text_area_tag field_name, custom_value.value, :id => field_id, :cols => 60, :rows => 3
30 text_area 'custom_value', 'value', :name => field_name, :id => field_id, :cols => 60, :rows => 3
30 when "bool"
31 when "bool"
31 check_box_tag(field_name, "1", custom_value.value == "1", :id => field_id) +
32 check_box 'custom_value', 'value', :name => field_name, :id => field_id
32 hidden_field_tag(field_name, "0")
33 when "list"
33 when "list"
34 select_tag field_name,
34 select 'custom_value', 'value', custom_field.possible_values.split('|'), { :include_blank => true }, :name => field_name, :id => field_id
35 "<option></option>" + options_for_select(custom_field.possible_values.split('|'),
36 custom_value.value), :id => field_id
37 end
35 end
38 end
36 end
39
37
38 # Return custom field label tag
40 def custom_field_label_tag(custom_value)
39 def custom_field_label_tag(custom_value)
41 content_tag "label", custom_value.custom_field.name +
40 content_tag "label", custom_value.custom_field.name +
42 (custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>" : ""),
41 (custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>" : ""),
43 :for => "custom_fields_#{custom_value.custom_field.id}"
42 :for => "custom_fields_#{custom_value.custom_field.id}"
44 end
43 end
45
44
45 # Return custom field tag with its label tag
46 def custom_field_tag_with_label(custom_value)
46 def custom_field_tag_with_label(custom_value)
47 case custom_value.custom_field.field_format
47 case custom_value.custom_field.field_format
48 when "bool"
48 when "bool"
49 # label is displayed inline after the checkbox
49 custom_field_tag(custom_value) + " " + custom_field_label_tag(custom_value)
50 custom_field_tag(custom_value) + " " + custom_field_label_tag(custom_value)
50 else
51 else
51 custom_field_label_tag(custom_value) + "<br />" + custom_field_tag(custom_value)
52 custom_field_label_tag(custom_value) + "<br />" + custom_field_tag(custom_value)
52 end
53 end
53 end
54 end
54
55
56 # Return a string used to display a custom value
55 def show_value(custom_value)
57 def show_value(custom_value)
56 case custom_value.custom_field.field_format
58 case custom_value.custom_field.field_format
57 when "bool"
59 when "bool"
58 l_YesNo(custom_value.value == "1")
60 l_YesNo(custom_value.value == "1")
59 else
61 else
60 custom_value.value
62 custom_value.value
61 end
63 end
62 end
64 end
63
65
66 # Return an array of custom field formats which can be used in select_tag
64 def custom_field_formats_for_select
67 def custom_field_formats_for_select
65 CustomField::FIELD_FORMATS.keys.collect { |k| [ l(CustomField::FIELD_FORMATS[k]), k ] }
68 CustomField::FIELD_FORMATS.keys.collect { |k| [ l(CustomField::FIELD_FORMATS[k]), k ] }
66 end
69 end
67 end
70 end
@@ -1,43 +1,38
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class CustomValue < ActiveRecord::Base
18 class CustomValue < ActiveRecord::Base
19 belongs_to :custom_field
19 belongs_to :custom_field
20 belongs_to :customized, :polymorphic => true
20 belongs_to :customized, :polymorphic => true
21
21
22 protected
22 protected
23 def validate
23 def validate
24 # errors are added to customized object unless it's nil
24 errors.add(:value, :activerecord_error_blank) and return if custom_field.is_required? and value.empty?
25 object = customized || self
25 errors.add(:value, :activerecord_error_invalid) unless custom_field.regexp.empty? or value =~ Regexp.new(custom_field.regexp)
26
26 errors.add(:value, :activerecord_error_too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length and value.length > 0
27 object.errors.add(custom_field.name, :activerecord_error_blank) if custom_field.is_required? and value.empty?
27 errors.add(:value, :activerecord_error_too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length
28 object.errors.add(custom_field.name, :activerecord_error_invalid) unless custom_field.regexp.empty? or value =~ Regexp.new(custom_field.regexp)
29
30 object.errors.add(custom_field.name, :activerecord_error_too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length and value.length > 0
31 object.errors.add(custom_field.name, :activerecord_error_too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length
32
33 case custom_field.field_format
28 case custom_field.field_format
34 when "int"
29 when "int"
35 object.errors.add(custom_field.name, :activerecord_error_not_a_number) unless value =~ /^[0-9]*$/
30 errors.add(:value, :activerecord_error_not_a_number) unless value =~ /^[0-9]*$/
36 when "date"
31 when "date"
37 object.errors.add(custom_field.name, :activerecord_error_invalid) unless value =~ /^(\d+)\/(\d+)\/(\d+)$/ or value.empty?
32 errors.add(:value, :activerecord_error_invalid) unless value =~ /^(\d+)\/(\d+)\/(\d+)$/ or value.empty?
38 when "list"
33 when "list"
39 object.errors.add(custom_field.name, :activerecord_error_inclusion) unless custom_field.possible_values.split('|').include? value or value.empty?
34 errors.add(:value, :activerecord_error_inclusion) unless custom_field.possible_values.split('|').include? value or value.empty?
40 end
35 end
41 end
36 end
42 end
37 end
43
38
@@ -1,38 +1,38
1 <h2><%=l(:label_register)%></h2>
1 <h2><%=l(:label_register)%></h2>
2
2
3 <%= start_form_tag %>
3 <%= start_form_tag %>
4 <%= error_messages_for 'user' %>
4 <%= error_messages_for 'user' %>
5
5
6 <div class="box">
6 <div class="box">
7 <!--[form:user]-->
7 <!--[form:user]-->
8 <p><label for="user_login"><%=l(:field_login)%></label> <span class="required">*</span><br/>
8 <p><label for="user_login"><%=l(:field_login)%></label> <span class="required">*</span><br/>
9 <%= text_field 'user', 'login', :size => 25 %></p>
9 <%= text_field 'user', 'login', :size => 25 %></p>
10
10
11 <p><label for="password"><%=l(:field_password)%></label> <span class="required">*</span><br/>
11 <p><label for="password"><%=l(:field_password)%></label> <span class="required">*</span><br/>
12 <%= password_field_tag 'password', nil, :size => 25 %></p>
12 <%= password_field_tag 'password', nil, :size => 25 %></p>
13
13
14 <p><label for="password_confirmation"><%=l(:field_password_confirmation)%></label> <span class="required">*</span><br/>
14 <p><label for="password_confirmation"><%=l(:field_password_confirmation)%></label> <span class="required">*</span><br/>
15 <%= password_field_tag 'password_confirmation', nil, :size => 25 %></p>
15 <%= password_field_tag 'password_confirmation', nil, :size => 25 %></p>
16
16
17 <p><label for="user_firstname"><%=l(:field_firstname)%></label> <span class="required">*</span><br/>
17 <p><label for="user_firstname"><%=l(:field_firstname)%></label> <span class="required">*</span><br/>
18 <%= text_field 'user', 'firstname' %></p>
18 <%= text_field 'user', 'firstname' %></p>
19
19
20 <p><label for="user_lastname"><%=l(:field_lastname)%></label> <span class="required">*</span><br/>
20 <p><label for="user_lastname"><%=l(:field_lastname)%></label> <span class="required">*</span><br/>
21 <%= text_field 'user', 'lastname' %></p>
21 <%= text_field 'user', 'lastname' %></p>
22
22
23 <p><label for="user_mail"><%=l(:field_mail)%></label> <span class="required">*</span><br/>
23 <p><label for="user_mail"><%=l(:field_mail)%></label> <span class="required">*</span><br/>
24 <%= text_field 'user', 'mail' %></p>
24 <%= text_field 'user', 'mail' %></p>
25
25
26 <p><label for="user_language"><%=l(:field_language)%></label><br/>
26 <p><label for="user_language"><%=l(:field_language)%></label><br/>
27 <%= select("user", "language", lang_options_for_select) %></p>
27 <%= select("user", "language", lang_options_for_select) %></p>
28
28
29 <% for custom_value in @custom_values %>
29 <% for @custom_value in @custom_values %>
30 <p><%= custom_field_tag_with_label custom_value %></p>
30 <p><%= custom_field_tag_with_label @custom_value %></p>
31 <% end %>
31 <% end %>
32
32
33 <p><%= check_box 'user', 'mail_notification' %> <label for="user_mail_notification"><%=l(:field_mail_notification)%></label></p>
33 <p><%= check_box 'user', 'mail_notification' %> <label for="user_mail_notification"><%=l(:field_mail_notification)%></label></p>
34 <!--[eoform:user]-->
34 <!--[eoform:user]-->
35 </div>
35 </div>
36
36
37 <%= submit_tag l(:button_submit) %>
37 <%= submit_tag l(:button_submit) %>
38 <%= end_form_tag %>
38 <%= end_form_tag %>
@@ -1,56 +1,56
1 <h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%= @issue.subject %></h2>
1 <h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%= @issue.subject %></h2>
2
2
3 <%= error_messages_for 'issue' %>
3 <%= error_messages_for 'issue' %>
4 <%= start_form_tag :action => 'edit', :id => @issue %>
4 <%= start_form_tag :action => 'edit', :id => @issue %>
5
5
6 <div class="box">
6 <div class="box">
7 <!--[form:issue]-->
7 <!--[form:issue]-->
8 <p><%=l(:field_status)%>: <b><%= @issue.status.name %></b></p>
8 <p><%=l(:field_status)%>: <b><%= @issue.status.name %></b></p>
9
9
10 <div style="float:left;margin-right:10px;">
10 <div style="float:left;margin-right:10px;">
11 <p><label for="issue_priority_id"><%=l(:field_priority)%> <span class="required">*</span></label><br/>
11 <p><label for="issue_priority_id"><%=l(:field_priority)%> <span class="required">*</span></label><br/>
12 <select name="issue[priority_id]">
12 <select name="issue[priority_id]">
13 <%= options_from_collection_for_select @priorities, "id", "name", @issue.priority_id %></p>
13 <%= options_from_collection_for_select @priorities, "id", "name", @issue.priority_id %></p>
14 </select></p>
14 </select></p>
15 </div>
15 </div>
16
16
17 <div style="float:left;margin-right:10px;">
17 <div style="float:left;margin-right:10px;">
18 <p><label for="issue_assigned_to_id"><%=l(:field_assigned_to)%></label><br/>
18 <p><label for="issue_assigned_to_id"><%=l(:field_assigned_to)%></label><br/>
19 <select name="issue[assigned_to_id]">
19 <select name="issue[assigned_to_id]">
20 <option value=""></option>
20 <option value=""></option>
21 <%= options_from_collection_for_select @issue.project.members, "user_id", "name", @issue.assigned_to_id %></p>
21 <%= options_from_collection_for_select @issue.project.members, "user_id", "name", @issue.assigned_to_id %></p>
22 </select></p>
22 </select></p>
23 </div>
23 </div>
24
24
25 <div>
25 <div>
26 <p><label for="issue_category_id"><%=l(:field_category)%></label><br/>
26 <p><label for="issue_category_id"><%=l(:field_category)%></label><br/>
27 <select name="issue[category_id]">
27 <select name="issue[category_id]">
28 <option value=""></option>
28 <option value=""></option>
29 <%= options_from_collection_for_select @project.issue_categories, "id", "name", @issue.category_id %></p>
29 <%= options_from_collection_for_select @project.issue_categories, "id", "name", @issue.category_id %></p>
30 </select></p>
30 </select></p>
31 </div>
31 </div>
32
32
33 <p><label for="issue_subject"><%=l(:field_subject)%></label><span class="required">*</span><br/>
33 <p><label for="issue_subject"><%=l(:field_subject)%></label><span class="required">*</span><br/>
34 <%= text_field 'issue', 'subject', :size => 60 %></p>
34 <%= text_field 'issue', 'subject', :size => 60 %></p>
35
35
36 <p><label for="issue_description"><%=l(:field_description)%></label><span class="required">*</span><br/>
36 <p><label for="issue_description"><%=l(:field_description)%></label><span class="required">*</span><br/>
37 <%= text_area 'issue', 'description', :cols => 60, :rows => 10 %></p>
37 <%= text_area 'issue', 'description', :cols => 60, :rows => 10 %></p>
38
38
39 <p><label for="issue_due_date"><%=l(:field_due_date)%></label><br />
39 <p><label for="issue_due_date"><%=l(:field_due_date)%></label><br />
40 <%= date_select 'issue', 'due_date', :start_year => Date.today.year, :include_blank => true %></p>
40 <%= date_select 'issue', 'due_date', :start_year => Date.today.year, :include_blank => true %></p>
41
41
42 <% for custom_value in @custom_values %>
42 <% for @custom_value in @custom_values %>
43 <p><%= custom_field_tag_with_label custom_value %></p>
43 <p><%= custom_field_tag_with_label @custom_value %></p>
44 <% end %>
44 <% end %>
45
45
46 <p><label for="issue_fixed_version"><%=l(:field_fixed_version)%></label><br/>
46 <p><label for="issue_fixed_version"><%=l(:field_fixed_version)%></label><br/>
47 <select name="issue[fixed_version_id]">
47 <select name="issue[fixed_version_id]">
48 <option value="">--none--</option>
48 <option value="">--none--</option>
49 <%= options_from_collection_for_select @project.versions, "id", "name", @issue.fixed_version_id %>
49 <%= options_from_collection_for_select @project.versions, "id", "name", @issue.fixed_version_id %>
50 </select></p>
50 </select></p>
51
51
52 <!--[eoform:issue]-->
52 <!--[eoform:issue]-->
53 </div>
53 </div>
54
54
55 <%= submit_tag l(:button_save) %>
55 <%= submit_tag l(:button_save) %>
56 <%= end_form_tag %>
56 <%= end_form_tag %>
@@ -1,41 +1,41
1 <%= error_messages_for 'project' %>
1 <%= error_messages_for 'project' %>
2
2
3 <div class="box">
3 <div class="box">
4 <!--[form:project]-->
4 <!--[form:project]-->
5 <p><label for="project_name"><%=l(:field_name)%> <span class="required">*</span></label><br/>
5 <p><label for="project_name"><%=l(:field_name)%> <span class="required">*</span></label><br/>
6 <%= text_field 'project', 'name' %></p>
6 <%= text_field 'project', 'name' %></p>
7
7
8 <% if admin_loggedin? %>
8 <% if admin_loggedin? %>
9 <p><label for="project_parent_id"><%=l(:field_parent)%></label><br/>
9 <p><label for="project_parent_id"><%=l(:field_parent)%></label><br/>
10 <select name="project[parent_id]">
10 <select name="project[parent_id]">
11 <option value=""></option>
11 <option value=""></option>
12 <%= options_from_collection_for_select @root_projects, "id", "name", @project.parent_id %>
12 <%= options_from_collection_for_select @root_projects, "id", "name", @project.parent_id %>
13 </select></p>
13 </select></p>
14 <% end %>
14 <% end %>
15
15
16 <p><label for="project_description"><%=l(:field_description)%> <span class="required">*</span></label><br/>
16 <p><label for="project_description"><%=l(:field_description)%> <span class="required">*</span></label><br/>
17 <%= text_area 'project', 'description', :cols => 60, :rows => 3 %></p>
17 <%= text_area 'project', 'description', :cols => 60, :rows => 3 %></p>
18
18
19 <p><label for="project_homepage"><%=l(:field_homepage)%></label><br/>
19 <p><label for="project_homepage"><%=l(:field_homepage)%></label><br/>
20 <%= text_field 'project', 'homepage', :size => 40 %></p>
20 <%= text_field 'project', 'homepage', :size => 40 %></p>
21
21
22 <p><%= check_box 'project', 'is_public' %>
22 <p><%= check_box 'project', 'is_public' %>
23 <label for="project_is_public"><%=l(:field_is_public)%></label></p>
23 <label for="project_is_public"><%=l(:field_is_public)%></label></p>
24
24
25 <% for custom_value in @custom_values %>
25 <% for @custom_value in @custom_values %>
26 <p><%= custom_field_tag_with_label custom_value %></p>
26 <p><%= custom_field_tag_with_label @custom_value %></p>
27 <% end %>
27 <% end %>
28
28
29 <fieldset><legend><%=l(:label_custom_field_plural)%></legend>
29 <fieldset><legend><%=l(:label_custom_field_plural)%></legend>
30 <% for custom_field in @custom_fields %>
30 <% for custom_field in @custom_fields %>
31 <input type="checkbox"
31 <input type="checkbox"
32
32
33 name="custom_field_ids[]"
33 name="custom_field_ids[]"
34 value="<%= custom_field.id %>"
34 value="<%= custom_field.id %>"
35 <%if @project.custom_fields.include? custom_field%>checked="checked"<%end%>
35 <%if @project.custom_fields.include? custom_field%>checked="checked"<%end%>
36 > <%= custom_field.name %>
36 > <%= custom_field.name %>
37
37
38 <% end %></fieldset>
38 <% end %></fieldset>
39
39
40 </div>
40 </div>
41 <!--[eoform:project]-->
41 <!--[eoform:project]-->
@@ -1,52 +1,52
1 <h2><%=l(:label_issue_new)%>: <%= @tracker.name %></h2>
1 <h2><%=l(:label_issue_new)%>: <%= @tracker.name %></h2>
2
2
3 <%= start_form_tag( { :action => 'add_issue', :id => @project }, :multipart => true) %>
3 <%= start_form_tag( { :action => 'add_issue', :id => @project }, :multipart => true) %>
4 <%= error_messages_for 'issue' %>
4 <%= error_messages_for 'issue' %>
5
5
6 <div class="box">
6 <div class="box">
7 <!--[form:issue]-->
7 <!--[form:issue]-->
8
8
9 <%= hidden_field_tag 'tracker_id', @tracker.id %>
9 <%= hidden_field_tag 'tracker_id', @tracker.id %>
10
10
11 <div style="float:left;margin-right:10px;">
11 <div style="float:left;margin-right:10px;">
12 <p><label for="issue_priority_id"><%=l(:field_priority)%> <span class="required">*</span></label><br />
12 <p><label for="issue_priority_id"><%=l(:field_priority)%> <span class="required">*</span></label><br />
13 <select name="issue[priority_id]">
13 <select name="issue[priority_id]">
14 <%= options_from_collection_for_select @priorities, "id", "name", @issue.priority_id %></p>
14 <%= options_from_collection_for_select @priorities, "id", "name", @issue.priority_id %></p>
15 </select></p>
15 </select></p>
16 </div>
16 </div>
17
17
18 <div style="float:left;margin-right:10px;">
18 <div style="float:left;margin-right:10px;">
19 <p><label for="issue_assigned_to_id"><%=l(:field_assigned_to)%></label><br />
19 <p><label for="issue_assigned_to_id"><%=l(:field_assigned_to)%></label><br />
20 <select name="issue[assigned_to_id]">
20 <select name="issue[assigned_to_id]">
21 <option value=""></option>
21 <option value=""></option>
22 <%= options_from_collection_for_select @issue.project.members, "user_id", "name", @issue.assigned_to_id %></p>
22 <%= options_from_collection_for_select @issue.project.members, "user_id", "name", @issue.assigned_to_id %></p>
23 </select></p>
23 </select></p>
24 </div>
24 </div>
25
25
26 <div>
26 <div>
27 <p><label for="issue_category_id"><%=l(:field_category)%></label><br />
27 <p><label for="issue_category_id"><%=l(:field_category)%></label><br />
28 <select name="issue[category_id]">
28 <select name="issue[category_id]">
29 <option value=""></option><%= options_from_collection_for_select @project.issue_categories, "id", "name", @issue.category_id %>
29 <option value=""></option><%= options_from_collection_for_select @project.issue_categories, "id", "name", @issue.category_id %>
30 </select></p>
30 </select></p>
31 </div>
31 </div>
32
32
33 <p><label for="issue_subject"><%=l(:field_subject)%> <span class="required">*</span></label><br />
33 <p><label for="issue_subject"><%=l(:field_subject)%> <span class="required">*</span></label><br />
34 <%= text_field 'issue', 'subject', :size => 80 %></p>
34 <%= text_field 'issue', 'subject', :size => 80 %></p>
35
35
36 <p><label for="issue_description"><%=l(:field_description)%> <span class="required">*</span></label><br />
36 <p><label for="issue_description"><%=l(:field_description)%> <span class="required">*</span></label><br />
37 <%= text_area 'issue', 'description', :cols => 60, :rows => 10 %></p>
37 <%= text_area 'issue', 'description', :cols => 60, :rows => 10 %></p>
38
38
39 <p><label for="issue_due_date"><%=l(:field_due_date)%></label><br />
39 <p><label for="issue_due_date"><%=l(:field_due_date)%></label><br />
40 <%= date_select 'issue', 'due_date', :start_year => Date.today.year, :include_blank => true %></p>
40 <%= date_select 'issue', 'due_date', :start_year => Date.today.year, :include_blank => true %></p>
41
41
42 <% for custom_value in @custom_values %>
42 <% for @custom_value in @custom_values %>
43 <p><%= custom_field_tag_with_label custom_value %></p>
43 <p><%= custom_field_tag_with_label @custom_value %></p>
44 <% end %>
44 <% end %>
45
45
46 <p><label for="attachment_file"><%=l(:label_attachment)%></label><br />
46 <p><label for="attachment_file"><%=l(:label_attachment)%></label><br />
47 <%= file_field 'attachment', 'file' %></p>
47 <%= file_field 'attachment', 'file' %></p>
48 <!--[eoform:issue]-->
48 <!--[eoform:issue]-->
49 </div>
49 </div>
50
50
51 <%= submit_tag l(:button_create) %>
51 <%= submit_tag l(:button_create) %>
52 <%= end_form_tag %> No newline at end of file
52 <%= end_form_tag %>
@@ -1,37 +1,37
1 <%= error_messages_for 'user' %>
1 <%= error_messages_for 'user' %>
2
2
3 <div class="box">
3 <div class="box">
4 <!--[form:user]-->
4 <!--[form:user]-->
5 <p><label for="user_login"><%=l(:field_login)%></label> <span class="required">*</span><br/>
5 <p><label for="user_login"><%=l(:field_login)%></label> <span class="required">*</span><br/>
6 <%= text_field 'user', 'login', :size => 25 %></p>
6 <%= text_field 'user', 'login', :size => 25 %></p>
7
7
8 <p><label for="password"><%=l(:field_password)%></label> <span class="required">*</span><br/>
8 <p><label for="password"><%=l(:field_password)%></label> <span class="required">*</span><br/>
9 <%= password_field_tag 'password', nil, :size => 25 %></p>
9 <%= password_field_tag 'password', nil, :size => 25 %></p>
10
10
11 <p><label for="password_confirmation"><%=l(:field_password_confirmation)%></label> <span class="required">*</span><br/>
11 <p><label for="password_confirmation"><%=l(:field_password_confirmation)%></label> <span class="required">*</span><br/>
12 <%= password_field_tag 'password_confirmation', nil, :size => 25 %></p>
12 <%= password_field_tag 'password_confirmation', nil, :size => 25 %></p>
13
13
14 <p><label for="user_firstname"><%=l(:field_firstname)%></label> <span class="required">*</span><br/>
14 <p><label for="user_firstname"><%=l(:field_firstname)%></label> <span class="required">*</span><br/>
15 <%= text_field 'user', 'firstname' %></p>
15 <%= text_field 'user', 'firstname' %></p>
16
16
17 <p><label for="user_lastname"><%=l(:field_lastname)%></label> <span class="required">*</span><br/>
17 <p><label for="user_lastname"><%=l(:field_lastname)%></label> <span class="required">*</span><br/>
18 <%= text_field 'user', 'lastname' %></p>
18 <%= text_field 'user', 'lastname' %></p>
19
19
20 <p><label for="user_mail"><%=l(:field_mail)%></label> <span class="required">*</span><br/>
20 <p><label for="user_mail"><%=l(:field_mail)%></label> <span class="required">*</span><br/>
21 <%= text_field 'user', 'mail' %></p>
21 <%= text_field 'user', 'mail' %></p>
22
22
23 <p><label for="user_language"><%=l(:field_language)%></label><br/>
23 <p><label for="user_language"><%=l(:field_language)%></label><br/>
24 <%= select("user", "language", lang_options_for_select) %></p>
24 <%= select("user", "language", lang_options_for_select) %></p>
25
25
26 <% for custom_value in @custom_values %>
26 <% for @custom_value in @custom_values %>
27 <p><%= custom_field_tag_with_label custom_value %></p>
27 <p><%= custom_field_tag_with_label @custom_value %></p>
28 <% end %>
28 <% end %>
29
29
30 <div style="clear: both;"></div>
30 <div style="clear: both;"></div>
31
31
32 <p><%= check_box 'user', 'admin' %> <label for="user_admin"><%=l(:field_admin)%></label></p>
32 <p><%= check_box 'user', 'admin' %> <label for="user_admin"><%=l(:field_admin)%></label></p>
33
33
34 <p><%= check_box 'user', 'mail_notification' %> <label for="user_mail_notification"><%=l(:field_mail_notification)%></label></p>
34 <p><%= check_box 'user', 'mail_notification' %> <label for="user_mail_notification"><%=l(:field_mail_notification)%></label></p>
35
35
36 <!--[eoform:user]-->
36 <!--[eoform:user]-->
37 </div>
37 </div>
General Comments 0
You need to be logged in to leave comments. Login now