##// END OF EJS Templates
Merged r1379 to r1385 from trunk....
Jean-Philippe Lang -
r1372:914d1e6645fd
parent child
Show More
This diff has been collapsed as it changes many lines, (623 lines changed) Show them Hide them
@@ -0,0 +1,623
1 _gloc_rule_default: '|n| n==1 ? "" : "_plural" '
2
3 actionview_datehelper_select_day_prefix:
4 actionview_datehelper_select_month_names: มกราคม,กุมภาพันธ์,มีนาคม,เมษายน,พฤษภาคม,มิถุนายน,กรกฎาคม,สิงหาคม,กันยายน,ตุลาคม,พฤศจิกายน,ธันวาคม
5 actionview_datehelper_select_month_names_abbr: ม.ค.,ก.พ.,มี.ค.,เม.ย.,พ.ค.,มิ.ย.,ก.ค.,ส.ค.,ก.ย.,ต.ค.,พ.ย.,ธ.ค.
6 actionview_datehelper_select_month_prefix:
7 actionview_datehelper_select_year_prefix:
8 actionview_datehelper_time_in_words_day: 1 วัน
9 actionview_datehelper_time_in_words_day_plural: %d วัน
10 actionview_datehelper_time_in_words_hour_about: ประมาณ 1 ชั่วโมง
11 actionview_datehelper_time_in_words_hour_about_plural: ประมาณ %d ชั่วโมง
12 actionview_datehelper_time_in_words_hour_about_single: ประมาณ 1 ชั่วโมง
13 actionview_datehelper_time_in_words_minute: 1 นาที
14 actionview_datehelper_time_in_words_minute_half: ครึ่งนาที
15 actionview_datehelper_time_in_words_minute_less_than: ไม่ถึงนาที
16 actionview_datehelper_time_in_words_minute_plural: %d นาที
17 actionview_datehelper_time_in_words_minute_single: 1 นาที
18 actionview_datehelper_time_in_words_second_less_than: ไม่ถึงวินาที
19 actionview_datehelper_time_in_words_second_less_than_plural: ไม่ถึง %d วินาที
20 actionview_instancetag_blank_option: กรุณาเลือก
21
22 activerecord_error_inclusion: ไม่อยู่ในรายการ
23 activerecord_error_exclusion: ถูกสงวนไว้
24 activerecord_error_invalid: ไม่ถูกต้อง
25 activerecord_error_confirmation: พิมพ์ไม่เหมือนเดิม
26 activerecord_error_accepted: ต้องยอมรับ
27 activerecord_error_empty: ต้องเติม
28 activerecord_error_blank: ต้องเติม
29 activerecord_error_too_long: ยาวเกินไป
30 activerecord_error_too_short: สั้นเกินไป
31 activerecord_error_wrong_length: ความยาวไม่ถูกต้อง
32 activerecord_error_taken: ถูกใช้ไปแล้ว
33 activerecord_error_not_a_number: ไม่ใช่ตัวเลข
34 activerecord_error_not_a_date: ไม่ใช่วันที่ ที่ถูกต้อง
35 activerecord_error_greater_than_start_date: ต้องมากกว่าวันเริ่ม
36 activerecord_error_not_same_project: ไม่ได้อยู่ในโครงการเดียวกัน
37 activerecord_error_circular_dependency: ความสัมพันธ์อ้างอิงเป็นวงกลม
38
39 general_fmt_age: %d ปี
40 general_fmt_age_plural: %d ปี
41 general_fmt_date: %%d/%%B/%%Y
42 general_fmt_datetime: %%d/%%B/%%Y %%H:%%M
43 general_fmt_datetime_short: %%d %%b, %%H:%%M
44 general_fmt_time: %%H:%%M
45 general_text_No: 'ไม่'
46 general_text_Yes: 'ใช่'
47 general_text_no: 'ไม่'
48 general_text_yes: 'ใช่'
49 general_lang_name: 'Thai (ไทย)'
50 general_csv_separator: ','
51 general_csv_encoding: Windows-874
52 general_pdf_encoding: cp874
53 general_day_names: จันทร์,อังคาร,พุธ,พฤหัสบดี,ศุกร์,เสาร์,อาทิตย์
54 general_first_day_of_week: '1'
55
56 notice_account_updated: บัญชีได้ถูกปรับปรุงแล้ว.
57 notice_account_invalid_creditentials: ชื้ผู้ใช้หรือรหัสผ่านไม่ถูกต้อง
58 notice_account_password_updated: รหัสได้ถูกปรับปรุงแล้ว.
59 notice_account_wrong_password: รหัสผ่านไม่ถูกต้อง
60 notice_account_register_done: บัญชีถูกสร้างแล้ว. กรุณาเช็คเมล์ แล้วคลิ๊กที่ลิงค์ในอีเมล์เพื่อเปิดใช้บัญชี
61 notice_account_unknown_email: ไม่มีผู้ใช้ที่ใช้อีเมล์นี้.
62 notice_can_t_change_password: บัญชีนี้ใช้การยืนยันตัวตนจากแหล่งภายนอก. ไม่สามารถปลี่ยนรหัสผ่านได้.
63 notice_account_lost_email_sent: เราได้ส่งอีเมล์พร้อมวิธีการสร้างรหัีสผ่านใหม่ให้คุณแล้ว กรุณาเช็คเมล์.
64 notice_account_activated: บัญชีของคุณได้เปิดใช้แล้ว. ตอนนี้คุณสามารถเข้าสู่ระบบได้แล้ว.
65 notice_successful_create: สร้างเสร็จแล้ว.
66 notice_successful_update: ปรับปรุงเสร็จแล้ว.
67 notice_successful_delete: ลบเสร็จแล้ว.
68 notice_successful_connection: ติดต่อสำเร็จแล้ว.
69 notice_file_not_found: หน้าที่คุณต้องการดูไม่มีอยู่จริง หรือถูกลบไปแล้ว.
70 notice_locking_conflict: ข้อมูลถูกปรับปรุงโดยผู้ใช้คนอื่น.
71 notice_not_authorized: คุณไม่มีสิทธิเข้าถึงหน้านี้.
72 notice_email_sent: อีเมล์ได้ถูกส่งถึง %s
73 notice_email_error: เกิดความผิดพลาดขณะกำส่งอีเมล์ (%s)
74 notice_feeds_access_key_reseted: RSS access key ของคุณถูก reset แล้ว.
75 notice_failed_to_save_issues: "%d ปัญหาจาก %d ปัญหาที่ถูกเลือกไม่สามารถจัดเก็บ: %s."
76 notice_no_issue_selected: "ไม่มีปัญหาที่ถูกเลือก! กรุณาเลือกปัญหาที่คุณต้องการแก้ไข."
77 notice_account_pending: "บัญชีของคุณสร้างเสร็จแล้ว ขณะนี้รอการอนุมัติจากผู้บริหารจัดการ."
78 notice_default_data_loaded: ค่าเริ่มต้นโหลดเสร็จแล้ว.
79
80 error_can_t_load_default_data: "ค่าเริ่มต้นโหลดไม่สำเร็จ: %s"
81 error_scm_not_found: "ไม่พบรุ่นที่ต้องการในแหล่งเก็บต้นฉบับ."
82 error_scm_command_failed: "เกิดความผิดพลาดในการเข้าถึงแหล่งเก็บต้นฉบับ: %s"
83 error_scm_annotate: "entry ไม่มีอยู่จริง หรือไม่สามารถเขียนหมายเหตุประกอบ."
84 error_issue_not_found_in_project: 'ไม่พบปัญหานี้ หรือปัญหาไม่ได้อยู่ในโครงการนี้'
85
86 mail_subject_lost_password: รหัสผ่าน %s ของคุณ
87 mail_body_lost_password: 'คลิ๊กที่ลิงค์ต่อไปนี้เพื่อเปลี่ยนรหัสผ่าน:'
88 mail_subject_register: เปิดบัญชี %s ของคุณ
89 mail_body_register: 'คลิ๊กที่ลิงค์ต่อไปนี้เพื่อเปลี่ยนรหัสผ่าน:'
90 mail_body_account_information_external: คุณสามารถใช้บัญชี "%s" เพื่อเข้าสู่ระบบ.
91 mail_body_account_information: ข้อมูลบัญชีของคุณ
92 mail_subject_account_activation_request: กรุณาเปิดบัญชี %s
93 mail_body_account_activation_request: 'ผู้ใช้ใหม่ (%s) ได้ลงทะเบียน. บัญชีของเขากำลังรออนุมัติ:'
94
95 gui_validation_error: 1 ข้อผิดพลาด
96 gui_validation_error_plural: %d ข้อผิดพลาด
97
98 field_name: ชื่อ
99 field_description: รายละเอียด
100 field_summary: สรุปย่อ
101 field_is_required: ต้องใส่
102 field_firstname: ชื่อ
103 field_lastname: นามสกุล
104 field_mail: อีเมล์
105 field_filename: แฟ้ม
106 field_filesize: ขนาด
107 field_downloads: ดาวน์โหลด
108 field_author: ผู้แต่ง
109 field_created_on: สร้าง
110 field_updated_on: ปรับปรุง
111 field_field_format: รูปแบบ
112 field_is_for_all: สำหรับทุกโครงการ
113 field_possible_values: ค่าที่เป็นไปได้
114 field_regexp: Regular expression
115 field_min_length: สั้นสุด
116 field_max_length: ยาวสุด
117 field_value: ค่า
118 field_category: ประเภท
119 field_title: ชื่อเรื่อง
120 field_project: โครงการ
121 field_issue: ปัญหา
122 field_status: สถานะ
123 field_notes: บันทึก
124 field_is_closed: ปัญหาจบ
125 field_is_default: ค่าเริ่มต้น
126 field_tracker: การติดตาม
127 field_subject: เรื่อง
128 field_due_date: วันครบกำหนด
129 field_assigned_to: มอบหมายให้
130 field_priority: ความสำคัญ
131 field_fixed_version: รุ่น
132 field_user: ผู้ใช้
133 field_role: บทบาท
134 field_homepage: หน้าแรก
135 field_is_public: สาธารณะ
136 field_parent: โครงการย่อยของ
137 field_is_in_chlog: ปัญหาแสดงใน รายกาเปลี่ยนแปลง
138 field_is_in_roadmap: ปัญหาแสดงใน แผนงาน
139 field_login: ชื่อที่ใช้เข้าระบบ
140 field_mail_notification: การแจ้งเตือนทางอีเมล์
141 field_admin: ผู้บริหารจัดการ
142 field_last_login_on: เข้าระบบครั้งสุดท้าย
143 field_language: ภาษา
144 field_effective_date: วันที่
145 field_password: รหัสผ่าน
146 field_new_password: รหัสผ่านใหม่
147 field_password_confirmation: ยืนยันรหัสผ่าน
148 field_version: รุ่น
149 field_type: ชนิด
150 field_host: โฮสต์
151 field_port: พอร์ต
152 field_account: บัญชี
153 field_base_dn: Base DN
154 field_attr_login: เข้าระบบ attribute
155 field_attr_firstname: ชื่อ attribute
156 field_attr_lastname: นามสกุล attribute
157 field_attr_mail: อีเมล์ attribute
158 field_onthefly: สร้างผู้ใช้ทันที
159 field_start_date: เริ่ม
160 field_done_ratio: %% สำเร็จ
161 field_auth_source: วิธีการยืนยันตัวตน
162 field_hide_mail: ซ่อนอีเมล์ของฉัน
163 field_comments: ความเห็น
164 field_url: URL
165 field_start_page: หน้าเริ่มต้น
166 field_subproject: โครงการย่อย
167 field_hours: ชั่วโมง
168 field_activity: กิจกรรม
169 field_spent_on: วันที่
170 field_identifier: ชื่อเฉพาะ
171 field_is_filter: ใช้เป็นตัวกรอง
172 field_issue_to_id: ปัญหาที่เกี่ยวข้อง
173 field_delay: เลื่อน
174 field_assignable: ปัญหาสามารถมอบหมายให้คนที่ทำบทบาทนี้
175 field_redirect_existing_links: ย้ายจุดเชื่อมโยงนี้
176 field_estimated_hours: เวลาที่ใช้โดยประมาณ
177 field_column_names: สดมภ์
178 field_time_zone: ย่านเวลา
179 field_searchable: ค้นหาได้
180 field_default_value: ค่าเริ่มต้น
181 field_comments_sorting: แสดงความเห็น
182
183 setting_app_title: ชื่อโปรแกรม
184 setting_app_subtitle: ชื่อโปรแกรมรอง
185 setting_welcome_text: ข้อความต้อนรับ
186 setting_default_language: ภาษาเริ่มต้น
187 setting_login_required: ต้องป้อนผู้ใช้-รหัสผ่าน
188 setting_self_registration: ลงทะเบียนด้วยตนเอง
189 setting_attachment_max_size: ขนาดแฟ้มแนบสูงสุด
190 setting_issues_export_limit: การส่งออกปัญหาสูงสุด
191 setting_mail_from: อีเมล์ที่ใช้ส่ง
192 setting_bcc_recipients: ไม่ระบุชื่อผู้รับ (bcc)
193 setting_host_name: ชื่อโฮสต์
194 setting_text_formatting: การจัดรูปแบบข้อความ
195 setting_wiki_compression: บีบอัดประวัติ Wiki
196 setting_feeds_limit: จำนวน Feed
197 setting_default_projects_public: โครงการใหม่มีค่าเริ่มต้นเป็น สาธารณะ
198 setting_autofetch_changesets: ดึง commits อัตโนมัติ
199 setting_sys_api_enabled: เปิดใช้ WS สำหรับการจัดการที่เก็บต้นฉบับ
200 setting_commit_ref_keywords: คำสำคัญ Referencing
201 setting_commit_fix_keywords: คำสำคัญ Fixing
202 setting_autologin: เข้าระบบอัตโนมัติ
203 setting_date_format: รูปแบบวันที่
204 setting_time_format: รูปแบบเวลา
205 setting_cross_project_issue_relations: อนุญาตให้ระบุปัญหาข้ามโครงการ
206 setting_issue_list_default_columns: สดมภ์เริ่มต้นแสดงในรายการปัญหา
207 setting_repositories_encodings: การเข้ารหัสที่เก็บต้นฉบับ
208 setting_emails_footer: คำลงท้ายอีเมล์
209 setting_protocol: Protocol
210 setting_per_page_options: ตัวเลือกจำนวนต่อหน้า
211 setting_user_format: รูปแบบการแสดงชื่อผู้ใช้
212 setting_activity_days_default: จำนวนวันที่แสดงในกิจกรรมของโครงการ
213 setting_display_subprojects_issues: แสดงปัญหาของโครงการย่อยในโครงการหลัก
214
215 project_module_issue_tracking: การติดตามปัญหา
216 project_module_time_tracking: การใช้เวลา
217 project_module_news: ข่าว
218 project_module_documents: เอกสาร
219 project_module_files: แฟ้ม
220 project_module_wiki: Wiki
221 project_module_repository: ที่เก็บต้นฉบับ
222 project_module_boards: กระดานข้อความ
223
224 label_user: ผู้ใช้
225 label_user_plural: ผู้ใช้
226 label_user_new: ผู้ใช้ใหม่
227 label_project: โครงการ
228 label_project_new: โครงการใหม่
229 label_project_plural: โครงการ
230 label_project_all: โครงการทั้งหมด
231 label_project_latest: โครงการล่าสุด
232 label_issue: ปัญหา
233 label_issue_new: ปัญหาใหม่
234 label_issue_plural: ปัญหา
235 label_issue_view_all: ดูปัญหาทั้งหมด
236 label_issues_by: ปัญหาโดย %s
237 label_issue_added: ปัญหาถูกเพิ่ม
238 label_issue_updated: ปัญหาถูกปรับปรุง
239 label_document: เอกสาร
240 label_document_new: เอกสารใหม่
241 label_document_plural: เอกสาร
242 label_document_added: เอกสารถูกเพิ่ม
243 label_role: บทบาท
244 label_role_plural: บทบาท
245 label_role_new: บทบาทใหม่
246 label_role_and_permissions: บทบาทและสิทธิ
247 label_member: สมาชิก
248 label_member_new: สมาชิกใหม่
249 label_member_plural: สมาชิก
250 label_tracker: การติดตาม
251 label_tracker_plural: การติดตาม
252 label_tracker_new: การติดตามใหม่
253 label_workflow: ลำดับงาน
254 label_issue_status: สถานะของปัญหา
255 label_issue_status_plural: สถานะของปัญหา
256 label_issue_status_new: สถานะใหม
257 label_issue_category: ประเภทของปัญหา
258 label_issue_category_plural: ประเภทของปัญหา
259 label_issue_category_new: ประเภทใหม่
260 label_custom_field: เขตข้อมูลแบบระบุเอง
261 label_custom_field_plural: เขตข้อมูลแบบระบุเอง
262 label_custom_field_new: สร้างเขตข้อมูลแบบระบุเอง
263 label_enumerations: รายการ
264 label_enumeration_new: สร้างใหม่
265 label_information: ข้อมูล
266 label_information_plural: ข้อมูล
267 label_please_login: กรุณาเข้าระบบก่อน
268 label_register: ลงทะเบียน
269 label_password_lost: ลืมรหัสผ่าน
270 label_home: หน้าแรก
271 label_my_page: หน้าของฉัน
272 label_my_account: บัญชีของฉัน
273 label_my_projects: โครงการของฉัน
274 label_administration: บริหารจัดการ
275 label_login: เข้าระบบ
276 label_logout: ออกระบบ
277 label_help: ช่วยเหลือ
278 label_reported_issues: ปัญหาที่แจ้งไว้
279 label_assigned_to_me_issues: ปัญหาที่มอบหมายให้ฉัน
280 label_last_login: ติดต่อครั้งสุดท้าย
281 label_last_updates: ปรับปรุงครั้งสุดท้าย
282 label_last_updates_plural: %d ปรับปรุงครั้งสุดท้าย
283 label_registered_on: ลงทะเบียนเมื่อ
284 label_activity: กิจกรรม
285 label_activity_plural: กิจกรรม
286 label_activity_latest: กิจกรรมล่าสุด
287 label_overall_activity: กิจกรรมโดยรวม
288 label_new: ใหม่
289 label_logged_as: เข้าระบบในชื่อ
290 label_environment: สภาพแวดล้อม
291 label_authentication: การยืนยันตัวตน
292 label_auth_source: วิธีการการยืนยันตัวตน
293 label_auth_source_new: สร้างวิธีการยืนยันตัวตนใหม่
294 label_auth_source_plural: วิธีการ Authentication
295 label_subproject_plural: โครงการย่อย
296 label_min_max_length: สั้น-ยาว สุดที่
297 label_list: รายการ
298 label_date: วันที่
299 label_integer: จำนวนเต็ม
300 label_float: จำนวนจริง
301 label_boolean: ถูกผิด
302 label_string: ข้อความ
303 label_text: ข้อความขนาดยาว
304 label_attribute: คุณลักษณะ
305 label_attribute_plural: คุณลักษณะ
306 label_download: %d ดาวน์โหลด
307 label_download_plural: %d ดาวน์โหลด
308 label_no_data: จำนวนข้อมูลที่แสดง
309 label_change_status: เปลี่ยนสถานะ
310 label_history: ประวัติ
311 label_attachment: แฟ้ม
312 label_attachment_new: แฟ้มใหม่
313 label_attachment_delete: ลบแฟ้ม
314 label_attachment_plural: แฟ้ม
315 label_file_added: แฟ้มถูกเพิ่ม
316 label_report: รายงาน
317 label_report_plural: รายงาน
318 label_news: ข่าว
319 label_news_new: เพิ่มข่าว
320 label_news_plural: ข่าว
321 label_news_latest: ข่าวล่าสุด
322 label_news_view_all: ดูข่าวทั้งหมด
323 label_news_added: ข่าวถูกเพิ่ม
324 label_change_log: บันทึกการเปลี่ยนแปลง
325 label_settings: ปรับแต่ง
326 label_overview: ภาพรวม
327 label_version: รุ่น
328 label_version_new: รุ่นใหม่
329 label_version_plural: รุ่น
330 label_confirmation: ยืนยัน
331 label_export_to: 'รูปแบบอื่นๆ :'
332 label_read: อ่าน...
333 label_public_projects: โครงการสาธารณะ
334 label_open_issues: เปิด
335 label_open_issues_plural: เปิด
336 label_closed_issues: ปิด
337 label_closed_issues_plural: ปิด
338 label_total: จำนวนรวม
339 label_permissions: สิทธิ
340 label_current_status: สถานะปัจจุบัน
341 label_new_statuses_allowed: อนุญาตให้มีสถานะใหม่
342 label_all: ทั้งหมด
343 label_none: ไม่มี
344 label_nobody: ไม่มีใคร
345 label_next: ต่อไป
346 label_previous: ก่อนหน้า
347 label_used_by: ถูกใช้โดย
348 label_details: รายละเอียด
349 label_add_note: เพิ่มบันทึก
350 label_per_page: ต่อหน้า
351 label_calendar: ปฏิทิน
352 label_months_from: เดือนจาก
353 label_gantt: Gantt
354 label_internal: ภายใน
355 label_last_changes: last %d เปลี่ยนแปลง
356 label_change_view_all: ดูการเปลี่ยนแปลงทั้งหมด
357 label_personalize_page: ปรับแต่งหน้านี้
358 label_comment: ความเห็น
359 label_comment_plural: ความเห็น
360 label_comment_add: เพิ่มความเห็น
361 label_comment_added: ความเห็นถูกเพิ่ม
362 label_comment_delete: ลบความเห็น
363 label_query: แบบสอบถามแบบกำหนดเอง
364 label_query_plural: แบบสอบถามแบบกำหนดเอง
365 label_query_new: แบบสอบถามใหม่
366 label_filter_add: เพิ่มตัวกรอง
367 label_filter_plural: ตัวกรอง
368 label_equals: คือ
369 label_not_equals: ไม่ใช่
370 label_in_less_than: น้อยกว่า
371 label_in_more_than: มากกว่า
372 label_in: ในช่วง
373 label_today: วันนี้
374 label_all_time: ตลอดเวลา
375 label_yesterday: เมื่อวาน
376 label_this_week: อาทิตย์นี้
377 label_last_week: อาทิตย์ที่แล้ว
378 label_last_n_days: %d วันย้อนหลัง
379 label_this_month: เดือนนี้
380 label_last_month: เดือนที่แล้ว
381 label_this_year: ปีนี้
382 label_date_range: ช่วงวันที่
383 label_less_than_ago: น้อยกว่าหนึ่งวัน
384 label_more_than_ago: มากกว่าหนึ่งวัน
385 label_ago: วันผ่านมาแล้ว
386 label_contains: มี...
387 label_not_contains: ไม่มี...
388 label_day_plural: วัน
389 label_repository: ที่เก็บต้นฉบับ
390 label_repository_plural: ที่เก็บต้นฉบับ
391 label_browse: เปิดหา
392 label_modification: %d เปลี่ยนแปลง
393 label_modification_plural: %d เปลี่ยนแปลง
394 label_revision: การแก้ไข
395 label_revision_plural: การแก้ไข
396 label_associated_revisions: การแก้ไขที่เกี่ยวข้อง
397 label_added: ถูกเพิ่ม
398 label_modified: ถูกแก้ไข
399 label_deleted: ถูกลบ
400 label_latest_revision: รุ่นการแก้ไขล่าสุด
401 label_latest_revision_plural: รุ่นการแก้ไขล่าสุด
402 label_view_revisions: ดูการแก้ไข
403 label_max_size: ขนาดใหญ่สุด
404 label_on: 'ใน'
405 label_sort_highest: ย้ายไปบนสุด
406 label_sort_higher: ย้ายขึ้น
407 label_sort_lower: ย้ายลง
408 label_sort_lowest: ย้ายไปล่างสุด
409 label_roadmap: แผนงาน
410 label_roadmap_due_in: ถึงกำหนดใน
411 label_roadmap_overdue: %s ช้ากว่ากำหนด
412 label_roadmap_no_issues: ไม่มีปัญหาสำหรับรุ่นนี้
413 label_search: ค้นหา
414 label_result_plural: ผลการค้นหา
415 label_all_words: ทุกคำ
416 label_wiki: Wiki
417 label_wiki_edit: แก้ไข Wiki
418 label_wiki_edit_plural: แก้ไข Wiki
419 label_wiki_page: หน้า Wiki
420 label_wiki_page_plural: หน้า Wiki
421 label_index_by_title: เรียงตามชื่อเรื่อง
422 label_index_by_date: เรียงตามวัน
423 label_current_version: รุ่นปัจจุบัน
424 label_preview: ตัวอย่างก่อนจัดเก็บ
425 label_feed_plural: Feeds
426 label_changes_details: รายละเอียดการเปลี่ยนแปลงทั้งหมด
427 label_issue_tracking: ติดตามปัญหา
428 label_spent_time: เวลาที่ใช้
429 label_f_hour: %.2f ชั่วโมง
430 label_f_hour_plural: %.2f ชั่วโมง
431 label_time_tracking: ติดตามการใช้เวลา
432 label_change_plural: เปลี่ยนแปลง
433 label_statistics: สถิติ
434 label_commits_per_month: Commits ต่อเดือน
435 label_commits_per_author: Commits ต่อผู้แต่ง
436 label_view_diff: ดูความแตกต่าง
437 label_diff_inline: inline
438 label_diff_side_by_side: side by side
439 label_options: ตัวเลือก
440 label_copy_workflow_from: คัดลอกลำดับงานจาก
441 label_permissions_report: รายงานสิทธิ
442 label_watched_issues: เฝ้าดูปัญหา
443 label_related_issues: ปัญหาที่เกี่ยวข้อง
444 label_applied_status: จัดเก็บสถานะ
445 label_loading: กำลังโหลด...
446 label_relation_new: ความสัมพันธ์ใหม่
447 label_relation_delete: ลบความสัมพันธ์
448 label_relates_to: สัมพันธ์กับ
449 label_duplicates: ซ้ำ
450 label_blocks: กีดกัน
451 label_blocked_by: กีดกันโดย
452 label_precedes: นำหน้า
453 label_follows: ตามหลัง
454 label_end_to_start: จบ-เริ่ม
455 label_end_to_end: จบ-จบ
456 label_start_to_start: เริ่ม-เริ่ม
457 label_start_to_end: เริ่ม-จบ
458 label_stay_logged_in: อยู่ในระบบต่อ
459 label_disabled: ไม่ใช้งาน
460 label_show_completed_versions: แสดงรุ่นที่สมบูรณ์
461 label_me: ฉัน
462 label_board: สภากาแฟ
463 label_board_new: สร้างสภากาแฟ
464 label_board_plural: สภากาแฟ
465 label_topic_plural: หัวข้อ
466 label_message_plural: ข้อความ
467 label_message_last: ข้อความล่าสุด
468 label_message_new: เขียนข้อความใหม่
469 label_message_posted: ข้อความถูกเพิ่มแล้ว
470 label_reply_plural: ตอบกลับ
471 label_send_information: ส่งรายละเอียดของบัญชีให้ผู้ใช้
472 label_year: ปี
473 label_month: เดือน
474 label_week: สัปดาห์
475 label_date_from: จาก
476 label_date_to: ถึง
477 label_language_based: ขึ้นอยู่กับภาษาของผู้ใช้
478 label_sort_by: เรียงโดย %s
479 label_send_test_email: ส่งจดหมายทดสอบ
480 label_feeds_access_key_created_on: RSS access key สร้างเมื่อ %s ที่ผ่านมา
481 label_module_plural: ส่วนประกอบ
482 label_added_time_by: เพิ่มโดย %s %s ที่ผ่านมา
483 label_updated_time: ปรับปรุง %s ที่ผ่านมา
484 label_jump_to_a_project: ไปที่โครงการ...
485 label_file_plural: แฟ้ม
486 label_changeset_plural: กลุ่มการเปลี่ยนแปลง
487 label_default_columns: สดมภ์เริ่มต้น
488 label_no_change_option: (ไม่เปลี่ยนแปลง)
489 label_bulk_edit_selected_issues: แก้ไขปัญหาที่เลือกทั้งหมด
490 label_theme: ชุดรูปแบบ
491 label_default: ค่าเริ่มต้น
492 label_search_titles_only: ค้นหาจากชื่อเรื่องเท่านั้น
493 label_user_mail_option_all: "ทุกๆ เหตุการณ์ในโครงการของฉัน"
494 label_user_mail_option_selected: "ทุกๆ เหตุการณ์ในโครงการที่เลือก..."
495 label_user_mail_option_none: "เฉพาะสิ่งที่ฉันเลือกหรือมีส่วนเกี่ยวข้อง"
496 label_user_mail_no_self_notified: "ฉันไม่ต้องการได้รับการแจ้งเตือนในสิ่งที่ฉันทำเอง"
497 label_registration_activation_by_email: เปิดบัญชีผ่านอีเมล์
498 label_registration_manual_activation: อนุมัติโดยผู้บริหารจัดการ
499 label_registration_automatic_activation: เปิดบัญชีอัตโนมัติ
500 label_display_per_page: 'ต่อหน้า: %s'
501 label_age: อายุ
502 label_change_properties: เปลี่ยนคุณสมบัติ
503 label_general: ทั่วๆ ไป
504 label_more: อื่น ๆ
505 label_scm: ตัวจัดการต้นฉบับ
506 label_plugins: ส่วนเสริม
507 label_ldap_authentication: การยืนยันตัวตนโดยใช้ LDAP
508 label_downloads_abbr: D/L
509 label_optional_description: รายละเอียดเพิ่มเติม
510 label_add_another_file: เพิ่มแฟ้มอื่นๆ
511 label_preferences: ค่าที่ชอบใจ
512 label_chronological_order: เรียงจากเก่าไปใหม่
513 label_reverse_chronological_order: เรียงจากใหม่ไปเก่า
514 label_planning: การวางแผน
515
516 button_login: เข้าระบบ
517 button_submit: จัดส่งข้อมูล
518 button_save: จัดเก็บ
519 button_check_all: เลือกทั้งหมด
520 button_uncheck_all: ไม่เลือกทั้งหมด
521 button_delete: ลบ
522 button_create: สร้าง
523 button_test: ทดสอบ
524 button_edit: แก้ไข
525 button_add: เพิ่ม
526 button_change: เปลี่ยนแปลง
527 button_apply: ประยุกต์ใช้
528 button_clear: ล้างข้อความ
529 button_lock: ล็อค
530 button_unlock: ยกเลิกการล็อค
531 button_download: ดาวน์โหลด
532 button_list: รายการ
533 button_view: มุมมอง
534 button_move: ย้าย
535 button_back: กลับ
536 button_cancel: ยกเลิก
537 button_activate: เปิดใช้
538 button_sort: จัดเรียง
539 button_log_time: บันทึกเวลา
540 button_rollback: ถอยกลับมาที่รุ่นนี้
541 button_watch: เฝ้าดู
542 button_unwatch: เลิกเฝ้าดู
543 button_reply: ตอบกลับ
544 button_archive: เก็บเข้าโกดัง
545 button_unarchive: เอาออกจากโกดัง
546 button_reset: เริ่มใหมท
547 button_rename: เปลี่ยนชื่อ
548 button_change_password: เปลี่ยนรหัสผ่าน
549 button_copy: คัดลอก
550 button_annotate: หมายเหตุประกอบ
551 button_update: ปรับปรุง
552 button_configure: ปรับแต่ง
553
554 status_active: เปิดใช้งานแล้ว
555 status_registered: รอการอนุมัติ
556 status_locked: ล็อค
557
558 text_select_mail_notifications: เลือกการกระทำที่ต้องการให้ส่งอีเมล์แจ้ง.
559 text_regexp_info: ตัวอย่าง ^[A-Z0-9]+$
560 text_min_max_length_info: 0 หมายถึงไม่จำกัด
561 text_project_destroy_confirmation: คุณแน่ใจไหมว่าต้องการลบโครงการและข้อมูลที่เกี่ยวข้่อง ?
562 text_subprojects_destroy_warning: 'โครงการย่อย: %s จะถูกลบด้วย.'
563 text_workflow_edit: เลือกบทบาทและการติดตาม เพื่อแก้ไขลำดับงาน
564 text_are_you_sure: คุณแน่ใจไหม ?
565 text_journal_changed: เปลี่ยนแปลงจาก %s เป็น %s
566 text_journal_set_to: ตั้งค่าเป็น %s
567 text_journal_deleted: ถูกลบ
568 text_tip_task_begin_day: งานที่เริ่มวันนี้
569 text_tip_task_end_day: งานที่จบวันนี้
570 text_tip_task_begin_end_day: งานที่เริ่มและจบวันนี้
571 text_project_identifier_info: 'ภาษาอังกฤษตัวเล็ก(a-z), ตัวเลข(0-9) และขีด (-) เท่านั้น.<br />เมื่อจัดเก็บแล้ว, ชื่อเฉพาะไม่สามารถเปลี่ยนแปลงได้'
572 text_caracters_maximum: สูงสุด %d ตัวอักษร.
573 text_caracters_minimum: ต้องยาวอย่างน้อย %d ตัวอักษร.
574 text_length_between: ความยาวระหว่าง %d ถึง %d ตัวอักษร.
575 text_tracker_no_workflow: ไม่ได้บัญญัติลำดับงานสำหรับการติดตามนี้
576 text_unallowed_characters: ตัวอักษรต้องห้าม
577 text_comma_separated: ใส่ได้หลายค่า โดยคั่นด้วยลูกน้ำ( ,).
578 text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages
579 text_issue_added: ปัญหา %s ถูกแจ้งโดย %s.
580 text_issue_updated: ปัญหา %s ถูกปรับปรุงโดย %s.
581 text_wiki_destroy_confirmation: คุณแน่ใจหรือว่าต้องการลบ wiki นี้พร้อมทั้งเนี้อหา?
582 text_issue_category_destroy_question: บางปัญหา (%d) อยู่ในประเภทนี้. คุณต้องการทำอย่างไร ?
583 text_issue_category_destroy_assignments: ลบประเภทนี้
584 text_issue_category_reassign_to: ระบุปัญหาในประเภทนี้
585 text_user_mail_option: "ในโครงการที่ไม่ได้เลือก, คุณจะได้รับการแจ้งเกี่ยวกับสิ่งที่คุณเฝ้าดูหรือมีส่วนเกี่ยวข้อง (เช่นปัญหาที่คุณแจ้งไว้หรือได้รับมอบหมาย)."
586 text_no_configuration_data: "บทบาท, การติดตาม, สถานะปัญหา และลำดับงานยังไม่ได้ถูกตั้งค่า.\nขอแนะนำให้โหลดค่าเริ่มต้น. คุณสามารถแก้ไขค่าได้หลังจากโหลดแล้ว."
587 text_load_default_configuration: โหลดค่าเริ่มต้น
588 text_status_changed_by_changeset: ประยุกต์ใช้ในกลุ่มการเปลี่ยนแปลง %s.
589 text_issues_destroy_confirmation: 'คุณแน่ใจไหมว่าต้องการลบปัญหา(ทั้งหลาย)ที่เลือกไว้?'
590 text_select_project_modules: 'เลือกส่วนประกอบที่ต้องการใช้งานสำหรับโครงการนี้:'
591 text_default_administrator_account_changed: ค่าเริ่มต้นของบัญชีผู้บริหารจัดการถูกเปลี่ยนแปลง
592 text_file_repository_writable: ที่เก็บต้นฉบับสามารถเขียนได้
593 text_rmagick_available: RMagick มีให้ใช้ (เป็นตัวเลือก)
594 text_destroy_time_entries_question: %.02f ชั่วโมงที่ถูกแจ้งในปัญหานี้จะโดนลบ. คุณต้องการทำอย่างไร?
595 text_destroy_time_entries: ลบเวลาที่รายงานไว้
596 text_assign_time_entries_to_project: ระบุเวลาที่ใช้ในโครงการนี้
597 text_reassign_time_entries: 'ระบุเวลาที่ใช้ในโครงการนี่อีกครั้ง:'
598
599 default_role_manager: ผู้จัดการ
600 default_role_developper: ผู้พัฒนา
601 default_role_reporter: ผู้รายงาน
602 default_tracker_bug: บั๊ก
603 default_tracker_feature: ลักษณะเด่น
604 default_tracker_support: สนับสนุน
605 default_issue_status_new: เกิดขึ้น
606 default_issue_status_assigned: รับมอบหมาย
607 default_issue_status_resolved: ดำเนินการ
608 default_issue_status_feedback: รอคำตอบ
609 default_issue_status_closed: จบ
610 default_issue_status_rejected: ยกเลิก
611 default_doc_category_user: เอกสารของผู้ใช้
612 default_doc_category_tech: เอกสารทางเทคนิค
613 default_priority_low: ต่ำ
614 default_priority_normal: ปกติ
615 default_priority_high: สูง
616 default_priority_urgent: เร่งด่วน
617 default_priority_immediate: ด่วนมาก
618 default_activity_design: ออกแบบ
619 default_activity_development: พัฒนา
620
621 enumeration_issue_priorities: ความสำคัญของปัญหา
622 enumeration_doc_categories: ประเภทเอกสาร
623 enumeration_activities: กิจกรรม (ใช้ในการติดตามเวลา)
@@ -0,0 +1,127
1 // ** I18N
2
3 // Calendar EN language
4 // Author: Gampol Thitinilnithi, <gampolt@gmail.com>
5 // Encoding: UTF-8
6 // Distributed under the same terms as the calendar itself.
7
8 // For translators: please use UTF-8 if possible. We strongly believe that
9 // Unicode is the answer to a real internationalized world. Also please
10 // include your contact information in the header, as can be seen above.
11
12 // full day names
13 Calendar._DN = new Array
14 ("อาทิตย์",
15 "จันทร์",
16 "อังคาร",
17 "พุธ",
18 "พฤหัสบดี",
19 "ศุกร์",
20 "เสาร์",
21 "อาทิตย์");
22
23 // Please note that the following array of short day names (and the same goes
24 // for short month names, _SMN) isn't absolutely necessary. We give it here
25 // for exemplification on how one can customize the short day names, but if
26 // they are simply the first N letters of the full name you can simply say:
27 //
28 // Calendar._SDN_len = N; // short day name length
29 // Calendar._SMN_len = N; // short month name length
30 //
31 // If N = 3 then this is not needed either since we assume a value of 3 if not
32 // present, to be compatible with translation files that were written before
33 // this feature.
34
35 // short day names
36 Calendar._SDN = new Array
37 ("อา.",
38 "จ.",
39 "อ.",
40 "พ.",
41 "พฤ.",
42 "ศ.",
43 "ส.",
44 "อา.");
45
46 // First day of the week. "0" means display Sunday first, "1" means display
47 // Monday first, etc.
48 Calendar._FD = 1;
49
50 // full month names
51 Calendar._MN = new Array
52 ("มกราคม",
53 "กุมภาพันธ์",
54 "มีนาคม",
55 "เมษายน",
56 "พฤษภาคม",
57 "มิถุนายน",
58 "กรกฎาคม",
59 "สิงหาคม",
60 "กันยายน",
61 "ตุลาคม",
62 "พฤศจิกายน",
63 "ธันวาคม");
64
65 // short month names
66 Calendar._SMN = new Array
67 ("ม.ค.",
68 "ก.พ.",
69 "มี.ค.",
70 "เม.ย.",
71 "พ.ค.",
72 "มิ.ย.",
73 "ก.ค.",
74 "ส.ค.",
75 "ก.ย.",
76 "ต.ค.",
77 "พ.ย.",
78 "ธ.ค.");
79
80 // tooltips
81 Calendar._TT = {};
82 Calendar._TT["INFO"] = "เกี่ยวกับปฏิทิน";
83
84 Calendar._TT["ABOUT"] =
85 "DHTML Date/Time Selector\n" +
86 "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
87 "For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
88 "Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
89 "\n\n" +
90 "Date selection:\n" +
91 "- Use the \xab, \xbb buttons to select year\n" +
92 "- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
93 "- Hold mouse button on any of the above buttons for faster selection.";
94 Calendar._TT["ABOUT_TIME"] = "\n\n" +
95 "Time selection:\n" +
96 "- Click on any of the time parts to increase it\n" +
97 "- or Shift-click to decrease it\n" +
98 "- or click and drag for faster selection.";
99
100 Calendar._TT["PREV_YEAR"] = "ปีที่แล้ว (ถ้ากดค้างจะมีเมนู)";
101 Calendar._TT["PREV_MONTH"] = "เดือนที่แล้ว (ถ้ากดค้างจะมีเมนู)";
102 Calendar._TT["GO_TODAY"] = "ไปที่วันนี้";
103 Calendar._TT["NEXT_MONTH"] = "เดือนหน้า (ถ้ากดค้างจะมีเมนู)";
104 Calendar._TT["NEXT_YEAR"] = "ปีหน้า (ถ้ากดค้างจะมีเมนู)";
105 Calendar._TT["SEL_DATE"] = "เลือกวัน";
106 Calendar._TT["DRAG_TO_MOVE"] = "กดแล้วลากเพื่อย้าย";
107 Calendar._TT["PART_TODAY"] = " (วันนี้)";
108
109 // the following is to inform that "%s" is to be the first day of week
110 // %s will be replaced with the day name.
111 Calendar._TT["DAY_FIRST"] = "แสดง %s เป็นวันแรก";
112
113 // This may be locale-dependent. It specifies the week-end days, as an array
114 // of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
115 // means Monday, etc.
116 Calendar._TT["WEEKEND"] = "0,6";
117
118 Calendar._TT["CLOSE"] = "ปิด";
119 Calendar._TT["TODAY"] = "วันนี้";
120 Calendar._TT["TIME_PART"] = "(Shift-)กดหรือกดแล้วลากเพื่อเปลี่ยนค่า";
121
122 // date formats
123 Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
124 Calendar._TT["TT_DATE_FORMAT"] = "%a %e %b";
125
126 Calendar._TT["WK"] = "wk";
127 Calendar._TT["TIME"] = "เวลา:";
@@ -0,0 +1,14
1 jsToolBar.strings = {};
2 jsToolBar.strings['Strong'] = 'หนา';
3 jsToolBar.strings['Italic'] = 'เอียง';
4 jsToolBar.strings['Underline'] = 'ขีดเส้นใต้';
5 jsToolBar.strings['Deleted'] = 'ขีดฆ่า';
6 jsToolBar.strings['Code'] = 'โค๊ดโปรแกรม';
7 jsToolBar.strings['Heading 1'] = 'หัวข้อ 1';
8 jsToolBar.strings['Heading 2'] = 'หัวข้อ 2';
9 jsToolBar.strings['Heading 3'] = 'หัวข้อ 3';
10 jsToolBar.strings['Unordered list'] = 'รายการ';
11 jsToolBar.strings['Ordered list'] = 'ลำดับเลข';
12 jsToolBar.strings['Preformatted text'] = 'รูปแบบข้อความคงที่';
13 jsToolBar.strings['Wiki link'] = 'เชื่อมโยงไปหน้า Wiki อื่น';
14 jsToolBar.strings['Image'] = 'รูปภาพ';
@@ -1,368 +1,372
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 QueryColumn
18 class QueryColumn
19 attr_accessor :name, :sortable, :default_order
19 attr_accessor :name, :sortable, :default_order
20 include GLoc
20 include GLoc
21
21
22 def initialize(name, options={})
22 def initialize(name, options={})
23 self.name = name
23 self.name = name
24 self.sortable = options[:sortable]
24 self.sortable = options[:sortable]
25 self.default_order = options[:default_order]
25 self.default_order = options[:default_order]
26 end
26 end
27
27
28 def caption
28 def caption
29 set_language_if_valid(User.current.language)
29 set_language_if_valid(User.current.language)
30 l("field_#{name}")
30 l("field_#{name}")
31 end
31 end
32 end
32 end
33
33
34 class QueryCustomFieldColumn < QueryColumn
34 class QueryCustomFieldColumn < QueryColumn
35
35
36 def initialize(custom_field)
36 def initialize(custom_field)
37 self.name = "cf_#{custom_field.id}".to_sym
37 self.name = "cf_#{custom_field.id}".to_sym
38 self.sortable = false
38 self.sortable = false
39 @cf = custom_field
39 @cf = custom_field
40 end
40 end
41
41
42 def caption
42 def caption
43 @cf.name
43 @cf.name
44 end
44 end
45
45
46 def custom_field
46 def custom_field
47 @cf
47 @cf
48 end
48 end
49 end
49 end
50
50
51 class Query < ActiveRecord::Base
51 class Query < ActiveRecord::Base
52 belongs_to :project
52 belongs_to :project
53 belongs_to :user
53 belongs_to :user
54 serialize :filters
54 serialize :filters
55 serialize :column_names
55 serialize :column_names
56
56
57 attr_protected :project_id, :user_id
57 attr_protected :project_id, :user_id
58
58
59 validates_presence_of :name, :on => :save
59 validates_presence_of :name, :on => :save
60 validates_length_of :name, :maximum => 255
60 validates_length_of :name, :maximum => 255
61
61
62 @@operators = { "=" => :label_equals,
62 @@operators = { "=" => :label_equals,
63 "!" => :label_not_equals,
63 "!" => :label_not_equals,
64 "o" => :label_open_issues,
64 "o" => :label_open_issues,
65 "c" => :label_closed_issues,
65 "c" => :label_closed_issues,
66 "!*" => :label_none,
66 "!*" => :label_none,
67 "*" => :label_all,
67 "*" => :label_all,
68 ">=" => '>=',
68 ">=" => '>=',
69 "<=" => '<=',
69 "<=" => '<=',
70 "<t+" => :label_in_less_than,
70 "<t+" => :label_in_less_than,
71 ">t+" => :label_in_more_than,
71 ">t+" => :label_in_more_than,
72 "t+" => :label_in,
72 "t+" => :label_in,
73 "t" => :label_today,
73 "t" => :label_today,
74 "w" => :label_this_week,
74 "w" => :label_this_week,
75 ">t-" => :label_less_than_ago,
75 ">t-" => :label_less_than_ago,
76 "<t-" => :label_more_than_ago,
76 "<t-" => :label_more_than_ago,
77 "t-" => :label_ago,
77 "t-" => :label_ago,
78 "~" => :label_contains,
78 "~" => :label_contains,
79 "!~" => :label_not_contains }
79 "!~" => :label_not_contains }
80
80
81 cattr_reader :operators
81 cattr_reader :operators
82
82
83 @@operators_by_filter_type = { :list => [ "=", "!" ],
83 @@operators_by_filter_type = { :list => [ "=", "!" ],
84 :list_status => [ "o", "=", "!", "c", "*" ],
84 :list_status => [ "o", "=", "!", "c", "*" ],
85 :list_optional => [ "=", "!", "!*", "*" ],
85 :list_optional => [ "=", "!", "!*", "*" ],
86 :list_subprojects => [ "*", "!*", "=" ],
86 :list_subprojects => [ "*", "!*", "=" ],
87 :date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ],
87 :date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ],
88 :date_past => [ ">t-", "<t-", "t-", "t", "w" ],
88 :date_past => [ ">t-", "<t-", "t-", "t", "w" ],
89 :string => [ "=", "~", "!", "!~" ],
89 :string => [ "=", "~", "!", "!~" ],
90 :text => [ "~", "!~" ],
90 :text => [ "~", "!~" ],
91 :integer => [ "=", ">=", "<=" ] }
91 :integer => [ "=", ">=", "<=" ] }
92
92
93 cattr_reader :operators_by_filter_type
93 cattr_reader :operators_by_filter_type
94
94
95 @@available_columns = [
95 @@available_columns = [
96 QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"),
96 QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"),
97 QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"),
97 QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"),
98 QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position", :default_order => 'desc'),
98 QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position", :default_order => 'desc'),
99 QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
99 QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
100 QueryColumn.new(:author),
100 QueryColumn.new(:author),
101 QueryColumn.new(:assigned_to, :sortable => "#{User.table_name}.lastname"),
101 QueryColumn.new(:assigned_to, :sortable => "#{User.table_name}.lastname"),
102 QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
102 QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
103 QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name"),
103 QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name"),
104 QueryColumn.new(:fixed_version, :sortable => "#{Version.table_name}.effective_date", :default_order => 'desc'),
104 QueryColumn.new(:fixed_version, :sortable => "#{Version.table_name}.effective_date", :default_order => 'desc'),
105 QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
105 QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
106 QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
106 QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
107 QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
107 QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
108 QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio"),
108 QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio"),
109 QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
109 QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
110 ]
110 ]
111 cattr_reader :available_columns
111 cattr_reader :available_columns
112
112
113 def initialize(attributes = nil)
113 def initialize(attributes = nil)
114 super attributes
114 super attributes
115 self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
115 self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
116 set_language_if_valid(User.current.language)
116 set_language_if_valid(User.current.language)
117 end
117 end
118
118
119 def after_initialize
119 def after_initialize
120 # Store the fact that project is nil (used in #editable_by?)
120 # Store the fact that project is nil (used in #editable_by?)
121 @is_for_all = project.nil?
121 @is_for_all = project.nil?
122 end
122 end
123
123
124 def validate
124 def validate
125 filters.each_key do |field|
125 filters.each_key do |field|
126 errors.add label_for(field), :activerecord_error_blank unless
126 errors.add label_for(field), :activerecord_error_blank unless
127 # filter requires one or more values
127 # filter requires one or more values
128 (values_for(field) and !values_for(field).first.empty?) or
128 (values_for(field) and !values_for(field).first.blank?) or
129 # filter doesn't require any value
129 # filter doesn't require any value
130 ["o", "c", "!*", "*", "t", "w"].include? operator_for(field)
130 ["o", "c", "!*", "*", "t", "w"].include? operator_for(field)
131 end if filters
131 end if filters
132 end
132 end
133
133
134 def editable_by?(user)
134 def editable_by?(user)
135 return false unless user
135 return false unless user
136 # Admin can edit them all and regular users can edit their private queries
136 # Admin can edit them all and regular users can edit their private queries
137 return true if user.admin? || (!is_public && self.user_id == user.id)
137 return true if user.admin? || (!is_public && self.user_id == user.id)
138 # Members can not edit public queries that are for all project (only admin is allowed to)
138 # Members can not edit public queries that are for all project (only admin is allowed to)
139 is_public && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
139 is_public && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
140 end
140 end
141
141
142 def available_filters
142 def available_filters
143 return @available_filters if @available_filters
143 return @available_filters if @available_filters
144
144
145 trackers = project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers
145 trackers = project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers
146
146
147 @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
147 @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
148 "tracker_id" => { :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } },
148 "tracker_id" => { :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } },
149 "priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI'], :order => 'position').collect{|s| [s.name, s.id.to_s] } },
149 "priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI'], :order => 'position').collect{|s| [s.name, s.id.to_s] } },
150 "subject" => { :type => :text, :order => 8 },
150 "subject" => { :type => :text, :order => 8 },
151 "created_on" => { :type => :date_past, :order => 9 },
151 "created_on" => { :type => :date_past, :order => 9 },
152 "updated_on" => { :type => :date_past, :order => 10 },
152 "updated_on" => { :type => :date_past, :order => 10 },
153 "start_date" => { :type => :date, :order => 11 },
153 "start_date" => { :type => :date, :order => 11 },
154 "due_date" => { :type => :date, :order => 12 },
154 "due_date" => { :type => :date, :order => 12 },
155 "done_ratio" => { :type => :integer, :order => 13 }}
155 "done_ratio" => { :type => :integer, :order => 13 }}
156
156
157 user_values = []
157 user_values = []
158 user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
158 user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
159 if project
159 if project
160 user_values += project.users.sort.collect{|s| [s.name, s.id.to_s] }
160 user_values += project.users.sort.collect{|s| [s.name, s.id.to_s] }
161 else
161 else
162 # members of the user's projects
162 # members of the user's projects
163 user_values += User.current.projects.collect(&:users).flatten.uniq.sort.collect{|s| [s.name, s.id.to_s] }
163 user_values += User.current.projects.collect(&:users).flatten.uniq.sort.collect{|s| [s.name, s.id.to_s] }
164 end
164 end
165 @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
165 @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
166 @available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
166 @available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
167
167
168 if project
168 if project
169 # project specific filters
169 # project specific filters
170 @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
170 @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
171 @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
171 @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
172 unless @project.active_children.empty?
172 unless @project.active_children.empty?
173 @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
173 @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
174 end
174 end
175 @project.all_custom_fields.select(&:is_filter?).each do |field|
175 @project.all_custom_fields.select(&:is_filter?).each do |field|
176 case field.field_format
176 case field.field_format
177 when "text"
177 when "text"
178 options = { :type => :text, :order => 20 }
178 options = { :type => :text, :order => 20 }
179 when "list"
179 when "list"
180 options = { :type => :list_optional, :values => field.possible_values, :order => 20}
180 options = { :type => :list_optional, :values => field.possible_values, :order => 20}
181 when "date"
181 when "date"
182 options = { :type => :date, :order => 20 }
182 options = { :type => :date, :order => 20 }
183 when "bool"
183 when "bool"
184 options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
184 options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
185 else
185 else
186 options = { :type => :string, :order => 20 }
186 options = { :type => :string, :order => 20 }
187 end
187 end
188 @available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
188 @available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
189 end
189 end
190 # remove category filter if no category defined
190 # remove category filter if no category defined
191 @available_filters.delete "category_id" if @available_filters["category_id"][:values].empty?
191 @available_filters.delete "category_id" if @available_filters["category_id"][:values].empty?
192 end
192 end
193 @available_filters
193 @available_filters
194 end
194 end
195
195
196 def add_filter(field, operator, values)
196 def add_filter(field, operator, values)
197 # values must be an array
197 # values must be an array
198 return unless values and values.is_a? Array # and !values.first.empty?
198 return unless values and values.is_a? Array # and !values.first.empty?
199 # check if field is defined as an available filter
199 # check if field is defined as an available filter
200 if available_filters.has_key? field
200 if available_filters.has_key? field
201 filter_options = available_filters[field]
201 filter_options = available_filters[field]
202 # check if operator is allowed for that filter
202 # check if operator is allowed for that filter
203 #if @@operators_by_filter_type[filter_options[:type]].include? operator
203 #if @@operators_by_filter_type[filter_options[:type]].include? operator
204 # allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]})
204 # allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]})
205 # filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator
205 # filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator
206 #end
206 #end
207 filters[field] = {:operator => operator, :values => values }
207 filters[field] = {:operator => operator, :values => values }
208 end
208 end
209 end
209 end
210
210
211 def add_short_filter(field, expression)
211 def add_short_filter(field, expression)
212 return unless expression
212 return unless expression
213 parms = expression.scan(/^(o|c|\!|\*)?(.*)$/).first
213 parms = expression.scan(/^(o|c|\!|\*)?(.*)$/).first
214 add_filter field, (parms[0] || "="), [parms[1] || ""]
214 add_filter field, (parms[0] || "="), [parms[1] || ""]
215 end
215 end
216
216
217 def has_filter?(field)
217 def has_filter?(field)
218 filters and filters[field]
218 filters and filters[field]
219 end
219 end
220
220
221 def operator_for(field)
221 def operator_for(field)
222 has_filter?(field) ? filters[field][:operator] : nil
222 has_filter?(field) ? filters[field][:operator] : nil
223 end
223 end
224
224
225 def values_for(field)
225 def values_for(field)
226 has_filter?(field) ? filters[field][:values] : nil
226 has_filter?(field) ? filters[field][:values] : nil
227 end
227 end
228
228
229 def label_for(field)
229 def label_for(field)
230 label = @available_filters[field][:name] if @available_filters.has_key?(field)
230 label = @available_filters[field][:name] if @available_filters.has_key?(field)
231 label ||= field.gsub(/\_id$/, "")
231 label ||= field.gsub(/\_id$/, "")
232 end
232 end
233
233
234 def available_columns
234 def available_columns
235 return @available_columns if @available_columns
235 return @available_columns if @available_columns
236 @available_columns = Query.available_columns
236 @available_columns = Query.available_columns
237 @available_columns += (project ?
237 @available_columns += (project ?
238 project.all_custom_fields :
238 project.all_custom_fields :
239 IssueCustomField.find(:all, :conditions => {:is_for_all => true})
239 IssueCustomField.find(:all, :conditions => {:is_for_all => true})
240 ).collect {|cf| QueryCustomFieldColumn.new(cf) }
240 ).collect {|cf| QueryCustomFieldColumn.new(cf) }
241 end
241 end
242
242
243 def columns
243 def columns
244 if has_default_columns?
244 if has_default_columns?
245 available_columns.select {|c| Setting.issue_list_default_columns.include?(c.name.to_s) }
245 available_columns.select {|c| Setting.issue_list_default_columns.include?(c.name.to_s) }
246 else
246 else
247 # preserve the column_names order
247 # preserve the column_names order
248 column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact
248 column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact
249 end
249 end
250 end
250 end
251
251
252 def column_names=(names)
252 def column_names=(names)
253 names = names.select {|n| n.is_a?(Symbol) || !n.blank? } if names
253 names = names.select {|n| n.is_a?(Symbol) || !n.blank? } if names
254 names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym } if names
254 names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym } if names
255 write_attribute(:column_names, names)
255 write_attribute(:column_names, names)
256 end
256 end
257
257
258 def has_column?(column)
258 def has_column?(column)
259 column_names && column_names.include?(column.name)
259 column_names && column_names.include?(column.name)
260 end
260 end
261
261
262 def has_default_columns?
262 def has_default_columns?
263 column_names.nil? || column_names.empty?
263 column_names.nil? || column_names.empty?
264 end
264 end
265
265
266 def statement
266 def statement
267 # project/subprojects clause
267 # project/subprojects clause
268 clause = ''
268 clause = ''
269 if project && !@project.active_children.empty?
269 if project && !@project.active_children.empty?
270 ids = [project.id]
270 ids = [project.id]
271 if has_filter?("subproject_id")
271 if has_filter?("subproject_id")
272 case operator_for("subproject_id")
272 case operator_for("subproject_id")
273 when '='
273 when '='
274 # include the selected subprojects
274 # include the selected subprojects
275 ids += values_for("subproject_id").each(&:to_i)
275 ids += values_for("subproject_id").each(&:to_i)
276 when '!*'
276 when '!*'
277 # main project only
277 # main project only
278 else
278 else
279 # all subprojects
279 # all subprojects
280 ids += project.active_children.collect{|p| p.id}
280 ids += project.active_children.collect{|p| p.id}
281 end
281 end
282 elsif Setting.display_subprojects_issues?
282 elsif Setting.display_subprojects_issues?
283 ids += project.active_children.collect{|p| p.id}
283 ids += project.active_children.collect{|p| p.id}
284 end
284 end
285 clause << "#{Issue.table_name}.project_id IN (%s)" % ids.join(',')
285 clause << "#{Issue.table_name}.project_id IN (%s)" % ids.join(',')
286 elsif project
286 elsif project
287 clause << "#{Issue.table_name}.project_id = %d" % project.id
287 clause << "#{Issue.table_name}.project_id = %d" % project.id
288 else
288 else
289 clause << Project.visible_by(User.current)
289 clause << Project.visible_by(User.current)
290 end
290 end
291
291
292 # filters clauses
292 # filters clauses
293 filters_clauses = []
293 filters_clauses = []
294 filters.each_key do |field|
294 filters.each_key do |field|
295 next if field == "subproject_id"
295 next if field == "subproject_id"
296 v = values_for(field).clone
296 v = values_for(field).clone
297 next unless v and !v.empty?
297 next unless v and !v.empty?
298
298
299 sql = ''
299 sql = ''
300 is_custom_filter = false
300 if field =~ /^cf_(\d+)$/
301 if field =~ /^cf_(\d+)$/
301 # custom field
302 # custom field
302 db_table = CustomValue.table_name
303 db_table = CustomValue.table_name
303 db_field = 'value'
304 db_field = 'value'
305 is_custom_filter = true
304 sql << "#{Issue.table_name}.id IN (SELECT #{Issue.table_name}.id FROM #{Issue.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{$1} WHERE "
306 sql << "#{Issue.table_name}.id IN (SELECT #{Issue.table_name}.id FROM #{Issue.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{$1} WHERE "
305 else
307 else
306 # regular field
308 # regular field
307 db_table = Issue.table_name
309 db_table = Issue.table_name
308 db_field = field
310 db_field = field
309 sql << '('
311 sql << '('
310 end
312 end
311
313
312 # "me" value subsitution
314 # "me" value subsitution
313 if %w(assigned_to_id author_id).include?(field)
315 if %w(assigned_to_id author_id).include?(field)
314 v.push(User.current.logged? ? User.current.id.to_s : "0") if v.delete("me")
316 v.push(User.current.logged? ? User.current.id.to_s : "0") if v.delete("me")
315 end
317 end
316
318
317 case operator_for field
319 case operator_for field
318 when "="
320 when "="
319 sql = sql + "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
321 sql = sql + "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
320 when "!"
322 when "!"
321 sql = sql + "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))"
323 sql = sql + "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))"
322 when "!*"
324 when "!*"
323 sql = sql + "#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} = ''"
325 sql = sql + "#{db_table}.#{db_field} IS NULL"
326 sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter
324 when "*"
327 when "*"
325 sql = sql + "#{db_table}.#{db_field} IS NOT NULL AND #{db_table}.#{db_field} <> ''"
328 sql = sql + "#{db_table}.#{db_field} IS NOT NULL"
329 sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter
326 when ">="
330 when ">="
327 sql = sql + "#{db_table}.#{db_field} >= #{v.first.to_i}"
331 sql = sql + "#{db_table}.#{db_field} >= #{v.first.to_i}"
328 when "<="
332 when "<="
329 sql = sql + "#{db_table}.#{db_field} <= #{v.first.to_i}"
333 sql = sql + "#{db_table}.#{db_field} <= #{v.first.to_i}"
330 when "o"
334 when "o"
331 sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id"
335 sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id"
332 when "c"
336 when "c"
333 sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id"
337 sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id"
334 when ">t-"
338 when ">t-"
335 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today + 1).to_time)]
339 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today + 1).to_time)]
336 when "<t-"
340 when "<t-"
337 sql = sql + "#{db_table}.#{db_field} <= '%s'" % connection.quoted_date((Date.today - v.first.to_i).to_time)
341 sql = sql + "#{db_table}.#{db_field} <= '%s'" % connection.quoted_date((Date.today - v.first.to_i).to_time)
338 when "t-"
342 when "t-"
339 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today - v.first.to_i + 1).to_time)]
343 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today - v.first.to_i + 1).to_time)]
340 when ">t+"
344 when ">t+"
341 sql = sql + "#{db_table}.#{db_field} >= '%s'" % connection.quoted_date((Date.today + v.first.to_i).to_time)
345 sql = sql + "#{db_table}.#{db_field} >= '%s'" % connection.quoted_date((Date.today + v.first.to_i).to_time)
342 when "<t+"
346 when "<t+"
343 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)]
347 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)]
344 when "t+"
348 when "t+"
345 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today + v.first.to_i).to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)]
349 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today + v.first.to_i).to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)]
346 when "t"
350 when "t"
347 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today+1).to_time)]
351 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today+1).to_time)]
348 when "w"
352 when "w"
349 from = l(:general_first_day_of_week) == '7' ?
353 from = l(:general_first_day_of_week) == '7' ?
350 # week starts on sunday
354 # week starts on sunday
351 ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) :
355 ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) :
352 # week starts on monday (Rails default)
356 # week starts on monday (Rails default)
353 Time.now.at_beginning_of_week
357 Time.now.at_beginning_of_week
354 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]
358 sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]
355 when "~"
359 when "~"
356 sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'"
360 sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'"
357 when "!~"
361 when "!~"
358 sql = sql + "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'"
362 sql = sql + "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'"
359 end
363 end
360 sql << ')'
364 sql << ')'
361 filters_clauses << sql
365 filters_clauses << sql
362 end if filters and valid?
366 end if filters and valid?
363
367
364 clause << ' AND ' unless clause.empty?
368 clause << ' AND ' unless clause.empty?
365 clause << filters_clauses.join(' AND ') unless filters_clauses.empty?
369 clause << filters_clauses.join(' AND ') unless filters_clauses.empty?
366 clause
370 clause
367 end
371 end
368 end
372 end
@@ -1,133 +1,133
1 require 'redmine/access_control'
1 require 'redmine/access_control'
2 require 'redmine/menu_manager'
2 require 'redmine/menu_manager'
3 require 'redmine/mime_type'
3 require 'redmine/mime_type'
4 require 'redmine/core_ext'
4 require 'redmine/core_ext'
5 require 'redmine/themes'
5 require 'redmine/themes'
6 require 'redmine/plugin'
6 require 'redmine/plugin'
7
7
8 begin
8 begin
9 require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick)
9 require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick)
10 rescue LoadError
10 rescue LoadError
11 # RMagick is not available
11 # RMagick is not available
12 end
12 end
13
13
14 REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs Bazaar Git )
14 REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs Bazaar Git )
15
15
16 # Permissions
16 # Permissions
17 Redmine::AccessControl.map do |map|
17 Redmine::AccessControl.map do |map|
18 map.permission :view_project, {:projects => [:show, :activity]}, :public => true
18 map.permission :view_project, {:projects => [:show, :activity]}, :public => true
19 map.permission :search_project, {:search => :index}, :public => true
19 map.permission :search_project, {:search => :index}, :public => true
20 map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
20 map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
21 map.permission :select_project_modules, {:projects => :modules}, :require => :member
21 map.permission :select_project_modules, {:projects => :modules}, :require => :member
22 map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member
22 map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member
23 map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member
23 map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member
24
24
25 map.project_module :issue_tracking do |map|
25 map.project_module :issue_tracking do |map|
26 # Issue categories
26 # Issue categories
27 map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member
27 map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member
28 # Issues
28 # Issues
29 map.permission :view_issues, {:projects => [:changelog, :roadmap],
29 map.permission :view_issues, {:projects => [:changelog, :roadmap],
30 :issues => [:index, :changes, :show, :context_menu],
30 :issues => [:index, :changes, :show, :context_menu],
31 :versions => [:show, :status_by],
31 :versions => [:show, :status_by],
32 :queries => :index,
32 :queries => :index,
33 :reports => :issue_report}, :public => true
33 :reports => :issue_report}, :public => true
34 map.permission :add_issues, {:issues => :new}
34 map.permission :add_issues, {:issues => :new}
35 map.permission :edit_issues, {:issues => [:edit, :bulk_edit, :destroy_attachment]}
35 map.permission :edit_issues, {:issues => [:edit, :bulk_edit, :destroy_attachment]}
36 map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
36 map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
37 map.permission :add_issue_notes, {:issues => :edit}
37 map.permission :add_issue_notes, {:issues => :edit}
38 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
38 map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
39 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
39 map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
40 map.permission :move_issues, {:issues => :move}, :require => :loggedin
40 map.permission :move_issues, {:issues => :move}, :require => :loggedin
41 map.permission :delete_issues, {:issues => :destroy}, :require => :member
41 map.permission :delete_issues, {:issues => :destroy}, :require => :member
42 # Queries
42 # Queries
43 map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member
43 map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member
44 map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin
44 map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin
45 # Gantt & calendar
45 # Gantt & calendar
46 map.permission :view_gantt, :projects => :gantt
46 map.permission :view_gantt, :projects => :gantt
47 map.permission :view_calendar, :projects => :calendar
47 map.permission :view_calendar, :projects => :calendar
48 end
48 end
49
49
50 map.project_module :time_tracking do |map|
50 map.project_module :time_tracking do |map|
51 map.permission :log_time, {:timelog => :edit}, :require => :loggedin
51 map.permission :log_time, {:timelog => :edit}, :require => :loggedin
52 map.permission :view_time_entries, :timelog => [:details, :report]
52 map.permission :view_time_entries, :timelog => [:details, :report]
53 map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member
53 map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member
54 map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin
54 map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin
55 end
55 end
56
56
57 map.project_module :news do |map|
57 map.project_module :news do |map|
58 map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member
58 map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member
59 map.permission :view_news, {:news => [:index, :show]}, :public => true
59 map.permission :view_news, {:news => [:index, :show]}, :public => true
60 map.permission :comment_news, {:news => :add_comment}
60 map.permission :comment_news, {:news => :add_comment}
61 end
61 end
62
62
63 map.project_module :documents do |map|
63 map.project_module :documents do |map|
64 map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin
64 map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin
65 map.permission :view_documents, :documents => [:index, :show, :download]
65 map.permission :view_documents, :documents => [:index, :show, :download]
66 end
66 end
67
67
68 map.project_module :files do |map|
68 map.project_module :files do |map|
69 map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin
69 map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin
70 map.permission :view_files, :projects => :list_files, :versions => :download
70 map.permission :view_files, :projects => :list_files, :versions => :download
71 end
71 end
72
72
73 map.project_module :wiki do |map|
73 map.project_module :wiki do |map|
74 map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
74 map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
75 map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
75 map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
76 map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
76 map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
77 map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :annotate, :special]
77 map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :annotate, :special]
78 map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment]
78 map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment]
79 end
79 end
80
80
81 map.project_module :repository do |map|
81 map.project_module :repository do |map|
82 map.permission :manage_repository, {:repositories => [:edit, :destroy]}, :require => :member
82 map.permission :manage_repository, {:repositories => [:edit, :destroy]}, :require => :member
83 map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph]
83 map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph]
84 map.permission :view_changesets, :repositories => [:show, :revisions, :revision]
84 map.permission :view_changesets, :repositories => [:show, :revisions, :revision]
85 end
85 end
86
86
87 map.project_module :boards do |map|
87 map.project_module :boards do |map|
88 map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member
88 map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member
89 map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true
89 map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true
90 map.permission :add_messages, {:messages => [:new, :reply]}
90 map.permission :add_messages, {:messages => [:new, :reply]}
91 map.permission :edit_messages, {:messages => :edit}, :require => :member
91 map.permission :edit_messages, {:messages => :edit}, :require => :member
92 map.permission :delete_messages, {:messages => :destroy}, :require => :member
92 map.permission :delete_messages, {:messages => :destroy}, :require => :member
93 end
93 end
94 end
94 end
95
95
96 Redmine::MenuManager.map :top_menu do |menu|
96 Redmine::MenuManager.map :top_menu do |menu|
97 menu.push :home, :home_url, :html => { :class => 'home' }
97 menu.push :home, :home_path, :html => { :class => 'home' }
98 menu.push :my_page, { :controller => 'my', :action => 'page' }, :html => { :class => 'mypage' }, :if => Proc.new { User.current.logged? }
98 menu.push :my_page, { :controller => 'my', :action => 'page' }, :html => { :class => 'mypage' }, :if => Proc.new { User.current.logged? }
99 menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural, :html => { :class => 'projects' }
99 menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural, :html => { :class => 'projects' }
100 menu.push :administration, { :controller => 'admin', :action => 'index' }, :html => { :class => 'admin' }, :if => Proc.new { User.current.admin? }
100 menu.push :administration, { :controller => 'admin', :action => 'index' }, :html => { :class => 'admin' }, :if => Proc.new { User.current.admin? }
101 menu.push :help, Redmine::Info.help_url, :html => { :class => 'help' }
101 menu.push :help, Redmine::Info.help_url, :html => { :class => 'help' }
102 end
102 end
103
103
104 Redmine::MenuManager.map :account_menu do |menu|
104 Redmine::MenuManager.map :account_menu do |menu|
105 menu.push :login, :signin_url, :html => { :class => 'login' }, :if => Proc.new { !User.current.logged? }
105 menu.push :login, :signin_path, :html => { :class => 'login' }, :if => Proc.new { !User.current.logged? }
106 menu.push :register, { :controller => 'account', :action => 'register' }, :html => { :class => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? }
106 menu.push :register, { :controller => 'account', :action => 'register' }, :html => { :class => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? }
107 menu.push :my_account, { :controller => 'my', :action => 'account' }, :html => { :class => 'myaccount' }, :if => Proc.new { User.current.logged? }
107 menu.push :my_account, { :controller => 'my', :action => 'account' }, :html => { :class => 'myaccount' }, :if => Proc.new { User.current.logged? }
108 menu.push :logout, :signout_url, :html => { :class => 'logout' }, :if => Proc.new { User.current.logged? }
108 menu.push :logout, :signout_path, :html => { :class => 'logout' }, :if => Proc.new { User.current.logged? }
109 end
109 end
110
110
111 Redmine::MenuManager.map :application_menu do |menu|
111 Redmine::MenuManager.map :application_menu do |menu|
112 # Empty
112 # Empty
113 end
113 end
114
114
115 Redmine::MenuManager.map :project_menu do |menu|
115 Redmine::MenuManager.map :project_menu do |menu|
116 menu.push :overview, { :controller => 'projects', :action => 'show' }
116 menu.push :overview, { :controller => 'projects', :action => 'show' }
117 menu.push :activity, { :controller => 'projects', :action => 'activity' }
117 menu.push :activity, { :controller => 'projects', :action => 'activity' }
118 menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' },
118 menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' },
119 :if => Proc.new { |p| p.versions.any? }
119 :if => Proc.new { |p| p.versions.any? }
120 menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
120 menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
121 menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new,
121 menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new,
122 :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
122 :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
123 menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
123 menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
124 menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
124 menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
125 menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil },
125 menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil },
126 :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
126 :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
127 menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
127 menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
128 :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
128 :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
129 menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_attachment_plural
129 menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_attachment_plural
130 menu.push :repository, { :controller => 'repositories', :action => 'show' },
130 menu.push :repository, { :controller => 'repositories', :action => 'show' },
131 :if => Proc.new { |p| p.repository && !p.repository.new_record? }
131 :if => Proc.new { |p| p.repository && !p.repository.new_record? }
132 menu.push :settings, { :controller => 'projects', :action => 'settings' }
132 menu.push :settings, { :controller => 'projects', :action => 'settings' }
133 end
133 end
@@ -1,40 +1,40
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2008 Jean-Philippe Lang
2 # Copyright (C) 2008 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 Redmine #:nodoc:
18 module Redmine #:nodoc:
19 module CoreExtensions #:nodoc:
19 module CoreExtensions #:nodoc:
20 module String #:nodoc:
20 module String #:nodoc:
21 # Custom string conversions
21 # Custom string conversions
22 module Conversions
22 module Conversions
23 # Parses hours format and returns a float
23 # Parses hours format and returns a float
24 def to_hours
24 def to_hours
25 s = self.dup
25 s = self.dup
26 s.strip!
26 s.strip!
27 unless s =~ %r{^[\d\.,]+$}
27 unless s =~ %r{^[\d\.,]+$}
28 # 2:30 => 2.5
28 # 2:30 => 2.5
29 s.gsub!(%r{^(\d+):(\d+)$}) { $1.to_i + $2.to_i / 60.0 }
29 s.gsub!(%r{^(\d+):(\d+)$}) { $1.to_i + $2.to_i / 60.0 }
30 # 2h30, 2h, 30m => 2.5, 2, 0.5
30 # 2h30, 2h, 30m => 2.5, 2, 0.5
31 s.gsub!(%r{^((\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0) : m[0] }
31 s.gsub!(%r{^((\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0) : m[0] }
32 end
32 end
33 # 2,5 => 2.5
33 # 2,5 => 2.5
34 s.gsub!(',', '.')
34 s.gsub!(',', '.')
35 s.to_f
35 begin; Kernel.Float(s); rescue; nil; end
36 end
36 end
37 end
37 end
38 end
38 end
39 end
39 end
40 end
40 end
@@ -1,63 +1,64
1 ---
1 ---
2 custom_fields_001:
2 custom_fields_001:
3 name: Database
3 name: Database
4 min_length: 0
4 min_length: 0
5 regexp: ""
5 regexp: ""
6 is_for_all: true
6 is_for_all: true
7 is_filter: true
7 type: IssueCustomField
8 type: IssueCustomField
8 max_length: 0
9 max_length: 0
9 possible_values: MySQL|PostgreSQL|Oracle
10 possible_values: MySQL|PostgreSQL|Oracle
10 id: 1
11 id: 1
11 is_required: false
12 is_required: false
12 field_format: list
13 field_format: list
13 default_value: ""
14 default_value: ""
14 custom_fields_002:
15 custom_fields_002:
15 name: Searchable field
16 name: Searchable field
16 min_length: 1
17 min_length: 1
17 regexp: ""
18 regexp: ""
18 is_for_all: true
19 is_for_all: true
19 type: IssueCustomField
20 type: IssueCustomField
20 max_length: 100
21 max_length: 100
21 possible_values: ""
22 possible_values: ""
22 id: 2
23 id: 2
23 is_required: false
24 is_required: false
24 field_format: string
25 field_format: string
25 searchable: true
26 searchable: true
26 default_value: "Default string"
27 default_value: "Default string"
27 custom_fields_003:
28 custom_fields_003:
28 name: Development status
29 name: Development status
29 min_length: 0
30 min_length: 0
30 regexp: ""
31 regexp: ""
31 is_for_all: false
32 is_for_all: false
32 type: ProjectCustomField
33 type: ProjectCustomField
33 max_length: 0
34 max_length: 0
34 possible_values: Stable|Beta|Alpha|Planning
35 possible_values: Stable|Beta|Alpha|Planning
35 id: 3
36 id: 3
36 is_required: true
37 is_required: true
37 field_format: list
38 field_format: list
38 default_value: ""
39 default_value: ""
39 custom_fields_004:
40 custom_fields_004:
40 name: Phone number
41 name: Phone number
41 min_length: 0
42 min_length: 0
42 regexp: ""
43 regexp: ""
43 is_for_all: false
44 is_for_all: false
44 type: UserCustomField
45 type: UserCustomField
45 max_length: 0
46 max_length: 0
46 possible_values: ""
47 possible_values: ""
47 id: 4
48 id: 4
48 is_required: false
49 is_required: false
49 field_format: string
50 field_format: string
50 default_value: ""
51 default_value: ""
51 custom_fields_005:
52 custom_fields_005:
52 name: Money
53 name: Money
53 min_length: 0
54 min_length: 0
54 regexp: ""
55 regexp: ""
55 is_for_all: false
56 is_for_all: false
56 type: UserCustomField
57 type: UserCustomField
57 max_length: 0
58 max_length: 0
58 possible_values: ""
59 possible_values: ""
59 id: 5
60 id: 5
60 is_required: false
61 is_required: false
61 field_format: float
62 field_format: float
62 default_value: ""
63 default_value: ""
63 No newline at end of file
64
@@ -1,507 +1,514
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 require File.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19 require 'issues_controller'
19 require 'issues_controller'
20
20
21 # Re-raise errors caught by the controller.
21 # Re-raise errors caught by the controller.
22 class IssuesController; def rescue_action(e) raise e end; end
22 class IssuesController; def rescue_action(e) raise e end; end
23
23
24 class IssuesControllerTest < Test::Unit::TestCase
24 class IssuesControllerTest < Test::Unit::TestCase
25 fixtures :projects,
25 fixtures :projects,
26 :users,
26 :users,
27 :roles,
27 :roles,
28 :members,
28 :members,
29 :issues,
29 :issues,
30 :issue_statuses,
30 :issue_statuses,
31 :trackers,
31 :trackers,
32 :projects_trackers,
32 :projects_trackers,
33 :issue_categories,
33 :issue_categories,
34 :enabled_modules,
34 :enabled_modules,
35 :enumerations,
35 :enumerations,
36 :attachments,
36 :attachments,
37 :workflows,
37 :workflows,
38 :custom_fields,
38 :custom_fields,
39 :custom_values,
39 :custom_values,
40 :custom_fields_trackers,
40 :custom_fields_trackers,
41 :time_entries
41 :time_entries
42
42
43 def setup
43 def setup
44 @controller = IssuesController.new
44 @controller = IssuesController.new
45 @request = ActionController::TestRequest.new
45 @request = ActionController::TestRequest.new
46 @response = ActionController::TestResponse.new
46 @response = ActionController::TestResponse.new
47 User.current = nil
47 User.current = nil
48 end
48 end
49
49
50 def test_index
50 def test_index
51 get :index
51 get :index
52 assert_response :success
52 assert_response :success
53 assert_template 'index.rhtml'
53 assert_template 'index.rhtml'
54 assert_not_nil assigns(:issues)
54 assert_not_nil assigns(:issues)
55 assert_nil assigns(:project)
55 assert_nil assigns(:project)
56 end
56 end
57
57
58 def test_index_with_project
58 def test_index_with_project
59 get :index, :project_id => 1
59 get :index, :project_id => 1
60 assert_response :success
60 assert_response :success
61 assert_template 'index.rhtml'
61 assert_template 'index.rhtml'
62 assert_not_nil assigns(:issues)
62 assert_not_nil assigns(:issues)
63 end
63 end
64
64
65 def test_index_with_project_and_filter
65 def test_index_with_project_and_filter
66 get :index, :project_id => 1, :set_filter => 1
66 get :index, :project_id => 1, :set_filter => 1
67 assert_response :success
67 assert_response :success
68 assert_template 'index.rhtml'
68 assert_template 'index.rhtml'
69 assert_not_nil assigns(:issues)
69 assert_not_nil assigns(:issues)
70 end
70 end
71
71
72 def test_index_csv_with_project
72 def test_index_csv_with_project
73 get :index, :format => 'csv'
73 get :index, :format => 'csv'
74 assert_response :success
74 assert_response :success
75 assert_not_nil assigns(:issues)
75 assert_not_nil assigns(:issues)
76 assert_equal 'text/csv', @response.content_type
76 assert_equal 'text/csv', @response.content_type
77
77
78 get :index, :project_id => 1, :format => 'csv'
78 get :index, :project_id => 1, :format => 'csv'
79 assert_response :success
79 assert_response :success
80 assert_not_nil assigns(:issues)
80 assert_not_nil assigns(:issues)
81 assert_equal 'text/csv', @response.content_type
81 assert_equal 'text/csv', @response.content_type
82 end
82 end
83
83
84 def test_index_pdf
84 def test_index_pdf
85 get :index, :format => 'pdf'
85 get :index, :format => 'pdf'
86 assert_response :success
86 assert_response :success
87 assert_not_nil assigns(:issues)
87 assert_not_nil assigns(:issues)
88 assert_equal 'application/pdf', @response.content_type
88 assert_equal 'application/pdf', @response.content_type
89
89
90 get :index, :project_id => 1, :format => 'pdf'
90 get :index, :project_id => 1, :format => 'pdf'
91 assert_response :success
91 assert_response :success
92 assert_not_nil assigns(:issues)
92 assert_not_nil assigns(:issues)
93 assert_equal 'application/pdf', @response.content_type
93 assert_equal 'application/pdf', @response.content_type
94 end
94 end
95
95
96 def test_changes
96 def test_changes
97 get :changes, :project_id => 1
97 get :changes, :project_id => 1
98 assert_response :success
98 assert_response :success
99 assert_not_nil assigns(:journals)
99 assert_not_nil assigns(:journals)
100 assert_equal 'application/atom+xml', @response.content_type
100 assert_equal 'application/atom+xml', @response.content_type
101 end
101 end
102
102
103 def test_show_by_anonymous
103 def test_show_by_anonymous
104 get :show, :id => 1
104 get :show, :id => 1
105 assert_response :success
105 assert_response :success
106 assert_template 'show.rhtml'
106 assert_template 'show.rhtml'
107 assert_not_nil assigns(:issue)
107 assert_not_nil assigns(:issue)
108 assert_equal Issue.find(1), assigns(:issue)
108 assert_equal Issue.find(1), assigns(:issue)
109
109
110 # anonymous role is allowed to add a note
110 # anonymous role is allowed to add a note
111 assert_tag :tag => 'form',
111 assert_tag :tag => 'form',
112 :descendant => { :tag => 'fieldset',
112 :descendant => { :tag => 'fieldset',
113 :child => { :tag => 'legend',
113 :child => { :tag => 'legend',
114 :content => /Notes/ } }
114 :content => /Notes/ } }
115 end
115 end
116
116
117 def test_show_by_manager
117 def test_show_by_manager
118 @request.session[:user_id] = 2
118 @request.session[:user_id] = 2
119 get :show, :id => 1
119 get :show, :id => 1
120 assert_response :success
120 assert_response :success
121
121
122 assert_tag :tag => 'form',
122 assert_tag :tag => 'form',
123 :descendant => { :tag => 'fieldset',
123 :descendant => { :tag => 'fieldset',
124 :child => { :tag => 'legend',
124 :child => { :tag => 'legend',
125 :content => /Change properties/ } },
125 :content => /Change properties/ } },
126 :descendant => { :tag => 'fieldset',
126 :descendant => { :tag => 'fieldset',
127 :child => { :tag => 'legend',
127 :child => { :tag => 'legend',
128 :content => /Log time/ } },
128 :content => /Log time/ } },
129 :descendant => { :tag => 'fieldset',
129 :descendant => { :tag => 'fieldset',
130 :child => { :tag => 'legend',
130 :child => { :tag => 'legend',
131 :content => /Notes/ } }
131 :content => /Notes/ } }
132 end
132 end
133
133
134 def test_get_new
134 def test_get_new
135 @request.session[:user_id] = 2
135 @request.session[:user_id] = 2
136 get :new, :project_id => 1, :tracker_id => 1
136 get :new, :project_id => 1, :tracker_id => 1
137 assert_response :success
137 assert_response :success
138 assert_template 'new'
138 assert_template 'new'
139
139
140 assert_tag :tag => 'input', :attributes => { :name => 'custom_fields[2]',
140 assert_tag :tag => 'input', :attributes => { :name => 'custom_fields[2]',
141 :value => 'Default string' }
141 :value => 'Default string' }
142 end
142 end
143
143
144 def test_get_new_without_tracker_id
144 def test_get_new_without_tracker_id
145 @request.session[:user_id] = 2
145 @request.session[:user_id] = 2
146 get :new, :project_id => 1
146 get :new, :project_id => 1
147 assert_response :success
147 assert_response :success
148 assert_template 'new'
148 assert_template 'new'
149
149
150 issue = assigns(:issue)
150 issue = assigns(:issue)
151 assert_not_nil issue
151 assert_not_nil issue
152 assert_equal Project.find(1).trackers.first, issue.tracker
152 assert_equal Project.find(1).trackers.first, issue.tracker
153 end
153 end
154
154
155 def test_update_new_form
155 def test_update_new_form
156 @request.session[:user_id] = 2
156 @request.session[:user_id] = 2
157 xhr :post, :new, :project_id => 1,
157 xhr :post, :new, :project_id => 1,
158 :issue => {:tracker_id => 2,
158 :issue => {:tracker_id => 2,
159 :subject => 'This is the test_new issue',
159 :subject => 'This is the test_new issue',
160 :description => 'This is the description',
160 :description => 'This is the description',
161 :priority_id => 5}
161 :priority_id => 5}
162 assert_response :success
162 assert_response :success
163 assert_template 'new'
163 assert_template 'new'
164 end
164 end
165
165
166 def test_post_new
166 def test_post_new
167 @request.session[:user_id] = 2
167 @request.session[:user_id] = 2
168 post :new, :project_id => 1,
168 post :new, :project_id => 1,
169 :issue => {:tracker_id => 1,
169 :issue => {:tracker_id => 1,
170 :subject => 'This is the test_new issue',
170 :subject => 'This is the test_new issue',
171 :description => 'This is the description',
171 :description => 'This is the description',
172 :priority_id => 5},
172 :priority_id => 5,
173 :estimated_hours => ''},
173 :custom_fields => {'2' => 'Value for field 2'}
174 :custom_fields => {'2' => 'Value for field 2'}
174 assert_redirected_to 'issues/show'
175 assert_redirected_to 'issues/show'
175
176
176 issue = Issue.find_by_subject('This is the test_new issue')
177 issue = Issue.find_by_subject('This is the test_new issue')
177 assert_not_nil issue
178 assert_not_nil issue
178 assert_equal 2, issue.author_id
179 assert_equal 2, issue.author_id
180 assert_nil issue.estimated_hours
179 v = issue.custom_values.find_by_custom_field_id(2)
181 v = issue.custom_values.find_by_custom_field_id(2)
180 assert_not_nil v
182 assert_not_nil v
181 assert_equal 'Value for field 2', v.value
183 assert_equal 'Value for field 2', v.value
182 end
184 end
183
185
184 def test_post_new_without_custom_fields_param
186 def test_post_new_without_custom_fields_param
185 @request.session[:user_id] = 2
187 @request.session[:user_id] = 2
186 post :new, :project_id => 1,
188 post :new, :project_id => 1,
187 :issue => {:tracker_id => 1,
189 :issue => {:tracker_id => 1,
188 :subject => 'This is the test_new issue',
190 :subject => 'This is the test_new issue',
189 :description => 'This is the description',
191 :description => 'This is the description',
190 :priority_id => 5}
192 :priority_id => 5}
191 assert_redirected_to 'issues/show'
193 assert_redirected_to 'issues/show'
192 end
194 end
193
195
194 def test_copy_issue
196 def test_copy_issue
195 @request.session[:user_id] = 2
197 @request.session[:user_id] = 2
196 get :new, :project_id => 1, :copy_from => 1
198 get :new, :project_id => 1, :copy_from => 1
197 assert_template 'new'
199 assert_template 'new'
198 assert_not_nil assigns(:issue)
200 assert_not_nil assigns(:issue)
199 orig = Issue.find(1)
201 orig = Issue.find(1)
200 assert_equal orig.subject, assigns(:issue).subject
202 assert_equal orig.subject, assigns(:issue).subject
201 end
203 end
202
204
203 def test_get_edit
205 def test_get_edit
204 @request.session[:user_id] = 2
206 @request.session[:user_id] = 2
205 get :edit, :id => 1
207 get :edit, :id => 1
206 assert_response :success
208 assert_response :success
207 assert_template 'edit'
209 assert_template 'edit'
208 assert_not_nil assigns(:issue)
210 assert_not_nil assigns(:issue)
209 assert_equal Issue.find(1), assigns(:issue)
211 assert_equal Issue.find(1), assigns(:issue)
210 end
212 end
211
213
212 def test_get_edit_with_params
214 def test_get_edit_with_params
213 @request.session[:user_id] = 2
215 @request.session[:user_id] = 2
214 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }
216 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }
215 assert_response :success
217 assert_response :success
216 assert_template 'edit'
218 assert_template 'edit'
217
219
218 issue = assigns(:issue)
220 issue = assigns(:issue)
219 assert_not_nil issue
221 assert_not_nil issue
220
222
221 assert_equal 5, issue.status_id
223 assert_equal 5, issue.status_id
222 assert_tag :select, :attributes => { :name => 'issue[status_id]' },
224 assert_tag :select, :attributes => { :name => 'issue[status_id]' },
223 :child => { :tag => 'option',
225 :child => { :tag => 'option',
224 :content => 'Closed',
226 :content => 'Closed',
225 :attributes => { :selected => 'selected' } }
227 :attributes => { :selected => 'selected' } }
226
228
227 assert_equal 7, issue.priority_id
229 assert_equal 7, issue.priority_id
228 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
230 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
229 :child => { :tag => 'option',
231 :child => { :tag => 'option',
230 :content => 'Urgent',
232 :content => 'Urgent',
231 :attributes => { :selected => 'selected' } }
233 :attributes => { :selected => 'selected' } }
232 end
234 end
233
235
234 def test_post_edit
236 def test_post_edit
235 @request.session[:user_id] = 2
237 @request.session[:user_id] = 2
236 ActionMailer::Base.deliveries.clear
238 ActionMailer::Base.deliveries.clear
237
239
238 issue = Issue.find(1)
240 issue = Issue.find(1)
239 old_subject = issue.subject
241 old_subject = issue.subject
240 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
242 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
241
243
242 post :edit, :id => 1, :issue => {:subject => new_subject}
244 post :edit, :id => 1, :issue => {:subject => new_subject}
243 assert_redirected_to 'issues/show/1'
245 assert_redirected_to 'issues/show/1'
244 issue.reload
246 issue.reload
245 assert_equal new_subject, issue.subject
247 assert_equal new_subject, issue.subject
246
248
247 mail = ActionMailer::Base.deliveries.last
249 mail = ActionMailer::Base.deliveries.last
248 assert_kind_of TMail::Mail, mail
250 assert_kind_of TMail::Mail, mail
249 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
251 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
250 assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
252 assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
251 end
253 end
252
254
253 def test_post_edit_with_status_and_assignee_change
255 def test_post_edit_with_status_and_assignee_change
254 issue = Issue.find(1)
256 issue = Issue.find(1)
255 assert_equal 1, issue.status_id
257 assert_equal 1, issue.status_id
256 @request.session[:user_id] = 2
258 @request.session[:user_id] = 2
257 post :edit,
259 assert_difference('TimeEntry.count', 0) do
258 :id => 1,
260 post :edit,
259 :issue => { :status_id => 2, :assigned_to_id => 3 },
261 :id => 1,
260 :notes => 'Assigned to dlopper'
262 :issue => { :status_id => 2, :assigned_to_id => 3 },
263 :notes => 'Assigned to dlopper',
264 :time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
265 end
261 assert_redirected_to 'issues/show/1'
266 assert_redirected_to 'issues/show/1'
262 issue.reload
267 issue.reload
263 assert_equal 2, issue.status_id
268 assert_equal 2, issue.status_id
264 j = issue.journals.find(:first, :order => 'id DESC')
269 j = issue.journals.find(:first, :order => 'id DESC')
265 assert_equal 'Assigned to dlopper', j.notes
270 assert_equal 'Assigned to dlopper', j.notes
266 assert_equal 2, j.details.size
271 assert_equal 2, j.details.size
267
272
268 mail = ActionMailer::Base.deliveries.last
273 mail = ActionMailer::Base.deliveries.last
269 assert mail.body.include?("Status changed from New to Assigned")
274 assert mail.body.include?("Status changed from New to Assigned")
270 end
275 end
271
276
272 def test_post_edit_with_note_only
277 def test_post_edit_with_note_only
273 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
278 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
274 # anonymous user
279 # anonymous user
275 post :edit,
280 post :edit,
276 :id => 1,
281 :id => 1,
277 :notes => notes
282 :notes => notes
278 assert_redirected_to 'issues/show/1'
283 assert_redirected_to 'issues/show/1'
279 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
284 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
280 assert_equal notes, j.notes
285 assert_equal notes, j.notes
281 assert_equal 0, j.details.size
286 assert_equal 0, j.details.size
282 assert_equal User.anonymous, j.user
287 assert_equal User.anonymous, j.user
283
288
284 mail = ActionMailer::Base.deliveries.last
289 mail = ActionMailer::Base.deliveries.last
285 assert mail.body.include?(notes)
290 assert mail.body.include?(notes)
286 end
291 end
287
292
288 def test_post_edit_with_note_and_spent_time
293 def test_post_edit_with_note_and_spent_time
289 @request.session[:user_id] = 2
294 @request.session[:user_id] = 2
290 spent_hours_before = Issue.find(1).spent_hours
295 spent_hours_before = Issue.find(1).spent_hours
291 post :edit,
296 assert_difference('TimeEntry.count') do
292 :id => 1,
297 post :edit,
293 :notes => '2.5 hours added',
298 :id => 1,
294 :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
299 :notes => '2.5 hours added',
300 :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
301 end
295 assert_redirected_to 'issues/show/1'
302 assert_redirected_to 'issues/show/1'
296
303
297 issue = Issue.find(1)
304 issue = Issue.find(1)
298
305
299 j = issue.journals.find(:first, :order => 'id DESC')
306 j = issue.journals.find(:first, :order => 'id DESC')
300 assert_equal '2.5 hours added', j.notes
307 assert_equal '2.5 hours added', j.notes
301 assert_equal 0, j.details.size
308 assert_equal 0, j.details.size
302
309
303 t = issue.time_entries.find(:first, :order => 'id DESC')
310 t = issue.time_entries.find(:first, :order => 'id DESC')
304 assert_not_nil t
311 assert_not_nil t
305 assert_equal 2.5, t.hours
312 assert_equal 2.5, t.hours
306 assert_equal spent_hours_before + 2.5, issue.spent_hours
313 assert_equal spent_hours_before + 2.5, issue.spent_hours
307 end
314 end
308
315
309 def test_post_edit_with_attachment_only
316 def test_post_edit_with_attachment_only
310 # anonymous user
317 # anonymous user
311 post :edit,
318 post :edit,
312 :id => 1,
319 :id => 1,
313 :notes => '',
320 :notes => '',
314 :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
321 :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
315 assert_redirected_to 'issues/show/1'
322 assert_redirected_to 'issues/show/1'
316 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
323 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
317 assert j.notes.blank?
324 assert j.notes.blank?
318 assert_equal 1, j.details.size
325 assert_equal 1, j.details.size
319 assert_equal 'testfile.txt', j.details.first.value
326 assert_equal 'testfile.txt', j.details.first.value
320 assert_equal User.anonymous, j.user
327 assert_equal User.anonymous, j.user
321
328
322 mail = ActionMailer::Base.deliveries.last
329 mail = ActionMailer::Base.deliveries.last
323 assert mail.body.include?('testfile.txt')
330 assert mail.body.include?('testfile.txt')
324 end
331 end
325
332
326 def test_post_edit_with_no_change
333 def test_post_edit_with_no_change
327 issue = Issue.find(1)
334 issue = Issue.find(1)
328 issue.journals.clear
335 issue.journals.clear
329 ActionMailer::Base.deliveries.clear
336 ActionMailer::Base.deliveries.clear
330
337
331 post :edit,
338 post :edit,
332 :id => 1,
339 :id => 1,
333 :notes => ''
340 :notes => ''
334 assert_redirected_to 'issues/show/1'
341 assert_redirected_to 'issues/show/1'
335
342
336 issue.reload
343 issue.reload
337 assert issue.journals.empty?
344 assert issue.journals.empty?
338 # No email should be sent
345 # No email should be sent
339 assert ActionMailer::Base.deliveries.empty?
346 assert ActionMailer::Base.deliveries.empty?
340 end
347 end
341
348
342 def test_bulk_edit
349 def test_bulk_edit
343 @request.session[:user_id] = 2
350 @request.session[:user_id] = 2
344 # update issues priority
351 # update issues priority
345 post :bulk_edit, :ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => ''
352 post :bulk_edit, :ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => ''
346 assert_response 302
353 assert_response 302
347 # check that the issues were updated
354 # check that the issues were updated
348 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
355 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
349 assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
356 assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
350 end
357 end
351
358
352 def test_bulk_unassign
359 def test_bulk_unassign
353 assert_not_nil Issue.find(2).assigned_to
360 assert_not_nil Issue.find(2).assigned_to
354 @request.session[:user_id] = 2
361 @request.session[:user_id] = 2
355 # unassign issues
362 # unassign issues
356 post :bulk_edit, :ids => [1, 2], :notes => 'Bulk unassigning', :assigned_to_id => 'none'
363 post :bulk_edit, :ids => [1, 2], :notes => 'Bulk unassigning', :assigned_to_id => 'none'
357 assert_response 302
364 assert_response 302
358 # check that the issues were updated
365 # check that the issues were updated
359 assert_nil Issue.find(2).assigned_to
366 assert_nil Issue.find(2).assigned_to
360 end
367 end
361
368
362 def test_move_one_issue_to_another_project
369 def test_move_one_issue_to_another_project
363 @request.session[:user_id] = 1
370 @request.session[:user_id] = 1
364 post :move, :id => 1, :new_project_id => 2
371 post :move, :id => 1, :new_project_id => 2
365 assert_redirected_to 'projects/ecookbook/issues'
372 assert_redirected_to 'projects/ecookbook/issues'
366 assert_equal 2, Issue.find(1).project_id
373 assert_equal 2, Issue.find(1).project_id
367 end
374 end
368
375
369 def test_bulk_move_to_another_project
376 def test_bulk_move_to_another_project
370 @request.session[:user_id] = 1
377 @request.session[:user_id] = 1
371 post :move, :ids => [1, 2], :new_project_id => 2
378 post :move, :ids => [1, 2], :new_project_id => 2
372 assert_redirected_to 'projects/ecookbook/issues'
379 assert_redirected_to 'projects/ecookbook/issues'
373 # Issues moved to project 2
380 # Issues moved to project 2
374 assert_equal 2, Issue.find(1).project_id
381 assert_equal 2, Issue.find(1).project_id
375 assert_equal 2, Issue.find(2).project_id
382 assert_equal 2, Issue.find(2).project_id
376 # No tracker change
383 # No tracker change
377 assert_equal 1, Issue.find(1).tracker_id
384 assert_equal 1, Issue.find(1).tracker_id
378 assert_equal 2, Issue.find(2).tracker_id
385 assert_equal 2, Issue.find(2).tracker_id
379 end
386 end
380
387
381 def test_bulk_move_to_another_tracker
388 def test_bulk_move_to_another_tracker
382 @request.session[:user_id] = 1
389 @request.session[:user_id] = 1
383 post :move, :ids => [1, 2], :new_tracker_id => 2
390 post :move, :ids => [1, 2], :new_tracker_id => 2
384 assert_redirected_to 'projects/ecookbook/issues'
391 assert_redirected_to 'projects/ecookbook/issues'
385 assert_equal 2, Issue.find(1).tracker_id
392 assert_equal 2, Issue.find(1).tracker_id
386 assert_equal 2, Issue.find(2).tracker_id
393 assert_equal 2, Issue.find(2).tracker_id
387 end
394 end
388
395
389 def test_context_menu_one_issue
396 def test_context_menu_one_issue
390 @request.session[:user_id] = 2
397 @request.session[:user_id] = 2
391 get :context_menu, :ids => [1]
398 get :context_menu, :ids => [1]
392 assert_response :success
399 assert_response :success
393 assert_template 'context_menu'
400 assert_template 'context_menu'
394 assert_tag :tag => 'a', :content => 'Edit',
401 assert_tag :tag => 'a', :content => 'Edit',
395 :attributes => { :href => '/issues/edit/1',
402 :attributes => { :href => '/issues/edit/1',
396 :class => 'icon-edit' }
403 :class => 'icon-edit' }
397 assert_tag :tag => 'a', :content => 'Closed',
404 assert_tag :tag => 'a', :content => 'Closed',
398 :attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5',
405 :attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5',
399 :class => '' }
406 :class => '' }
400 assert_tag :tag => 'a', :content => 'Immediate',
407 assert_tag :tag => 'a', :content => 'Immediate',
401 :attributes => { :href => '/issues/edit/1?issue%5Bpriority_id%5D=8',
408 :attributes => { :href => '/issues/edit/1?issue%5Bpriority_id%5D=8',
402 :class => '' }
409 :class => '' }
403 assert_tag :tag => 'a', :content => 'Dave Lopper',
410 assert_tag :tag => 'a', :content => 'Dave Lopper',
404 :attributes => { :href => '/issues/edit/1?issue%5Bassigned_to_id%5D=3',
411 :attributes => { :href => '/issues/edit/1?issue%5Bassigned_to_id%5D=3',
405 :class => '' }
412 :class => '' }
406 assert_tag :tag => 'a', :content => 'Copy',
413 assert_tag :tag => 'a', :content => 'Copy',
407 :attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1',
414 :attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1',
408 :class => 'icon-copy' }
415 :class => 'icon-copy' }
409 assert_tag :tag => 'a', :content => 'Move',
416 assert_tag :tag => 'a', :content => 'Move',
410 :attributes => { :href => '/issues/move?ids%5B%5D=1',
417 :attributes => { :href => '/issues/move?ids%5B%5D=1',
411 :class => 'icon-move' }
418 :class => 'icon-move' }
412 assert_tag :tag => 'a', :content => 'Delete',
419 assert_tag :tag => 'a', :content => 'Delete',
413 :attributes => { :href => '/issues/destroy?ids%5B%5D=1',
420 :attributes => { :href => '/issues/destroy?ids%5B%5D=1',
414 :class => 'icon-del' }
421 :class => 'icon-del' }
415 end
422 end
416
423
417 def test_context_menu_one_issue_by_anonymous
424 def test_context_menu_one_issue_by_anonymous
418 get :context_menu, :ids => [1]
425 get :context_menu, :ids => [1]
419 assert_response :success
426 assert_response :success
420 assert_template 'context_menu'
427 assert_template 'context_menu'
421 assert_tag :tag => 'a', :content => 'Delete',
428 assert_tag :tag => 'a', :content => 'Delete',
422 :attributes => { :href => '#',
429 :attributes => { :href => '#',
423 :class => 'icon-del disabled' }
430 :class => 'icon-del disabled' }
424 end
431 end
425
432
426 def test_context_menu_multiple_issues_of_same_project
433 def test_context_menu_multiple_issues_of_same_project
427 @request.session[:user_id] = 2
434 @request.session[:user_id] = 2
428 get :context_menu, :ids => [1, 2]
435 get :context_menu, :ids => [1, 2]
429 assert_response :success
436 assert_response :success
430 assert_template 'context_menu'
437 assert_template 'context_menu'
431 assert_tag :tag => 'a', :content => 'Edit',
438 assert_tag :tag => 'a', :content => 'Edit',
432 :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;ids%5B%5D=2',
439 :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;ids%5B%5D=2',
433 :class => 'icon-edit' }
440 :class => 'icon-edit' }
434 assert_tag :tag => 'a', :content => 'Move',
441 assert_tag :tag => 'a', :content => 'Move',
435 :attributes => { :href => '/issues/move?ids%5B%5D=1&amp;ids%5B%5D=2',
442 :attributes => { :href => '/issues/move?ids%5B%5D=1&amp;ids%5B%5D=2',
436 :class => 'icon-move' }
443 :class => 'icon-move' }
437 assert_tag :tag => 'a', :content => 'Delete',
444 assert_tag :tag => 'a', :content => 'Delete',
438 :attributes => { :href => '/issues/destroy?ids%5B%5D=1&amp;ids%5B%5D=2',
445 :attributes => { :href => '/issues/destroy?ids%5B%5D=1&amp;ids%5B%5D=2',
439 :class => 'icon-del' }
446 :class => 'icon-del' }
440 end
447 end
441
448
442 def test_context_menu_multiple_issues_of_different_project
449 def test_context_menu_multiple_issues_of_different_project
443 @request.session[:user_id] = 2
450 @request.session[:user_id] = 2
444 get :context_menu, :ids => [1, 2, 4]
451 get :context_menu, :ids => [1, 2, 4]
445 assert_response :success
452 assert_response :success
446 assert_template 'context_menu'
453 assert_template 'context_menu'
447 assert_tag :tag => 'a', :content => 'Delete',
454 assert_tag :tag => 'a', :content => 'Delete',
448 :attributes => { :href => '#',
455 :attributes => { :href => '#',
449 :class => 'icon-del disabled' }
456 :class => 'icon-del disabled' }
450 end
457 end
451
458
452 def test_destroy_issue_with_no_time_entries
459 def test_destroy_issue_with_no_time_entries
453 assert_nil TimeEntry.find_by_issue_id(2)
460 assert_nil TimeEntry.find_by_issue_id(2)
454 @request.session[:user_id] = 2
461 @request.session[:user_id] = 2
455 post :destroy, :id => 2
462 post :destroy, :id => 2
456 assert_redirected_to 'projects/ecookbook/issues'
463 assert_redirected_to 'projects/ecookbook/issues'
457 assert_nil Issue.find_by_id(2)
464 assert_nil Issue.find_by_id(2)
458 end
465 end
459
466
460 def test_destroy_issues_with_time_entries
467 def test_destroy_issues_with_time_entries
461 @request.session[:user_id] = 2
468 @request.session[:user_id] = 2
462 post :destroy, :ids => [1, 3]
469 post :destroy, :ids => [1, 3]
463 assert_response :success
470 assert_response :success
464 assert_template 'destroy'
471 assert_template 'destroy'
465 assert_not_nil assigns(:hours)
472 assert_not_nil assigns(:hours)
466 assert Issue.find_by_id(1) && Issue.find_by_id(3)
473 assert Issue.find_by_id(1) && Issue.find_by_id(3)
467 end
474 end
468
475
469 def test_destroy_issues_and_destroy_time_entries
476 def test_destroy_issues_and_destroy_time_entries
470 @request.session[:user_id] = 2
477 @request.session[:user_id] = 2
471 post :destroy, :ids => [1, 3], :todo => 'destroy'
478 post :destroy, :ids => [1, 3], :todo => 'destroy'
472 assert_redirected_to 'projects/ecookbook/issues'
479 assert_redirected_to 'projects/ecookbook/issues'
473 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
480 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
474 assert_nil TimeEntry.find_by_id([1, 2])
481 assert_nil TimeEntry.find_by_id([1, 2])
475 end
482 end
476
483
477 def test_destroy_issues_and_assign_time_entries_to_project
484 def test_destroy_issues_and_assign_time_entries_to_project
478 @request.session[:user_id] = 2
485 @request.session[:user_id] = 2
479 post :destroy, :ids => [1, 3], :todo => 'nullify'
486 post :destroy, :ids => [1, 3], :todo => 'nullify'
480 assert_redirected_to 'projects/ecookbook/issues'
487 assert_redirected_to 'projects/ecookbook/issues'
481 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
488 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
482 assert_nil TimeEntry.find(1).issue_id
489 assert_nil TimeEntry.find(1).issue_id
483 assert_nil TimeEntry.find(2).issue_id
490 assert_nil TimeEntry.find(2).issue_id
484 end
491 end
485
492
486 def test_destroy_issues_and_reassign_time_entries_to_another_issue
493 def test_destroy_issues_and_reassign_time_entries_to_another_issue
487 @request.session[:user_id] = 2
494 @request.session[:user_id] = 2
488 post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
495 post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
489 assert_redirected_to 'projects/ecookbook/issues'
496 assert_redirected_to 'projects/ecookbook/issues'
490 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
497 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
491 assert_equal 2, TimeEntry.find(1).issue_id
498 assert_equal 2, TimeEntry.find(1).issue_id
492 assert_equal 2, TimeEntry.find(2).issue_id
499 assert_equal 2, TimeEntry.find(2).issue_id
493 end
500 end
494
501
495 def test_destroy_attachment
502 def test_destroy_attachment
496 issue = Issue.find(3)
503 issue = Issue.find(3)
497 a = issue.attachments.size
504 a = issue.attachments.size
498 @request.session[:user_id] = 2
505 @request.session[:user_id] = 2
499 post :destroy_attachment, :id => 3, :attachment_id => 1
506 post :destroy_attachment, :id => 3, :attachment_id => 1
500 assert_redirected_to 'issues/show/3'
507 assert_redirected_to 'issues/show/3'
501 assert_nil Attachment.find_by_id(1)
508 assert_nil Attachment.find_by_id(1)
502 issue.reload
509 issue.reload
503 assert_equal((a-1), issue.attachments.size)
510 assert_equal((a-1), issue.attachments.size)
504 j = issue.journals.find(:first, :order => 'created_on DESC')
511 j = issue.journals.find(:first, :order => 'created_on DESC')
505 assert_equal 'attachment', j.details.first.property
512 assert_equal 'attachment', j.details.first.property
506 end
513 end
507 end
514 end
@@ -1,74 +1,148
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 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 require File.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19
19
20 class QueryTest < Test::Unit::TestCase
20 class QueryTest < Test::Unit::TestCase
21 fixtures :projects, :users, :members, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries
21 fixtures :projects, :users, :members, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries
22
22
23 def test_query_with_multiple_custom_fields
23 def test_query_with_multiple_custom_fields
24 query = Query.find(1)
24 query = Query.find(1)
25 assert query.valid?
25 assert query.valid?
26 assert query.statement.include?("#{CustomValue.table_name}.value IN ('MySQL')")
26 assert query.statement.include?("#{CustomValue.table_name}.value IN ('MySQL')")
27 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
27 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
28 assert_equal 1, issues.length
28 assert_equal 1, issues.length
29 assert_equal Issue.find(3), issues.first
29 assert_equal Issue.find(3), issues.first
30 end
30 end
31
31
32 def test_operator_none
33 query = Query.new(:project => Project.find(1), :name => '_')
34 query.add_filter('fixed_version_id', '!*', [''])
35 query.add_filter('cf_1', '!*', [''])
36 assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NULL")
37 assert query.statement.include?("#{CustomValue.table_name}.value IS NULL OR #{CustomValue.table_name}.value = ''")
38 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
39 end
40
41 def test_operator_all
42 query = Query.new(:project => Project.find(1), :name => '_')
43 query.add_filter('fixed_version_id', '*', [''])
44 query.add_filter('cf_1', '*', [''])
45 assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NOT NULL")
46 assert query.statement.include?("#{CustomValue.table_name}.value IS NOT NULL AND #{CustomValue.table_name}.value <> ''")
47 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
48 end
49
50 def test_operator_greater_than
51 query = Query.new(:project => Project.find(1), :name => '_')
52 query.add_filter('done_ratio', '>=', ['40'])
53 assert query.statement.include?("#{Issue.table_name}.done_ratio >= 40")
54 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
55 end
56
57 def test_operator_in_more_than
58 query = Query.new(:project => Project.find(1), :name => '_')
59 query.add_filter('due_date', '>t+', ['15'])
60 assert query.statement.include?("#{Issue.table_name}.due_date >=")
61 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
62 end
63
64 def test_operator_in_less_than
65 query = Query.new(:project => Project.find(1), :name => '_')
66 query.add_filter('due_date', '<t+', ['15'])
67 assert query.statement.include?("#{Issue.table_name}.due_date BETWEEN")
68 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
69 end
70
71 def test_operator_today
72 query = Query.new(:project => Project.find(1), :name => '_')
73 query.add_filter('due_date', 't', [''])
74 assert query.statement.include?("#{Issue.table_name}.due_date BETWEEN")
75 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
76 end
77
78 def test_operator_this_week_on_date
79 query = Query.new(:project => Project.find(1), :name => '_')
80 query.add_filter('due_date', 'w', [''])
81 assert query.statement.include?("#{Issue.table_name}.due_date BETWEEN")
82 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
83 end
84
85 def test_operator_this_week_on_datetime
86 query = Query.new(:project => Project.find(1), :name => '_')
87 query.add_filter('created_on', 'w', [''])
88 assert query.statement.include?("#{Issue.table_name}.created_on BETWEEN")
89 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
90 end
91
92 def test_operator_contains
93 query = Query.new(:project => Project.find(1), :name => '_')
94 query.add_filter('subject', '~', ['string'])
95 assert query.statement.include?("#{Issue.table_name}.subject LIKE '%string%'")
96 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
97 end
98
99 def test_operator_does_not_contains
100 query = Query.new(:project => Project.find(1), :name => '_')
101 query.add_filter('subject', '!~', ['string'])
102 assert query.statement.include?("#{Issue.table_name}.subject NOT LIKE '%string%'")
103 issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
104 end
105
32 def test_default_columns
106 def test_default_columns
33 q = Query.new
107 q = Query.new
34 assert !q.columns.empty?
108 assert !q.columns.empty?
35 end
109 end
36
110
37 def test_set_column_names
111 def test_set_column_names
38 q = Query.new
112 q = Query.new
39 q.column_names = ['tracker', :subject, '', 'unknonw_column']
113 q.column_names = ['tracker', :subject, '', 'unknonw_column']
40 assert_equal [:tracker, :subject], q.columns.collect {|c| c.name}
114 assert_equal [:tracker, :subject], q.columns.collect {|c| c.name}
41 c = q.columns.first
115 c = q.columns.first
42 assert q.has_column?(c)
116 assert q.has_column?(c)
43 end
117 end
44
118
45 def test_editable_by
119 def test_editable_by
46 admin = User.find(1)
120 admin = User.find(1)
47 manager = User.find(2)
121 manager = User.find(2)
48 developer = User.find(3)
122 developer = User.find(3)
49
123
50 # Public query on project 1
124 # Public query on project 1
51 q = Query.find(1)
125 q = Query.find(1)
52 assert q.editable_by?(admin)
126 assert q.editable_by?(admin)
53 assert q.editable_by?(manager)
127 assert q.editable_by?(manager)
54 assert !q.editable_by?(developer)
128 assert !q.editable_by?(developer)
55
129
56 # Private query on project 1
130 # Private query on project 1
57 q = Query.find(2)
131 q = Query.find(2)
58 assert q.editable_by?(admin)
132 assert q.editable_by?(admin)
59 assert !q.editable_by?(manager)
133 assert !q.editable_by?(manager)
60 assert q.editable_by?(developer)
134 assert q.editable_by?(developer)
61
135
62 # Private query for all projects
136 # Private query for all projects
63 q = Query.find(3)
137 q = Query.find(3)
64 assert q.editable_by?(admin)
138 assert q.editable_by?(admin)
65 assert !q.editable_by?(manager)
139 assert !q.editable_by?(manager)
66 assert q.editable_by?(developer)
140 assert q.editable_by?(developer)
67
141
68 # Public query for all projects
142 # Public query for all projects
69 q = Query.find(4)
143 q = Query.find(4)
70 assert q.editable_by?(admin)
144 assert q.editable_by?(admin)
71 assert !q.editable_by?(manager)
145 assert !q.editable_by?(manager)
72 assert !q.editable_by?(developer)
146 assert !q.editable_by?(developer)
73 end
147 end
74 end
148 end
General Comments 0
You need to be logged in to leave comments. Login now