Compare commits
1821
Commits
1.0.0
..
1.2-stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e6d1b6c35 | ||
|
|
5c4b618bce | ||
|
|
2f87b3bae3 | ||
|
|
1848fcd91e | ||
|
|
40a14cafbc | ||
|
|
f252108f30 | ||
|
|
6d57380712 | ||
|
|
00d1b230e0 | ||
|
|
d19a0b70e0 | ||
|
|
535b5ccf2b | ||
|
|
a441667b8d | ||
|
|
d4246334e0 | ||
|
|
c8c48a7816 | ||
|
|
fa894328bb | ||
|
|
63e2e52dd3 | ||
|
|
ff75a959e0 | ||
|
|
5d1388db02 | ||
|
|
3e4d1fb04f | ||
|
|
2858979b69 | ||
|
|
be09ba039b | ||
|
|
a5adecb40c | ||
|
|
f328373ffd | ||
|
|
367ad46911 | ||
|
|
909cb9ab78 | ||
|
|
8c2869f521 | ||
|
|
20e54f46b0 | ||
|
|
88e918f64d | ||
|
|
b6f0d9da8a | ||
|
|
d6bf26ace7 | ||
|
|
21910aa428 | ||
|
|
f22ff1f1c2 | ||
|
|
83a2283b7d | ||
|
|
03b2162e6c | ||
|
|
c605477da5 | ||
|
|
35ec8e3570 | ||
|
|
6e68bf8ab4 | ||
|
|
d181a2221a | ||
|
|
e4034bc74b | ||
|
|
310d4c52ce | ||
|
|
1d1b3fc77d | ||
|
|
5e58434567 | ||
|
|
8da22803be | ||
|
|
83ab216d70 | ||
|
|
4104741383 | ||
|
|
6dac4a499f | ||
|
|
e0a8442b09 | ||
|
|
6dd11c9558 | ||
|
|
1608ca3d98 | ||
|
|
0ef89ee4ea | ||
|
|
4813672728 | ||
|
|
ade5409310 | ||
|
|
605f1745ff | ||
|
|
8158a26ee8 | ||
|
|
4682acf040 | ||
|
|
3955f81b3f | ||
|
|
16f56a4677 | ||
|
|
f77b83451b | ||
|
|
2f2a93c6ef | ||
|
|
5c282222a0 | ||
|
|
61b4f41539 | ||
|
|
73e27a48e0 | ||
|
|
51d7c568b0 | ||
|
|
51d772de70 | ||
|
|
86845b1989 | ||
|
|
723d60a1ce | ||
|
|
b128fcaf0d | ||
|
|
73dd0c49dd | ||
|
|
cc7274f38c | ||
|
|
d0f3b8fa4d | ||
|
|
2302955bc5 | ||
|
|
90f83db148 | ||
|
|
b6dbf26c86 | ||
|
|
8c7e0e279c | ||
|
|
6f15634e12 | ||
|
|
7e837aa34d | ||
|
|
6c89118bac | ||
|
|
260c07eb73 | ||
|
|
7914381cdd | ||
|
|
65ce05326a | ||
|
|
112c7a1b15 | ||
|
|
23a31dfe27 | ||
|
|
0dc50cb0b1 | ||
|
|
88163849b4 | ||
|
|
058f36cc6f | ||
|
|
11cf38a1a8 | ||
|
|
37d7a9d62d | ||
|
|
1b299369bf | ||
|
|
cbe42633c9 | ||
|
|
25657168b1 | ||
|
|
4852b38efc | ||
|
|
b882993d6a | ||
|
|
b6c46aa19d | ||
|
|
0903db52d9 | ||
|
|
93d256c4a8 | ||
|
|
64a68b86c6 | ||
|
|
1d79bbce44 | ||
|
|
87211bcb75 | ||
|
|
68e97858cb | ||
|
|
f5a6b0cf93 | ||
|
|
3cf0bd713d | ||
|
|
36bce52f63 | ||
|
|
94f5c73746 | ||
|
|
8b6fd63a59 | ||
|
|
ba6b822e97 | ||
|
|
b44044a76a | ||
|
|
eb3a4587c9 | ||
|
|
a8550ba8a6 | ||
|
|
0527e8cedf | ||
|
|
2a799e8367 | ||
|
|
3e9ad22fad | ||
|
|
a5bcdf6d2c | ||
|
|
3dcd5d746a | ||
|
|
971aa889f9 | ||
|
|
cdc1dfb1e7 | ||
|
|
30255b8054 | ||
|
|
97b697a678 | ||
|
|
8e87cd6f77 | ||
|
|
65bee7efa3 | ||
|
|
2325831d81 | ||
|
|
c7f8ea6a37 | ||
|
|
edc4f6d54b | ||
|
|
bf0046b5af | ||
|
|
3de4afe53a | ||
|
|
d15912eb6a | ||
|
|
656e651c33 | ||
|
|
9543e0a103 | ||
|
|
441f2f216f | ||
|
|
15228c9958 | ||
|
|
5f33a09320 | ||
|
|
7d77c3544a | ||
|
|
102c9afadf | ||
|
|
16ba6bcb77 | ||
|
|
df37e5cfab | ||
|
|
f58b86bbb8 | ||
|
|
95f68ba6d9 | ||
|
|
171c4b2747 | ||
|
|
860a6ce78d | ||
|
|
26d42c26fa | ||
|
|
c69c434609 | ||
|
|
9381d30ae8 | ||
|
|
136bf86307 | ||
|
|
07f42c53d0 | ||
|
|
22e143f0b3 | ||
|
|
1701de9123 | ||
|
|
0ce6793181 | ||
|
|
bacc44feab | ||
|
|
4f9a1cd614 | ||
|
|
44ed963a46 | ||
|
|
113316cf1e | ||
|
|
17ed97d580 | ||
|
|
19c52bc671 | ||
|
|
d15de8ee12 | ||
|
|
006c82267e | ||
|
|
887e7c6781 | ||
|
|
6280d9e9b2 | ||
|
|
3996d5f42e | ||
|
|
579abc1802 | ||
|
|
dc2efa503a | ||
|
|
0e6cdeb860 | ||
|
|
3b9ef033bf | ||
|
|
2ae54a0fc1 | ||
|
|
a87e6e1265 | ||
|
|
61b1146f9d | ||
|
|
c509c744fd | ||
|
|
1be21f2413 | ||
|
|
eaf430b630 | ||
|
|
d2789248f7 | ||
|
|
f08f09a9d3 | ||
|
|
2c2760d041 | ||
|
|
218e2f32ee | ||
|
|
f2b01aeb4d | ||
|
|
fabf54a368 | ||
|
|
6b07f86883 | ||
|
|
36d2ea9a6c | ||
|
|
2dca48be53 | ||
|
|
7678aa9445 | ||
|
|
9c355ee6c3 | ||
|
|
723030e40a | ||
|
|
e6ed112d9d | ||
|
|
1b4a5e5aff | ||
|
|
7e1f04bdfb | ||
|
|
5543ec5f5a | ||
|
|
782f7ca3bf | ||
|
|
331489e8b8 | ||
|
|
760168366e | ||
|
|
61fb6d6e10 | ||
|
|
61c5740a86 | ||
|
|
c9a3d925ca | ||
|
|
a1e3cf8218 | ||
|
|
c8309589b6 | ||
|
|
0840ad69ea | ||
|
|
2c817160ab | ||
|
|
cbd1715109 | ||
|
|
3d4a3315f6 | ||
|
|
7296315c95 | ||
|
|
eb65817ff9 | ||
|
|
f36d8cacba | ||
|
|
e4d726bde3 | ||
|
|
f1f4362b50 | ||
|
|
27a491766f | ||
|
|
fe7e8fa590 | ||
|
|
24d58543be | ||
|
|
9376f6e2c3 | ||
|
|
098655dbd0 | ||
|
|
8dc8c625f6 | ||
|
|
6fea3e997b | ||
|
|
7111bdd426 | ||
|
|
40d9d4f08c | ||
|
|
9831c27fd0 | ||
|
|
7a8552cbad | ||
|
|
59066eaa44 | ||
|
|
a913bc6a9d | ||
|
|
b2670f4650 | ||
|
|
441985fb24 | ||
|
|
04b1c974fb | ||
|
|
b86fe9a604 | ||
|
|
1150917358 | ||
|
|
966390148f | ||
|
|
5e36c24f66 | ||
|
|
7e308ae375 | ||
|
|
554c6f0d4a | ||
|
|
5d4e4f241c | ||
|
|
6eaf34c214 | ||
|
|
944829861d | ||
|
|
c42fdcd26a | ||
|
|
fb41e3dab4 | ||
|
|
6f0de178f9 | ||
|
|
3660e28c05 | ||
|
|
c5554dd65e | ||
|
|
71088ed847 | ||
|
|
1f0ddc3199 | ||
|
|
574511fced | ||
|
|
5b8dfe0372 | ||
|
|
4eb3af53d0 | ||
|
|
22e80f04ae | ||
|
|
e357057559 | ||
|
|
6f8e3c031f | ||
|
|
32cb715db9 | ||
|
|
da5140b1ac | ||
|
|
c810b9db9c | ||
|
|
01c5311662 | ||
|
|
f2e5b62448 | ||
|
|
fdea829952 | ||
|
|
4e8fab3206 | ||
|
|
817f185e57 | ||
|
|
274bd27c54 | ||
|
|
42a367b258 | ||
|
|
2d7ce91e80 | ||
|
|
07fe60b639 | ||
|
|
435e9b326c | ||
|
|
de13c0007b | ||
|
|
1122fd0e6a | ||
|
|
a955a5140b | ||
|
|
5e1576b8b4 | ||
|
|
dfa509b69e | ||
|
|
3ec87dd73f | ||
|
|
d3a953450e | ||
|
|
13e64ba624 | ||
|
|
0aaa2b1b87 | ||
|
|
6a5c9ed3c7 | ||
|
|
596670d615 | ||
|
|
97abb12aeb | ||
|
|
674a61dc8e | ||
|
|
b829acfb4a | ||
|
|
0f245c0e56 | ||
|
|
b3ffd36c56 | ||
|
|
7f8a73e60d | ||
|
|
4c963cc9dc | ||
|
|
7ca5a4939e | ||
|
|
b0f5d3cd88 | ||
|
|
39930c3f4d | ||
|
|
763931d584 | ||
|
|
d3d9830936 | ||
|
|
5d8bb7904c | ||
|
|
2cab592b20 | ||
|
|
e5606c8d32 | ||
|
|
be7cfb949d | ||
|
|
06bd7e35c6 | ||
|
|
bfe1993758 | ||
|
|
38d5925d70 | ||
|
|
4ea8f1637c | ||
|
|
d65c3d438d | ||
|
|
625b7d9051 | ||
|
|
13a5032dbe | ||
|
|
042a7661e3 | ||
|
|
4cbe231c8c | ||
|
|
57c5b4ea74 | ||
|
|
ab430a13b5 | ||
|
|
d21b35d32a | ||
|
|
5ca257181f | ||
|
|
4ee79a60ef | ||
|
|
9888f13eb0 | ||
|
|
ee3cf64d52 | ||
|
|
b8850ca9d6 | ||
|
|
30aecd5e25 | ||
|
|
3e2a67be4f | ||
|
|
12565cc1ee | ||
|
|
03ce61bb99 | ||
|
|
ac3845daaf | ||
|
|
bc06f85cb3 | ||
|
|
1a947a1617 | ||
|
|
9c09b74dff | ||
|
|
b5130b17a0 | ||
|
|
fa5f4ff77a | ||
|
|
850059d0cf | ||
|
|
6520d484bf | ||
|
|
cddc5f70a3 | ||
|
|
092cfc0229 | ||
|
|
9121a060a5 | ||
|
|
1d78dd8324 | ||
|
|
16c0b67941 | ||
|
|
398f6dd2fc | ||
|
|
b85517ae2a | ||
|
|
392a7c3bc2 | ||
|
|
308c24104b | ||
|
|
e5e8f889f5 | ||
|
|
3907900ec6 | ||
|
|
26684541c1 | ||
|
|
8ce41f900f | ||
|
|
0a07cec7bd | ||
|
|
d9e549fa4d | ||
|
|
2c993df47d | ||
|
|
8dba849a89 | ||
|
|
d778281881 | ||
|
|
ed6618a4eb | ||
|
|
e96bf8adfe | ||
|
|
76051ab4b2 | ||
|
|
653884f27b | ||
|
|
5fe5e3dba3 | ||
|
|
77b102c3df | ||
|
|
2714f6bcac | ||
|
|
0418774f50 | ||
|
|
f3a069281e | ||
|
|
b97087bad5 | ||
|
|
29f6dd2a9e | ||
|
|
3b50809423 | ||
|
|
5742f78bd1 | ||
|
|
ba2fb5340e | ||
|
|
48a6fb45a7 | ||
|
|
e25dd95389 | ||
|
|
a5d528c6c2 | ||
|
|
32a52a6540 | ||
|
|
0681d086e2 | ||
|
|
23a27bd6e4 | ||
|
|
e28ac7f880 | ||
|
|
a05a2e0c4d | ||
|
|
615c81f3df | ||
|
|
e68206852e | ||
|
|
ab768cecdd | ||
|
|
c29bc896cc | ||
|
|
f289d4e354 | ||
|
|
1952439ea0 | ||
|
|
12bad10573 | ||
|
|
9cb76de334 | ||
|
|
3a5cf54128 | ||
|
|
541a56d6e8 | ||
|
|
099c8a6608 | ||
|
|
6eb8b5fb4a | ||
|
|
02b43944e3 | ||
|
|
673fe7f372 | ||
|
|
99693d644c | ||
|
|
4fe71148f6 | ||
|
|
cccbee024e | ||
|
|
fa1fe47191 | ||
|
|
5c2c85a68a | ||
|
|
ff6a86364e | ||
|
|
c5257f6e0d | ||
|
|
c4b58726e6 | ||
|
|
ab6b848304 | ||
|
|
f157ecb91a | ||
|
|
e78bc574c2 | ||
|
|
2c08b71e8f | ||
|
|
20f5b6b45d | ||
|
|
9c01d83951 | ||
|
|
5da0151bfb | ||
|
|
bd26c9666d | ||
|
|
9f8ede65b5 | ||
|
|
530151e1d9 | ||
|
|
dc8968b03e | ||
|
|
ed296ec9c6 | ||
|
|
f69572b956 | ||
|
|
1194235faa | ||
|
|
e9e477426a | ||
|
|
2db0475454 | ||
|
|
6d75ac6560 | ||
|
|
dafdcf3879 | ||
|
|
a49339c646 | ||
|
|
19098302ea | ||
|
|
59d82995fe | ||
|
|
e6fe554d43 | ||
|
|
e6e0578d29 | ||
|
|
479d9380a7 | ||
|
|
2711f4c745 | ||
|
|
773b248669 | ||
|
|
1ea1606007 | ||
|
|
0d942beb49 | ||
|
|
c33be450e7 | ||
|
|
114e3f3b82 | ||
|
|
03fb61a782 | ||
|
|
12f4b8b6d9 | ||
|
|
931fd58de6 | ||
|
|
fbdbdf96fe | ||
|
|
9c3a9fdd87 | ||
|
|
919bf61cae | ||
|
|
973f3eb50e | ||
|
|
c17a78c771 | ||
|
|
6f4461830c | ||
|
|
86d9ea32db | ||
|
|
2336093739 | ||
|
|
a7c178f6a6 | ||
|
|
19a9cba214 | ||
|
|
193af67f99 | ||
|
|
18df827244 | ||
|
|
97b4ee2fef | ||
|
|
905a809774 | ||
|
|
8df05b9a6d | ||
|
|
741967ae68 | ||
|
|
bba6199e51 | ||
|
|
4924b99ff9 | ||
|
|
20c6dfd1af | ||
|
|
84b5a6e7b5 | ||
|
|
fb6c9a1396 | ||
|
|
956e8af591 | ||
|
|
d6a483684b | ||
|
|
7575989c78 | ||
|
|
ee7fe09b1e | ||
|
|
ff77ecee86 | ||
|
|
69bb041c46 | ||
|
|
19c6266a7d | ||
|
|
cd34602b4f | ||
|
|
7fa85fabae | ||
|
|
5dbaffd094 | ||
|
|
7ada45d3a2 | ||
|
|
ca5ce92cfc | ||
|
|
18d0618007 | ||
|
|
0a132e48f9 | ||
|
|
ed7091cda1 | ||
|
|
8632efcce2 | ||
|
|
bd4af1b9cb | ||
|
|
daeebe144a | ||
|
|
f64666f4b4 | ||
|
|
8d67224fe1 | ||
|
|
46bd78aa21 | ||
|
|
880e8e575a | ||
|
|
93fabf23ae | ||
|
|
fdb0151869 | ||
|
|
88a93d7e10 | ||
|
|
c9f31f0332 | ||
|
|
fb0641d43f | ||
|
|
c47144a14f | ||
|
|
67c85251c3 | ||
|
|
57f63d513c | ||
|
|
07df1242b9 | ||
|
|
4673f0cf31 | ||
|
|
fab9aca747 | ||
|
|
02c5577a26 | ||
|
|
f62605c636 | ||
|
|
ed3efeb960 | ||
|
|
0566e453e1 | ||
|
|
c5195c8972 | ||
|
|
363d9de8bb | ||
|
|
828ce5d227 | ||
|
|
d5b97d49c6 | ||
|
|
d3737db6b5 | ||
|
|
1721148bae | ||
|
|
ba807648ea | ||
|
|
ef4219b9f5 | ||
|
|
c2503bc56c | ||
|
|
6da0d5d366 | ||
|
|
d1eb1fb07d | ||
|
|
20c6a278ad | ||
|
|
f4745d4960 | ||
|
|
3597c8b909 | ||
|
|
92023176b8 | ||
|
|
fb9fed39fe | ||
|
|
f29a4dd6c5 | ||
|
|
80d126d003 | ||
|
|
7fe397e8fd | ||
|
|
c2b0a5bee0 | ||
|
|
f7bed294c1 | ||
|
|
d03de4449f | ||
|
|
058766b92a | ||
|
|
592825d241 | ||
|
|
7e77d5ddf9 | ||
|
|
fbde32341e | ||
|
|
8749b98b93 | ||
|
|
25d6ed38b6 | ||
|
|
50cb5921b5 | ||
|
|
7e3de248c3 | ||
|
|
36eac0dc8d | ||
|
|
82d5de4b4e | ||
|
|
8696835b42 | ||
|
|
7ad046f53d | ||
|
|
8c853fe66f | ||
|
|
794abbf324 | ||
|
|
2a2e6d71e3 | ||
|
|
582b3a0008 | ||
|
|
f97b9ea02c | ||
|
|
379503b591 | ||
|
|
bb929f4f75 | ||
|
|
d67e4ff2f4 | ||
|
|
a20a75817e | ||
|
|
2dc0875a72 | ||
|
|
6d0f8f1db9 | ||
|
|
109b248e9c | ||
|
|
479f6674da | ||
|
|
97677748ba | ||
|
|
f164adfb50 | ||
|
|
3c4eb22b99 | ||
|
|
031af32770 | ||
|
|
80e4ad63bd | ||
|
|
79fb4a4c35 | ||
|
|
8dcde8fc59 | ||
|
|
3b22d12c9c | ||
|
|
32cec1b172 | ||
|
|
fab0344286 | ||
|
|
346cee061f | ||
|
|
c7228b260f | ||
|
|
f0dfff4866 | ||
|
|
3aaaddb52a | ||
|
|
f89d04074e | ||
|
|
a96f7053fc | ||
|
|
d6e6871e29 | ||
|
|
241d8534f4 | ||
|
|
2589d61bab | ||
|
|
f9d1426f58 | ||
|
|
10977749af | ||
|
|
76209a54ed | ||
|
|
1a19a0d4bf | ||
|
|
e2843a4b71 | ||
|
|
ef999320bb | ||
|
|
67e414dbd3 | ||
|
|
c194cdef2c | ||
|
|
c87d171c12 | ||
|
|
94f71773b6 | ||
|
|
79b7e89cf9 | ||
|
|
a8e7936337 | ||
|
|
c80fe134f5 | ||
|
|
eb4ca1ac29 | ||
|
|
a7c510fd0a | ||
|
|
5512e397ee | ||
|
|
a78b12706a | ||
|
|
2507bcd8e7 | ||
|
|
d7fccb0d8e | ||
|
|
dab753ba28 | ||
|
|
5f8c4e0703 | ||
|
|
e788ae7015 | ||
|
|
6c8708f7e2 | ||
|
|
2043096011 | ||
|
|
f16cddd57a | ||
|
|
37205a8991 | ||
|
|
da2c511cd1 | ||
|
|
c84d2e6699 | ||
|
|
991d39a9ac | ||
|
|
eae0620e3a | ||
|
|
50fe1ecc18 | ||
|
|
80e2eed702 | ||
|
|
5beef16378 | ||
|
|
910d85be47 | ||
|
|
04a22fa757 | ||
|
|
bebf8247a7 | ||
|
|
7e5bc046d6 | ||
|
|
19d524cdad | ||
|
|
a20f140734 | ||
|
|
d43bc98a49 | ||
|
|
b091c98238 | ||
|
|
12c856124b | ||
|
|
cc534137ba | ||
|
|
1cd4f5b353 | ||
|
|
6968d0da19 | ||
|
|
7cdb4f2a87 | ||
|
|
b344456b6f | ||
|
|
ffd0a9c72c | ||
|
|
1242e448f3 | ||
|
|
949b355ef2 | ||
|
|
f0d32f6567 | ||
|
|
0ceeecc854 | ||
|
|
bc6b219fc9 | ||
|
|
df04f56891 | ||
|
|
d09e496a57 | ||
|
|
20b33942ba | ||
|
|
cad14abea7 | ||
|
|
37c6480e44 | ||
|
|
fbf23a14b8 | ||
|
|
c4616e0ae0 | ||
|
|
3bff6eb660 | ||
|
|
a7aee902f2 | ||
|
|
5bb06ae42d | ||
|
|
bb48d96d30 | ||
|
|
62952a9885 | ||
|
|
340cf8204c | ||
|
|
34f1bc0f08 | ||
|
|
3cc7353093 | ||
|
|
6db0e8dcef | ||
|
|
ae16fb3e5f | ||
|
|
6b44d1b27e | ||
|
|
6fad67c887 | ||
|
|
3991d08858 | ||
|
|
c52f928f35 | ||
|
|
aa0d01b3d9 | ||
|
|
5fd891aa72 | ||
|
|
5b9655ab8e | ||
|
|
0b68a74fc7 | ||
|
|
e9a33eff14 | ||
|
|
9df194ff16 | ||
|
|
0a0819f81e | ||
|
|
28a8d62fe4 | ||
|
|
ae2304449b | ||
|
|
9287f3cf73 | ||
|
|
4bf5c42b2b | ||
|
|
7b72dc874d | ||
|
|
32a9937d4e | ||
|
|
0606dfdb62 | ||
|
|
a5384e4e88 | ||
|
|
a6798d6cc2 | ||
|
|
4491f71441 | ||
|
|
91dc3245dd | ||
|
|
d595bed7ef | ||
|
|
25aa4d4fa0 | ||
|
|
064e8476e8 | ||
|
|
717e2a0a9f | ||
|
|
51242b967d | ||
|
|
71360a0f66 | ||
|
|
f86779bd59 | ||
|
|
4c3d8b681b | ||
|
|
39c7f2942c | ||
|
|
5778d3c51e | ||
|
|
f690341d9e | ||
|
|
bf68788867 | ||
|
|
d5bb4b349a | ||
|
|
3be326f0a4 | ||
|
|
85b891ec9e | ||
|
|
ce6377b406 | ||
|
|
ed8b82b012 | ||
|
|
bac26830e5 | ||
|
|
c6ec41473e | ||
|
|
572af75c6e | ||
|
|
003460e77a | ||
|
|
740051b769 | ||
|
|
18431d3681 | ||
|
|
cae3fcce54 | ||
|
|
f31df6c02f | ||
|
|
6536c53e09 | ||
|
|
b9ce061319 | ||
|
|
c12453ec4e | ||
|
|
1104c3900c | ||
|
|
c711ead46c | ||
|
|
1b0473c38e | ||
|
|
e297c1c244 | ||
|
|
1ef54041da | ||
|
|
fee9d605a3 | ||
|
|
3bc9972d5e | ||
|
|
b30ece064b | ||
|
|
d21f7fe1bf | ||
|
|
46d970a552 | ||
|
|
ce3a03f4e8 | ||
|
|
bb2aec653d | ||
|
|
fd316c99fa | ||
|
|
1ee96293c3 | ||
|
|
1a454b8f39 | ||
|
|
c2d2761caa | ||
|
|
d0ea5fae62 | ||
|
|
406aa946e5 | ||
|
|
5eea9ec61a | ||
|
|
2f2cdfd96a | ||
|
|
561f6bb6d1 | ||
|
|
b23bf1f299 | ||
|
|
2e0fdb39ef | ||
|
|
d6e2e81f0c | ||
|
|
411c7100cb | ||
|
|
a4bad14359 | ||
|
|
470ff0c6e5 | ||
|
|
73a248530a | ||
|
|
7f923cdc66 | ||
|
|
7ca82846fc | ||
|
|
d20bc57be0 | ||
|
|
91e4d7d298 | ||
|
|
00277a2a0a | ||
|
|
44214ed1aa | ||
|
|
5823481d6e | ||
|
|
47dccc53b3 | ||
|
|
c41a3ace07 | ||
|
|
c9a3700cfc | ||
|
|
5f7f69e214 | ||
|
|
2b8d32a30e | ||
|
|
8cf42fabf6 | ||
|
|
da6c149275 | ||
|
|
405fc07e90 | ||
|
|
c2095f5e2f | ||
|
|
13eea4266e | ||
|
|
e3dae9ddbf | ||
|
|
1af6527e42 | ||
|
|
efccc61d79 | ||
|
|
1eab530e92 | ||
|
|
098fabd6ce | ||
|
|
c2baf187ac | ||
|
|
2029df01ae | ||
|
|
8a31517288 | ||
|
|
ab31a114fd | ||
|
|
f6c5426605 | ||
|
|
70a641c9bc | ||
|
|
87945f2ff5 | ||
|
|
3b20bd76a8 | ||
|
|
6d13ed58db | ||
|
|
d435195764 | ||
|
|
846ac262ec | ||
|
|
3c06f66d71 | ||
|
|
87bcb21563 | ||
|
|
01fed468fa | ||
|
|
0f0fbeb26d | ||
|
|
7bca8c4212 | ||
|
|
4ab4c21890 | ||
|
|
70ec78d013 | ||
|
|
b0ade644d6 | ||
|
|
90ed078445 | ||
|
|
dfe83ffa91 | ||
|
|
afbd83d404 | ||
|
|
8cd93159d6 | ||
|
|
80b59f3cf4 | ||
|
|
859e8ae828 | ||
|
|
2b899b73ad | ||
|
|
bc5be82683 | ||
|
|
eda002d0df | ||
|
|
737247f4c9 | ||
|
|
2c4cc25433 | ||
|
|
6550ef9df5 | ||
|
|
b972b5a647 | ||
|
|
4e7835c68c | ||
|
|
516320e82b | ||
|
|
063ae06b09 | ||
|
|
a669dfbd7f | ||
|
|
25ea0f34a6 | ||
|
|
4641716771 | ||
|
|
a80b909cc8 | ||
|
|
cf8d195929 | ||
|
|
c6e34b0c11 | ||
|
|
2be6f54f23 | ||
|
|
1cd6a2aa84 | ||
|
|
122ba564b9 | ||
|
|
10f66e425e | ||
|
|
f96d7ce8e0 | ||
|
|
dbe71b4f3b | ||
|
|
3ec97f951e | ||
|
|
8b39f62a4c | ||
|
|
b12994e12e | ||
|
|
64c026e34e | ||
|
|
dafb0b1227 | ||
|
|
706485aaec | ||
|
|
4d0cc94d91 | ||
|
|
325af8d48c | ||
|
|
988841d69a | ||
|
|
8db478808d | ||
|
|
404ba921e2 | ||
|
|
56a7ff0bc7 | ||
|
|
2d97a7453b | ||
|
|
8b0144248c | ||
|
|
b257ad1457 | ||
|
|
000cf8fa9e | ||
|
|
b9b2f24540 | ||
|
|
aff157f0a0 | ||
|
|
ad5dcaf179 | ||
|
|
22e8d9b949 | ||
|
|
13d6b3129b | ||
|
|
af968bfb22 | ||
|
|
ba0c9069ed | ||
|
|
1c03b418e1 | ||
|
|
2d3f69f8b1 | ||
|
|
f7edfe7652 | ||
|
|
9730ff2225 | ||
|
|
bf58ad61e5 | ||
|
|
70d765e906 | ||
|
|
393df388fc | ||
|
|
86eed08fbf | ||
|
|
927a6b045e | ||
|
|
e6a425dd72 | ||
|
|
d42ce927c7 | ||
|
|
96ff8ef4bc | ||
|
|
08f44b67f5 | ||
|
|
100a53d240 | ||
|
|
78af4f429f | ||
|
|
3ef5daaf35 | ||
|
|
4f9d3f80c4 | ||
|
|
a2baf9f695 | ||
|
|
ca5951b4f6 | ||
|
|
590cc111fc | ||
|
|
7ec605fe04 | ||
|
|
437c5658d7 | ||
|
|
f6ac158de9 | ||
|
|
69311c9d2f | ||
|
|
023a0efa10 | ||
|
|
c58c14cc73 | ||
|
|
91b1f9be51 | ||
|
|
5d72122039 | ||
|
|
c17ff5f024 | ||
|
|
4d7e61c49e | ||
|
|
5a5cb39de0 | ||
|
|
26a82965f0 | ||
|
|
f15b12556f | ||
|
|
cb297048df | ||
|
|
7ba5b27d09 | ||
|
|
d43493fc79 | ||
|
|
fb0d24d37e | ||
|
|
53b41950d1 | ||
|
|
79eba572af | ||
|
|
0597adfe53 | ||
|
|
9000cdbf2f | ||
|
|
d5ee82cea9 | ||
|
|
9e191adcae | ||
|
|
bf251a586b | ||
|
|
ec2fd81f7b | ||
|
|
002ff62e33 | ||
|
|
b9bfb0f117 | ||
|
|
d590a5583b | ||
|
|
e580dbc6a3 | ||
|
|
e6cbb1cd6b | ||
|
|
3f3b6c8fd2 | ||
|
|
f161d1833c | ||
|
|
f1a4867fce | ||
|
|
dc63efa535 | ||
|
|
bda4f7b6ee | ||
|
|
95c7140cdf | ||
|
|
53ad42e1d8 | ||
|
|
3d551f97e1 | ||
|
|
3acae2529e | ||
|
|
679e40dfb4 | ||
|
|
2ac4ea11a5 | ||
|
|
631de456f4 | ||
|
|
e1ae0e9777 | ||
|
|
82538dd07e | ||
|
|
f655353f64 | ||
|
|
0b3f2bc650 | ||
|
|
f279b48288 | ||
|
|
85462261ac | ||
|
|
e53c8cfc1b | ||
|
|
6424155f59 | ||
|
|
50cb77cfbb | ||
|
|
88dc1412d7 | ||
|
|
2201a343e4 | ||
|
|
3ea7b9a768 | ||
|
|
08429506c5 | ||
|
|
09996c3524 | ||
|
|
e6e4256ee4 | ||
|
|
a9d089dbcb | ||
|
|
899d1d8acb | ||
|
|
f065c6f461 | ||
|
|
8d0d1d50cc | ||
|
|
c051572070 | ||
|
|
b404ba776f | ||
|
|
4923ff76fa | ||
|
|
e27866be5b | ||
|
|
0502df816d | ||
|
|
e904a5aae6 | ||
|
|
9df5750906 | ||
|
|
64be81a433 | ||
|
|
a8ccddc289 | ||
|
|
a08c64e11f | ||
|
|
899d410e0b | ||
|
|
0786b9ef99 | ||
|
|
7ffdd961e9 | ||
|
|
16b02fcfad | ||
|
|
2a161b4576 | ||
|
|
20fa628de5 | ||
|
|
bae1763a09 | ||
|
|
de5c337df2 | ||
|
|
83df013f47 | ||
|
|
fba3d5d327 | ||
|
|
5f889932b6 | ||
|
|
b6dfa0b081 | ||
|
|
1ec3f1c696 | ||
|
|
dbb0d880a7 | ||
|
|
78f11a232f | ||
|
|
3328a1fc37 | ||
|
|
36dbb3906b | ||
|
|
6f5ffce799 | ||
|
|
208d2d4090 | ||
|
|
d317aec3ef | ||
|
|
3285a721b1 | ||
|
|
cf2b4d49f0 | ||
|
|
6702b26515 | ||
|
|
8944150ace | ||
|
|
59c791b2e1 | ||
|
|
081a90701a | ||
|
|
29c1aadbb5 | ||
|
|
c8ce22c275 | ||
|
|
a5e55a9053 | ||
|
|
cb2dc02a67 | ||
|
|
3c3e16e022 | ||
|
|
953e8e0f72 | ||
|
|
f3822e18bd | ||
|
|
7e96ea617c | ||
|
|
620e428e95 | ||
|
|
cbe59c5990 | ||
|
|
5abec74de3 | ||
|
|
5edc631791 | ||
|
|
bf6ec48bea | ||
|
|
0445c1e9cb | ||
|
|
7927bc2d89 | ||
|
|
8d641203d4 | ||
|
|
d48a7e148e | ||
|
|
e4103aab16 | ||
|
|
a340b17d80 | ||
|
|
59bf5cea6e | ||
|
|
9375f1c3a4 | ||
|
|
72d6b2c8df | ||
|
|
b914a3648a | ||
|
|
2e2055c051 | ||
|
|
7db930f1b4 | ||
|
|
1423890735 | ||
|
|
b8b35ab05f | ||
|
|
f7127e9466 | ||
|
|
fcf0162c8d | ||
|
|
d96fd25e64 | ||
|
|
21c79827ff | ||
|
|
099ba68836 | ||
|
|
0d63e9e8fd | ||
|
|
cb8c2d59bf | ||
|
|
542e0cb88d | ||
|
|
732ee35b2f | ||
|
|
651976eebd | ||
|
|
45cba97088 | ||
|
|
eea06ab770 | ||
|
|
bf032661f7 | ||
|
|
b5bf2fb322 | ||
|
|
d3d7ea08f4 | ||
|
|
f41848fda4 | ||
|
|
28feb58754 | ||
|
|
ef189164bf | ||
|
|
11c660e91f | ||
|
|
ec8d9a7911 | ||
|
|
b1cc8511c7 | ||
|
|
2ebaf1372d | ||
|
|
c072d3b62f | ||
|
|
6dc57e752d | ||
|
|
b235e36946 | ||
|
|
74f44a5b6a | ||
|
|
f9717c0bda | ||
|
|
16be7f2e30 | ||
|
|
779cab05f8 | ||
|
|
45239fcb0a | ||
|
|
f36f5d0fee | ||
|
|
4f5f98220e | ||
|
|
15ebb42579 | ||
|
|
084bdd7559 | ||
|
|
4e0031a8f0 | ||
|
|
de71851e98 | ||
|
|
266e33b5f1 | ||
|
|
d5b268129c | ||
|
|
e2adda86c2 | ||
|
|
7d47bf8a7f | ||
|
|
7c7bbf6d18 | ||
|
|
71ac6a29f0 | ||
|
|
cc6931f58d | ||
|
|
d0324858c1 | ||
|
|
c95e4fbea9 | ||
|
|
c381ce10e4 | ||
|
|
3abdd84a49 | ||
|
|
3a39fc6176 | ||
|
|
d03dd88717 | ||
|
|
6d763215a9 | ||
|
|
9294fb4699 | ||
|
|
0e32fcf93e | ||
|
|
04aca2fcb9 | ||
|
|
dc4ab44938 | ||
|
|
7e6a5ec7ab | ||
|
|
c809c0c498 | ||
|
|
c4b84ec510 | ||
|
|
5086bc4383 | ||
|
|
32bd4ec0b4 | ||
|
|
10830d4dd3 | ||
|
|
08ee6a3932 | ||
|
|
3c0fdd4938 | ||
|
|
a1364ed2b8 | ||
|
|
daac76f1b6 | ||
|
|
5aca773ff9 | ||
|
|
984cb589ef | ||
|
|
30063d14c1 | ||
|
|
5d9962751c | ||
|
|
3a56e1eeab | ||
|
|
90d4447bd3 | ||
|
|
fce4dcb5a6 | ||
|
|
827efee243 | ||
|
|
334132289c | ||
|
|
0df520961c | ||
|
|
3beebe7409 | ||
|
|
372cd6e44e | ||
|
|
5b01b3d594 | ||
|
|
e41b76b459 | ||
|
|
923d1f831f | ||
|
|
7257eabfc0 | ||
|
|
8fb446e87f | ||
|
|
36009de154 | ||
|
|
8d3773e0e1 | ||
|
|
2aff1749ae | ||
|
|
82c670ba03 | ||
|
|
17219baa62 | ||
|
|
d8e1af6156 | ||
|
|
53249469a0 | ||
|
|
b7dffa44c9 | ||
|
|
32e69dcaca | ||
|
|
5c3caf2e6b | ||
|
|
923558e45c | ||
|
|
71aac2e3fe | ||
|
|
cc210c58a4 | ||
|
|
bc09628249 | ||
|
|
c3e8fc5f1a | ||
|
|
a79c89eb3c | ||
|
|
0220e7db3b | ||
|
|
b59becdfbc | ||
|
|
d245102e97 | ||
|
|
ee0d7d9bf0 | ||
|
|
270dda120c | ||
|
|
5f5dec16f2 | ||
|
|
c09b6edaf4 | ||
|
|
165ab7e6c3 | ||
|
|
f2c750c3e9 | ||
|
|
984283dde9 | ||
|
|
089c23f228 | ||
|
|
e7cc1f4b4b | ||
|
|
026c9e87c0 | ||
|
|
571ecf07e3 | ||
|
|
93bc9b17a9 | ||
|
|
e1eafe3b25 | ||
|
|
eb1271bb44 | ||
|
|
06c9eea67a | ||
|
|
06f078a813 | ||
|
|
7664892b5d | ||
|
|
f03e338880 | ||
|
|
d7aa303a5c | ||
|
|
c781cbb2f7 | ||
|
|
5d0869bcde | ||
|
|
186a64c557 | ||
|
|
5f44bf1e7a | ||
|
|
2627419131 | ||
|
|
ca807c8d92 | ||
|
|
d06f4d013d | ||
|
|
2d115bbe70 | ||
|
|
a78d565959 | ||
|
|
e1ad561cf6 | ||
|
|
2b80f46361 | ||
|
|
ead20ec2e5 | ||
|
|
af8689db98 | ||
|
|
9a8c88ec0a | ||
|
|
8bdf73882e | ||
|
|
3a20d13262 | ||
|
|
61667a2171 | ||
|
|
9937ac677f | ||
|
|
4bf84ca468 | ||
|
|
a2e47f9fba | ||
|
|
e51aeb5a40 | ||
|
|
f27637b07c | ||
|
|
ce84bb1a01 | ||
|
|
3ab981c04c | ||
|
|
0edde5da92 | ||
|
|
d671b11641 | ||
|
|
a93d6a1621 | ||
|
|
f8da0127f7 | ||
|
|
494c2b5007 | ||
|
|
35f075d8ad | ||
|
|
7dfd0bf679 | ||
|
|
bb248fb037 | ||
|
|
87a6d79b5b | ||
|
|
9f50e63583 | ||
|
|
4257b1d9ad | ||
|
|
c37f638912 | ||
|
|
d43284ba04 | ||
|
|
1d6fbe5602 | ||
|
|
11e4c5c1ea | ||
|
|
1236e037f2 | ||
|
|
069d057143 | ||
|
|
496f22e422 | ||
|
|
d78fa206c2 | ||
|
|
727ce783c0 | ||
|
|
e68507265e | ||
|
|
2f7084f7a2 | ||
|
|
111ae3c2e9 | ||
|
|
4abdc0f225 | ||
|
|
40f2d5a995 | ||
|
|
a11e3a85d6 | ||
|
|
0efc783a7e | ||
|
|
a189b4b377 | ||
|
|
8963579be3 | ||
|
|
ca3b503478 | ||
|
|
c35a79ab44 | ||
|
|
317c35c36b | ||
|
|
ea33418828 | ||
|
|
17591a3ea5 | ||
|
|
11c72f2823 | ||
|
|
842968f636 | ||
|
|
7a9136f93a | ||
|
|
3e463c4e69 | ||
|
|
4b096e9a56 | ||
|
|
7ddb1c694a | ||
|
|
20a54f1ef5 | ||
|
|
fdff8d6b9c | ||
|
|
e29b99c67e | ||
|
|
490ad9eeb8 | ||
|
|
58f5d3ab09 | ||
|
|
f357912d21 | ||
|
|
329b2aa263 | ||
|
|
1c5cd49cd2 | ||
|
|
915107a0ec | ||
|
|
af01f5259b | ||
|
|
824adaf30c | ||
|
|
a092f5e0b9 | ||
|
|
3861214ccc | ||
|
|
537c53f869 | ||
|
|
c6e1d4f39d | ||
|
|
96f82be2f4 | ||
|
|
190d288381 | ||
|
|
0833abd9e5 | ||
|
|
68fe853477 | ||
|
|
8c9be39350 | ||
|
|
25d642e0ea | ||
|
|
0247a149c4 | ||
|
|
0b19757303 | ||
|
|
0e0a8c01ea | ||
|
|
b3c517387a | ||
|
|
d393306a0c | ||
|
|
b6f12e28d7 | ||
|
|
55fdc23981 | ||
|
|
628130ef5c | ||
|
|
a3a9661da6 | ||
|
|
17f1b1d0bc | ||
|
|
bd9a3a720c | ||
|
|
66c979d63c | ||
|
|
7a3d385b8e | ||
|
|
0a87041504 | ||
|
|
0185d23c54 | ||
|
|
1f836a1d43 | ||
|
|
05210f18ed | ||
|
|
4b1e16e13b | ||
|
|
671b16f898 | ||
|
|
700577c533 | ||
|
|
724afdf49d | ||
|
|
862058795f | ||
|
|
5274230fda | ||
|
|
8acdda9816 | ||
|
|
08ed9cb5d5 | ||
|
|
4fe8259017 | ||
|
|
ef3fbeeaa0 | ||
|
|
2c4836cbae | ||
|
|
202ebe1d12 | ||
|
|
109afa7881 | ||
|
|
82c6d84de8 | ||
|
|
ee8ae3c09b | ||
|
|
f66b53577f | ||
|
|
a6fad1eb66 | ||
|
|
ec9eb44d6b | ||
|
|
aed08706e0 | ||
|
|
0d5d93343e | ||
|
|
9a3ae4cee5 | ||
|
|
2547e57168 | ||
|
|
2afc8e8c95 | ||
|
|
50bbb97848 | ||
|
|
a9429df880 | ||
|
|
4f1b1d9242 | ||
|
|
e3b3152a5d | ||
|
|
05f260da65 | ||
|
|
5d026d6fd3 | ||
|
|
41f190e8ed | ||
|
|
60d80653ba | ||
|
|
9c1db1e545 | ||
|
|
cc4e8fe0d6 | ||
|
|
8b98c05879 | ||
|
|
8b5ebd92c9 | ||
|
|
3493bb1d37 | ||
|
|
4957f91639 | ||
|
|
2a11abdcfc | ||
|
|
4caca2492b | ||
|
|
da43c0ddc6 | ||
|
|
632151dfff | ||
|
|
cee9df5b2f | ||
|
|
a88077a0bd | ||
|
|
fe37f45cb5 | ||
|
|
6aaf5db1e6 | ||
|
|
ddaf897596 | ||
|
|
40b953f05a | ||
|
|
95638e8f6d | ||
|
|
109fd2cdfc | ||
|
|
e9ab2de1e7 | ||
|
|
9c070fe092 | ||
|
|
fcdeb1613a | ||
|
|
3ee203ef0c | ||
|
|
c1ec8c5ea3 | ||
|
|
0ffe328c0a | ||
|
|
10ca61a13b | ||
|
|
33d6b90616 | ||
|
|
9f1a63075e | ||
|
|
08f02c5b65 | ||
|
|
f7f858f056 | ||
|
|
2b79e05e6c | ||
|
|
f922fa765f | ||
|
|
17595c4e31 | ||
|
|
a5e3ac2864 | ||
|
|
48d3ab5f44 | ||
|
|
3c8df553ae | ||
|
|
ab2933a414 | ||
|
|
0b53c7c224 | ||
|
|
d39e12c202 | ||
|
|
898a8c885b | ||
|
|
73a2d926f6 | ||
|
|
a2a01e6b72 | ||
|
|
b20210e83c | ||
|
|
777ccf1328 | ||
|
|
507f9d753f | ||
|
|
55acbcb560 | ||
|
|
7dd464c577 | ||
|
|
3b28a0e231 | ||
|
|
5d32ce6e91 | ||
|
|
4cefae0aaa | ||
|
|
e173f7e72d | ||
|
|
abd2762aed | ||
|
|
1df08afefd | ||
|
|
0d3703c0b3 | ||
|
|
8fb9728b45 | ||
|
|
b8dee485ca | ||
|
|
07a49b94ad | ||
|
|
144ca23442 | ||
|
|
e4faf3553a | ||
|
|
b9385dceb9 | ||
|
|
494cd8cc36 | ||
|
|
419b195019 | ||
|
|
ccdea234ad | ||
|
|
6e1fa1603b | ||
|
|
fd3c85dc0d | ||
|
|
e17fadd07a | ||
|
|
e9f62d1209 | ||
|
|
0e3017dc62 | ||
|
|
e809d40f4e | ||
|
|
ced782ecb2 | ||
|
|
46f2f9cff7 | ||
|
|
befd725b8b | ||
|
|
7ef527a653 | ||
|
|
d2b6a6bc2c | ||
|
|
b2425dbe7f | ||
|
|
4c46fa4ef4 | ||
|
|
2b24b6c9bb | ||
|
|
effc33fe5b | ||
|
|
61a517179d | ||
|
|
acb0d96617 | ||
|
|
e14e244f7b | ||
|
|
7d0b1b3830 | ||
|
|
a81953ef84 | ||
|
|
88d847a1d5 | ||
|
|
7a35682cd9 | ||
|
|
89627d0334 | ||
|
|
98b3a50657 | ||
|
|
43f6a62680 | ||
|
|
c19e3fbe3a | ||
|
|
2f3b1ca6b8 | ||
|
|
eda1cd2faa | ||
|
|
ebb19c5863 | ||
|
|
fdd0a2ca9b | ||
|
|
f17e1ce368 | ||
|
|
d67185ec7e | ||
|
|
36b99a4ed3 | ||
|
|
fb51f27b8a | ||
|
|
e92cd2091c | ||
|
|
6a6b68d295 | ||
|
|
80b329d031 | ||
|
|
331cdbed2f | ||
|
|
a6f05b5e56 | ||
|
|
35b9972c81 | ||
|
|
7b7577c747 | ||
|
|
a9c4ec31ca | ||
|
|
f1a5dca2ba | ||
|
|
88727bf070 | ||
|
|
bebde1596c | ||
|
|
2cbf60851f | ||
|
|
a9eea27742 | ||
|
|
50d962bba1 | ||
|
|
18cb215d72 | ||
|
|
b017a846ba | ||
|
|
1ff52e5c5a | ||
|
|
08c093bc85 | ||
|
|
ed246cef41 | ||
|
|
e4f72a8e3a | ||
|
|
a223a0dffd | ||
|
|
ef28bf6d88 | ||
|
|
5207211b6d | ||
|
|
0743ba89d4 | ||
|
|
0617625f48 | ||
|
|
d0a076cbfd | ||
|
|
7484096cdc | ||
|
|
e2df831b53 | ||
|
|
3ad213c29a | ||
|
|
e7a9c386ef | ||
|
|
306a47023c | ||
|
|
88d65c5149 | ||
|
|
9222cf91ea | ||
|
|
072c4ad14c | ||
|
|
9fb770ba50 | ||
|
|
7620142b70 | ||
|
|
e6118347d3 | ||
|
|
1bf33bb619 | ||
|
|
f4c5fe43cb | ||
|
|
9ee02d04f3 | ||
|
|
ad18cfda32 | ||
|
|
6ad68ae027 | ||
|
|
0f8680adfd | ||
|
|
e86b8febdc | ||
|
|
5e1c42cbe3 | ||
|
|
7958facadc | ||
|
|
8487e0a5b8 | ||
|
|
29fddddaf1 | ||
|
|
e0d6f8db1d | ||
|
|
a4c5787b53 | ||
|
|
2d9b9362a9 | ||
|
|
ce8113dea2 | ||
|
|
2e1bcb2abf | ||
|
|
2ae2d3ef83 | ||
|
|
d29052f682 | ||
|
|
35c35a193c | ||
|
|
1294fe2c96 | ||
|
|
ad727d3781 | ||
|
|
488285e123 | ||
|
|
1c7079db3f | ||
|
|
2c830770cb | ||
|
|
9748567452 | ||
|
|
d3a926df64 | ||
|
|
44ffc5a336 | ||
|
|
92d34234b0 | ||
|
|
3eebd827d7 | ||
|
|
6659c630b2 | ||
|
|
4d557dd512 | ||
|
|
74de89d1dd | ||
|
|
5e725070e0 | ||
|
|
dd87ebef58 | ||
|
|
82f528ddc8 | ||
|
|
ad62060753 | ||
|
|
f2ae2e9239 | ||
|
|
d2cc2861de | ||
|
|
e9a0e6dbc8 | ||
|
|
af7006dff6 | ||
|
|
0025a66200 | ||
|
|
03d4ecbbff | ||
|
|
21c0b868ae | ||
|
|
df9ea24136 | ||
|
|
07fe46e9df | ||
|
|
283d25d823 | ||
|
|
d076c19822 | ||
|
|
1ee7f31f4d | ||
|
|
d78a510642 | ||
|
|
3ef41c3131 | ||
|
|
759048e73a | ||
|
|
3b53ec20e6 | ||
|
|
c8dc7fff08 | ||
|
|
523febf9c1 | ||
|
|
72f58c4c40 | ||
|
|
0661cf6d87 | ||
|
|
703b0ec422 | ||
|
|
3d76a67a2e | ||
|
|
ef288fbff7 | ||
|
|
8a8ca40364 | ||
|
|
03397f605c | ||
|
|
c42b0ad6b7 | ||
|
|
4695754d2a | ||
|
|
339bcc97e0 | ||
|
|
6d4126f17e | ||
|
|
599bc45073 | ||
|
|
84dd413f22 | ||
|
|
f7529c94f6 | ||
|
|
7d7c67daba | ||
|
|
a7595ec191 | ||
|
|
93847ae337 | ||
|
|
525656a490 | ||
|
|
86e17ce74f | ||
|
|
0c24f88ce1 | ||
|
|
df88dc117f | ||
|
|
620c1e2789 | ||
|
|
8a86b2d2bc | ||
|
|
084e9e2e57 | ||
|
|
74a94ed4ad | ||
|
|
88a802b25e | ||
|
|
edc35d4d5b | ||
|
|
98c7c179ca | ||
|
|
8f7da03419 | ||
|
|
27f76d20ce | ||
|
|
1c3823cbb0 | ||
|
|
bc1703d7b6 | ||
|
|
4f4a62c6d0 | ||
|
|
3c1576e364 | ||
|
|
9f18426ca7 | ||
|
|
252dcad3f6 | ||
|
|
b48291ec63 | ||
|
|
6a586c39e9 | ||
|
|
335f8da5e8 | ||
|
|
9ac043a096 | ||
|
|
17f86d964f | ||
|
|
f9f1bd58d6 | ||
|
|
e120f2aab4 | ||
|
|
a8cf13e8c8 | ||
|
|
ac60fc9c1c | ||
|
|
aaee26ae22 | ||
|
|
29e0bca43a | ||
|
|
a8b12bcb52 | ||
|
|
758f2f0a4e | ||
|
|
a49c7f95e2 | ||
|
|
0a2ec6ef04 | ||
|
|
87ae744dce | ||
|
|
2066b2f666 | ||
|
|
9e2d401f43 | ||
|
|
1d4f28a54d | ||
|
|
e4f319fe61 | ||
|
|
cde02954c8 | ||
|
|
a4d7a99c22 | ||
|
|
3409333522 | ||
|
|
8407db9854 | ||
|
|
00d50157d3 | ||
|
|
67f1131a20 | ||
|
|
f2b42237d0 | ||
|
|
5f57bceabb | ||
|
|
10ba08ce13 | ||
|
|
cd71c1cc0a | ||
|
|
ab6a93b029 | ||
|
|
252e4983fb | ||
|
|
3e3315c103 | ||
|
|
0e19aa4362 | ||
|
|
8524d505c5 | ||
|
|
b898200803 | ||
|
|
4715a37937 | ||
|
|
318bd10c7f | ||
|
|
9c6377964c | ||
|
|
b17e145d75 | ||
|
|
b0a1a04008 | ||
|
|
bfa61c1ec4 | ||
|
|
d7c607fd8b | ||
|
|
80e0e1c544 | ||
|
|
8841ba97c6 | ||
|
|
7fb0fe2e91 | ||
|
|
224921460a | ||
|
|
9157482049 | ||
|
|
88e593ee02 | ||
|
|
558a951ed6 | ||
|
|
37ed02553a | ||
|
|
f7cf8aa878 | ||
|
|
9284a32c9a | ||
|
|
f6c633212a | ||
|
|
735a83c596 | ||
|
|
eaf6bb1e9b | ||
|
|
a1f12e3ade | ||
|
|
d0a3aab2e7 | ||
|
|
ea59d93dc8 | ||
|
|
e9775097ec | ||
|
|
96ce0f017c | ||
|
|
483133285e | ||
|
|
a52417eca9 | ||
|
|
c78f442095 | ||
|
|
ae3fd4cb59 | ||
|
|
3d6cb1435c | ||
|
|
054b7d28f1 | ||
|
|
8458faed11 | ||
|
|
d24e66370b | ||
|
|
620c48fbbb | ||
|
|
4faca3cd4a | ||
|
|
97140f6a78 | ||
|
|
4a6a551d07 | ||
|
|
d180c833b9 | ||
|
|
6608cda084 | ||
|
|
ec3975ef5b | ||
|
|
dfc76ce642 | ||
|
|
7087a53f27 | ||
|
|
cfc3ee4f5a | ||
|
|
77c6188ec2 | ||
|
|
1158716f46 | ||
|
|
6b72c66893 | ||
|
|
1f237388bd | ||
|
|
06b0176a3e | ||
|
|
427ec05c8b | ||
|
|
0f55adf31a | ||
|
|
8bb75da1ac | ||
|
|
3ba3c540fb | ||
|
|
3e95d12b75 | ||
|
|
ee91e34096 | ||
|
|
2fab7bd9b1 | ||
|
|
2ee45e8cac | ||
|
|
c4a218358f | ||
|
|
d7cdd58db6 | ||
|
|
97a9210483 | ||
|
|
8ef06826c3 | ||
|
|
eaab2ede76 | ||
|
|
abf988ad69 | ||
|
|
d4ab2ab4b9 | ||
|
|
e0e8c14c2a | ||
|
|
0eb7d8f614 | ||
|
|
aa84e6c179 | ||
|
|
fa3d71bed9 | ||
|
|
7482d2f5f4 | ||
|
|
44c9ad687f | ||
|
|
63866407f1 | ||
|
|
2ca9bb3cca | ||
|
|
635c177eea | ||
|
|
d9e960873c | ||
|
|
f8ca6e58aa | ||
|
|
475530e59f | ||
|
|
3b01ea9fa4 | ||
|
|
ae498a06e2 | ||
|
|
dca6fb92f9 | ||
|
|
1c047dfeb8 | ||
|
|
7f9d2b0804 | ||
|
|
024ff96ee2 | ||
|
|
666c54e86c | ||
|
|
f79a6f701a | ||
|
|
338e407a91 | ||
|
|
6f841b7f43 | ||
|
|
8a2aa5d217 | ||
|
|
b67e4a87e4 | ||
|
|
c50b611f85 | ||
|
|
73167fb4f2 | ||
|
|
c55e060bab | ||
|
|
7d934c984a | ||
|
|
4b1dd334a5 | ||
|
|
c967899b14 | ||
|
|
30dc4fec99 | ||
|
|
7e359d3d7e | ||
|
|
0395eb99de | ||
|
|
a04d64881c | ||
|
|
27049b848d | ||
|
|
bed79f523b | ||
|
|
d5fde17bf5 | ||
|
|
db2ecd3010 | ||
|
|
ba56b3f763 | ||
|
|
b2eeeb6fa0 | ||
|
|
147a16cbf8 | ||
|
|
7c5497db65 | ||
|
|
abb83f4c4f | ||
|
|
f8b79c52cb | ||
|
|
55cf64393d | ||
|
|
31b9868fc1 | ||
|
|
c91ca4fcd9 | ||
|
|
1cf67b3a1d | ||
|
|
5d6245b059 | ||
|
|
8dc0d4b916 | ||
|
|
c514dd6885 | ||
|
|
e7e7a91b85 | ||
|
|
6ffcbaa7b3 | ||
|
|
1b1a059d90 | ||
|
|
d41391e87a | ||
|
|
8ebe03ef86 | ||
|
|
cc9d356a55 | ||
|
|
e9efa5b981 | ||
|
|
70bf0706b2 | ||
|
|
17eab0f5f9 | ||
|
|
c399e76324 | ||
|
|
397222f198 | ||
|
|
22e3cba0b7 | ||
|
|
4b045badcf | ||
|
|
0e951c0716 | ||
|
|
d9f2bccf70 | ||
|
|
d642964035 | ||
|
|
7824eca775 | ||
|
|
eea456ed84 | ||
|
|
1e4776fa64 | ||
|
|
a29c35e08f | ||
|
|
0ca74df604 | ||
|
|
a6f891d1b1 | ||
|
|
ed608cb7d3 | ||
|
|
b7e3f80e14 | ||
|
|
b1921830de | ||
|
|
d8ef4b6f4d | ||
|
|
d0bbe830ad | ||
|
|
dc26fd215b | ||
|
|
d9652183f6 | ||
|
|
432b00df40 | ||
|
|
cac3b1e538 | ||
|
|
2fbf7bbcf1 | ||
|
|
128c92779c | ||
|
|
2589bec48b | ||
|
|
f17c990a77 | ||
|
|
b26ba17184 | ||
|
|
c259ada6e1 | ||
|
|
d3381fb518 | ||
|
|
c058bc2245 | ||
|
|
f3baa5bfee | ||
|
|
297eb6f81b | ||
|
|
c06c22cf2e | ||
|
|
fef21d5aa2 | ||
|
|
ce99f3247f | ||
|
|
c8177b99ed | ||
|
|
5823a71c18 | ||
|
|
06c0e5ad1c | ||
|
|
c20308c7ba | ||
|
|
1bfbc012f5 | ||
|
|
0271105794 | ||
|
|
bbbfd4ee4c | ||
|
|
e8468b51cc | ||
|
|
718816c5d4 | ||
|
|
71dd4b8a7d | ||
|
|
435c90eb47 | ||
|
|
700c302fca | ||
|
|
d2986eb98f | ||
|
|
eabf1ff3e7 | ||
|
|
4acd990ee2 | ||
|
|
84ebd786d6 | ||
|
|
156eca4d22 | ||
|
|
73f12765a9 | ||
|
|
7798e1b1f7 | ||
|
|
068771ea07 | ||
|
|
e59156b446 | ||
|
|
5592e77fc6 | ||
|
|
b255b7760a | ||
|
|
2ecca7e4df | ||
|
|
c43ef6e769 | ||
|
|
e59c927ee5 | ||
|
|
e13790c62c | ||
|
|
a034172b24 | ||
|
|
86ba692bf5 | ||
|
|
d06a1a7fa4 | ||
|
|
4853dd97fd | ||
|
|
e8f3dd07dd | ||
|
|
fda1a0cb3b | ||
|
|
a04e1bd582 | ||
|
|
747b9ec568 | ||
|
|
437690119b | ||
|
|
26ef9da02b | ||
|
|
4c9f261a24 | ||
|
|
244e94de80 | ||
|
|
582ed86d82 | ||
|
|
c059300d99 | ||
|
|
a61ee73e69 | ||
|
|
0316af7f6b | ||
|
|
3a3263102a | ||
|
|
79e30e7087 | ||
|
|
0a224e8bb1 | ||
|
|
d3517e87e5 | ||
|
|
ffb3d9260a | ||
|
|
bd51119460 | ||
|
|
319849caf8 | ||
|
|
83e0be5d07 | ||
|
|
76fcf136d0 | ||
|
|
83bfb8cd2b | ||
|
|
768d67f27b | ||
|
|
1781d87477 | ||
|
|
2f380a7985 | ||
|
|
b3c5bf3f2e | ||
|
|
7a952136e0 | ||
|
|
a7fd592db4 | ||
|
|
e9686cbbe5 | ||
|
|
53b131ba2a | ||
|
|
02b7423b73 | ||
|
|
deed1b949d | ||
|
|
20305418f4 | ||
|
|
401197a895 | ||
|
|
4948121af0 | ||
|
|
1f2f953687 | ||
|
|
3b20774c54 | ||
|
|
01d1a02df4 | ||
|
|
51359704a0 | ||
|
|
55fbf6836b | ||
|
|
a09a39402e | ||
|
|
6a76aef375 | ||
|
|
3bc29e29e0 | ||
|
|
1a4f5e87f2 | ||
|
|
e58513c976 | ||
|
|
f62a1827f3 | ||
|
|
1809eefe4c | ||
|
|
09331ec432 | ||
|
|
944d1a68bd | ||
|
|
81a28e9ffa | ||
|
|
099761d8fb | ||
|
|
ffdaead5b7 | ||
|
|
5fdfe02b3a | ||
|
|
bd193a026d | ||
|
|
eb1f58f962 | ||
|
|
b8ea556616 | ||
|
|
ebb445c364 | ||
|
|
35dba0f412 | ||
|
|
0d967c0572 | ||
|
|
c4d44af54c | ||
|
|
969bf2107b | ||
|
|
bde8ab84f2 | ||
|
|
be6e0927f3 | ||
|
|
cdfc57d544 | ||
|
|
8900797ada | ||
|
|
1b90703157 | ||
|
|
41c055363e | ||
|
|
12e10f6956 | ||
|
|
4b69a895df | ||
|
|
f2a8057d63 | ||
|
|
878bb55522 | ||
|
|
d36700eeee | ||
|
|
41f8d043eb | ||
|
|
109b42f482 | ||
|
|
4c656fcffc | ||
|
|
3a2efb4757 | ||
|
|
5e1c295230 | ||
|
|
abf3ee4999 | ||
|
|
bdb3937e0f | ||
|
|
8d52608dba | ||
|
|
bf7476af5b | ||
|
|
2295b61cb6 | ||
|
|
06878e5004 | ||
|
|
763ab07942 | ||
|
|
9da4ee5fcc | ||
|
|
270b559d36 | ||
|
|
d771fa9289 | ||
|
|
563c879e44 | ||
|
|
db11030410 | ||
|
|
cbe266079e | ||
|
|
c5071cd091 | ||
|
|
a9f5a17c67 | ||
|
|
c799d03ece | ||
|
|
b6d9f2bddf | ||
|
|
4776a5a427 | ||
|
|
a2ce6e236c | ||
|
|
c1068bf0cd | ||
|
|
83b4343d2d | ||
|
|
b5e90972d8 | ||
|
|
daa8eaa9ae | ||
|
|
a188abbe28 | ||
|
|
1ebb0d9cae | ||
|
|
f92dcdf50a | ||
|
|
b925325ddb | ||
|
|
5b08b2f33d | ||
|
|
30821586cb | ||
|
|
ab1e74d16c | ||
|
|
91380eeaab | ||
|
|
3eea03d70e | ||
|
|
56e984b5e7 | ||
|
|
daa4272c0e | ||
|
|
bc951a9d4f | ||
|
|
2e2241cf84 | ||
|
|
80256cf298 | ||
|
|
95673a9ee4 | ||
|
|
dfcb5a666f | ||
|
|
b67b3820a1 | ||
|
|
5b4bd8a59a | ||
|
|
22fa8d9b31 | ||
|
|
dcd2204786 | ||
|
|
05527be943 | ||
|
|
fc9b984cc1 | ||
|
|
7e565eed34 | ||
|
|
dfd1d0c7fe | ||
|
|
9696557897 | ||
|
|
e4c5a91d0e | ||
|
|
1c53668bc9 | ||
|
|
af58531482 | ||
|
|
1fcc1bdc89 | ||
|
|
57372d9d8e | ||
|
|
eefb36177d | ||
|
|
01788e83e7 | ||
|
|
782a5f1218 | ||
|
|
fc6e7f12b7 | ||
|
|
a256e4b1dc | ||
|
|
73ba49a715 | ||
|
|
c090d115e2 | ||
|
|
e6e21046c0 | ||
|
|
1f8d396e3f | ||
|
|
3eff27344b | ||
|
|
e63acb70ca | ||
|
|
a24f448dc0 | ||
|
|
d2b0a51848 | ||
|
|
22c978ad94 | ||
|
|
13fe01a185 | ||
|
|
32f6fa5b00 | ||
|
|
f18b126fba | ||
|
|
a6112ef40d | ||
|
|
ff43bb1a74 | ||
|
|
e43f9fc21e | ||
|
|
0cfa757db0 | ||
|
|
83e4cf3dd4 | ||
|
|
52c624aabd | ||
|
|
424b482579 | ||
|
|
a1b89a53eb | ||
|
|
e00884bcca | ||
|
|
56e3953a71 | ||
|
|
56a6d86af5 | ||
|
|
bc5d32d6de | ||
|
|
780bdccc42 | ||
|
|
a1b607480a | ||
|
|
5b64f0ff96 | ||
|
|
2e14ba95a0 | ||
|
|
2c79572e4b | ||
|
|
7a3dcdc67f | ||
|
|
ab546a14cb | ||
|
|
041bca6ac9 | ||
|
|
e4af6e77a7 | ||
|
|
0bcde4ab28 | ||
|
|
8a2bc5772e | ||
|
|
491c9d2b55 | ||
|
|
70973fda64 | ||
|
|
8c79385261 | ||
|
|
a544a1e57c | ||
|
|
07cd12978e | ||
|
|
6f3ae29522 | ||
|
|
6e14b8a6af | ||
|
|
16969fdbbb | ||
|
|
13234f8552 | ||
|
|
25037b841b | ||
|
|
d3158e37b9 | ||
|
|
5c525f0b41 | ||
|
|
ca663fcd10 | ||
|
|
dbb8645353 | ||
|
|
702b7296a0 | ||
|
|
5f20bc240e | ||
|
|
2a85a1cebf | ||
|
|
4f2d1b7424 | ||
|
|
db55ea8cb3 | ||
|
|
e1c3415795 | ||
|
|
701d2eaeac | ||
|
|
bdad35a736 | ||
|
|
cb5e63d846 | ||
|
|
c47d23a87b | ||
|
|
73d9368039 | ||
|
|
91f7cbb79d | ||
|
|
72ce4f3ab9 | ||
|
|
66820dbed3 | ||
|
|
fd0623bf69 | ||
|
|
379c0a1dd4 | ||
|
|
fe63eefc1f | ||
|
|
a9a4e0d6b8 | ||
|
|
7f49f07e9a | ||
|
|
90490c92a0 | ||
|
|
a628b0f186 | ||
|
|
4fef8b601d | ||
|
|
fa8d0c5c6f | ||
|
|
854ba2a8d2 | ||
|
|
c087e6f895 | ||
|
|
6807d070da | ||
|
|
09a681db8b | ||
|
|
9cfa15917d |
@@ -1,4 +1,7 @@
|
|||||||
|
/.project
|
||||||
|
/.loadpath
|
||||||
/config/additional_environment.rb
|
/config/additional_environment.rb
|
||||||
|
/config/configuration.yml
|
||||||
/config/database.yml
|
/config/database.yml
|
||||||
/config/email.yml
|
/config/email.yml
|
||||||
/config/initializers/session_store.rb
|
/config/initializers/session_store.rb
|
||||||
@@ -7,6 +10,8 @@
|
|||||||
/db/*.sqlite3
|
/db/*.sqlite3
|
||||||
/db/schema.rb
|
/db/schema.rb
|
||||||
/files/*
|
/files/*
|
||||||
|
/lib/redmine/scm/adapters/mercurial/redminehelper.pyc
|
||||||
|
/lib/redmine/scm/adapters/mercurial/redminehelper.pyo
|
||||||
/log/*.log*
|
/log/*.log*
|
||||||
/log/mongrel_debug
|
/log/mongrel_debug
|
||||||
/public/dispatch.*
|
/public/dispatch.*
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
syntax: glob
|
||||||
|
|
||||||
|
.project
|
||||||
|
.loadpath
|
||||||
|
config/additional_environment.rb
|
||||||
|
config/configuration.yml
|
||||||
|
config/database.yml
|
||||||
|
config/email.yml
|
||||||
|
config/initializers/session_store.rb
|
||||||
|
coverage
|
||||||
|
db/*.db
|
||||||
|
db/*.sqlite3
|
||||||
|
db/schema.rb
|
||||||
|
files/*
|
||||||
|
lib/redmine/scm/adapters/mercurial/redminehelper.pyc
|
||||||
|
lib/redmine/scm/adapters/mercurial/redminehelper.pyo
|
||||||
|
log/*.log*
|
||||||
|
log/mongrel_debug
|
||||||
|
public/dispatch.*
|
||||||
|
public/plugin_assets
|
||||||
|
tmp/*
|
||||||
|
tmp/cache/*
|
||||||
|
tmp/sessions/*
|
||||||
|
tmp/sockets/*
|
||||||
|
tmp/test/*
|
||||||
|
vendor/rails
|
||||||
|
*.rbc
|
||||||
|
.svn/
|
||||||
|
.git/
|
||||||
@@ -83,9 +83,9 @@ class AccountController < ApplicationController
|
|||||||
else
|
else
|
||||||
@user = User.new(params[:user])
|
@user = User.new(params[:user])
|
||||||
@user.admin = false
|
@user.admin = false
|
||||||
@user.status = User::STATUS_REGISTERED
|
@user.register
|
||||||
if session[:auth_source_registration]
|
if session[:auth_source_registration]
|
||||||
@user.status = User::STATUS_ACTIVE
|
@user.activate
|
||||||
@user.login = session[:auth_source_registration][:login]
|
@user.login = session[:auth_source_registration][:login]
|
||||||
@user.auth_source_id = session[:auth_source_registration][:auth_source_id]
|
@user.auth_source_id = session[:auth_source_registration][:auth_source_id]
|
||||||
if @user.save
|
if @user.save
|
||||||
@@ -116,8 +116,8 @@ class AccountController < ApplicationController
|
|||||||
token = Token.find_by_action_and_value('register', params[:token])
|
token = Token.find_by_action_and_value('register', params[:token])
|
||||||
redirect_to(home_url) && return unless token and !token.expired?
|
redirect_to(home_url) && return unless token and !token.expired?
|
||||||
user = token.user
|
user = token.user
|
||||||
redirect_to(home_url) && return unless user.status == User::STATUS_REGISTERED
|
redirect_to(home_url) && return unless user.registered?
|
||||||
user.status = User::STATUS_ACTIVE
|
user.activate
|
||||||
if user.save
|
if user.save
|
||||||
token.destroy
|
token.destroy
|
||||||
flash[:notice] = l(:notice_account_activated)
|
flash[:notice] = l(:notice_account_activated)
|
||||||
@@ -170,7 +170,7 @@ class AccountController < ApplicationController
|
|||||||
user.mail = registration['email'] unless registration['email'].nil?
|
user.mail = registration['email'] unless registration['email'].nil?
|
||||||
user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
|
user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
|
||||||
user.random_password
|
user.random_password
|
||||||
user.status = User::STATUS_REGISTERED
|
user.register
|
||||||
|
|
||||||
case Setting.self_registration
|
case Setting.self_registration
|
||||||
when '1'
|
when '1'
|
||||||
@@ -203,12 +203,24 @@ class AccountController < ApplicationController
|
|||||||
self.logged_user = user
|
self.logged_user = user
|
||||||
# generate a key and set cookie if autologin
|
# generate a key and set cookie if autologin
|
||||||
if params[:autologin] && Setting.autologin?
|
if params[:autologin] && Setting.autologin?
|
||||||
token = Token.create(:user => user, :action => 'autologin')
|
set_autologin_cookie(user)
|
||||||
cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }
|
|
||||||
end
|
end
|
||||||
call_hook(:controller_account_success_authentication_after, {:user => user })
|
call_hook(:controller_account_success_authentication_after, {:user => user })
|
||||||
redirect_back_or_default :controller => 'my', :action => 'page'
|
redirect_back_or_default :controller => 'my', :action => 'page'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_autologin_cookie(user)
|
||||||
|
token = Token.create(:user => user, :action => 'autologin')
|
||||||
|
cookie_name = Redmine::Configuration['autologin_cookie_name'] || 'autologin'
|
||||||
|
cookie_options = {
|
||||||
|
:value => token.value,
|
||||||
|
:expires => 1.year.from_now,
|
||||||
|
:path => (Redmine::Configuration['autologin_cookie_path'] || '/'),
|
||||||
|
:secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false),
|
||||||
|
:httponly => true
|
||||||
|
}
|
||||||
|
cookies[cookie_name] = cookie_options
|
||||||
|
end
|
||||||
|
|
||||||
# Onthefly creation failed, display the registration form to fill/fix attributes
|
# Onthefly creation failed, display the registration form to fill/fix attributes
|
||||||
def onthefly_creation_failed(user, auth_source_options = { })
|
def onthefly_creation_failed(user, auth_source_options = { })
|
||||||
@@ -241,7 +253,7 @@ class AccountController < ApplicationController
|
|||||||
# Pass a block for behavior when a user fails to save
|
# Pass a block for behavior when a user fails to save
|
||||||
def register_automatically(user, &block)
|
def register_automatically(user, &block)
|
||||||
# Automatic activation
|
# Automatic activation
|
||||||
user.status = User::STATUS_ACTIVE
|
user.activate
|
||||||
user.last_login_on = Time.now
|
user.last_login_on = Time.now
|
||||||
if user.save
|
if user.save
|
||||||
self.logged_user = user
|
self.logged_user = user
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class ActivitiesController < ApplicationController
|
||||||
|
menu_item :activity
|
||||||
|
before_filter :find_optional_project
|
||||||
|
accept_rss_auth :index
|
||||||
|
|
||||||
|
def index
|
||||||
|
@days = Setting.activity_days_default.to_i
|
||||||
|
|
||||||
|
if params[:from]
|
||||||
|
begin; @date_to = params[:from].to_date + 1; rescue; end
|
||||||
|
end
|
||||||
|
|
||||||
|
@date_to ||= Date.today + 1
|
||||||
|
@date_from = @date_to - @days
|
||||||
|
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
||||||
|
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
||||||
|
|
||||||
|
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
|
||||||
|
:with_subprojects => @with_subprojects,
|
||||||
|
:author => @author)
|
||||||
|
@activity.scope_select {|t| !params["show_#{t}"].nil?}
|
||||||
|
@activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
|
||||||
|
|
||||||
|
events = @activity.events(@date_from, @date_to)
|
||||||
|
|
||||||
|
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
@events_by_day = events.group_by(&:event_date)
|
||||||
|
render :layout => false if request.xhr?
|
||||||
|
}
|
||||||
|
format.atom {
|
||||||
|
title = l(:label_activity)
|
||||||
|
if @author
|
||||||
|
title = @author.name
|
||||||
|
elsif @activity.scope.size == 1
|
||||||
|
title = l("label_#{@activity.scope.first.singularize}_plural")
|
||||||
|
end
|
||||||
|
render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# TODO: refactor, duplicated in projects_controller
|
||||||
|
def find_optional_project
|
||||||
|
return true unless params[:id]
|
||||||
|
@project = Project.find(params[:id])
|
||||||
|
authorize
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -17,9 +17,7 @@
|
|||||||
|
|
||||||
class AdminController < ApplicationController
|
class AdminController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
|
|
||||||
@@ -30,22 +28,20 @@ class AdminController < ApplicationController
|
|||||||
def projects
|
def projects
|
||||||
@status = params[:status] ? params[:status].to_i : 1
|
@status = params[:status] ? params[:status].to_i : 1
|
||||||
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
|
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
|
||||||
|
|
||||||
unless params[:name].blank?
|
unless params[:name].blank?
|
||||||
name = "%#{params[:name].strip.downcase}%"
|
name = "%#{params[:name].strip.downcase}%"
|
||||||
c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name]
|
c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name]
|
||||||
end
|
end
|
||||||
|
|
||||||
@projects = Project.find :all, :order => 'lft',
|
@projects = Project.find :all, :order => 'lft',
|
||||||
:conditions => c.conditions
|
:conditions => c.conditions
|
||||||
|
|
||||||
render :action => "projects", :layout => false if request.xhr?
|
render :action => "projects", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def plugins
|
def plugins
|
||||||
@plugins = Redmine::Plugin.all
|
@plugins = Redmine::Plugin.all
|
||||||
end
|
end
|
||||||
|
|
||||||
# Loads the default configuration
|
# Loads the default configuration
|
||||||
# (roles, trackers, statuses, workflow, enumerations)
|
# (roles, trackers, statuses, workflow, enumerations)
|
||||||
def default_configuration
|
def default_configuration
|
||||||
@@ -59,7 +55,7 @@ class AdminController < ApplicationController
|
|||||||
end
|
end
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_email
|
def test_email
|
||||||
raise_delivery_errors = ActionMailer::Base.raise_delivery_errors
|
raise_delivery_errors = ActionMailer::Base.raise_delivery_errors
|
||||||
# Force ActionMailer to raise delivery errors so we can catch it
|
# Force ActionMailer to raise delivery errors so we can catch it
|
||||||
@@ -73,14 +69,16 @@ class AdminController < ApplicationController
|
|||||||
ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
|
ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
|
||||||
redirect_to :controller => 'settings', :action => 'edit', :tab => 'notifications'
|
redirect_to :controller => 'settings', :action => 'edit', :tab => 'notifications'
|
||||||
end
|
end
|
||||||
|
|
||||||
def info
|
def info
|
||||||
@db_adapter_name = ActiveRecord::Base.connection.adapter_name
|
@db_adapter_name = ActiveRecord::Base.connection.adapter_name
|
||||||
@checklist = [
|
@checklist = [
|
||||||
[:text_default_administrator_account_changed, User.find(:first, :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?],
|
[:text_default_administrator_account_changed,
|
||||||
|
User.find(:first,
|
||||||
|
:conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?],
|
||||||
[:text_file_repository_writable, File.writable?(Attachment.storage_path)],
|
[:text_file_repository_writable, File.writable?(Attachment.storage_path)],
|
||||||
[:text_plugin_assets_writable, File.writable?(Engines.public_directory)],
|
[:text_plugin_assets_writable, File.writable?(Engines.public_directory)],
|
||||||
[:text_rmagick_available, Object.const_defined?(:Magick)]
|
[:text_rmagick_available, Object.const_defined?(:Magick)]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -18,34 +18,37 @@
|
|||||||
require 'uri'
|
require 'uri'
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
|
|
||||||
|
class Unauthorized < Exception; end
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
|
|
||||||
layout 'base'
|
layout 'base'
|
||||||
exempt_from_layout 'builder'
|
exempt_from_layout 'builder', 'rsb'
|
||||||
|
|
||||||
# Remove broken cookie after upgrade from 0.8.x (#4292)
|
# Remove broken cookie after upgrade from 0.8.x (#4292)
|
||||||
# See https://rails.lighthouseapp.com/projects/8994/tickets/3360
|
# See https://rails.lighthouseapp.com/projects/8994/tickets/3360
|
||||||
# TODO: remove it when Rails is fixed
|
# TODO: remove it when Rails is fixed
|
||||||
before_filter :delete_broken_cookies
|
before_filter :delete_broken_cookies
|
||||||
def delete_broken_cookies
|
def delete_broken_cookies
|
||||||
if cookies['_redmine_session'] && cookies['_redmine_session'] !~ /--/
|
if cookies['_redmine_session'] && cookies['_redmine_session'] !~ /--/
|
||||||
cookies.delete '_redmine_session'
|
cookies.delete '_redmine_session'
|
||||||
redirect_to home_path
|
redirect_to home_path
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before_filter :user_setup, :check_if_login_required, :set_localization
|
before_filter :user_setup, :check_if_login_required, :set_localization
|
||||||
filter_parameter_logging :password
|
filter_parameter_logging :password
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
||||||
|
rescue_from ::Unauthorized, :with => :deny_access
|
||||||
|
|
||||||
include Redmine::Search::Controller
|
include Redmine::Search::Controller
|
||||||
include Redmine::MenuManager::MenuController
|
include Redmine::MenuManager::MenuController
|
||||||
helper Redmine::MenuManager::MenuHelper
|
helper Redmine::MenuManager::MenuHelper
|
||||||
|
|
||||||
Redmine::Scm::Base.all.each do |scm|
|
Redmine::Scm::Base.all.each do |scm|
|
||||||
require_dependency "repository/#{scm.underscore}"
|
require_dependency "repository/#{scm.underscore}"
|
||||||
end
|
end
|
||||||
@@ -56,7 +59,7 @@ class ApplicationController < ActionController::Base
|
|||||||
# Find the current user
|
# Find the current user
|
||||||
User.current = find_current_user
|
User.current = find_current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the current user or nil if no user is logged in
|
# Returns the current user or nil if no user is logged in
|
||||||
# and starts a session if needed
|
# and starts a session if needed
|
||||||
def find_current_user
|
def find_current_user
|
||||||
@@ -68,13 +71,13 @@ class ApplicationController < ActionController::Base
|
|||||||
user = User.try_to_autologin(cookies[:autologin])
|
user = User.try_to_autologin(cookies[:autologin])
|
||||||
session[:user_id] = user.id if user
|
session[:user_id] = user.id if user
|
||||||
user
|
user
|
||||||
elsif params[:format] == 'atom' && params[:key] && accept_key_auth_actions.include?(params[:action])
|
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?
|
||||||
# RSS key authentication does not start a session
|
# RSS key authentication does not start a session
|
||||||
User.find_by_rss_key(params[:key])
|
User.find_by_rss_key(params[:key])
|
||||||
elsif Setting.rest_api_enabled? && ['xml', 'json'].include?(params[:format])
|
elsif Setting.rest_api_enabled? && accept_api_auth?
|
||||||
if params[:key].present? && accept_key_auth_actions.include?(params[:action])
|
if (key = api_key_from_request)
|
||||||
# Use API key
|
# Use API key
|
||||||
User.find_by_api_key(params[:key])
|
User.find_by_api_key(key)
|
||||||
else
|
else
|
||||||
# HTTP Basic, either username/password or API key/random
|
# HTTP Basic, either username/password or API key/random
|
||||||
authenticate_with_http_basic do |username, password|
|
authenticate_with_http_basic do |username, password|
|
||||||
@@ -94,14 +97,14 @@ class ApplicationController < ActionController::Base
|
|||||||
User.current = User.anonymous
|
User.current = User.anonymous
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# check if login is globally required to access the application
|
# check if login is globally required to access the application
|
||||||
def check_if_login_required
|
def check_if_login_required
|
||||||
# no check needed if user is already logged in
|
# no check needed if user is already logged in
|
||||||
return true if User.current.logged?
|
return true if User.current.logged?
|
||||||
require_login if Setting.login_required?
|
require_login if Setting.login_required?
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_localization
|
def set_localization
|
||||||
lang = nil
|
lang = nil
|
||||||
if User.current.logged?
|
if User.current.logged?
|
||||||
@@ -117,7 +120,7 @@ class ApplicationController < ActionController::Base
|
|||||||
lang ||= Setting.default_language
|
lang ||= Setting.default_language
|
||||||
set_language_if_valid(lang)
|
set_language_if_valid(lang)
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_login
|
def require_login
|
||||||
if !User.current.logged?
|
if !User.current.logged?
|
||||||
# Extract only the basic url parameters on non-GET requests
|
# Extract only the basic url parameters on non-GET requests
|
||||||
@@ -146,15 +149,23 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def deny_access
|
def deny_access
|
||||||
User.current.logged? ? render_403 : require_login
|
User.current.logged? ? render_403 : require_login
|
||||||
end
|
end
|
||||||
|
|
||||||
# Authorize the user for the requested action
|
# Authorize the user for the requested action
|
||||||
def authorize(ctrl = params[:controller], action = params[:action], global = false)
|
def authorize(ctrl = params[:controller], action = params[:action], global = false)
|
||||||
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project, :global => global)
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
||||||
allowed ? true : deny_access
|
if allowed
|
||||||
|
true
|
||||||
|
else
|
||||||
|
if @project && @project.archived?
|
||||||
|
render_403 :message => :notice_not_authorized_archived_project
|
||||||
|
else
|
||||||
|
deny_access
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Authorize the user for the requested action outside a project
|
# Authorize the user for the requested action outside a project
|
||||||
@@ -169,6 +180,13 @@ class ApplicationController < ActionController::Base
|
|||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Find project of id params[:project_id]
|
||||||
|
def find_project_by_project_id
|
||||||
|
@project = Project.find(params[:project_id])
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
# Find a project based on params[:project_id]
|
# Find a project based on params[:project_id]
|
||||||
# TODO: some subclasses override this, see about merging their logic
|
# TODO: some subclasses override this, see about merging their logic
|
||||||
def find_optional_project
|
def find_optional_project
|
||||||
@@ -182,7 +200,7 @@ class ApplicationController < ActionController::Base
|
|||||||
# Finds and sets @project based on @object.project
|
# Finds and sets @project based on @object.project
|
||||||
def find_project_from_association
|
def find_project_from_association
|
||||||
render_404 unless @object.present?
|
render_404 unless @object.present?
|
||||||
|
|
||||||
@project = @object.project
|
@project = @object.project
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
@@ -201,7 +219,30 @@ class ApplicationController < ActionController::Base
|
|||||||
def self.model_object(model)
|
def self.model_object(model)
|
||||||
write_inheritable_attribute('model_object', model)
|
write_inheritable_attribute('model_object', model)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Filter for bulk issue operations
|
||||||
|
def find_issues
|
||||||
|
@issues = Issue.find_all_by_id(params[:id] || params[:ids])
|
||||||
|
raise ActiveRecord::RecordNotFound if @issues.empty?
|
||||||
|
if @issues.detect {|issue| !issue.visible?}
|
||||||
|
deny_access
|
||||||
|
return
|
||||||
|
end
|
||||||
|
@projects = @issues.collect(&:project).compact.uniq
|
||||||
|
@project = @projects.first if @projects.size == 1
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check if project is unique before bulk operations
|
||||||
|
def check_project_uniqueness
|
||||||
|
unless @project
|
||||||
|
# TODO: let users bulk edit/move/destroy issues from different projects
|
||||||
|
render_error 'Can not bulk edit/move/destroy issues from different projects'
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# make sure that the user is a member of the project (or admin) if project is private
|
# make sure that the user is a member of the project (or admin) if project is private
|
||||||
# used as a before_filter for actions that do not require any particular permission on the project
|
# used as a before_filter for actions that do not require any particular permission on the project
|
||||||
def check_project_privacy
|
def check_project_privacy
|
||||||
@@ -218,6 +259,10 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def back_url
|
||||||
|
params[:back_url] || request.env['HTTP_REFERER']
|
||||||
|
end
|
||||||
|
|
||||||
def redirect_back_or_default(default)
|
def redirect_back_or_default(default)
|
||||||
back_url = CGI.unescape(params[:back_url].to_s)
|
back_url = CGI.unescape(params[:back_url].to_s)
|
||||||
if !back_url.blank?
|
if !back_url.blank?
|
||||||
@@ -233,52 +278,54 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to default
|
redirect_to default
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_403
|
def render_403(options={})
|
||||||
@project = nil
|
@project = nil
|
||||||
respond_to do |format|
|
render_error({:message => :notice_not_authorized, :status => 403}.merge(options))
|
||||||
format.html { render :template => "common/403", :layout => (request.xhr? ? false : 'base'), :status => 403 }
|
|
||||||
format.atom { head 403 }
|
|
||||||
format.xml { head 403 }
|
|
||||||
format.js { head 403 }
|
|
||||||
format.json { head 403 }
|
|
||||||
end
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_404
|
def render_404(options={})
|
||||||
respond_to do |format|
|
render_error({:message => :notice_file_not_found, :status => 404}.merge(options))
|
||||||
format.html { render :template => "common/404", :layout => !request.xhr?, :status => 404 }
|
|
||||||
format.atom { head 404 }
|
|
||||||
format.xml { head 404 }
|
|
||||||
format.js { head 404 }
|
|
||||||
format.json { head 404 }
|
|
||||||
end
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_error(msg)
|
# Renders an error response
|
||||||
|
def render_error(arg)
|
||||||
|
arg = {:message => arg} unless arg.is_a?(Hash)
|
||||||
|
|
||||||
|
@message = arg[:message]
|
||||||
|
@message = l(@message) if @message.is_a?(Symbol)
|
||||||
|
@status = arg[:status] || 500
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash.now[:error] = msg
|
render :template => 'common/error', :layout => use_layout, :status => @status
|
||||||
render :text => '', :layout => !request.xhr?, :status => 500
|
|
||||||
}
|
}
|
||||||
format.atom { head 500 }
|
format.atom { head @status }
|
||||||
format.xml { head 500 }
|
format.xml { head @status }
|
||||||
format.js { head 500 }
|
format.js { head @status }
|
||||||
format.json { head 500 }
|
format.json { head @status }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Picks which layout to use based on the request
|
||||||
|
#
|
||||||
|
# @return [boolean, string] name of the layout to use or false for no layout
|
||||||
|
def use_layout
|
||||||
|
request.xhr? ? false : 'base'
|
||||||
|
end
|
||||||
|
|
||||||
def invalid_authenticity_token
|
def invalid_authenticity_token
|
||||||
if api_request?
|
if api_request?
|
||||||
logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)."
|
logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)."
|
||||||
end
|
end
|
||||||
render_error "Invalid form authenticity token."
|
render_error "Invalid form authenticity token."
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_feed(items, options={})
|
def render_feed(items, options={})
|
||||||
@items = items || []
|
@items = items || []
|
||||||
@items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
|
@items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
|
||||||
@items = @items.slice(0, Setting.feeds_limit.to_i)
|
@items = @items.slice(0, Setting.feeds_limit.to_i)
|
||||||
@@ -286,15 +333,42 @@ class ApplicationController < ActionController::Base
|
|||||||
render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
|
render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: remove in Redmine 1.4
|
||||||
def self.accept_key_auth(*actions)
|
def self.accept_key_auth(*actions)
|
||||||
actions = actions.flatten.map(&:to_s)
|
ActiveSupport::Deprecation.warn "ApplicationController.accept_key_auth is deprecated and will be removed in Redmine 1.4. Use accept_rss_auth (or accept_api_auth) instead."
|
||||||
write_inheritable_attribute('accept_key_auth_actions', actions)
|
accept_rss_auth(*actions)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: remove in Redmine 1.4
|
||||||
def accept_key_auth_actions
|
def accept_key_auth_actions
|
||||||
self.class.read_inheritable_attribute('accept_key_auth_actions') || []
|
ActiveSupport::Deprecation.warn "ApplicationController.accept_key_auth_actions is deprecated and will be removed in Redmine 1.4. Use accept_rss_auth (or accept_api_auth) instead."
|
||||||
|
self.class.accept_rss_auth
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.accept_rss_auth(*actions)
|
||||||
|
if actions.any?
|
||||||
|
write_inheritable_attribute('accept_rss_auth_actions', actions)
|
||||||
|
else
|
||||||
|
read_inheritable_attribute('accept_rss_auth_actions') || []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def accept_rss_auth?(action=action_name)
|
||||||
|
self.class.accept_rss_auth.include?(action.to_sym)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.accept_api_auth(*actions)
|
||||||
|
if actions.any?
|
||||||
|
write_inheritable_attribute('accept_api_auth_actions', actions)
|
||||||
|
else
|
||||||
|
read_inheritable_attribute('accept_api_auth_actions') || []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def accept_api_auth?(action=action_name)
|
||||||
|
self.class.accept_api_auth.include?(action.to_sym)
|
||||||
|
end
|
||||||
|
|
||||||
# Returns the number of objects that should be displayed
|
# Returns the number of objects that should be displayed
|
||||||
# on the paginated list
|
# on the paginated list
|
||||||
def per_page_option
|
def per_page_option
|
||||||
@@ -310,6 +384,30 @@ class ApplicationController < ActionController::Base
|
|||||||
per_page
|
per_page
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns offset and limit used to retrieve objects
|
||||||
|
# for an API response based on offset, limit and page parameters
|
||||||
|
def api_offset_and_limit(options=params)
|
||||||
|
if options[:offset].present?
|
||||||
|
offset = options[:offset].to_i
|
||||||
|
if offset < 0
|
||||||
|
offset = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
limit = options[:limit].to_i
|
||||||
|
if limit < 1
|
||||||
|
limit = 25
|
||||||
|
elsif limit > 100
|
||||||
|
limit = 100
|
||||||
|
end
|
||||||
|
if offset.nil? && options[:page].present?
|
||||||
|
offset = (options[:page].to_i - 1) * limit
|
||||||
|
offset = 0 if offset < 0
|
||||||
|
end
|
||||||
|
offset ||= 0
|
||||||
|
|
||||||
|
[offset, limit]
|
||||||
|
end
|
||||||
|
|
||||||
# qvalues http header parser
|
# qvalues http header parser
|
||||||
# code taken from webrick
|
# code taken from webrick
|
||||||
def parse_qvalues(value)
|
def parse_qvalues(value)
|
||||||
@@ -330,21 +428,45 @@ class ApplicationController < ActionController::Base
|
|||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a string that can be used as filename value in Content-Disposition header
|
# Returns a string that can be used as filename value in Content-Disposition header
|
||||||
def filename_for_content_disposition(name)
|
def filename_for_content_disposition(name)
|
||||||
request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name
|
request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_request?
|
def api_request?
|
||||||
%w(xml json).include? params[:format]
|
%w(xml json).include? params[:format]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the API key present in the request
|
||||||
|
def api_key_from_request
|
||||||
|
if params[:key].present?
|
||||||
|
params[:key]
|
||||||
|
elsif request.headers["X-Redmine-API-Key"].present?
|
||||||
|
request.headers["X-Redmine-API-Key"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Renders a warning flash if obj has unsaved attachments
|
# Renders a warning flash if obj has unsaved attachments
|
||||||
def render_attachment_warning_if_needed(obj)
|
def render_attachment_warning_if_needed(obj)
|
||||||
flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present?
|
flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Sets the `flash` notice or error based the number of issues that did not save
|
||||||
|
#
|
||||||
|
# @param [Array, Issue] issues all of the saved and unsaved Issues
|
||||||
|
# @param [Array, Integer] unsaved_issue_ids the issue ids that were not saved
|
||||||
|
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
|
||||||
|
if unsaved_issue_ids.empty?
|
||||||
|
flash[:notice] = l(:notice_successful_update) unless issues.empty?
|
||||||
|
else
|
||||||
|
flash[:error] = l(:notice_failed_to_save_issues,
|
||||||
|
:count => unsaved_issue_ids.size,
|
||||||
|
:total => issues.size,
|
||||||
|
:ids => '#' + unsaved_issue_ids.join(', #'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Rescues an invalid query statement. Just in case...
|
# Rescues an invalid query statement. Just in case...
|
||||||
def query_statement_invalid(exception)
|
def query_statement_invalid(exception)
|
||||||
logger.error "Query::StatementInvalid: #{exception.message}" if logger
|
logger.error "Query::StatementInvalid: #{exception.message}" if logger
|
||||||
@@ -359,5 +481,37 @@ class ApplicationController < ActionController::Base
|
|||||||
{ attribute => error }
|
{ attribute => error }
|
||||||
end.to_json
|
end.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Renders API response on validation failure
|
||||||
|
def render_validation_errors(object)
|
||||||
|
options = { :status => :unprocessable_entity, :layout => false }
|
||||||
|
options.merge!(case params[:format]
|
||||||
|
when 'xml'; { :xml => object.errors }
|
||||||
|
when 'json'; { :json => {'errors' => object.errors} } # ActiveResource client compliance
|
||||||
|
else
|
||||||
|
raise "Unknown format #{params[:format]} in #render_validation_errors"
|
||||||
|
end
|
||||||
|
)
|
||||||
|
render options
|
||||||
|
end
|
||||||
|
|
||||||
|
# Overrides #default_template so that the api template
|
||||||
|
# is used automatically if it exists
|
||||||
|
def default_template(action_name = self.action_name)
|
||||||
|
if api_request?
|
||||||
|
begin
|
||||||
|
return self.view_paths.find_template(default_template_name(action_name), 'api')
|
||||||
|
rescue ::ActionView::MissingTemplate
|
||||||
|
# the api template was not found
|
||||||
|
# fallback to the default behaviour
|
||||||
|
end
|
||||||
|
end
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
# Overrides #pick_layout so that #render with no arguments
|
||||||
|
# doesn't use the layout for api requests
|
||||||
|
def pick_layout(*args)
|
||||||
|
api_request? ? nil : super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -19,9 +19,9 @@ class AttachmentsController < ApplicationController
|
|||||||
before_filter :find_project
|
before_filter :find_project
|
||||||
before_filter :file_readable, :read_authorize, :except => :destroy
|
before_filter :file_readable, :read_authorize, :except => :destroy
|
||||||
before_filter :delete_authorize, :only => :destroy
|
before_filter :delete_authorize, :only => :destroy
|
||||||
|
|
||||||
verify :method => :post, :only => :destroy
|
verify :method => :post, :only => :destroy
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if @attachment.is_diff?
|
if @attachment.is_diff?
|
||||||
@diff = File.new(@attachment.diskfile, "rb").read
|
@diff = File.new(@attachment.diskfile, "rb").read
|
||||||
@@ -33,19 +33,19 @@ class AttachmentsController < ApplicationController
|
|||||||
download
|
download
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def download
|
def download
|
||||||
if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
|
if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
|
||||||
@attachment.increment_download
|
@attachment.increment_download
|
||||||
end
|
end
|
||||||
|
|
||||||
# images are sent inline
|
# images are sent inline
|
||||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||||
:type => detect_content_type(@attachment),
|
:type => detect_content_type(@attachment),
|
||||||
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
# Make sure association callbacks are called
|
# Make sure association callbacks are called
|
||||||
@attachment.container.attachments.delete(@attachment)
|
@attachment.container.attachments.delete(@attachment)
|
||||||
@@ -53,7 +53,7 @@ class AttachmentsController < ApplicationController
|
|||||||
rescue ::ActionController::RedirectBackError
|
rescue ::ActionController::RedirectBackError
|
||||||
redirect_to :controller => 'projects', :action => 'show', :id => @project
|
redirect_to :controller => 'projects', :action => 'show', :id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@attachment = Attachment.find(params[:id])
|
@attachment = Attachment.find(params[:id])
|
||||||
@@ -63,20 +63,20 @@ private
|
|||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks that the file exists and is readable
|
# Checks that the file exists and is readable
|
||||||
def file_readable
|
def file_readable
|
||||||
@attachment.readable? ? true : render_404
|
@attachment.readable? ? true : render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_authorize
|
def read_authorize
|
||||||
@attachment.visible? ? true : deny_access
|
@attachment.visible? ? true : deny_access
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_authorize
|
def delete_authorize
|
||||||
@attachment.deletable? ? true : deny_access
|
@attachment.deletable? ? true : deny_access
|
||||||
end
|
end
|
||||||
|
|
||||||
def detect_content_type(attachment)
|
def detect_content_type(attachment)
|
||||||
content_type = attachment.content_type
|
content_type = attachment.content_type
|
||||||
if content_type.blank?
|
if content_type.blank?
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
class AutoCompletesController < ApplicationController
|
||||||
|
before_filter :find_project
|
||||||
|
|
||||||
|
def issues
|
||||||
|
@issues = []
|
||||||
|
q = params[:q].to_s
|
||||||
|
query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
|
||||||
|
if q.match(/^\d+$/)
|
||||||
|
@issues << query.visible.find_by_id(q.to_i)
|
||||||
|
end
|
||||||
|
unless q.blank?
|
||||||
|
@issues += query.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
|
||||||
|
end
|
||||||
|
@issues.compact!
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_project
|
||||||
|
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
|
||||||
|
@project = Project.find(project_id)
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
class BoardsController < ApplicationController
|
class BoardsController < ApplicationController
|
||||||
default_search_scope :messages
|
default_search_scope :messages
|
||||||
before_filter :find_project, :find_board_if_available, :authorize
|
before_filter :find_project, :find_board_if_available, :authorize
|
||||||
|
accept_rss_auth :index, :show
|
||||||
|
|
||||||
helper :messages
|
helper :messages
|
||||||
include MessagesHelper
|
include MessagesHelper
|
||||||
|
|||||||
@@ -1,4 +1,22 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class CalendarsController < ApplicationController
|
class CalendarsController < ApplicationController
|
||||||
|
menu_item :calendar
|
||||||
before_filter :find_optional_project
|
before_filter :find_optional_project
|
||||||
|
|
||||||
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
|
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
|
||||||
@@ -7,6 +25,8 @@ class CalendarsController < ApplicationController
|
|||||||
helper :projects
|
helper :projects
|
||||||
helper :queries
|
helper :queries
|
||||||
include QueriesHelper
|
include QueriesHelper
|
||||||
|
helper :sort
|
||||||
|
include SortHelper
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if params[:year] and params[:year].to_i > 1900
|
if params[:year] and params[:year].to_i > 1900
|
||||||
@@ -31,8 +51,6 @@ class CalendarsController < ApplicationController
|
|||||||
@calendar.events = events
|
@calendar.events = events
|
||||||
end
|
end
|
||||||
|
|
||||||
render :layout => false if request.xhr?
|
render :action => 'show', :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
class CommentsController < ApplicationController
|
||||||
|
default_search_scope :news
|
||||||
|
model_object News
|
||||||
|
before_filter :find_model_object
|
||||||
|
before_filter :find_project_from_association
|
||||||
|
before_filter :authorize
|
||||||
|
|
||||||
|
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
def create
|
||||||
|
@comment = Comment.new(params[:comment])
|
||||||
|
@comment.author = User.current
|
||||||
|
if @news.comments << @comment
|
||||||
|
flash[:notice] = l(:label_comment_added)
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to :controller => 'news', :action => 'show', :id => @news
|
||||||
|
end
|
||||||
|
|
||||||
|
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
def destroy
|
||||||
|
@news.comments.find(params[:comment_id]).destroy
|
||||||
|
redirect_to :controller => 'news', :action => 'show', :id => @news
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# ApplicationController's find_model_object sets it based on the controller
|
||||||
|
# name so it needs to be overriden and set to @news instead
|
||||||
|
def find_model_object
|
||||||
|
super
|
||||||
|
@news = @object
|
||||||
|
@comment = nil
|
||||||
|
@news
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
class ContextMenusController < ApplicationController
|
||||||
|
helper :watchers
|
||||||
|
helper :issues
|
||||||
|
|
||||||
|
def issues
|
||||||
|
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
|
||||||
|
|
||||||
|
if (@issues.size == 1)
|
||||||
|
@issue = @issues.first
|
||||||
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||||
|
else
|
||||||
|
@allowed_statuses = @issues.map do |i|
|
||||||
|
i.new_statuses_allowed_to(User.current)
|
||||||
|
end.inject do |memo,s|
|
||||||
|
memo & s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@projects = @issues.collect(&:project).compact.uniq
|
||||||
|
@project = @projects.first if @projects.size == 1
|
||||||
|
|
||||||
|
@can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
|
||||||
|
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
||||||
|
:update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)),
|
||||||
|
:move => (@project && User.current.allowed_to?(:move_issues, @project)),
|
||||||
|
:copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
|
||||||
|
:delete => User.current.allowed_to?(:delete_issues, @projects)
|
||||||
|
}
|
||||||
|
if @project
|
||||||
|
@assignables = @project.assignable_users
|
||||||
|
@assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
|
||||||
|
@trackers = @project.trackers
|
||||||
|
else
|
||||||
|
#when multiple projects, we only keep the intersection of each set
|
||||||
|
@assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a}
|
||||||
|
@trackers = @projects.map(&:trackers).inject{|memo,t| memo & t}
|
||||||
|
end
|
||||||
|
|
||||||
|
@priorities = IssuePriority.all.reverse
|
||||||
|
@statuses = IssueStatus.find(:all, :order => 'position')
|
||||||
|
@back = back_url
|
||||||
|
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
|
|
||||||
|
def time_entries
|
||||||
|
@time_entries = TimeEntry.all(
|
||||||
|
:conditions => {:id => params[:ids]}, :include => :project)
|
||||||
|
@projects = @time_entries.collect(&:project).compact.uniq
|
||||||
|
@project = @projects.first if @projects.size == 1
|
||||||
|
@activities = TimeEntryActivity.shared.active
|
||||||
|
@can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects),
|
||||||
|
:delete => User.current.allowed_to?(:edit_time_entries, @projects)
|
||||||
|
}
|
||||||
|
@back = back_url
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -38,8 +38,9 @@ class CustomFieldsController < ApplicationController
|
|||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field)
|
call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field)
|
||||||
redirect_to :action => 'index', :tab => @custom_field.class.name
|
redirect_to :action => 'index', :tab => @custom_field.class.name
|
||||||
|
else
|
||||||
|
@trackers = Tracker.find(:all, :order => 'position')
|
||||||
end
|
end
|
||||||
@trackers = Tracker.find(:all, :order => 'position')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@@ -48,8 +49,9 @@ class CustomFieldsController < ApplicationController
|
|||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field)
|
call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field)
|
||||||
redirect_to :action => 'index', :tab => @custom_field.class.name
|
redirect_to :action => 'index', :tab => @custom_field.class.name
|
||||||
|
else
|
||||||
|
@trackers = Tracker.find(:all, :order => 'position')
|
||||||
end
|
end
|
||||||
@trackers = Tracker.find(:all, :order => 'position')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|||||||
@@ -75,10 +75,12 @@ class EnumerationsController < ApplicationController
|
|||||||
# No associated objects
|
# No associated objects
|
||||||
@enumeration.destroy
|
@enumeration.destroy
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
|
return
|
||||||
elsif params[:reassign_to_id]
|
elsif params[:reassign_to_id]
|
||||||
if reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id])
|
if reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id])
|
||||||
@enumeration.destroy(reassign_to)
|
@enumeration.destroy(reassign_to)
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@enumerations = @enumeration.class.find(:all) - [@enumeration]
|
@enumerations = @enumeration.class.find(:all) - [@enumeration]
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
class FilesController < ApplicationController
|
||||||
|
menu_item :files
|
||||||
|
|
||||||
|
before_filter :find_project_by_project_id
|
||||||
|
before_filter :authorize
|
||||||
|
|
||||||
|
helper :sort
|
||||||
|
include SortHelper
|
||||||
|
|
||||||
|
def index
|
||||||
|
sort_init 'filename', 'asc'
|
||||||
|
sort_update 'filename' => "#{Attachment.table_name}.filename",
|
||||||
|
'created_on' => "#{Attachment.table_name}.created_on",
|
||||||
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
|
||||||
|
@containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
|
||||||
|
@containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
|
||||||
|
render :layout => !request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@versions = @project.versions.sort
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
||||||
|
attachments = Attachment.attach_files(container, params[:attachments])
|
||||||
|
render_attachment_warning_if_needed(container)
|
||||||
|
|
||||||
|
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||||
|
Mailer.deliver_attachments_added(attachments[:files])
|
||||||
|
end
|
||||||
|
redirect_to project_files_path(@project)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,8 +1,27 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class GanttsController < ApplicationController
|
class GanttsController < ApplicationController
|
||||||
|
menu_item :gantt
|
||||||
before_filter :find_optional_project
|
before_filter :find_optional_project
|
||||||
|
|
||||||
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
|
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
|
||||||
|
|
||||||
|
helper :gantt
|
||||||
helper :issues
|
helper :issues
|
||||||
helper :projects
|
helper :projects
|
||||||
helper :queries
|
helper :queries
|
||||||
@@ -13,33 +32,17 @@ class GanttsController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@gantt = Redmine::Helpers::Gantt.new(params)
|
@gantt = Redmine::Helpers::Gantt.new(params)
|
||||||
|
@gantt.project = @project
|
||||||
retrieve_query
|
retrieve_query
|
||||||
@query.group_by = nil
|
@query.group_by = nil
|
||||||
if @query.valid?
|
@gantt.query = @query if @query.valid?
|
||||||
events = []
|
|
||||||
# Issues that have start and due dates
|
|
||||||
events += @query.issues(:include => [:tracker, :assigned_to, :priority],
|
|
||||||
:order => "start_date, due_date",
|
|
||||||
:conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
|
|
||||||
)
|
|
||||||
# Issues that don't have a due date but that are assigned to a version with a date
|
|
||||||
events += @query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version],
|
|
||||||
:order => "start_date, effective_date",
|
|
||||||
:conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
|
|
||||||
)
|
|
||||||
# Versions
|
|
||||||
events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to])
|
|
||||||
|
|
||||||
@gantt.events = events
|
|
||||||
end
|
|
||||||
|
|
||||||
basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
|
basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => "show", :layout => !request.xhr? }
|
format.html { render :action => "show", :layout => !request.xhr? }
|
||||||
format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image')
|
format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image')
|
||||||
format.pdf { send_data(gantt_to_pdf(@gantt, @project), :type => 'application/pdf', :filename => "#{basename}.pdf") }
|
format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class GroupsController < ApplicationController
|
|||||||
|
|
||||||
def autocomplete_for_user
|
def autocomplete_for_user
|
||||||
@group = Group.find(params[:id])
|
@group = Group.find(params[:id])
|
||||||
@users = User.active.like(params[:q]).find(:all, :limit => 100) - @group.users
|
@users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100)
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -141,14 +141,22 @@ class GroupsController < ApplicationController
|
|||||||
@membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
|
@membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
|
||||||
@membership.save if request.post?
|
@membership.save if request.post?
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
|
if @membership.valid?
|
||||||
format.js {
|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
|
||||||
render(:update) {|page|
|
format.js {
|
||||||
page.replace_html "tab-content-memberships", :partial => 'groups/memberships'
|
render(:update) {|page|
|
||||||
page.visual_effect(:highlight, "member-#{@membership.id}")
|
page.replace_html "tab-content-memberships", :partial => 'groups/memberships'
|
||||||
}
|
page.visual_effect(:highlight, "member-#{@membership.id}")
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
|
else
|
||||||
|
format.js {
|
||||||
|
render(:update) {|page|
|
||||||
|
page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_membership
|
def destroy_membership
|
||||||
|
|||||||
@@ -65,10 +65,12 @@ class IssueCategoriesController < ApplicationController
|
|||||||
# No issue assigned to this category
|
# No issue assigned to this category
|
||||||
@category.destroy
|
@category.destroy
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
|
||||||
|
return
|
||||||
elsif params[:todo]
|
elsif params[:todo]
|
||||||
reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
|
reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
|
||||||
@category.destroy(reassign_to)
|
@category.destroy(reassign_to)
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
|
||||||
|
return
|
||||||
end
|
end
|
||||||
@categories = @project.issue_categories - [@category]
|
@categories = @project.issue_categories - [@category]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
class IssueMovesController < ApplicationController
|
||||||
|
default_search_scope :issues
|
||||||
|
before_filter :find_issues, :check_project_uniqueness
|
||||||
|
before_filter :authorize
|
||||||
|
|
||||||
|
def new
|
||||||
|
prepare_for_issue_move
|
||||||
|
render :layout => false if request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
prepare_for_issue_move
|
||||||
|
|
||||||
|
if request.post?
|
||||||
|
new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
|
||||||
|
unsaved_issue_ids = []
|
||||||
|
moved_issues = []
|
||||||
|
@issues.each do |issue|
|
||||||
|
issue.reload
|
||||||
|
issue.init_journal(User.current)
|
||||||
|
issue.current_journal.notes = @notes if @notes.present?
|
||||||
|
call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy })
|
||||||
|
if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)})
|
||||||
|
moved_issues << r
|
||||||
|
else
|
||||||
|
unsaved_issue_ids << issue.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
|
||||||
|
|
||||||
|
if params[:follow]
|
||||||
|
if @issues.size == 1 && moved_issues.size == 1
|
||||||
|
redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first
|
||||||
|
else
|
||||||
|
redirect_to :controller => 'issues', :action => 'index', :project_id => (@target_project || @project)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
redirect_to :controller => 'issues', :action => 'index', :project_id => @project
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def prepare_for_issue_move
|
||||||
|
@issues.sort!
|
||||||
|
@copy = params[:copy_options] && params[:copy_options][:copy]
|
||||||
|
@allowed_projects = Issue.allowed_target_projects_on_move
|
||||||
|
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
|
||||||
|
@target_project ||= @project
|
||||||
|
@trackers = @target_project.trackers
|
||||||
|
@available_statuses = Workflow.available_statuses(@project)
|
||||||
|
@notes = params[:notes]
|
||||||
|
@notes ||= ''
|
||||||
|
end
|
||||||
|
|
||||||
|
def extract_changed_attributes_for_move(params)
|
||||||
|
changed_attributes = {}
|
||||||
|
[:assigned_to_id, :status_id, :start_date, :due_date, :priority_id].each do |valid_attribute|
|
||||||
|
unless params[valid_attribute].blank?
|
||||||
|
changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
changed_attributes
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
@@ -28,6 +28,7 @@ class IssueRelationsController < ApplicationController
|
|||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
||||||
format.js do
|
format.js do
|
||||||
|
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
|
||||||
render :update do |page|
|
render :update do |page|
|
||||||
page.replace_html "relations", :partial => 'issues/relations'
|
page.replace_html "relations", :partial => 'issues/relations'
|
||||||
if @relation.errors.empty?
|
if @relation.errors.empty?
|
||||||
@@ -47,7 +48,10 @@ class IssueRelationsController < ApplicationController
|
|||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
||||||
format.js { render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'} }
|
format.js {
|
||||||
|
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
|
||||||
|
render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -18,21 +18,23 @@
|
|||||||
class IssuesController < ApplicationController
|
class IssuesController < ApplicationController
|
||||||
menu_item :new_issue, :only => [:new, :create]
|
menu_item :new_issue, :only => [:new, :create]
|
||||||
default_search_scope :issues
|
default_search_scope :issues
|
||||||
|
|
||||||
before_filter :find_issue, :only => [:show, :edit, :update, :reply]
|
before_filter :find_issue, :only => [:show, :edit, :update]
|
||||||
before_filter :find_issues, :only => [:bulk_edit, :move, :destroy]
|
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
|
||||||
before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete]
|
before_filter :check_project_uniqueness, :only => [:move, :perform_move]
|
||||||
before_filter :authorize, :except => [:index, :changes, :preview, :context_menu]
|
before_filter :find_project, :only => [:new, :create]
|
||||||
before_filter :find_optional_project, :only => [:index, :changes]
|
before_filter :authorize, :except => [:index]
|
||||||
|
before_filter :find_optional_project, :only => [:index]
|
||||||
before_filter :check_for_default_issue_status, :only => [:new, :create]
|
before_filter :check_for_default_issue_status, :only => [:new, :create]
|
||||||
before_filter :build_new_issue_from_params, :only => [:new, :create]
|
before_filter :build_new_issue_from_params, :only => [:new, :create]
|
||||||
accept_key_auth :index, :show, :changes
|
accept_rss_auth :index, :show
|
||||||
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
|
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
|
||||||
|
|
||||||
helper :journals
|
helper :journals
|
||||||
helper :projects
|
helper :projects
|
||||||
include ProjectsHelper
|
include ProjectsHelper
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
include CustomFieldsHelper
|
include CustomFieldsHelper
|
||||||
helper :issue_relations
|
helper :issue_relations
|
||||||
@@ -43,10 +45,13 @@ class IssuesController < ApplicationController
|
|||||||
include AttachmentsHelper
|
include AttachmentsHelper
|
||||||
helper :queries
|
helper :queries
|
||||||
include QueriesHelper
|
include QueriesHelper
|
||||||
|
helper :repositories
|
||||||
|
include RepositoriesHelper
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
include IssuesHelper
|
include IssuesHelper
|
||||||
helper :timelog
|
helper :timelog
|
||||||
|
helper :gantt
|
||||||
include Redmine::Export::PDF
|
include Redmine::Export::PDF
|
||||||
|
|
||||||
verify :method => [:post, :delete],
|
verify :method => [:post, :delete],
|
||||||
@@ -54,35 +59,38 @@ class IssuesController < ApplicationController
|
|||||||
:render => { :nothing => true, :status => :method_not_allowed }
|
:render => { :nothing => true, :status => :method_not_allowed }
|
||||||
|
|
||||||
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
verify :method => :post, :only => :bulk_update, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
|
||||||
def index
|
def index
|
||||||
retrieve_query
|
retrieve_query
|
||||||
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
|
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
|
||||||
sort_update(@query.sortable_columns)
|
sort_update(@query.sortable_columns)
|
||||||
|
|
||||||
if @query.valid?
|
if @query.valid?
|
||||||
limit = case params[:format]
|
case params[:format]
|
||||||
when 'csv', 'pdf'
|
when 'csv', 'pdf'
|
||||||
Setting.issues_export_limit.to_i
|
@limit = Setting.issues_export_limit.to_i
|
||||||
when 'atom'
|
when 'atom'
|
||||||
Setting.feeds_limit.to_i
|
@limit = Setting.feeds_limit.to_i
|
||||||
|
when 'xml', 'json'
|
||||||
|
@offset, @limit = api_offset_and_limit
|
||||||
else
|
else
|
||||||
per_page_option
|
@limit = per_page_option
|
||||||
end
|
end
|
||||||
|
|
||||||
@issue_count = @query.issue_count
|
@issue_count = @query.issue_count
|
||||||
@issue_pages = Paginator.new self, @issue_count, limit, params['page']
|
@issue_pages = Paginator.new self, @issue_count, @limit, params['page']
|
||||||
|
@offset ||= @issue_pages.current.offset
|
||||||
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
|
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
|
||||||
:order => sort_clause,
|
:order => sort_clause,
|
||||||
:offset => @issue_pages.current.offset,
|
:offset => @offset,
|
||||||
:limit => limit)
|
:limit => @limit)
|
||||||
@issue_count_by_group = @query.issue_count_by_group
|
@issue_count_by_group = @query.issue_count_by_group
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
|
format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
|
||||||
format.xml { render :layout => false }
|
format.api
|
||||||
format.json { render :text => @issues.to_json, :layout => false }
|
|
||||||
format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
|
format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
|
||||||
format.csv { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
|
format.csv { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
|
||||||
format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
|
format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
|
||||||
@@ -94,37 +102,26 @@ class IssuesController < ApplicationController
|
|||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
def changes
|
|
||||||
retrieve_query
|
|
||||||
sort_init 'id', 'desc'
|
|
||||||
sort_update(@query.sortable_columns)
|
|
||||||
|
|
||||||
if @query.valid?
|
|
||||||
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
|
|
||||||
:limit => 25)
|
|
||||||
end
|
|
||||||
@title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
|
|
||||||
render :layout => false, :content_type => 'application/atom+xml'
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
render_404
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
|
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
|
||||||
@journals.each_with_index {|j,i| j.indice = i+1}
|
@journals.each_with_index {|j,i| j.indice = i+1}
|
||||||
@journals.reverse! if User.current.wants_comments_in_reverse_order?
|
@journals.reverse! if User.current.wants_comments_in_reverse_order?
|
||||||
@changesets = @issue.changesets.visible.all
|
|
||||||
@changesets.reverse! if User.current.wants_comments_in_reverse_order?
|
if User.current.allowed_to?(:view_changesets, @project)
|
||||||
|
@changesets = @issue.changesets.visible.all
|
||||||
|
@changesets.reverse! if User.current.wants_comments_in_reverse_order?
|
||||||
|
end
|
||||||
|
|
||||||
|
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
|
||||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||||
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||||||
@priorities = IssuePriority.all
|
@priorities = IssuePriority.all
|
||||||
@time_entry = TimeEntry.new
|
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :template => 'issues/show.rhtml' }
|
format.html { render :template => 'issues/show.rhtml' }
|
||||||
format.xml { render :layout => false }
|
format.api
|
||||||
format.json { render :text => @issue.to_json, :layout => false }
|
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
|
||||||
format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
|
|
||||||
format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
|
format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -132,7 +129,10 @@ class IssuesController < ApplicationController
|
|||||||
# Add a new issue
|
# Add a new issue
|
||||||
# The new issue will be created from an existing one if copy_from parameter is given
|
# The new issue will be created from an existing one if copy_from parameter is given
|
||||||
def new
|
def new
|
||||||
render :action => 'new', :layout => !request.xhr?
|
respond_to do |format|
|
||||||
|
format.html { render :action => 'new', :layout => !request.xhr? }
|
||||||
|
format.js { render :partial => 'attributes' }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -144,26 +144,20 @@ class IssuesController < ApplicationController
|
|||||||
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
|
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
redirect_to(params[:continue] ? { :action => 'new', :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
|
redirect_to(params[:continue] ? { :action => 'new', :project_id => @project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
|
||||||
{ :action => 'show', :id => @issue })
|
{ :action => 'show', :id => @issue })
|
||||||
}
|
}
|
||||||
format.xml { render :action => 'show', :status => :created, :location => url_for(:controller => 'issues', :action => 'show', :id => @issue) }
|
format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
|
||||||
format.json { render :text => @issue.to_json, :status => :created, :location => url_for(:controller => 'issues', :action => 'show'), :layout => false }
|
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'new' }
|
format.html { render :action => 'new' }
|
||||||
format.xml { render(:xml => @issue.errors, :status => :unprocessable_entity); return }
|
format.api { render_validation_errors(@issue) }
|
||||||
format.json { render :text => object_errors_to_json(@issue), :status => :unprocessable_entity, :layout => false }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Attributes that can be updated on workflow transition (without :edit permission)
|
|
||||||
# TODO: make it configurable (at least per role)
|
|
||||||
UPDATABLE_ATTRS_ON_TRANSITION = %w(status_id assigned_to_id fixed_version_id done_ratio) unless const_defined?(:UPDATABLE_ATTRS_ON_TRANSITION)
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
update_issue_from_params
|
update_issue_from_params
|
||||||
|
|
||||||
@@ -184,8 +178,7 @@ class IssuesController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_back_or_default({:action => 'show', :id => @issue}) }
|
format.html { redirect_back_or_default({:action => 'show', :id => @issue}) }
|
||||||
format.xml { head :ok }
|
format.api { head :ok }
|
||||||
format.json { head :ok }
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render_attachment_warning_if_needed(@issue)
|
render_attachment_warning_if_needed(@issue)
|
||||||
@@ -194,106 +187,39 @@ class IssuesController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'edit' }
|
format.html { render :action => 'edit' }
|
||||||
format.xml { render :xml => @issue.errors, :status => :unprocessable_entity }
|
format.api { render_validation_errors(@issue) }
|
||||||
format.json { render :text => object_errors_to_json(@issue), :status => :unprocessable_entity, :layout => false }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def reply
|
|
||||||
journal = Journal.find(params[:journal_id]) if params[:journal_id]
|
|
||||||
if journal
|
|
||||||
user = journal.user
|
|
||||||
text = journal.notes
|
|
||||||
else
|
|
||||||
user = @issue.author
|
|
||||||
text = @issue.description
|
|
||||||
end
|
|
||||||
# Replaces pre blocks with [...]
|
|
||||||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
|
||||||
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
|
||||||
content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
|
||||||
|
|
||||||
render(:update) { |page|
|
|
||||||
page.<< "$('notes').value = \"#{escape_javascript content}\";"
|
|
||||||
page.show 'update'
|
|
||||||
page << "Form.Element.focus('notes');"
|
|
||||||
page << "Element.scrollTo('update');"
|
|
||||||
page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# Bulk edit a set of issues
|
# Bulk edit a set of issues
|
||||||
def bulk_edit
|
def bulk_edit
|
||||||
@issues.sort!
|
@issues.sort!
|
||||||
if request.post?
|
@available_statuses = @projects.map{|p|Workflow.available_statuses(p)}.inject{|memo,w|memo & w}
|
||||||
attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
|
@custom_fields = @projects.map{|p|p.all_issue_custom_fields}.inject{|memo,c|memo & c}
|
||||||
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
|
@assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a}
|
||||||
attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values]
|
@trackers = @projects.map(&:trackers).inject{|memo,t| memo & t}
|
||||||
|
|
||||||
unsaved_issue_ids = []
|
|
||||||
@issues.each do |issue|
|
|
||||||
issue.reload
|
|
||||||
journal = issue.init_journal(User.current, params[:notes])
|
|
||||||
issue.safe_attributes = attributes
|
|
||||||
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
|
|
||||||
unless issue.save
|
|
||||||
# Keep unsaved issue ids to display them in flash error
|
|
||||||
unsaved_issue_ids << issue.id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
|
|
||||||
redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
@available_statuses = Workflow.available_statuses(@project)
|
|
||||||
@custom_fields = @project.all_issue_custom_fields
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def move
|
def bulk_update
|
||||||
@issues.sort!
|
@issues.sort!
|
||||||
@copy = params[:copy_options] && params[:copy_options][:copy]
|
attributes = parse_params_for_bulk_issue_attributes(params)
|
||||||
@allowed_projects = Issue.allowed_target_projects_on_move
|
|
||||||
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
|
|
||||||
@target_project ||= @project
|
|
||||||
@trackers = @target_project.trackers
|
|
||||||
@available_statuses = Workflow.available_statuses(@project)
|
|
||||||
if request.post?
|
|
||||||
new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
|
|
||||||
unsaved_issue_ids = []
|
|
||||||
moved_issues = []
|
|
||||||
@issues.each do |issue|
|
|
||||||
issue.reload
|
|
||||||
changed_attributes = {}
|
|
||||||
[:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute|
|
|
||||||
unless params[valid_attribute].blank?
|
|
||||||
changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
issue.init_journal(User.current)
|
|
||||||
call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy })
|
|
||||||
if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => changed_attributes})
|
|
||||||
moved_issues << r
|
|
||||||
else
|
|
||||||
unsaved_issue_ids << issue.id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
|
|
||||||
|
|
||||||
if params[:follow]
|
unsaved_issue_ids = []
|
||||||
if @issues.size == 1 && moved_issues.size == 1
|
@issues.each do |issue|
|
||||||
redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first
|
issue.reload
|
||||||
else
|
journal = issue.init_journal(User.current, params[:notes])
|
||||||
redirect_to :controller => 'issues', :action => 'index', :project_id => (@target_project || @project)
|
issue.safe_attributes = attributes
|
||||||
end
|
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
|
||||||
else
|
unless issue.save
|
||||||
redirect_to :controller => 'issues', :action => 'index', :project_id => @project
|
# Keep unsaved issue ids to display them in flash error
|
||||||
|
unsaved_issue_ids << issue.id
|
||||||
end
|
end
|
||||||
return
|
|
||||||
end
|
end
|
||||||
render :layout => false if request.xhr?
|
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
|
||||||
|
redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
|
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
|
||||||
if @hours > 0
|
if @hours > 0
|
||||||
@@ -311,121 +237,44 @@ class IssuesController < ApplicationController
|
|||||||
TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
|
TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
unless params[:format] == 'xml' || params[:format] == 'json'
|
# display the destroy form if it's a user request
|
||||||
# display the destroy form if it's a user request
|
return unless api_request?
|
||||||
return
|
end
|
||||||
end
|
end
|
||||||
|
@issues.each do |issue|
|
||||||
|
begin
|
||||||
|
issue.reload.destroy
|
||||||
|
rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
|
||||||
|
# nothing to do, issue was already deleted (eg. by a parent)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@issues.each(&:destroy)
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to :action => 'index', :project_id => @project }
|
format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
|
||||||
format.xml { head :ok }
|
format.api { head :ok }
|
||||||
format.json { head :ok }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def context_menu
|
|
||||||
@issues = Issue.find_all_by_id(params[:ids], :include => :project)
|
|
||||||
if (@issues.size == 1)
|
|
||||||
@issue = @issues.first
|
|
||||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
|
||||||
end
|
|
||||||
projects = @issues.collect(&:project).compact.uniq
|
|
||||||
@project = projects.first if projects.size == 1
|
|
||||||
|
|
||||||
@can = {:edit => (@project && User.current.allowed_to?(:edit_issues, @project)),
|
|
||||||
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
|
||||||
:update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
|
|
||||||
:move => (@project && User.current.allowed_to?(:move_issues, @project)),
|
|
||||||
:copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
|
|
||||||
:delete => (@project && User.current.allowed_to?(:delete_issues, @project))
|
|
||||||
}
|
|
||||||
if @project
|
|
||||||
@assignables = @project.assignable_users
|
|
||||||
@assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
|
|
||||||
@trackers = @project.trackers
|
|
||||||
end
|
|
||||||
|
|
||||||
@priorities = IssuePriority.all.reverse
|
|
||||||
@statuses = IssueStatus.find(:all, :order => 'position')
|
|
||||||
@back = params[:back_url] || request.env['HTTP_REFERER']
|
|
||||||
|
|
||||||
render :layout => false
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_form
|
|
||||||
if params[:id].blank?
|
|
||||||
@issue = Issue.new
|
|
||||||
@issue.project = @project
|
|
||||||
else
|
|
||||||
@issue = @project.issues.visible.find(params[:id])
|
|
||||||
end
|
|
||||||
@issue.attributes = params[:issue]
|
|
||||||
@allowed_statuses = ([@issue.status] + @issue.status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq
|
|
||||||
@priorities = IssuePriority.all
|
|
||||||
|
|
||||||
render :partial => 'attributes'
|
|
||||||
end
|
|
||||||
|
|
||||||
def preview
|
|
||||||
@issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
|
|
||||||
if @issue
|
|
||||||
@attachements = @issue.attachments
|
|
||||||
@description = params[:issue] && params[:issue][:description]
|
|
||||||
if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
|
|
||||||
@description = nil
|
|
||||||
end
|
|
||||||
@notes = params[:notes]
|
|
||||||
else
|
|
||||||
@description = (params[:issue] ? params[:issue][:description] : nil)
|
|
||||||
end
|
|
||||||
render :layout => false
|
|
||||||
end
|
|
||||||
|
|
||||||
def auto_complete
|
|
||||||
@issues = []
|
|
||||||
q = params[:q].to_s
|
|
||||||
if q.match(/^\d+$/)
|
|
||||||
@issues << @project.issues.visible.find_by_id(q.to_i)
|
|
||||||
end
|
|
||||||
unless q.blank?
|
|
||||||
@issues += @project.issues.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
|
|
||||||
end
|
|
||||||
render :layout => false
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_issue
|
def find_issue
|
||||||
|
# Issue.visible.find(...) can not be used to redirect user to the login form
|
||||||
|
# if the issue actually exists but requires authentication
|
||||||
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
|
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
|
||||||
|
unless @issue.visible?
|
||||||
|
deny_access
|
||||||
|
return
|
||||||
|
end
|
||||||
@project = @issue.project
|
@project = @issue.project
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
# Filter for bulk operations
|
|
||||||
def find_issues
|
|
||||||
@issues = Issue.find_all_by_id(params[:id] || params[:ids])
|
|
||||||
raise ActiveRecord::RecordNotFound if @issues.empty?
|
|
||||||
projects = @issues.collect(&:project).compact.uniq
|
|
||||||
if projects.size == 1
|
|
||||||
@project = projects.first
|
|
||||||
else
|
|
||||||
# TODO: let users bulk edit/move/destroy issues from different projects
|
|
||||||
render_error 'Can not bulk edit/move/destroy issues from different projects'
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
render_404
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_project
|
def find_project
|
||||||
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
|
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
|
||||||
@project = Project.find(project_id)
|
@project = Project.find(project_id)
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
# Used by #edit and #update to set some common instance variables
|
# Used by #edit and #update to set some common instance variables
|
||||||
# from the params
|
# from the params
|
||||||
# TODO: Refactor, not everything in here is needed by #edit
|
# TODO: Refactor, not everything in here is needed by #edit
|
||||||
@@ -433,56 +282,55 @@ private
|
|||||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||||
@priorities = IssuePriority.all
|
@priorities = IssuePriority.all
|
||||||
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||||||
@time_entry = TimeEntry.new
|
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
||||||
|
@time_entry.attributes = params[:time_entry]
|
||||||
@notes = params[:notes]
|
|
||||||
@issue.init_journal(User.current, @notes)
|
|
||||||
# User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
|
|
||||||
if (@edit_allowed || !@allowed_statuses.empty?) && params[:issue]
|
|
||||||
attrs = params[:issue].dup
|
|
||||||
attrs.delete_if {|k,v| !UPDATABLE_ATTRS_ON_TRANSITION.include?(k) } unless @edit_allowed
|
|
||||||
attrs.delete(:status_id) unless @allowed_statuses.detect {|s| s.id.to_s == attrs[:status_id].to_s}
|
|
||||||
@issue.safe_attributes = attrs
|
|
||||||
end
|
|
||||||
|
|
||||||
|
@notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
|
||||||
|
@issue.init_journal(User.current, @notes)
|
||||||
|
@issue.safe_attributes = params[:issue]
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Refactor, lots of extra code in here
|
# TODO: Refactor, lots of extra code in here
|
||||||
|
# TODO: Changing tracker on an existing issue should not trigger this
|
||||||
def build_new_issue_from_params
|
def build_new_issue_from_params
|
||||||
@issue = Issue.new
|
if params[:id].blank?
|
||||||
@issue.copy_from(params[:copy_from]) if params[:copy_from]
|
@issue = Issue.new
|
||||||
|
@issue.copy_from(params[:copy_from]) if params[:copy_from]
|
||||||
|
@issue.project = @project
|
||||||
|
else
|
||||||
|
@issue = @project.issues.visible.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
@issue.project = @project
|
@issue.project = @project
|
||||||
|
@issue.author = User.current
|
||||||
# Tracker must be set before custom field values
|
# Tracker must be set before custom field values
|
||||||
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
|
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
|
||||||
if @issue.tracker.nil?
|
if @issue.tracker.nil?
|
||||||
render_error l(:error_no_tracker_in_project)
|
render_error l(:error_no_tracker_in_project)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@issue.start_date ||= Date.today
|
||||||
if params[:issue].is_a?(Hash)
|
if params[:issue].is_a?(Hash)
|
||||||
@issue.safe_attributes = params[:issue]
|
@issue.safe_attributes = params[:issue]
|
||||||
@issue.watcher_user_ids = params[:issue]['watcher_user_ids'] if User.current.allowed_to?(:add_issue_watchers, @project)
|
if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record?
|
||||||
|
@issue.watcher_user_ids = params[:issue]['watcher_user_ids']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@issue.author = User.current
|
|
||||||
@issue.start_date ||= Date.today
|
|
||||||
@priorities = IssuePriority.all
|
@priorities = IssuePriority.all
|
||||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
|
|
||||||
if unsaved_issue_ids.empty?
|
|
||||||
flash[:notice] = l(:notice_successful_update) unless issues.empty?
|
|
||||||
else
|
|
||||||
flash[:error] = l(:notice_failed_to_save_issues,
|
|
||||||
:count => unsaved_issue_ids.size,
|
|
||||||
:total => issues.size,
|
|
||||||
:ids => '#' + unsaved_issue_ids.join(', #'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_for_default_issue_status
|
def check_for_default_issue_status
|
||||||
if IssueStatus.default.nil?
|
if IssueStatus.default.nil?
|
||||||
render_error l(:error_no_default_issue_status)
|
render_error l(:error_no_default_issue_status)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parse_params_for_bulk_issue_attributes(params)
|
||||||
|
attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
|
||||||
|
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
|
||||||
|
attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values]
|
||||||
|
attributes
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -16,9 +16,71 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class JournalsController < ApplicationController
|
class JournalsController < ApplicationController
|
||||||
before_filter :find_journal
|
before_filter :find_journal, :only => [:edit, :diff]
|
||||||
|
before_filter :find_issue, :only => [:new]
|
||||||
|
before_filter :find_optional_project, :only => [:index]
|
||||||
|
before_filter :authorize, :only => [:new, :edit, :diff]
|
||||||
|
accept_rss_auth :index
|
||||||
|
menu_item :issues
|
||||||
|
|
||||||
|
helper :issues
|
||||||
|
helper :custom_fields
|
||||||
|
helper :queries
|
||||||
|
include QueriesHelper
|
||||||
|
helper :sort
|
||||||
|
include SortHelper
|
||||||
|
|
||||||
|
def index
|
||||||
|
retrieve_query
|
||||||
|
sort_init 'id', 'desc'
|
||||||
|
sort_update(@query.sortable_columns)
|
||||||
|
|
||||||
|
if @query.valid?
|
||||||
|
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
|
||||||
|
:limit => 25)
|
||||||
|
end
|
||||||
|
@title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
|
||||||
|
render :layout => false, :content_type => 'application/atom+xml'
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
def diff
|
||||||
|
@issue = @journal.issue
|
||||||
|
if params[:detail_id].present?
|
||||||
|
@detail = @journal.details.find_by_id(params[:detail_id])
|
||||||
|
else
|
||||||
|
@detail = @journal.details.detect {|d| d.prop_key == 'description'}
|
||||||
|
end
|
||||||
|
(render_404; return false) unless @issue && @detail
|
||||||
|
@diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value)
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
journal = Journal.find(params[:journal_id]) if params[:journal_id]
|
||||||
|
if journal
|
||||||
|
user = journal.user
|
||||||
|
text = journal.notes
|
||||||
|
else
|
||||||
|
user = @issue.author
|
||||||
|
text = @issue.description
|
||||||
|
end
|
||||||
|
# Replaces pre blocks with [...]
|
||||||
|
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||||
|
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
||||||
|
content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||||
|
|
||||||
|
render(:update) { |page|
|
||||||
|
page.<< "$('notes').value = \"#{escape_javascript content}\";"
|
||||||
|
page.show 'update'
|
||||||
|
page << "Form.Element.focus('notes');"
|
||||||
|
page << "Element.scrollTo('update');"
|
||||||
|
page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
(render_403; return false) unless @journal.editable_by?(User.current)
|
||||||
if request.post?
|
if request.post?
|
||||||
@journal.update_attributes(:notes => params[:notes]) if params[:notes]
|
@journal.update_attributes(:notes => params[:notes]) if params[:notes]
|
||||||
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
|
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
|
||||||
@@ -27,15 +89,31 @@ class JournalsController < ApplicationController
|
|||||||
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id }
|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id }
|
||||||
format.js { render :action => 'update' }
|
format.js { render :action => 'update' }
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
# TODO: implement non-JS journal update
|
||||||
|
render :nothing => true
|
||||||
|
}
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_journal
|
def find_journal
|
||||||
@journal = Journal.find(params[:id])
|
@journal = Journal.find(params[:id])
|
||||||
(render_403; return false) unless @journal.editable_by?(User.current)
|
|
||||||
@project = @journal.journalized.project
|
@project = @journal.journalized.project
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: duplicated in IssuesController
|
||||||
|
def find_issue
|
||||||
|
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
|
||||||
|
@project = @issue.project
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class MailHandlerController < ActionController::Base
|
class MailHandlerController < ActionController::Base
|
||||||
before_filter :check_credential
|
before_filter :check_credential
|
||||||
|
|
||||||
verify :method => :post,
|
verify :method => :post,
|
||||||
:only => :index,
|
:only => :index,
|
||||||
:render => { :nothing => true, :status => 405 }
|
:render => { :nothing => true, :status => 405 }
|
||||||
|
|
||||||
# Submits an incoming email to MailHandler
|
# Submits an incoming email to MailHandler
|
||||||
def index
|
def index
|
||||||
options = params.dup
|
options = params.dup
|
||||||
@@ -32,9 +32,9 @@ class MailHandlerController < ActionController::Base
|
|||||||
render :nothing => true, :status => :unprocessable_entity
|
render :nothing => true, :status => :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check_credential
|
def check_credential
|
||||||
User.current = nil
|
User.current = nil
|
||||||
unless Setting.mail_handler_api_enabled? && params[:key].to_s == Setting.mail_handler_api_key
|
unless Setting.mail_handler_api_enabled? && params[:key].to_s == Setting.mail_handler_api_key
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class MyController < ApplicationController
|
|||||||
before_filter :require_login
|
before_filter :require_login
|
||||||
|
|
||||||
helper :issues
|
helper :issues
|
||||||
|
helper :users
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
|
|
||||||
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
|
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
|
||||||
@@ -53,25 +54,18 @@ class MyController < ApplicationController
|
|||||||
@user = User.current
|
@user = User.current
|
||||||
@pref = @user.pref
|
@pref = @user.pref
|
||||||
if request.post?
|
if request.post?
|
||||||
@user.attributes = params[:user]
|
@user.safe_attributes = params[:user]
|
||||||
@user.mail_notification = (params[:notification_option] == 'all')
|
|
||||||
@user.pref.attributes = params[:pref]
|
@user.pref.attributes = params[:pref]
|
||||||
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
||||||
if @user.save
|
if @user.save
|
||||||
@user.pref.save
|
@user.pref.save
|
||||||
@user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
set_language_if_valid @user.language
|
set_language_if_valid @user.language
|
||||||
flash[:notice] = l(:notice_account_updated)
|
flash[:notice] = l(:notice_account_updated)
|
||||||
redirect_to :action => 'account'
|
redirect_to :action => 'account'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@notification_options = [[l(:label_user_mail_option_all), 'all'],
|
|
||||||
[l(:label_user_mail_option_none), 'none']]
|
|
||||||
# Only users that belong to more than 1 project can select projects for which they are notified
|
|
||||||
# Note that @user.membership.size would fail since AR ignores :include association option when doing a count
|
|
||||||
@notification_options.insert 1, [l(:label_user_mail_option_selected), 'selected'] if @user.memberships.length > 1
|
|
||||||
@notification_option = @user.mail_notification? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Manage user's password
|
# Manage user's password
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -18,23 +18,37 @@
|
|||||||
class NewsController < ApplicationController
|
class NewsController < ApplicationController
|
||||||
default_search_scope :news
|
default_search_scope :news
|
||||||
model_object News
|
model_object News
|
||||||
before_filter :find_model_object, :except => [:new, :index, :preview]
|
before_filter :find_model_object, :except => [:new, :create, :index]
|
||||||
before_filter :find_project_from_association, :except => [:new, :index, :preview]
|
before_filter :find_project_from_association, :except => [:new, :create, :index]
|
||||||
before_filter :find_project, :only => [:new, :preview]
|
before_filter :find_project, :only => [:new, :create]
|
||||||
before_filter :authorize, :except => [:index, :preview]
|
before_filter :authorize, :except => [:index]
|
||||||
before_filter :find_optional_project, :only => :index
|
before_filter :find_optional_project, :only => :index
|
||||||
accept_key_auth :index
|
accept_rss_auth :index
|
||||||
|
accept_api_auth :index
|
||||||
|
|
||||||
|
helper :watchers
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@news_pages, @newss = paginate :news,
|
case params[:format]
|
||||||
:per_page => 10,
|
when 'xml', 'json'
|
||||||
:conditions => Project.allowed_to_condition(User.current, :view_news, :project => @project),
|
@offset, @limit = api_offset_and_limit
|
||||||
:include => [:author, :project],
|
else
|
||||||
:order => "#{News.table_name}.created_on DESC"
|
@limit = 10
|
||||||
|
end
|
||||||
|
|
||||||
|
scope = @project ? @project.news.visible : News.visible
|
||||||
|
|
||||||
|
@news_count = scope.count
|
||||||
|
@news_pages = Paginator.new self, @news_count, @limit, params['page']
|
||||||
|
@offset ||= @news_pages.current.offset
|
||||||
|
@newss = scope.all(:include => [:author, :project],
|
||||||
|
:order => "#{News.table_name}.created_on DESC",
|
||||||
|
:offset => @offset,
|
||||||
|
:limit => @limit)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :layout => false if request.xhr? }
|
format.html { render :layout => false if request.xhr? }
|
||||||
format.xml { render :xml => @newss.to_xml }
|
format.api
|
||||||
format.json { render :json => @newss.to_json }
|
|
||||||
format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
|
format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -46,49 +60,38 @@ class NewsController < ApplicationController
|
|||||||
|
|
||||||
def new
|
def new
|
||||||
@news = News.new(:project => @project, :author => User.current)
|
@news = News.new(:project => @project, :author => User.current)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@news = News.new(:project => @project, :author => User.current)
|
||||||
if request.post?
|
if request.post?
|
||||||
@news.attributes = params[:news]
|
@news.attributes = params[:news]
|
||||||
if @news.save
|
if @news.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :controller => 'news', :action => 'index', :project_id => @project
|
redirect_to :controller => 'news', :action => 'index', :project_id => @project
|
||||||
|
else
|
||||||
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if request.post? and @news.update_attributes(params[:news])
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if request.put? and @news.update_attributes(params[:news])
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'show', :id => @news
|
redirect_to :action => 'show', :id => @news
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_comment
|
|
||||||
@comment = Comment.new(params[:comment])
|
|
||||||
@comment.author = User.current
|
|
||||||
if @news.comments << @comment
|
|
||||||
flash[:notice] = l(:label_comment_added)
|
|
||||||
redirect_to :action => 'show', :id => @news
|
|
||||||
else
|
else
|
||||||
show
|
render :action => 'edit'
|
||||||
render :action => 'show'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_comment
|
|
||||||
@news.comments.find(params[:comment_id]).destroy
|
|
||||||
redirect_to :action => 'show', :id => @news
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@news.destroy
|
@news.destroy
|
||||||
redirect_to :action => 'index', :project_id => @project
|
redirect_to :action => 'index', :project_id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
def preview
|
|
||||||
@text = (params[:news] ? params[:news][:description] : nil)
|
|
||||||
render :partial => 'common/preview'
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@project = Project.find(params[:project_id])
|
@project = Project.find(params[:project_id])
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class PreviewsController < ApplicationController
|
||||||
|
before_filter :find_project
|
||||||
|
|
||||||
|
def issue
|
||||||
|
@issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
|
||||||
|
if @issue
|
||||||
|
@attachements = @issue.attachments
|
||||||
|
@description = params[:issue] && params[:issue][:description]
|
||||||
|
if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
|
||||||
|
@description = nil
|
||||||
|
end
|
||||||
|
@notes = params[:notes]
|
||||||
|
else
|
||||||
|
@description = (params[:issue] ? params[:issue][:description] : nil)
|
||||||
|
end
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
|
|
||||||
|
def news
|
||||||
|
@text = (params[:news] ? params[:news][:description] : nil)
|
||||||
|
render :partial => 'common/preview'
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_project
|
||||||
|
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
|
||||||
|
@project = Project.find(project_id)
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
class ProjectEnumerationsController < ApplicationController
|
||||||
|
before_filter :find_project_by_project_id
|
||||||
|
before_filter :authorize
|
||||||
|
|
||||||
|
def update
|
||||||
|
if request.put? && params[:enumerations]
|
||||||
|
Project.transaction do
|
||||||
|
params[:enumerations].each do |id, activity|
|
||||||
|
@project.update_or_create_time_entry_activity(id, activity)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@project.time_entry_activities.each do |time_entry_activity|
|
||||||
|
time_entry_activity.destroy(time_entry_activity.parent)
|
||||||
|
end
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -17,24 +17,22 @@
|
|||||||
|
|
||||||
class ProjectsController < ApplicationController
|
class ProjectsController < ApplicationController
|
||||||
menu_item :overview
|
menu_item :overview
|
||||||
menu_item :activity, :only => :activity
|
|
||||||
menu_item :roadmap, :only => :roadmap
|
menu_item :roadmap, :only => :roadmap
|
||||||
menu_item :files, :only => [:list_files, :add_file]
|
|
||||||
menu_item :settings, :only => :settings
|
menu_item :settings, :only => :settings
|
||||||
|
|
||||||
before_filter :find_project, :except => [ :index, :list, :add, :copy, :activity ]
|
before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
|
||||||
before_filter :find_optional_project, :only => :activity
|
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
|
||||||
before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy, :activity ]
|
before_filter :authorize_global, :only => [:new, :create]
|
||||||
before_filter :authorize_global, :only => :add
|
|
||||||
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
||||||
accept_key_auth :activity, :index
|
accept_rss_auth :index
|
||||||
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller|
|
|
||||||
|
after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller|
|
||||||
if controller.request.post?
|
if controller.request.post?
|
||||||
controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt'
|
controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
@@ -52,8 +50,10 @@ class ProjectsController < ApplicationController
|
|||||||
format.html {
|
format.html {
|
||||||
@projects = Project.visible.find(:all, :order => 'lft')
|
@projects = Project.visible.find(:all, :order => 'lft')
|
||||||
}
|
}
|
||||||
format.xml {
|
format.api {
|
||||||
@projects = Project.visible.find(:all, :order => 'lft')
|
@offset, @limit = api_offset_and_limit
|
||||||
|
@project_count = Project.visible.count
|
||||||
|
@projects = Project.visible.all(:offset => @offset, :limit => @limit, :order => 'lft')
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
projects = Project.visible.find(:all, :order => 'created_on DESC',
|
projects = Project.visible.find(:all, :order => 'created_on DESC',
|
||||||
@@ -63,40 +63,41 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new project
|
def new
|
||||||
def add
|
|
||||||
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||||
@trackers = Tracker.all
|
@trackers = Tracker.all
|
||||||
@project = Project.new(params[:project])
|
@project = Project.new(params[:project])
|
||||||
if request.get?
|
end
|
||||||
@project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
|
|
||||||
@project.trackers = Tracker.all
|
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
@project.is_public = Setting.default_projects_public?
|
def create
|
||||||
@project.enabled_module_names = Setting.default_projects_modules
|
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||||
else
|
@trackers = Tracker.all
|
||||||
@project.enabled_module_names = params[:enabled_modules]
|
@project = Project.new
|
||||||
if validate_parent_id && @project.save
|
@project.safe_attributes = params[:project]
|
||||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
|
||||||
# Add current user as a project member if he is not admin
|
if validate_parent_id && @project.save
|
||||||
unless User.current.admin?
|
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
# Add current user as a project member if he is not admin
|
||||||
m = Member.new(:user => User.current, :roles => [r])
|
unless User.current.admin?
|
||||||
@project.members << m
|
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||||
end
|
m = Member.new(:user => User.current, :roles => [r])
|
||||||
respond_to do |format|
|
@project.members << m
|
||||||
format.html {
|
|
||||||
flash[:notice] = l(:notice_successful_create)
|
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
|
||||||
}
|
|
||||||
format.xml { head :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
respond_to do |format|
|
|
||||||
format.html
|
|
||||||
format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_create)
|
||||||
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
||||||
|
}
|
||||||
|
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :action => 'new' }
|
||||||
|
format.api { render_validation_errors(@project) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy
|
def copy
|
||||||
@@ -115,18 +116,18 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
Mailer.with_deliveries(params[:notifications] == '1') do
|
Mailer.with_deliveries(params[:notifications] == '1') do
|
||||||
@project = Project.new(params[:project])
|
@project = Project.new
|
||||||
@project.enabled_module_names = params[:enabled_modules]
|
@project.safe_attributes = params[:project]
|
||||||
if validate_parent_id && @project.copy(@source_project, :only => params[:only])
|
if validate_parent_id && @project.copy(@source_project, :only => params[:only])
|
||||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :controller => 'admin', :action => 'projects'
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
||||||
elsif !@project.new_record?
|
elsif !@project.new_record?
|
||||||
# Project was created
|
# Project was created
|
||||||
# But some objects were not copied due to validation failures
|
# But some objects were not copied due to validation failures
|
||||||
# (eg. issues from disabled trackers)
|
# (eg. issues from disabled trackers)
|
||||||
# TODO: inform about that
|
# TODO: inform about that
|
||||||
redirect_to :controller => 'admin', :action => 'projects'
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -142,7 +143,7 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
@users_by_role = @project.users_by_role
|
@users_by_role = @project.users_by_role
|
||||||
@subprojects = @project.children.visible
|
@subprojects = @project.children.visible.all
|
||||||
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
||||||
@trackers = @project.rolled_up_trackers
|
@trackers = @project.rolled_up_trackers
|
||||||
|
|
||||||
@@ -155,16 +156,15 @@ class ProjectsController < ApplicationController
|
|||||||
:include => [:project, :status, :tracker],
|
:include => [:project, :status, :tracker],
|
||||||
:conditions => cond)
|
:conditions => cond)
|
||||||
|
|
||||||
TimeEntry.visible_by(User.current) do
|
if User.current.allowed_to?(:view_time_entries, @project)
|
||||||
@total_hours = TimeEntry.sum(:hours,
|
@total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f
|
||||||
:include => :project,
|
|
||||||
:conditions => cond).to_f
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@key = User.current.rss_key
|
@key = User.current.rss_key
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xml
|
format.api
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -177,34 +177,36 @@ class ProjectsController < ApplicationController
|
|||||||
@wiki ||= @project.wiki
|
@wiki ||= @project.wiki
|
||||||
end
|
end
|
||||||
|
|
||||||
# Edit @project
|
|
||||||
def edit
|
def edit
|
||||||
if request.get?
|
end
|
||||||
|
|
||||||
|
# TODO: convert to PUT only
|
||||||
|
verify :method => [:post, :put], :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
def update
|
||||||
|
@project.safe_attributes = params[:project]
|
||||||
|
if validate_parent_id && @project.save
|
||||||
|
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_to :action => 'settings', :id => @project
|
||||||
|
}
|
||||||
|
format.api { head :ok }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@project.attributes = params[:project]
|
respond_to do |format|
|
||||||
if validate_parent_id && @project.save
|
format.html {
|
||||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
settings
|
||||||
respond_to do |format|
|
render :action => 'settings'
|
||||||
format.html {
|
}
|
||||||
flash[:notice] = l(:notice_successful_update)
|
format.api { render_validation_errors(@project) }
|
||||||
redirect_to :action => 'settings', :id => @project
|
|
||||||
}
|
|
||||||
format.xml { head :ok }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
respond_to do |format|
|
|
||||||
format.html {
|
|
||||||
settings
|
|
||||||
render :action => 'settings'
|
|
||||||
}
|
|
||||||
format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
verify :method => :post, :only => :modules, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
def modules
|
def modules
|
||||||
@project.enabled_module_names = params[:enabled_modules]
|
@project.enabled_module_names = params[:enabled_module_names]
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'settings', :id => @project, :tab => 'modules'
|
redirect_to :action => 'settings', :id => @project, :tab => 'modules'
|
||||||
end
|
end
|
||||||
@@ -229,11 +231,11 @@ class ProjectsController < ApplicationController
|
|||||||
if request.get?
|
if request.get?
|
||||||
# display confirmation view
|
# display confirmation view
|
||||||
else
|
else
|
||||||
if params[:format] == 'xml' || params[:confirm]
|
if api_request? || params[:confirm]
|
||||||
@project_to_destroy.destroy
|
@project_to_destroy.destroy
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to :controller => 'admin', :action => 'projects' }
|
format.html { redirect_to :controller => 'admin', :action => 'projects' }
|
||||||
format.xml { head :ok }
|
format.api { head :ok }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -241,120 +243,6 @@ class ProjectsController < ApplicationController
|
|||||||
@project = nil
|
@project = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_file
|
|
||||||
if request.post?
|
|
||||||
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
|
||||||
attachments = Attachment.attach_files(container, params[:attachments])
|
|
||||||
render_attachment_warning_if_needed(container)
|
|
||||||
|
|
||||||
if !attachments.empty? && Setting.notified_events.include?('file_added')
|
|
||||||
Mailer.deliver_attachments_added(attachments[:files])
|
|
||||||
end
|
|
||||||
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
|
||||||
return
|
|
||||||
end
|
|
||||||
@versions = @project.versions.sort
|
|
||||||
end
|
|
||||||
|
|
||||||
def save_activities
|
|
||||||
if request.post? && params[:enumerations]
|
|
||||||
Project.transaction do
|
|
||||||
params[:enumerations].each do |id, activity|
|
|
||||||
@project.update_or_create_time_entry_activity(id, activity)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
flash[:notice] = l(:notice_successful_update)
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
|
|
||||||
end
|
|
||||||
|
|
||||||
def reset_activities
|
|
||||||
@project.time_entry_activities.each do |time_entry_activity|
|
|
||||||
time_entry_activity.destroy(time_entry_activity.parent)
|
|
||||||
end
|
|
||||||
flash[:notice] = l(:notice_successful_update)
|
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'activities', :id => @project
|
|
||||||
end
|
|
||||||
|
|
||||||
def list_files
|
|
||||||
sort_init 'filename', 'asc'
|
|
||||||
sort_update 'filename' => "#{Attachment.table_name}.filename",
|
|
||||||
'created_on' => "#{Attachment.table_name}.created_on",
|
|
||||||
'size' => "#{Attachment.table_name}.filesize",
|
|
||||||
'downloads' => "#{Attachment.table_name}.downloads"
|
|
||||||
|
|
||||||
@containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
|
|
||||||
@containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
|
|
||||||
render :layout => !request.xhr?
|
|
||||||
end
|
|
||||||
|
|
||||||
def roadmap
|
|
||||||
@trackers = @project.trackers.find(:all, :order => 'position')
|
|
||||||
retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
|
|
||||||
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
|
||||||
project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
|
|
||||||
|
|
||||||
@versions = @project.shared_versions || []
|
|
||||||
@versions += @project.rolled_up_versions.visible if @with_subprojects
|
|
||||||
@versions = @versions.uniq.sort
|
|
||||||
@versions.reject! {|version| version.closed? || version.completed? } unless params[:completed]
|
|
||||||
|
|
||||||
@issues_by_version = {}
|
|
||||||
unless @selected_tracker_ids.empty?
|
|
||||||
@versions.each do |version|
|
|
||||||
issues = version.fixed_issues.visible.find(:all,
|
|
||||||
:include => [:project, :status, :tracker, :priority],
|
|
||||||
:conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids},
|
|
||||||
:order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
|
|
||||||
@issues_by_version[version] = issues
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
|
|
||||||
end
|
|
||||||
|
|
||||||
def activity
|
|
||||||
@days = Setting.activity_days_default.to_i
|
|
||||||
|
|
||||||
if params[:from]
|
|
||||||
begin; @date_to = params[:from].to_date + 1; rescue; end
|
|
||||||
end
|
|
||||||
|
|
||||||
@date_to ||= Date.today + 1
|
|
||||||
@date_from = @date_to - @days
|
|
||||||
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
|
||||||
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
|
||||||
|
|
||||||
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
|
|
||||||
:with_subprojects => @with_subprojects,
|
|
||||||
:author => @author)
|
|
||||||
@activity.scope_select {|t| !params["show_#{t}"].nil?}
|
|
||||||
@activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
|
|
||||||
|
|
||||||
events = @activity.events(@date_from, @date_to)
|
|
||||||
|
|
||||||
if events.empty? || stale?(:etag => [events.first, User.current])
|
|
||||||
respond_to do |format|
|
|
||||||
format.html {
|
|
||||||
@events_by_day = events.group_by(&:event_date)
|
|
||||||
render :layout => false if request.xhr?
|
|
||||||
}
|
|
||||||
format.atom {
|
|
||||||
title = l(:label_activity)
|
|
||||||
if @author
|
|
||||||
title = @author.name
|
|
||||||
elsif @activity.scope.size == 1
|
|
||||||
title = l("label_#{@activity.scope.first.singularize}_plural")
|
|
||||||
end
|
|
||||||
render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
render_404
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_optional_project
|
def find_optional_project
|
||||||
return true unless params[:id]
|
return true unless params[:id]
|
||||||
@@ -364,14 +252,6 @@ private
|
|||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil)
|
|
||||||
if ids = params[:tracker_ids]
|
|
||||||
@selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
|
|
||||||
else
|
|
||||||
@selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Validates parent_id param according to user's permissions
|
# Validates parent_id param according to user's permissions
|
||||||
# TODO: move it to Project model in a validation that depends on User.current
|
# TODO: move it to Project model in a validation that depends on User.current
|
||||||
def validate_parent_id
|
def validate_parent_id
|
||||||
|
|||||||
@@ -25,10 +25,11 @@ class QueriesController < ApplicationController
|
|||||||
@query.project = params[:query_is_for_all] ? nil : @project
|
@query.project = params[:query_is_for_all] ? nil : @project
|
||||||
@query.user = User.current
|
@query.user = User.current
|
||||||
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
||||||
@query.column_names = nil if params[:default_columns]
|
|
||||||
|
|
||||||
@query.add_filters(params[:fields], params[:operators], params[:values]) if params[:fields]
|
@query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) if params[:fields] || params[:f]
|
||||||
@query.group_by ||= params[:group_by]
|
@query.group_by ||= params[:group_by]
|
||||||
|
@query.column_names = params[:c] if params[:c]
|
||||||
|
@query.column_names = nil if params[:default_columns]
|
||||||
|
|
||||||
if request.post? && params[:confirm] && @query.save
|
if request.post? && params[:confirm] && @query.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
@@ -41,10 +42,12 @@ class QueriesController < ApplicationController
|
|||||||
def edit
|
def edit
|
||||||
if request.post?
|
if request.post?
|
||||||
@query.filters = {}
|
@query.filters = {}
|
||||||
@query.add_filters(params[:fields], params[:operators], params[:values]) if params[:fields]
|
@query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) if params[:fields] || params[:f]
|
||||||
@query.attributes = params[:query]
|
@query.attributes = params[:query]
|
||||||
@query.project = nil if params[:query_is_for_all]
|
@query.project = nil if params[:query_is_for_all]
|
||||||
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
||||||
|
@query.group_by ||= params[:group_by]
|
||||||
|
@query.column_names = params[:c] if params[:c]
|
||||||
@query.column_names = nil if params[:default_columns]
|
@query.column_names = nil if params[:default_columns]
|
||||||
|
|
||||||
if @query.save
|
if @query.save
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -26,33 +26,45 @@ class RepositoriesController < ApplicationController
|
|||||||
menu_item :repository
|
menu_item :repository
|
||||||
menu_item :settings, :only => :edit
|
menu_item :settings, :only => :edit
|
||||||
default_search_scope :changesets
|
default_search_scope :changesets
|
||||||
|
|
||||||
before_filter :find_repository, :except => :edit
|
before_filter :find_repository, :except => :edit
|
||||||
before_filter :find_project, :only => :edit
|
before_filter :find_project, :only => :edit
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
accept_key_auth :revisions
|
accept_rss_auth :revisions
|
||||||
|
|
||||||
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@repository = @project.repository
|
@repository = @project.repository
|
||||||
if !@repository
|
if !@repository && !params[:repository_scm].blank?
|
||||||
@repository = Repository.factory(params[:repository_scm])
|
@repository = Repository.factory(params[:repository_scm])
|
||||||
@repository.project = @project if @repository
|
@repository.project = @project if @repository
|
||||||
end
|
end
|
||||||
if request.post? && @repository
|
if request.post? && @repository
|
||||||
@repository.attributes = params[:repository]
|
p1 = params[:repository]
|
||||||
|
p = {}
|
||||||
|
p_extra = {}
|
||||||
|
p1.each do |k, v|
|
||||||
|
if k =~ /^extra_/
|
||||||
|
p_extra[k] = v
|
||||||
|
else
|
||||||
|
p[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@repository.attributes = p
|
||||||
|
@repository.merge_extra_info(p_extra)
|
||||||
@repository.save
|
@repository.save
|
||||||
end
|
end
|
||||||
render(:update) do |page|
|
render(:update) do |page|
|
||||||
page.replace_html "tab-content-repository", :partial => 'projects/settings/repository'
|
page.replace_html "tab-content-repository",
|
||||||
|
:partial => 'projects/settings/repository'
|
||||||
if @repository && !@project.repository
|
if @repository && !@project.repository
|
||||||
@project.reload #needed to reload association
|
@project.reload # needed to reload association
|
||||||
page.replace_html "main-menu", render_main_menu(@project)
|
page.replace_html "main-menu", render_main_menu(@project)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def committers
|
def committers
|
||||||
@committers = @repository.committers
|
@committers = @repository.committers
|
||||||
@users = @project.users
|
@users = @project.users
|
||||||
@@ -67,16 +79,20 @@ class RepositoriesController < ApplicationController
|
|||||||
redirect_to :action => 'committers', :id => @project
|
redirect_to :action => 'committers', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@repository.destroy
|
@repository.destroy
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'repository'
|
redirect_to :controller => 'projects',
|
||||||
|
:action => 'settings',
|
||||||
|
:id => @project,
|
||||||
|
:tab => 'repository'
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
||||||
|
|
||||||
@entries = @repository.entries(@path, @rev)
|
@entries = @repository.entries(@path, @rev)
|
||||||
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||||||
if request.xhr?
|
if request.xhr?
|
||||||
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
|
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
|
||||||
else
|
else
|
||||||
@@ -88,30 +104,31 @@ class RepositoriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
alias_method :browse, :show
|
alias_method :browse, :show
|
||||||
|
|
||||||
def changes
|
def changes
|
||||||
@entry = @repository.entry(@path, @rev)
|
@entry = @repository.entry(@path, @rev)
|
||||||
(show_error_not_found; return) unless @entry
|
(show_error_not_found; return) unless @entry
|
||||||
@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i)
|
@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i)
|
||||||
@properties = @repository.properties(@path, @rev)
|
@properties = @repository.properties(@path, @rev)
|
||||||
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||||||
end
|
end
|
||||||
|
|
||||||
def revisions
|
def revisions
|
||||||
@changeset_count = @repository.changesets.count
|
@changeset_count = @repository.changesets.count
|
||||||
@changeset_pages = Paginator.new self, @changeset_count,
|
@changeset_pages = Paginator.new self, @changeset_count,
|
||||||
per_page_option,
|
per_page_option,
|
||||||
params['page']
|
params['page']
|
||||||
@changesets = @repository.changesets.find(:all,
|
@changesets = @repository.changesets.find(:all,
|
||||||
:limit => @changeset_pages.items_per_page,
|
:limit => @changeset_pages.items_per_page,
|
||||||
:offset => @changeset_pages.current.offset,
|
:offset => @changeset_pages.current.offset,
|
||||||
:include => [:user, :repository])
|
:include => [:user, :repository])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :layout => false if request.xhr? }
|
format.html { render :layout => false if request.xhr? }
|
||||||
format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") }
|
format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def entry
|
def entry
|
||||||
@entry = @repository.entry(@path, @rev)
|
@entry = @repository.entry(@path, @rev)
|
||||||
(show_error_not_found; return) unless @entry
|
(show_error_not_found; return) unless @entry
|
||||||
@@ -121,24 +138,46 @@ class RepositoriesController < ApplicationController
|
|||||||
|
|
||||||
@content = @repository.cat(@path, @rev)
|
@content = @repository.cat(@path, @rev)
|
||||||
(show_error_not_found; return) unless @content
|
(show_error_not_found; return) unless @content
|
||||||
if 'raw' == params[:format] || @content.is_binary_data? || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte)
|
if 'raw' == params[:format] ||
|
||||||
|
(@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
|
||||||
|
! is_entry_text_data?(@content, @path)
|
||||||
# Force the download
|
# Force the download
|
||||||
send_data @content, :filename => @path.split('/').last
|
send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
|
||||||
|
send_type = Redmine::MimeType.of(@path)
|
||||||
|
send_opt[:type] = send_type.to_s if send_type
|
||||||
|
send_data @content, send_opt
|
||||||
else
|
else
|
||||||
# Prevent empty lines when displaying a file with Windows style eol
|
# Prevent empty lines when displaying a file with Windows style eol
|
||||||
|
# TODO: UTF-16
|
||||||
|
# Is this needs? AttachmentsController reads file simply.
|
||||||
@content.gsub!("\r\n", "\n")
|
@content.gsub!("\r\n", "\n")
|
||||||
end
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_entry_text_data?(ent, path)
|
||||||
|
# UTF-16 contains "\x00".
|
||||||
|
# It is very strict that file contains less than 30% of ascii symbols
|
||||||
|
# in non Western Europe.
|
||||||
|
return true if Redmine::MimeType.is_type?('text', path)
|
||||||
|
# Ruby 1.8.6 has a bug of integer divisions.
|
||||||
|
# http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F
|
||||||
|
return false if ent.is_binary_data?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
private :is_entry_text_data?
|
||||||
|
|
||||||
def annotate
|
def annotate
|
||||||
@entry = @repository.entry(@path, @rev)
|
@entry = @repository.entry(@path, @rev)
|
||||||
(show_error_not_found; return) unless @entry
|
(show_error_not_found; return) unless @entry
|
||||||
|
|
||||||
@annotate = @repository.scm.annotate(@path, @rev)
|
@annotate = @repository.scm.annotate(@path, @rev)
|
||||||
(render_error l(:error_scm_annotate); return) if @annotate.nil? || @annotate.empty?
|
(render_error l(:error_scm_annotate); return) if @annotate.nil? || @annotate.empty?
|
||||||
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision
|
def revision
|
||||||
|
raise ChangesetNotFound if @rev.blank?
|
||||||
@changeset = @repository.find_changeset_by_name(@rev)
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||||||
raise ChangesetNotFound unless @changeset
|
raise ChangesetNotFound unless @changeset
|
||||||
|
|
||||||
@@ -149,7 +188,7 @@ class RepositoriesController < ApplicationController
|
|||||||
rescue ChangesetNotFound
|
rescue ChangesetNotFound
|
||||||
show_error_not_found
|
show_error_not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff
|
def diff
|
||||||
if params[:format] == 'diff'
|
if params[:format] == 'diff'
|
||||||
@diff = @repository.diff(@path, @rev, @rev_to)
|
@diff = @repository.diff(@path, @rev, @rev_to)
|
||||||
@@ -162,26 +201,30 @@ class RepositoriesController < ApplicationController
|
|||||||
else
|
else
|
||||||
@diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
|
@diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
|
||||||
@diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
|
@diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
|
||||||
|
|
||||||
# Save diff type as user preference
|
# Save diff type as user preference
|
||||||
if User.current.logged? && @diff_type != User.current.pref[:diff_type]
|
if User.current.logged? && @diff_type != User.current.pref[:diff_type]
|
||||||
User.current.pref[:diff_type] = @diff_type
|
User.current.pref[:diff_type] = @diff_type
|
||||||
User.current.preference.save
|
User.current.preference.save
|
||||||
end
|
end
|
||||||
|
@cache_key = "repositories/diff/#{@repository.id}/" +
|
||||||
@cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")
|
Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}")
|
||||||
unless read_fragment(@cache_key)
|
unless read_fragment(@cache_key)
|
||||||
@diff = @repository.diff(@path, @rev, @rev_to)
|
@diff = @repository.diff(@path, @rev, @rev_to)
|
||||||
show_error_not_found unless @diff
|
show_error_not_found unless @diff
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||||||
|
@changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil
|
||||||
|
@diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def stats
|
def stats
|
||||||
end
|
end
|
||||||
|
|
||||||
def graph
|
def graph
|
||||||
data = nil
|
data = nil
|
||||||
case params[:graph]
|
case params[:graph]
|
||||||
when "commits_per_month"
|
when "commits_per_month"
|
||||||
data = graph_commits_per_month(@repository)
|
data = graph_commits_per_month(@repository)
|
||||||
@@ -195,8 +238,11 @@ class RepositoriesController < ApplicationController
|
|||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i
|
||||||
|
|
||||||
def find_repository
|
def find_repository
|
||||||
@project = Project.find(params[:id])
|
@project = Project.find(params[:id])
|
||||||
@repository = @project.repository
|
@repository = @project.repository
|
||||||
@@ -205,6 +251,12 @@ private
|
|||||||
@path ||= ''
|
@path ||= ''
|
||||||
@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip
|
@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip
|
||||||
@rev_to = params[:rev_to]
|
@rev_to = params[:rev_to]
|
||||||
|
|
||||||
|
unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE)
|
||||||
|
if @repository.branches.blank?
|
||||||
|
raise InvalidRevisionParam
|
||||||
|
end
|
||||||
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
rescue InvalidRevisionParam
|
rescue InvalidRevisionParam
|
||||||
@@ -212,29 +264,33 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show_error_not_found
|
def show_error_not_found
|
||||||
render_error l(:error_scm_not_found)
|
render_error :message => l(:error_scm_not_found), :status => 404
|
||||||
end
|
end
|
||||||
|
|
||||||
# Handler for Redmine::Scm::Adapters::CommandFailed exception
|
# Handler for Redmine::Scm::Adapters::CommandFailed exception
|
||||||
def show_error_command_failed(exception)
|
def show_error_command_failed(exception)
|
||||||
render_error l(:error_scm_command_failed, exception.message)
|
render_error l(:error_scm_command_failed, exception.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def graph_commits_per_month(repository)
|
def graph_commits_per_month(repository)
|
||||||
@date_to = Date.today
|
@date_to = Date.today
|
||||||
@date_from = @date_to << 11
|
@date_from = @date_to << 11
|
||||||
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
|
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
|
||||||
commits_by_day = repository.changesets.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
|
commits_by_day = repository.changesets.count(
|
||||||
|
:all, :group => :commit_date,
|
||||||
|
:conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
|
||||||
commits_by_month = [0] * 12
|
commits_by_month = [0] * 12
|
||||||
commits_by_day.each {|c| commits_by_month[c.first.to_date.months_ago] += c.last }
|
commits_by_day.each {|c| commits_by_month[c.first.to_date.months_ago] += c.last }
|
||||||
|
|
||||||
changes_by_day = repository.changes.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
|
changes_by_day = repository.changes.count(
|
||||||
|
:all, :group => :commit_date,
|
||||||
|
:conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
|
||||||
changes_by_month = [0] * 12
|
changes_by_month = [0] * 12
|
||||||
changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last }
|
changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last }
|
||||||
|
|
||||||
fields = []
|
fields = []
|
||||||
12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)}
|
12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)}
|
||||||
|
|
||||||
graph = SVG::Graph::Bar.new(
|
graph = SVG::Graph::Bar.new(
|
||||||
:height => 300,
|
:height => 300,
|
||||||
:width => 800,
|
:width => 800,
|
||||||
@@ -246,7 +302,7 @@ private
|
|||||||
:graph_title => l(:label_commits_per_month),
|
:graph_title => l(:label_commits_per_month),
|
||||||
:show_graph_title => true
|
:show_graph_title => true
|
||||||
)
|
)
|
||||||
|
|
||||||
graph.add_data(
|
graph.add_data(
|
||||||
:data => commits_by_month[0..11].reverse,
|
:data => commits_by_month[0..11].reverse,
|
||||||
:title => l(:label_revision_plural)
|
:title => l(:label_revision_plural)
|
||||||
@@ -256,7 +312,7 @@ private
|
|||||||
:data => changes_by_month[0..11].reverse,
|
:data => changes_by_month[0..11].reverse,
|
||||||
:title => l(:label_change_plural)
|
:title => l(:label_change_plural)
|
||||||
)
|
)
|
||||||
|
|
||||||
graph.burn
|
graph.burn
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -266,18 +322,18 @@ private
|
|||||||
|
|
||||||
changes_by_author = repository.changes.count(:all, :group => :committer)
|
changes_by_author = repository.changes.count(:all, :group => :committer)
|
||||||
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
||||||
|
|
||||||
fields = commits_by_author.collect {|r| r.first}
|
fields = commits_by_author.collect {|r| r.first}
|
||||||
commits_data = commits_by_author.collect {|r| r.last}
|
commits_data = commits_by_author.collect {|r| r.last}
|
||||||
changes_data = commits_by_author.collect {|r| h[r.first] || 0}
|
changes_data = commits_by_author.collect {|r| h[r.first] || 0}
|
||||||
|
|
||||||
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||||
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||||
changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10
|
changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10
|
||||||
|
|
||||||
# Remove email adress in usernames
|
# Remove email adress in usernames
|
||||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||||
|
|
||||||
graph = SVG::Graph::BarHorizontal.new(
|
graph = SVG::Graph::BarHorizontal.new(
|
||||||
:height => 400,
|
:height => 400,
|
||||||
:width => 800,
|
:width => 800,
|
||||||
@@ -289,22 +345,18 @@ private
|
|||||||
:graph_title => l(:label_commits_per_author),
|
:graph_title => l(:label_commits_per_author),
|
||||||
:show_graph_title => true
|
:show_graph_title => true
|
||||||
)
|
)
|
||||||
|
|
||||||
graph.add_data(
|
graph.add_data(
|
||||||
:data => commits_data,
|
:data => commits_data,
|
||||||
:title => l(:label_revision_plural)
|
:title => l(:label_revision_plural)
|
||||||
)
|
)
|
||||||
|
|
||||||
graph.add_data(
|
graph.add_data(
|
||||||
:data => changes_data,
|
:data => changes_data,
|
||||||
:title => l(:label_change_plural)
|
:title => l(:label_change_plural)
|
||||||
)
|
)
|
||||||
|
|
||||||
graph.burn
|
graph.burn
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class Date
|
class Date
|
||||||
def months_ago(date = Date.today)
|
def months_ago(date = Date.today)
|
||||||
(date.year - self.year)*12 + (date.month - self.month)
|
(date.year - self.year)*12 + (date.month - self.month)
|
||||||
|
|||||||
@@ -38,9 +38,10 @@ class RolesController < ApplicationController
|
|||||||
end
|
end
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
|
else
|
||||||
|
@permissions = @role.setable_permissions
|
||||||
|
@roles = Role.find :all, :order => 'builtin, position'
|
||||||
end
|
end
|
||||||
@permissions = @role.setable_permissions
|
|
||||||
@roles = Role.find :all, :order => 'builtin, position'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@@ -48,8 +49,9 @@ class RolesController < ApplicationController
|
|||||||
if request.post? and @role.update_attributes(params[:role])
|
if request.post? and @role.update_attributes(params[:role])
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
|
else
|
||||||
|
@permissions = @role.setable_permissions
|
||||||
end
|
end
|
||||||
@permissions = @role.setable_permissions
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -24,8 +24,8 @@ class SearchController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@question = params[:q] || ""
|
@question = params[:q] || ""
|
||||||
@question.strip!
|
@question.strip!
|
||||||
@all_words = params[:all_words] || (params[:submit] ? false : true)
|
@all_words = params[:all_words] ? params[:all_words].present? : true
|
||||||
@titles_only = !params[:titles_only].nil?
|
@titles_only = params[:titles_only] ? params[:titles_only].present? : false
|
||||||
|
|
||||||
projects_to_search =
|
projects_to_search =
|
||||||
case params[:scope]
|
case params[:scope]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
class SettingsController < ApplicationController
|
class SettingsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@@ -26,7 +26,7 @@ class SettingsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated)
|
@notifiables = Redmine::Notifiable.all
|
||||||
if request.post? && params[:settings] && params[:settings].is_a?(Hash)
|
if request.post? && params[:settings] && params[:settings].is_a?(Hash)
|
||||||
settings = (params[:settings] || {}).dup.symbolize_keys
|
settings = (params[:settings] || {}).dup.symbolize_keys
|
||||||
settings.each do |name, value|
|
settings.each do |name, value|
|
||||||
@@ -36,14 +36,16 @@ class SettingsController < ApplicationController
|
|||||||
end
|
end
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'edit', :tab => params[:tab]
|
redirect_to :action => 'edit', :tab => params[:tab]
|
||||||
return
|
else
|
||||||
end
|
@options = {}
|
||||||
@options = {}
|
@options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
|
||||||
@options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
|
@deliveries = ActionMailer::Base.perform_deliveries
|
||||||
@deliveries = ActionMailer::Base.perform_deliveries
|
|
||||||
|
|
||||||
@guessed_host_and_path = request.host_with_port.dup
|
@guessed_host_and_path = request.host_with_port.dup
|
||||||
@guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
|
@guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
|
||||||
|
|
||||||
|
Redmine::Themes.rescan
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def plugin
|
def plugin
|
||||||
@@ -52,9 +54,10 @@ class SettingsController < ApplicationController
|
|||||||
Setting["plugin_#{@plugin.id}"] = params[:settings]
|
Setting["plugin_#{@plugin.id}"] = params[:settings]
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'plugin', :id => @plugin.id
|
redirect_to :action => 'plugin', :id => @plugin.id
|
||||||
|
else
|
||||||
|
@partial = @plugin.settings[:partial]
|
||||||
|
@settings = Setting["plugin_#{@plugin.id}"]
|
||||||
end
|
end
|
||||||
@partial = @plugin.settings[:partial]
|
|
||||||
@settings = Setting["plugin_#{@plugin.id}"]
|
|
||||||
rescue Redmine::PluginNotFound
|
rescue Redmine::PluginNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ class SysController < ActionController::Base
|
|||||||
|
|
||||||
def projects
|
def projects
|
||||||
p = Project.active.has_module(:repository).find(:all, :include => :repository, :order => 'identifier')
|
p = Project.active.has_module(:repository).find(:all, :include => :repository, :order => 'identifier')
|
||||||
render :xml => p.to_xml(:include => :repository)
|
# extra_info attribute from repository breaks activeresource client
|
||||||
|
render :xml => p.to_xml(:only => [:id, :identifier, :name, :is_public, :status], :include => {:repository => {:only => [:id, :url]}})
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_project_repository
|
def create_project_repository
|
||||||
@@ -31,7 +32,7 @@ class SysController < ActionController::Base
|
|||||||
logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}."
|
logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}."
|
||||||
project.repository = Repository.factory(params[:vendor], params[:repository])
|
project.repository = Repository.factory(params[:vendor], params[:repository])
|
||||||
if project.repository && project.repository.save
|
if project.repository && project.repository.save
|
||||||
render :xml => project.repository, :status => 201
|
render :xml => project.repository.to_xml(:only => [:id, :url]), :status => 201
|
||||||
else
|
else
|
||||||
render :nothing => true, :status => 422
|
render :nothing => true, :status => 422
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,209 @@
|
|||||||
|
class TimeEntryReportsController < ApplicationController
|
||||||
|
menu_item :issues
|
||||||
|
before_filter :find_optional_project
|
||||||
|
before_filter :load_available_criterias
|
||||||
|
|
||||||
|
helper :sort
|
||||||
|
include SortHelper
|
||||||
|
helper :issues
|
||||||
|
helper :timelog
|
||||||
|
include TimelogHelper
|
||||||
|
helper :custom_fields
|
||||||
|
include CustomFieldsHelper
|
||||||
|
|
||||||
|
def report
|
||||||
|
@criterias = params[:criterias] || []
|
||||||
|
@criterias = @criterias.select{|criteria| @available_criterias.has_key? criteria}
|
||||||
|
@criterias.uniq!
|
||||||
|
@criterias = @criterias[0,3]
|
||||||
|
|
||||||
|
@columns = (params[:columns] && %w(year month week day).include?(params[:columns])) ? params[:columns] : 'month'
|
||||||
|
|
||||||
|
retrieve_date_range
|
||||||
|
|
||||||
|
unless @criterias.empty?
|
||||||
|
sql_select = @criterias.collect{|criteria| @available_criterias[criteria][:sql] + " AS " + criteria}.join(', ')
|
||||||
|
sql_group_by = @criterias.collect{|criteria| @available_criterias[criteria][:sql]}.join(', ')
|
||||||
|
sql_condition = ''
|
||||||
|
|
||||||
|
if @project.nil?
|
||||||
|
sql_condition = Project.allowed_to_condition(User.current, :view_time_entries)
|
||||||
|
elsif @issue.nil?
|
||||||
|
sql_condition = @project.project_condition(Setting.display_subprojects_issues?)
|
||||||
|
else
|
||||||
|
sql_condition = "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}"
|
||||||
|
end
|
||||||
|
|
||||||
|
sql = "SELECT #{sql_select}, tyear, tmonth, tweek, spent_on, SUM(hours) AS hours"
|
||||||
|
sql << " FROM #{TimeEntry.table_name}"
|
||||||
|
sql << time_report_joins
|
||||||
|
sql << " WHERE"
|
||||||
|
sql << " (%s) AND" % sql_condition
|
||||||
|
sql << " (spent_on BETWEEN '%s' AND '%s')" % [ActiveRecord::Base.connection.quoted_date(@from), ActiveRecord::Base.connection.quoted_date(@to)]
|
||||||
|
sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek, spent_on"
|
||||||
|
|
||||||
|
@hours = ActiveRecord::Base.connection.select_all(sql)
|
||||||
|
|
||||||
|
@hours.each do |row|
|
||||||
|
case @columns
|
||||||
|
when 'year'
|
||||||
|
row['year'] = row['tyear']
|
||||||
|
when 'month'
|
||||||
|
row['month'] = "#{row['tyear']}-#{row['tmonth']}"
|
||||||
|
when 'week'
|
||||||
|
row['week'] = "#{row['tyear']}-#{row['tweek']}"
|
||||||
|
when 'day'
|
||||||
|
row['day'] = "#{row['spent_on']}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@total_hours = @hours.inject(0) {|s,k| s = s + k['hours'].to_f}
|
||||||
|
|
||||||
|
@periods = []
|
||||||
|
# Date#at_beginning_of_ not supported in Rails 1.2.x
|
||||||
|
date_from = @from.to_time
|
||||||
|
# 100 columns max
|
||||||
|
while date_from <= @to.to_time && @periods.length < 100
|
||||||
|
case @columns
|
||||||
|
when 'year'
|
||||||
|
@periods << "#{date_from.year}"
|
||||||
|
date_from = (date_from + 1.year).at_beginning_of_year
|
||||||
|
when 'month'
|
||||||
|
@periods << "#{date_from.year}-#{date_from.month}"
|
||||||
|
date_from = (date_from + 1.month).at_beginning_of_month
|
||||||
|
when 'week'
|
||||||
|
@periods << "#{date_from.year}-#{date_from.to_date.cweek}"
|
||||||
|
date_from = (date_from + 7.day).at_beginning_of_week
|
||||||
|
when 'day'
|
||||||
|
@periods << "#{date_from.to_date}"
|
||||||
|
date_from = date_from + 1.day
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :layout => !request.xhr? }
|
||||||
|
format.csv { send_data(report_to_csv(@criterias, @periods, @hours), :type => 'text/csv; header=present', :filename => 'timelog.csv') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# TODO: duplicated in TimelogController
|
||||||
|
def find_optional_project
|
||||||
|
if !params[:issue_id].blank?
|
||||||
|
@issue = Issue.find(params[:issue_id])
|
||||||
|
@project = @issue.project
|
||||||
|
elsif !params[:project_id].blank?
|
||||||
|
@project = Project.find(params[:project_id])
|
||||||
|
end
|
||||||
|
deny_access unless User.current.allowed_to?(:view_time_entries, @project, :global => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Retrieves the date range based on predefined ranges or specific from/to param dates
|
||||||
|
# TODO: duplicated in TimelogController
|
||||||
|
def retrieve_date_range
|
||||||
|
@free_period = false
|
||||||
|
@from, @to = nil, nil
|
||||||
|
|
||||||
|
if params[:period_type] == '1' || (params[:period_type].nil? && !params[:period].nil?)
|
||||||
|
case params[:period].to_s
|
||||||
|
when 'today'
|
||||||
|
@from = @to = Date.today
|
||||||
|
when 'yesterday'
|
||||||
|
@from = @to = Date.today - 1
|
||||||
|
when 'current_week'
|
||||||
|
@from = Date.today - (Date.today.cwday - 1)%7
|
||||||
|
@to = @from + 6
|
||||||
|
when 'last_week'
|
||||||
|
@from = Date.today - 7 - (Date.today.cwday - 1)%7
|
||||||
|
@to = @from + 6
|
||||||
|
when '7_days'
|
||||||
|
@from = Date.today - 7
|
||||||
|
@to = Date.today
|
||||||
|
when 'current_month'
|
||||||
|
@from = Date.civil(Date.today.year, Date.today.month, 1)
|
||||||
|
@to = (@from >> 1) - 1
|
||||||
|
when 'last_month'
|
||||||
|
@from = Date.civil(Date.today.year, Date.today.month, 1) << 1
|
||||||
|
@to = (@from >> 1) - 1
|
||||||
|
when '30_days'
|
||||||
|
@from = Date.today - 30
|
||||||
|
@to = Date.today
|
||||||
|
when 'current_year'
|
||||||
|
@from = Date.civil(Date.today.year, 1, 1)
|
||||||
|
@to = Date.civil(Date.today.year, 12, 31)
|
||||||
|
end
|
||||||
|
elsif params[:period_type] == '2' || (params[:period_type].nil? && (!params[:from].nil? || !params[:to].nil?))
|
||||||
|
begin; @from = params[:from].to_s.to_date unless params[:from].blank?; rescue; end
|
||||||
|
begin; @to = params[:to].to_s.to_date unless params[:to].blank?; rescue; end
|
||||||
|
@free_period = true
|
||||||
|
else
|
||||||
|
# default
|
||||||
|
end
|
||||||
|
|
||||||
|
@from, @to = @to, @from if @from && @to && @from > @to
|
||||||
|
@from ||= (TimeEntry.earilest_date_for_project(@project) || Date.today)
|
||||||
|
@to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_available_criterias
|
||||||
|
@available_criterias = { 'project' => {:sql => "#{TimeEntry.table_name}.project_id",
|
||||||
|
:klass => Project,
|
||||||
|
:label => :label_project},
|
||||||
|
'version' => {:sql => "#{Issue.table_name}.fixed_version_id",
|
||||||
|
:klass => Version,
|
||||||
|
:label => :label_version},
|
||||||
|
'category' => {:sql => "#{Issue.table_name}.category_id",
|
||||||
|
:klass => IssueCategory,
|
||||||
|
:label => :field_category},
|
||||||
|
'member' => {:sql => "#{TimeEntry.table_name}.user_id",
|
||||||
|
:klass => User,
|
||||||
|
:label => :label_member},
|
||||||
|
'tracker' => {:sql => "#{Issue.table_name}.tracker_id",
|
||||||
|
:klass => Tracker,
|
||||||
|
:label => :label_tracker},
|
||||||
|
'activity' => {:sql => "#{TimeEntry.table_name}.activity_id",
|
||||||
|
:klass => TimeEntryActivity,
|
||||||
|
:label => :label_activity},
|
||||||
|
'issue' => {:sql => "#{TimeEntry.table_name}.issue_id",
|
||||||
|
:klass => Issue,
|
||||||
|
:label => :label_issue}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add list and boolean custom fields as available criterias
|
||||||
|
custom_fields = (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields)
|
||||||
|
custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
||||||
|
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Issue' AND c.customized_id = #{Issue.table_name}.id)",
|
||||||
|
:format => cf.field_format,
|
||||||
|
:label => cf.name}
|
||||||
|
end if @project
|
||||||
|
|
||||||
|
# Add list and boolean time entry custom fields
|
||||||
|
TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
||||||
|
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id)",
|
||||||
|
:format => cf.field_format,
|
||||||
|
:label => cf.name}
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add list and boolean time entry activity custom fields
|
||||||
|
TimeEntryActivityCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
||||||
|
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Enumeration' AND c.customized_id = #{TimeEntry.table_name}.activity_id)",
|
||||||
|
:format => cf.field_format,
|
||||||
|
:label => cf.name}
|
||||||
|
end
|
||||||
|
|
||||||
|
call_hook(:controller_timelog_available_criterias, { :available_criterias => @available_criterias, :project => @project })
|
||||||
|
@available_criterias
|
||||||
|
end
|
||||||
|
|
||||||
|
def time_report_joins
|
||||||
|
sql = ''
|
||||||
|
sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id"
|
||||||
|
sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id"
|
||||||
|
# TODO: rename hook
|
||||||
|
call_hook(:controller_timelog_time_report_joins, {:sql => sql} )
|
||||||
|
sql
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -17,11 +17,13 @@
|
|||||||
|
|
||||||
class TimelogController < ApplicationController
|
class TimelogController < ApplicationController
|
||||||
menu_item :issues
|
menu_item :issues
|
||||||
before_filter :find_project, :authorize, :only => [:edit, :destroy]
|
before_filter :find_project, :only => [:new, :create]
|
||||||
before_filter :find_optional_project, :only => [:report, :details]
|
before_filter :find_time_entry, :only => [:show, :edit, :update]
|
||||||
before_filter :load_available_criterias, :only => [:report]
|
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||||
|
before_filter :authorize, :except => [:index]
|
||||||
verify :method => :post, :only => :destroy, :redirect_to => { :action => :details }
|
before_filter :find_optional_project, :only => [:index]
|
||||||
|
accept_rss_auth :index
|
||||||
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
@@ -30,84 +32,7 @@ class TimelogController < ApplicationController
|
|||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
include CustomFieldsHelper
|
include CustomFieldsHelper
|
||||||
|
|
||||||
def report
|
def index
|
||||||
@criterias = params[:criterias] || []
|
|
||||||
@criterias = @criterias.select{|criteria| @available_criterias.has_key? criteria}
|
|
||||||
@criterias.uniq!
|
|
||||||
@criterias = @criterias[0,3]
|
|
||||||
|
|
||||||
@columns = (params[:columns] && %w(year month week day).include?(params[:columns])) ? params[:columns] : 'month'
|
|
||||||
|
|
||||||
retrieve_date_range
|
|
||||||
|
|
||||||
unless @criterias.empty?
|
|
||||||
sql_select = @criterias.collect{|criteria| @available_criterias[criteria][:sql] + " AS " + criteria}.join(', ')
|
|
||||||
sql_group_by = @criterias.collect{|criteria| @available_criterias[criteria][:sql]}.join(', ')
|
|
||||||
sql_condition = ''
|
|
||||||
|
|
||||||
if @project.nil?
|
|
||||||
sql_condition = Project.allowed_to_condition(User.current, :view_time_entries)
|
|
||||||
elsif @issue.nil?
|
|
||||||
sql_condition = @project.project_condition(Setting.display_subprojects_issues?)
|
|
||||||
else
|
|
||||||
sql_condition = "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}"
|
|
||||||
end
|
|
||||||
|
|
||||||
sql = "SELECT #{sql_select}, tyear, tmonth, tweek, spent_on, SUM(hours) AS hours"
|
|
||||||
sql << " FROM #{TimeEntry.table_name}"
|
|
||||||
sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id"
|
|
||||||
sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id"
|
|
||||||
sql << " WHERE"
|
|
||||||
sql << " (%s) AND" % sql_condition
|
|
||||||
sql << " (spent_on BETWEEN '%s' AND '%s')" % [ActiveRecord::Base.connection.quoted_date(@from), ActiveRecord::Base.connection.quoted_date(@to)]
|
|
||||||
sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek, spent_on"
|
|
||||||
|
|
||||||
@hours = ActiveRecord::Base.connection.select_all(sql)
|
|
||||||
|
|
||||||
@hours.each do |row|
|
|
||||||
case @columns
|
|
||||||
when 'year'
|
|
||||||
row['year'] = row['tyear']
|
|
||||||
when 'month'
|
|
||||||
row['month'] = "#{row['tyear']}-#{row['tmonth']}"
|
|
||||||
when 'week'
|
|
||||||
row['week'] = "#{row['tyear']}-#{row['tweek']}"
|
|
||||||
when 'day'
|
|
||||||
row['day'] = "#{row['spent_on']}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@total_hours = @hours.inject(0) {|s,k| s = s + k['hours'].to_f}
|
|
||||||
|
|
||||||
@periods = []
|
|
||||||
# Date#at_beginning_of_ not supported in Rails 1.2.x
|
|
||||||
date_from = @from.to_time
|
|
||||||
# 100 columns max
|
|
||||||
while date_from <= @to.to_time && @periods.length < 100
|
|
||||||
case @columns
|
|
||||||
when 'year'
|
|
||||||
@periods << "#{date_from.year}"
|
|
||||||
date_from = (date_from + 1.year).at_beginning_of_year
|
|
||||||
when 'month'
|
|
||||||
@periods << "#{date_from.year}-#{date_from.month}"
|
|
||||||
date_from = (date_from + 1.month).at_beginning_of_month
|
|
||||||
when 'week'
|
|
||||||
@periods << "#{date_from.year}-#{date_from.to_date.cweek}"
|
|
||||||
date_from = (date_from + 7.day).at_beginning_of_week
|
|
||||||
when 'day'
|
|
||||||
@periods << "#{date_from.to_date}"
|
|
||||||
date_from = date_from + 1.day
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html { render :layout => !request.xhr? }
|
|
||||||
format.csv { send_data(report_to_csv(@criterias, @periods, @hours), :type => 'text/csv; header=present', :filename => 'timelog.csv') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def details
|
|
||||||
sort_init 'spent_on', 'desc'
|
sort_init 'spent_on', 'desc'
|
||||||
sort_update 'spent_on' => 'spent_on',
|
sort_update 'spent_on' => 'spent_on',
|
||||||
'user' => 'user_id',
|
'user' => 'user_id',
|
||||||
@@ -117,90 +42,215 @@ class TimelogController < ApplicationController
|
|||||||
'hours' => 'hours'
|
'hours' => 'hours'
|
||||||
|
|
||||||
cond = ARCondition.new
|
cond = ARCondition.new
|
||||||
if @project.nil?
|
if @issue
|
||||||
cond << Project.allowed_to_condition(User.current, :view_time_entries)
|
|
||||||
elsif @issue.nil?
|
|
||||||
cond << @project.project_condition(Setting.display_subprojects_issues?)
|
|
||||||
else
|
|
||||||
cond << "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}"
|
cond << "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}"
|
||||||
|
elsif @project
|
||||||
|
cond << @project.project_condition(Setting.display_subprojects_issues?)
|
||||||
end
|
end
|
||||||
|
|
||||||
retrieve_date_range
|
retrieve_date_range
|
||||||
cond << ['spent_on BETWEEN ? AND ?', @from, @to]
|
cond << ['spent_on BETWEEN ? AND ?', @from, @to]
|
||||||
|
|
||||||
TimeEntry.visible_by(User.current) do
|
respond_to do |format|
|
||||||
respond_to do |format|
|
format.html {
|
||||||
format.html {
|
# Paginate results
|
||||||
# Paginate results
|
@entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions)
|
||||||
@entry_count = TimeEntry.count(:include => [:project, :issue], :conditions => cond.conditions)
|
@entry_pages = Paginator.new self, @entry_count, per_page_option, params['page']
|
||||||
@entry_pages = Paginator.new self, @entry_count, per_page_option, params['page']
|
@entries = TimeEntry.visible.find(:all,
|
||||||
@entries = TimeEntry.find(:all,
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
:include => [:project, :activity, :user, {:issue => :tracker}],
|
:conditions => cond.conditions,
|
||||||
:conditions => cond.conditions,
|
:order => sort_clause,
|
||||||
:order => sort_clause,
|
:limit => @entry_pages.items_per_page,
|
||||||
:limit => @entry_pages.items_per_page,
|
:offset => @entry_pages.current.offset)
|
||||||
:offset => @entry_pages.current.offset)
|
@total_hours = TimeEntry.visible.sum(:hours, :include => [:project, :issue], :conditions => cond.conditions).to_f
|
||||||
@total_hours = TimeEntry.sum(:hours, :include => [:project, :issue], :conditions => cond.conditions).to_f
|
|
||||||
|
|
||||||
render :layout => !request.xhr?
|
render :layout => !request.xhr?
|
||||||
}
|
}
|
||||||
format.atom {
|
format.api {
|
||||||
entries = TimeEntry.find(:all,
|
@entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions)
|
||||||
:include => [:project, :activity, :user, {:issue => :tracker}],
|
@offset, @limit = api_offset_and_limit
|
||||||
:conditions => cond.conditions,
|
@entries = TimeEntry.visible.find(:all,
|
||||||
:order => "#{TimeEntry.table_name}.created_on DESC",
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
:limit => Setting.feeds_limit.to_i)
|
:conditions => cond.conditions,
|
||||||
render_feed(entries, :title => l(:label_spent_time))
|
:order => sort_clause,
|
||||||
}
|
:limit => @limit,
|
||||||
format.csv {
|
:offset => @offset)
|
||||||
# Export all entries
|
}
|
||||||
@entries = TimeEntry.find(:all,
|
format.atom {
|
||||||
:include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}],
|
entries = TimeEntry.visible.find(:all,
|
||||||
:conditions => cond.conditions,
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
:order => sort_clause)
|
:conditions => cond.conditions,
|
||||||
send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv')
|
:order => "#{TimeEntry.table_name}.created_on DESC",
|
||||||
}
|
:limit => Setting.feeds_limit.to_i)
|
||||||
end
|
render_feed(entries, :title => l(:label_spent_time))
|
||||||
|
}
|
||||||
|
format.csv {
|
||||||
|
# Export all entries
|
||||||
|
@entries = TimeEntry.visible.find(:all,
|
||||||
|
:include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}],
|
||||||
|
:conditions => cond.conditions,
|
||||||
|
:order => sort_clause)
|
||||||
|
send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv')
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def show
|
||||||
(render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)
|
respond_to do |format|
|
||||||
|
# TODO: Implement html response
|
||||||
|
format.html { render :nothing => true, :status => 406 }
|
||||||
|
format.api
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
|
||||||
|
@time_entry.attributes = params[:time_entry]
|
||||||
|
|
||||||
|
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
|
||||||
|
render :action => 'edit'
|
||||||
|
end
|
||||||
|
|
||||||
|
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
def create
|
||||||
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
|
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
|
||||||
@time_entry.attributes = params[:time_entry]
|
@time_entry.attributes = params[:time_entry]
|
||||||
|
|
||||||
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
|
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
|
||||||
|
|
||||||
if request.post? and @time_entry.save
|
if @time_entry.save
|
||||||
flash[:notice] = l(:notice_successful_update)
|
respond_to do |format|
|
||||||
redirect_back_or_default :action => 'details', :project_id => @time_entry.project
|
format.html {
|
||||||
return
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_back_or_default :action => 'index', :project_id => @time_entry.project
|
||||||
|
}
|
||||||
|
format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :action => 'edit' }
|
||||||
|
format.api { render_validation_errors(@time_entry) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def edit
|
||||||
(render_404; return) unless @time_entry
|
@time_entry.attributes = params[:time_entry]
|
||||||
(render_403; return) unless @time_entry.editable_by?(User.current)
|
|
||||||
if @time_entry.destroy && @time_entry.destroyed?
|
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
|
||||||
flash[:notice] = l(:notice_successful_delete)
|
end
|
||||||
|
|
||||||
|
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
def update
|
||||||
|
@time_entry.attributes = params[:time_entry]
|
||||||
|
|
||||||
|
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
|
||||||
|
|
||||||
|
if @time_entry.save
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_back_or_default :action => 'index', :project_id => @time_entry.project
|
||||||
|
}
|
||||||
|
format.api { head :ok }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
flash[:error] = l(:notice_unable_delete_time_entry)
|
respond_to do |format|
|
||||||
|
format.html { render :action => 'edit' }
|
||||||
|
format.api { render_validation_errors(@time_entry) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def bulk_edit
|
||||||
|
@available_activities = TimeEntryActivity.shared.active
|
||||||
|
@custom_fields = TimeEntry.first.available_custom_fields
|
||||||
|
end
|
||||||
|
|
||||||
|
def bulk_update
|
||||||
|
attributes = parse_params_for_bulk_time_entry_attributes(params)
|
||||||
|
|
||||||
|
unsaved_time_entry_ids = []
|
||||||
|
@time_entries.each do |time_entry|
|
||||||
|
time_entry.reload
|
||||||
|
time_entry.attributes = attributes
|
||||||
|
call_hook(:controller_time_entries_bulk_edit_before_save, { :params => params, :time_entry => time_entry })
|
||||||
|
unless time_entry.save
|
||||||
|
# Keep unsaved time_entry ids to display them in flash error
|
||||||
|
unsaved_time_entry_ids << time_entry.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
set_flash_from_bulk_time_entry_save(@time_entries, unsaved_time_entry_ids)
|
||||||
|
redirect_back_or_default({:controller => 'timelog', :action => 'index', :project_id => @projects.first})
|
||||||
|
end
|
||||||
|
|
||||||
|
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
def destroy
|
||||||
|
@time_entries.each do |t|
|
||||||
|
begin
|
||||||
|
unless t.destroy && t.destroyed?
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:error] = l(:notice_unable_delete_time_entry)
|
||||||
|
redirect_to :back
|
||||||
|
}
|
||||||
|
format.api { render_validation_errors(t) }
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
rescue ::ActionController::RedirectBackError
|
||||||
|
redirect_to :action => 'index', :project_id => @projects.first
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_delete)
|
||||||
|
redirect_back_or_default(:action => 'index', :project_id => @projects.first)
|
||||||
|
}
|
||||||
|
format.api { head :ok }
|
||||||
end
|
end
|
||||||
redirect_to :back
|
|
||||||
rescue ::ActionController::RedirectBackError
|
|
||||||
redirect_to :action => 'details', :project_id => @time_entry.project
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def find_time_entry
|
||||||
|
@time_entry = TimeEntry.find(params[:id])
|
||||||
|
unless @time_entry.editable_by?(User.current)
|
||||||
|
render_403
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
@project = @time_entry.project
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_time_entries
|
||||||
|
@time_entries = TimeEntry.find_all_by_id(params[:id] || params[:ids])
|
||||||
|
raise ActiveRecord::RecordNotFound if @time_entries.empty?
|
||||||
|
@projects = @time_entries.collect(&:project).compact.uniq
|
||||||
|
@project = @projects.first if @projects.size == 1
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_flash_from_bulk_time_entry_save(time_entries, unsaved_time_entry_ids)
|
||||||
|
if unsaved_time_entry_ids.empty?
|
||||||
|
flash[:notice] = l(:notice_successful_update) unless time_entries.empty?
|
||||||
|
else
|
||||||
|
flash[:error] = l(:notice_failed_to_save_time_entries,
|
||||||
|
:count => unsaved_time_entry_ids.size,
|
||||||
|
:total => time_entries.size,
|
||||||
|
:ids => '#' + unsaved_time_entry_ids.join(', #'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def find_project
|
def find_project
|
||||||
if params[:id]
|
if (issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id])).present?
|
||||||
@time_entry = TimeEntry.find(params[:id])
|
@issue = Issue.find(issue_id)
|
||||||
@project = @time_entry.project
|
|
||||||
elsif params[:issue_id]
|
|
||||||
@issue = Issue.find(params[:issue_id])
|
|
||||||
@project = @issue.project
|
@project = @issue.project
|
||||||
elsif params[:project_id]
|
elsif (project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])).present?
|
||||||
@project = Project.find(params[:project_id])
|
@project = Project.find(project_id)
|
||||||
else
|
else
|
||||||
render_404
|
render_404
|
||||||
return false
|
return false
|
||||||
@@ -261,57 +311,14 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
@from, @to = @to, @from if @from && @to && @from > @to
|
@from, @to = @to, @from if @from && @to && @from > @to
|
||||||
@from ||= (TimeEntry.minimum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) || Date.today) - 1
|
@from ||= (TimeEntry.earilest_date_for_project(@project) || Date.today)
|
||||||
@to ||= (TimeEntry.maximum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) || Date.today)
|
@to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_available_criterias
|
def parse_params_for_bulk_time_entry_attributes(params)
|
||||||
@available_criterias = { 'project' => {:sql => "#{TimeEntry.table_name}.project_id",
|
attributes = (params[:time_entry] || {}).reject {|k,v| v.blank?}
|
||||||
:klass => Project,
|
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
|
||||||
:label => :label_project},
|
attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values]
|
||||||
'version' => {:sql => "#{Issue.table_name}.fixed_version_id",
|
attributes
|
||||||
:klass => Version,
|
|
||||||
:label => :label_version},
|
|
||||||
'category' => {:sql => "#{Issue.table_name}.category_id",
|
|
||||||
:klass => IssueCategory,
|
|
||||||
:label => :field_category},
|
|
||||||
'member' => {:sql => "#{TimeEntry.table_name}.user_id",
|
|
||||||
:klass => User,
|
|
||||||
:label => :label_member},
|
|
||||||
'tracker' => {:sql => "#{Issue.table_name}.tracker_id",
|
|
||||||
:klass => Tracker,
|
|
||||||
:label => :label_tracker},
|
|
||||||
'activity' => {:sql => "#{TimeEntry.table_name}.activity_id",
|
|
||||||
:klass => TimeEntryActivity,
|
|
||||||
:label => :label_activity},
|
|
||||||
'issue' => {:sql => "#{TimeEntry.table_name}.issue_id",
|
|
||||||
:klass => Issue,
|
|
||||||
:label => :label_issue}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add list and boolean custom fields as available criterias
|
|
||||||
custom_fields = (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields)
|
|
||||||
custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
|
||||||
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Issue' AND c.customized_id = #{Issue.table_name}.id)",
|
|
||||||
:format => cf.field_format,
|
|
||||||
:label => cf.name}
|
|
||||||
end if @project
|
|
||||||
|
|
||||||
# Add list and boolean time entry custom fields
|
|
||||||
TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
|
||||||
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id)",
|
|
||||||
:format => cf.field_format,
|
|
||||||
:label => cf.name}
|
|
||||||
end
|
|
||||||
|
|
||||||
# Add list and boolean time entry activity custom fields
|
|
||||||
TimeEntryActivityCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
|
||||||
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Enumeration' AND c.customized_id = #{TimeEntry.table_name}.activity_id)",
|
|
||||||
:format => cf.field_format,
|
|
||||||
:label => cf.name}
|
|
||||||
end
|
|
||||||
|
|
||||||
call_hook(:controller_timelog_available_criterias, { :available_criterias => @available_criterias, :project => @project })
|
|
||||||
@available_criterias
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -19,6 +19,8 @@ class UsersController < ApplicationController
|
|||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
|
||||||
before_filter :require_admin, :except => :show
|
before_filter :require_admin, :except => :show
|
||||||
|
before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership]
|
||||||
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
@@ -29,6 +31,16 @@ class UsersController < ApplicationController
|
|||||||
sort_init 'login', 'asc'
|
sort_init 'login', 'asc'
|
||||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||||
|
|
||||||
|
case params[:format]
|
||||||
|
when 'xml', 'json'
|
||||||
|
@offset, @limit = api_offset_and_limit
|
||||||
|
else
|
||||||
|
@limit = per_page_option
|
||||||
|
end
|
||||||
|
|
||||||
|
scope = User
|
||||||
|
scope = scope.in_group(params[:group_id].to_i) if params[:group_id].present?
|
||||||
|
|
||||||
@status = params[:status] ? params[:status].to_i : 1
|
@status = params[:status] ? params[:status].to_i : 1
|
||||||
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
|
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
|
||||||
|
|
||||||
@@ -37,26 +49,27 @@ class UsersController < ApplicationController
|
|||||||
c << ["LOWER(login) LIKE ? OR LOWER(firstname) LIKE ? OR LOWER(lastname) LIKE ? OR LOWER(mail) LIKE ?", name, name, name, name]
|
c << ["LOWER(login) LIKE ? OR LOWER(firstname) LIKE ? OR LOWER(lastname) LIKE ? OR LOWER(mail) LIKE ?", name, name, name, name]
|
||||||
end
|
end
|
||||||
|
|
||||||
@user_count = User.count(:conditions => c.conditions)
|
@user_count = scope.count(:conditions => c.conditions)
|
||||||
@user_pages = Paginator.new self, @user_count,
|
@user_pages = Paginator.new self, @user_count, @limit, params['page']
|
||||||
per_page_option,
|
@offset ||= @user_pages.current.offset
|
||||||
params['page']
|
@users = scope.find :all,
|
||||||
@users = User.find :all,:order => sort_clause,
|
:order => sort_clause,
|
||||||
:conditions => c.conditions,
|
:conditions => c.conditions,
|
||||||
:limit => @user_pages.items_per_page,
|
:limit => @limit,
|
||||||
:offset => @user_pages.current.offset
|
:offset => @offset
|
||||||
|
|
||||||
render :layout => !request.xhr?
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
@groups = Group.all.sort
|
||||||
|
render :layout => !request.xhr?
|
||||||
|
}
|
||||||
|
format.api
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user = User.find(params[:id])
|
# show projects based on current user visibility
|
||||||
@custom_values = @user.custom_values
|
@memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||||
|
|
||||||
# show only public projects and private projects that the logged in user is also a member of
|
|
||||||
@memberships = @user.memberships.select do |membership|
|
|
||||||
membership.project.is_public? || (User.current.member_of?(membership.project))
|
|
||||||
end
|
|
||||||
|
|
||||||
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
|
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
|
||||||
@events_by_day = events.group_by(&:event_date)
|
@events_by_day = events.group_by(&:event_date)
|
||||||
@@ -67,74 +80,141 @@ class UsersController < ApplicationController
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
render :layout => 'base'
|
|
||||||
|
respond_to do |format|
|
||||||
rescue ActiveRecord::RecordNotFound
|
format.html { render :layout => 'base' }
|
||||||
render_404
|
format.api
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add
|
def new
|
||||||
if request.get?
|
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
||||||
@user = User.new(:language => Setting.default_language)
|
@auth_sources = AuthSource.find(:all)
|
||||||
|
end
|
||||||
|
|
||||||
|
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
def create
|
||||||
|
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
||||||
|
@user.safe_attributes = params[:user]
|
||||||
|
@user.admin = params[:user][:admin] || false
|
||||||
|
@user.login = params[:user][:login]
|
||||||
|
@user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation] unless @user.auth_source_id
|
||||||
|
|
||||||
|
# TODO: Similar to My#account
|
||||||
|
@user.pref.attributes = params[:pref]
|
||||||
|
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
||||||
|
|
||||||
|
if @user.save
|
||||||
|
@user.pref.save
|
||||||
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
|
|
||||||
|
Mailer.deliver_account_information(@user, params[:user][:password]) if params[:send_information]
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_create)
|
||||||
|
redirect_to(params[:continue] ?
|
||||||
|
{:controller => 'users', :action => 'new'} :
|
||||||
|
{:controller => 'users', :action => 'edit', :id => @user}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
format.api { render :action => 'show', :status => :created, :location => user_url(@user) }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@user = User.new(params[:user])
|
@auth_sources = AuthSource.find(:all)
|
||||||
@user.admin = params[:user][:admin] || false
|
# Clear password input
|
||||||
@user.login = params[:user][:login]
|
@user.password = @user.password_confirmation = nil
|
||||||
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id
|
|
||||||
if @user.save
|
respond_to do |format|
|
||||||
Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
|
format.html { render :action => 'new' }
|
||||||
flash[:notice] = l(:notice_successful_create)
|
format.api { render_validation_errors(@user) }
|
||||||
redirect_to(params[:continue] ? {:controller => 'users', :action => 'add'} :
|
|
||||||
{:controller => 'users', :action => 'edit', :id => @user})
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@auth_sources = AuthSource.find(:all)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@user = User.find(params[:id])
|
|
||||||
if request.post?
|
|
||||||
@user.admin = params[:user][:admin] if params[:user][:admin]
|
|
||||||
@user.login = params[:user][:login] if params[:user][:login]
|
|
||||||
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id
|
|
||||||
@user.group_ids = params[:user][:group_ids] if params[:user][:group_ids]
|
|
||||||
@user.attributes = params[:user]
|
|
||||||
# Was the account actived ? (do it before User#save clears the change)
|
|
||||||
was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE])
|
|
||||||
if @user.save
|
|
||||||
if was_activated
|
|
||||||
Mailer.deliver_account_activated(@user)
|
|
||||||
elsif @user.active? && params[:send_information] && !params[:password].blank? && @user.auth_source_id.nil?
|
|
||||||
Mailer.deliver_account_information(@user, params[:password])
|
|
||||||
end
|
|
||||||
flash[:notice] = l(:notice_successful_update)
|
|
||||||
redirect_to :back
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@auth_sources = AuthSource.find(:all)
|
@auth_sources = AuthSource.find(:all)
|
||||||
@membership ||= Member.new
|
@membership ||= Member.new
|
||||||
|
end
|
||||||
|
|
||||||
|
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
def update
|
||||||
|
@user.admin = params[:user][:admin] if params[:user][:admin]
|
||||||
|
@user.login = params[:user][:login] if params[:user][:login]
|
||||||
|
if params[:user][:password].present? && (@user.auth_source_id.nil? || params[:user][:auth_source_id].blank?)
|
||||||
|
@user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation]
|
||||||
|
end
|
||||||
|
@user.safe_attributes = params[:user]
|
||||||
|
# Was the account actived ? (do it before User#save clears the change)
|
||||||
|
was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE])
|
||||||
|
# TODO: Similar to My#account
|
||||||
|
@user.pref.attributes = params[:pref]
|
||||||
|
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
||||||
|
|
||||||
|
if @user.save
|
||||||
|
@user.pref.save
|
||||||
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
|
|
||||||
|
if was_activated
|
||||||
|
Mailer.deliver_account_activated(@user)
|
||||||
|
elsif @user.active? && params[:send_information] && !params[:user][:password].blank? && @user.auth_source_id.nil?
|
||||||
|
Mailer.deliver_account_information(@user, params[:user][:password])
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_to :back
|
||||||
|
}
|
||||||
|
format.api { head :ok }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@auth_sources = AuthSource.find(:all)
|
||||||
|
@membership ||= Member.new
|
||||||
|
# Clear password input
|
||||||
|
@user.password = @user.password_confirmation = nil
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :action => :edit }
|
||||||
|
format.api { render_validation_errors(@user) }
|
||||||
|
end
|
||||||
|
end
|
||||||
rescue ::ActionController::RedirectBackError
|
rescue ::ActionController::RedirectBackError
|
||||||
redirect_to :controller => 'users', :action => 'edit', :id => @user
|
redirect_to :controller => 'users', :action => 'edit', :id => @user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
|
def destroy
|
||||||
|
@user.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to(users_url) }
|
||||||
|
format.api { head :ok }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit_membership
|
def edit_membership
|
||||||
@user = User.find(params[:id])
|
|
||||||
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
|
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
|
||||||
@membership.save if request.post?
|
@membership.save if request.post?
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
|
if @membership.valid?
|
||||||
format.js {
|
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
|
||||||
render(:update) {|page|
|
format.js {
|
||||||
page.replace_html "tab-content-memberships", :partial => 'users/memberships'
|
render(:update) {|page|
|
||||||
page.visual_effect(:highlight, "member-#{@membership.id}")
|
page.replace_html "tab-content-memberships", :partial => 'users/memberships'
|
||||||
}
|
page.visual_effect(:highlight, "member-#{@membership.id}")
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
|
else
|
||||||
|
format.js {
|
||||||
|
render(:update) {|page|
|
||||||
|
page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_membership
|
def destroy_membership
|
||||||
@user = User.find(params[:id])
|
|
||||||
@membership = Member.find(params[:membership_id])
|
@membership = Member.find(params[:membership_id])
|
||||||
if request.post? && @membership.deletable?
|
if request.post? && @membership.deletable?
|
||||||
@membership.destroy
|
@membership.destroy
|
||||||
@@ -144,4 +224,17 @@ class UsersController < ApplicationController
|
|||||||
format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'users/memberships'} }
|
format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'users/memberships'} }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_user
|
||||||
|
if params[:id] == 'current'
|
||||||
|
require_login || return
|
||||||
|
@user = User.current
|
||||||
|
else
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
end
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,15 +18,42 @@
|
|||||||
class VersionsController < ApplicationController
|
class VersionsController < ApplicationController
|
||||||
menu_item :roadmap
|
menu_item :roadmap
|
||||||
model_object Version
|
model_object Version
|
||||||
before_filter :find_model_object, :except => [:new, :close_completed]
|
before_filter :find_model_object, :except => [:index, :new, :create, :close_completed]
|
||||||
before_filter :find_project_from_association, :except => [:new, :close_completed]
|
before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed]
|
||||||
before_filter :find_project, :only => [:new, :close_completed]
|
before_filter :find_project, :only => [:index, :new, :create, :close_completed]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
|
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
helper :projects
|
helper :projects
|
||||||
|
|
||||||
|
def index
|
||||||
|
@trackers = @project.trackers.find(:all, :order => 'position')
|
||||||
|
retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
|
||||||
|
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
||||||
|
project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
|
||||||
|
|
||||||
|
@versions = @project.shared_versions || []
|
||||||
|
@versions += @project.rolled_up_versions.visible if @with_subprojects
|
||||||
|
@versions = @versions.uniq.sort
|
||||||
|
@versions.reject! {|version| version.closed? || version.completed? } unless params[:completed]
|
||||||
|
|
||||||
|
@issues_by_version = {}
|
||||||
|
unless @selected_tracker_ids.empty?
|
||||||
|
@versions.each do |version|
|
||||||
|
issues = version.fixed_issues.visible.find(:all,
|
||||||
|
:include => [:project, :status, :tracker, :priority],
|
||||||
|
:conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids},
|
||||||
|
:order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
|
||||||
|
@issues_by_version[version] = issues
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@issues = @version.fixed_issues.visible.find(:all,
|
||||||
|
:include => [:status, :tracker, :priority],
|
||||||
|
:order => "#{Tracker.table_name}.position, #{Issue.table_name}.id")
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@@ -36,6 +63,17 @@ class VersionsController < ApplicationController
|
|||||||
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
|
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
|
||||||
@version.attributes = attributes
|
@version.attributes = attributes
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
# TODO: refactor with code above in #new
|
||||||
|
@version = @project.versions.build
|
||||||
|
if params[:version]
|
||||||
|
attributes = params[:version].dup
|
||||||
|
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
|
||||||
|
@version.attributes = attributes
|
||||||
|
end
|
||||||
|
|
||||||
if request.post?
|
if request.post?
|
||||||
if @version.save
|
if @version.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -52,7 +90,7 @@ class VersionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html { render :action => 'new' }
|
||||||
format.js do
|
format.js do
|
||||||
render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) }
|
render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) }
|
||||||
end
|
end
|
||||||
@@ -60,20 +98,27 @@ class VersionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if request.post? && params[:version]
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if request.put? && params[:version]
|
||||||
attributes = params[:version].dup
|
attributes = params[:version].dup
|
||||||
attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
|
attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
|
||||||
if @version.update_attributes(attributes)
|
if @version.update_attributes(attributes)
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :action => 'edit' }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def close_completed
|
def close_completed
|
||||||
if request.post?
|
if request.put?
|
||||||
@project.close_completed_versions
|
@project.close_completed_versions
|
||||||
end
|
end
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
@@ -102,4 +147,13 @@ private
|
|||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil)
|
||||||
|
if ids = params[:tracker_ids]
|
||||||
|
@selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
|
||||||
|
else
|
||||||
|
@selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -76,21 +76,13 @@ private
|
|||||||
|
|
||||||
def set_watcher(user, watching)
|
def set_watcher(user, watching)
|
||||||
@watched.set_watcher(user, watching)
|
@watched.set_watcher(user, watching)
|
||||||
if params[:replace].present?
|
|
||||||
if params[:replace].is_a? Array
|
|
||||||
replace_ids = params[:replace]
|
|
||||||
else
|
|
||||||
replace_ids = [params[:replace]]
|
|
||||||
end
|
|
||||||
else
|
|
||||||
replace_ids = ['watcher']
|
|
||||||
end
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to :back }
|
format.html { redirect_to :back }
|
||||||
format.js do
|
format.js do
|
||||||
render(:update) do |page|
|
render(:update) do |page|
|
||||||
replace_ids.each do |replace_id|
|
c = watcher_css(@watched)
|
||||||
page.replace_html replace_id, watcher_link(@watched, user, :replace => replace_ids)
|
page.select(".#{c}").each do |item|
|
||||||
|
page.replace_html item, watcher_link(@watched, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,37 +1,60 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require 'diff'
|
require 'diff'
|
||||||
|
|
||||||
|
# The WikiController follows the Rails REST controller pattern but with
|
||||||
|
# a few differences
|
||||||
|
#
|
||||||
|
# * index - shows a list of WikiPages grouped by page or date
|
||||||
|
# * new - not used
|
||||||
|
# * create - not used
|
||||||
|
# * show - will also show the form for creating a new wiki page
|
||||||
|
# * edit - used to edit an existing or new page
|
||||||
|
# * update - used to save a wiki page update to the database, including new pages
|
||||||
|
# * destroy - normal
|
||||||
|
#
|
||||||
|
# Other member and collection methods are also used
|
||||||
|
#
|
||||||
|
# TODO: still being worked on
|
||||||
class WikiController < ApplicationController
|
class WikiController < ApplicationController
|
||||||
default_search_scope :wiki_pages
|
default_search_scope :wiki_pages
|
||||||
before_filter :find_wiki, :authorize
|
before_filter :find_wiki, :authorize
|
||||||
|
before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
|
||||||
before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
|
before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
|
||||||
|
|
||||||
verify :method => :post, :only => [:destroy, :protect], :redirect_to => { :action => :index }
|
|
||||||
|
|
||||||
helper :attachments
|
helper :attachments
|
||||||
include AttachmentsHelper
|
include AttachmentsHelper
|
||||||
helper :watchers
|
helper :watchers
|
||||||
|
|
||||||
# display a page (in editing mode if it doesn't exist)
|
# List of pages, sorted alphabetically and by parent (hierarchy)
|
||||||
def index
|
def index
|
||||||
page_title = params[:page]
|
load_pages_for_index
|
||||||
@page = @wiki.find_or_new_page(page_title)
|
@pages_by_parent_id = @pages.group_by(&:parent_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
# List of page, by last update
|
||||||
|
def date_index
|
||||||
|
load_pages_for_index
|
||||||
|
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
|
||||||
|
end
|
||||||
|
|
||||||
|
# display a page (in editing mode if it doesn't exist)
|
||||||
|
def show
|
||||||
if @page.new_record?
|
if @page.new_record?
|
||||||
if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
|
if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
|
||||||
edit
|
edit
|
||||||
@@ -60,45 +83,57 @@ class WikiController < ApplicationController
|
|||||||
@editable = editable?
|
@editable = editable?
|
||||||
render :action => 'show'
|
render :action => 'show'
|
||||||
end
|
end
|
||||||
|
|
||||||
# edit an existing page or a new one
|
# edit an existing page or a new one
|
||||||
def edit
|
def edit
|
||||||
@page = @wiki.find_or_new_page(params[:page])
|
|
||||||
return render_403 unless editable?
|
return render_403 unless editable?
|
||||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||||
|
|
||||||
@content = @page.content_for_version(params[:version])
|
@content = @page.content_for_version(params[:version])
|
||||||
@content.text = initial_page_content(@page) if @content.text.blank?
|
@content.text = initial_page_content(@page) if @content.text.blank?
|
||||||
# don't keep previous comment
|
# don't keep previous comment
|
||||||
@content.comments = nil
|
@content.comments = nil
|
||||||
if request.get?
|
|
||||||
# To prevent StaleObjectError exception when reverting to a previous version
|
# To prevent StaleObjectError exception when reverting to a previous version
|
||||||
@content.version = @page.content.version
|
@content.version = @page.content.version
|
||||||
else
|
end
|
||||||
if !@page.new_record? && @content.text == params[:content][:text]
|
|
||||||
attachments = Attachment.attach_files(@page, params[:attachments])
|
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
render_attachment_warning_if_needed(@page)
|
# Creates a new page or updates an existing one
|
||||||
# don't save if text wasn't changed
|
def update
|
||||||
redirect_to :action => 'index', :id => @project, :page => @page.title
|
return render_403 unless editable?
|
||||||
return
|
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||||
end
|
|
||||||
#@content.text = params[:content][:text]
|
@content = @page.content_for_version(params[:version])
|
||||||
#@content.comments = params[:content][:comments]
|
@content.text = initial_page_content(@page) if @content.text.blank?
|
||||||
@content.attributes = params[:content]
|
# don't keep previous comment
|
||||||
@content.author = User.current
|
@content.comments = nil
|
||||||
# if page is new @page.save will also save content, but not if page isn't a new record
|
|
||||||
if (@page.new_record? ? @page.save : @content.save)
|
if !@page.new_record? && params[:content].present? && @content.text == params[:content][:text]
|
||||||
attachments = Attachment.attach_files(@page, params[:attachments])
|
attachments = Attachment.attach_files(@page, params[:attachments])
|
||||||
render_attachment_warning_if_needed(@page)
|
render_attachment_warning_if_needed(@page)
|
||||||
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
|
# don't save if text wasn't changed
|
||||||
redirect_to :action => 'index', :id => @project, :page => @page.title
|
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
||||||
end
|
return
|
||||||
end
|
end
|
||||||
|
@content.attributes = params[:content]
|
||||||
|
@content.author = User.current
|
||||||
|
# if page is new @page.save will also save content, but not if page isn't a new record
|
||||||
|
if (@page.new_record? ? @page.save : @content.save)
|
||||||
|
attachments = Attachment.attach_files(@page, params[:attachments])
|
||||||
|
render_attachment_warning_if_needed(@page)
|
||||||
|
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
|
||||||
|
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
||||||
|
else
|
||||||
|
render :action => 'edit'
|
||||||
|
end
|
||||||
|
|
||||||
rescue ActiveRecord::StaleObjectError
|
rescue ActiveRecord::StaleObjectError
|
||||||
# Optimistic locking exception
|
# Optimistic locking exception
|
||||||
flash[:error] = l(:notice_locking_conflict)
|
flash.now[:error] = l(:notice_locking_conflict)
|
||||||
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
|
|
||||||
# rename a page
|
# rename a page
|
||||||
def rename
|
def rename
|
||||||
return render_403 unless editable?
|
return render_403 unless editable?
|
||||||
@@ -107,21 +142,22 @@ class WikiController < ApplicationController
|
|||||||
@original_title = @page.pretty_title
|
@original_title = @page.pretty_title
|
||||||
if request.post? && @page.update_attributes(params[:wiki_page])
|
if request.post? && @page.update_attributes(params[:wiki_page])
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'index', :id => @project, :page => @page.title
|
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
verify :method => :post, :only => :protect, :redirect_to => { :action => :show }
|
||||||
def protect
|
def protect
|
||||||
@page.update_attribute :protected, params[:protected]
|
@page.update_attribute :protected, params[:protected]
|
||||||
redirect_to :action => 'index', :id => @project, :page => @page.title
|
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
||||||
end
|
end
|
||||||
|
|
||||||
# show page history
|
# show page history
|
||||||
def history
|
def history
|
||||||
@version_count = @page.content.versions.count
|
@version_count = @page.content.versions.count
|
||||||
@version_pages = Paginator.new self, @version_count, per_page_option, params['p']
|
@version_pages = Paginator.new self, @version_count, per_page_option, params['p']
|
||||||
# don't load text
|
# don't load text
|
||||||
@versions = @page.content.versions.find :all,
|
@versions = @page.content.versions.find :all,
|
||||||
:select => "id, author_id, comments, updated_on, version",
|
:select => "id, author_id, comments, updated_on, version",
|
||||||
:order => 'version DESC',
|
:order => 'version DESC',
|
||||||
:limit => @version_pages.items_per_page + 1,
|
:limit => @version_pages.items_per_page + 1,
|
||||||
@@ -129,22 +165,23 @@ class WikiController < ApplicationController
|
|||||||
|
|
||||||
render :layout => false if request.xhr?
|
render :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff
|
def diff
|
||||||
@diff = @page.diff(params[:version], params[:version_from])
|
@diff = @page.diff(params[:version], params[:version_from])
|
||||||
render_404 unless @diff
|
render_404 unless @diff
|
||||||
end
|
end
|
||||||
|
|
||||||
def annotate
|
def annotate
|
||||||
@annotate = @page.annotate(params[:version])
|
@annotate = @page.annotate(params[:version])
|
||||||
render_404 unless @annotate
|
render_404 unless @annotate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
verify :method => :delete, :only => [:destroy], :redirect_to => { :action => :show }
|
||||||
# Removes a wiki page and its history
|
# Removes a wiki page and its history
|
||||||
# Children can be either set as root pages, removed or reassigned to another parent page
|
# Children can be either set as root pages, removed or reassigned to another parent page
|
||||||
def destroy
|
def destroy
|
||||||
return render_403 unless editable?
|
return render_403 unless editable?
|
||||||
|
|
||||||
@descendants_count = @page.descendants.size
|
@descendants_count = @page.descendants.size
|
||||||
if @descendants_count > 0
|
if @descendants_count > 0
|
||||||
case params[:todo]
|
case params[:todo]
|
||||||
@@ -166,41 +203,22 @@ class WikiController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
@page.destroy
|
@page.destroy
|
||||||
redirect_to :action => 'special', :id => @project, :page => 'Page_index'
|
redirect_to :action => 'index', :project_id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
# display special pages
|
# Export wiki to a single html file
|
||||||
def special
|
def export
|
||||||
page_title = params[:page].downcase
|
if User.current.allowed_to?(:export_wiki_pages, @project)
|
||||||
case page_title
|
@pages = @wiki.pages.find :all, :order => 'title'
|
||||||
# show pages index, sorted by title
|
export = render_to_string :action => 'export_multiple', :layout => false
|
||||||
when 'page_index', 'date_index'
|
send_data(export, :type => 'text/html', :filename => "wiki.html")
|
||||||
# eager load information about last updates, without loading text
|
|
||||||
@pages = @wiki.pages.find :all, :select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on",
|
|
||||||
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
|
|
||||||
:order => 'title'
|
|
||||||
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
|
|
||||||
@pages_by_parent_id = @pages.group_by(&:parent_id)
|
|
||||||
# export wiki to a single html file
|
|
||||||
when 'export'
|
|
||||||
if User.current.allowed_to?(:export_wiki_pages, @project)
|
|
||||||
@pages = @wiki.pages.find :all, :order => 'title'
|
|
||||||
export = render_to_string :action => 'export_multiple', :layout => false
|
|
||||||
send_data(export, :type => 'text/html', :filename => "wiki.html")
|
|
||||||
else
|
|
||||||
redirect_to :action => 'index', :id => @project, :page => nil
|
|
||||||
end
|
|
||||||
return
|
|
||||||
else
|
else
|
||||||
# requested special page doesn't exist, redirect to default page
|
redirect_to :action => 'show', :project_id => @project, :id => nil
|
||||||
redirect_to :action => 'index', :id => @project, :page => nil
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
render :action => "special_#{page_title}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def preview
|
def preview
|
||||||
page = @wiki.find_page(params[:page])
|
page = @wiki.find_page(params[:id])
|
||||||
# page is nil when previewing a new page
|
# page is nil when previewing a new page
|
||||||
return render_403 unless page.nil? || editable?(page)
|
return render_403 unless page.nil? || editable?(page)
|
||||||
if page
|
if page
|
||||||
@@ -215,25 +233,39 @@ class WikiController < ApplicationController
|
|||||||
return render_403 unless editable?
|
return render_403 unless editable?
|
||||||
attachments = Attachment.attach_files(@page, params[:attachments])
|
attachments = Attachment.attach_files(@page, params[:attachments])
|
||||||
render_attachment_warning_if_needed(@page)
|
render_attachment_warning_if_needed(@page)
|
||||||
redirect_to :action => 'index', :page => @page.title
|
redirect_to :action => 'show', :id => @page.title, :project_id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_wiki
|
def find_wiki
|
||||||
@project = Project.find(params[:id])
|
@project = Project.find(params[:project_id])
|
||||||
@wiki = @project.wiki
|
@wiki = @project.wiki
|
||||||
render_404 unless @wiki
|
render_404 unless @wiki
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Finds the requested page or a new page if it doesn't exist
|
||||||
|
def find_existing_or_new_page
|
||||||
|
@page = @wiki.find_or_new_page(params[:id])
|
||||||
|
if @wiki.page_found_with_redirect?
|
||||||
|
redirect_to params.update(:id => @page.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Finds the requested page and returns a 404 error if it doesn't exist
|
# Finds the requested page and returns a 404 error if it doesn't exist
|
||||||
def find_existing_page
|
def find_existing_page
|
||||||
@page = @wiki.find_page(params[:page])
|
@page = @wiki.find_page(params[:id])
|
||||||
render_404 if @page.nil?
|
if @page.nil?
|
||||||
|
render_404
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if @wiki.page_found_with_redirect?
|
||||||
|
redirect_to params.update(:id => @page.title)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if the current user is allowed to edit the page, otherwise false
|
# Returns true if the current user is allowed to edit the page, otherwise false
|
||||||
def editable?(page = @page)
|
def editable?(page = @page)
|
||||||
page.editable_by?(User.current)
|
page.editable_by?(User.current)
|
||||||
@@ -245,4 +277,8 @@ private
|
|||||||
extend helper unless self.instance_of?(helper)
|
extend helper unless self.instance_of?(helper)
|
||||||
helper.instance_method(:initial_page_content).bind(self).call(page)
|
helper.instance_method(:initial_page_content).bind(self).call(page)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def load_pages_for_index
|
||||||
|
@pages = @wiki.pages.with_updated_on.all(:order => 'title', :include => {:wiki => :project})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,14 +32,17 @@ class WorkflowsController < ApplicationController
|
|||||||
|
|
||||||
if request.post?
|
if request.post?
|
||||||
Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
|
Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
|
||||||
(params[:issue_status] || []).each { |old, news|
|
(params[:issue_status] || []).each { |status_id, transitions|
|
||||||
news.each { |new|
|
transitions.each { |new_status_id, options|
|
||||||
@role.workflows.build(:tracker_id => @tracker.id, :old_status_id => old, :new_status_id => new)
|
author = options.is_a?(Array) && options.include?('author') && !options.include?('always')
|
||||||
|
assignee = options.is_a?(Array) && options.include?('assignee') && !options.include?('always')
|
||||||
|
@role.workflows.build(:tracker_id => @tracker.id, :old_status_id => status_id, :new_status_id => new_status_id, :author => author, :assignee => assignee)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if @role.save
|
if @role.save
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker
|
redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -48,6 +51,14 @@ class WorkflowsController < ApplicationController
|
|||||||
@statuses = @tracker.issue_statuses
|
@statuses = @tracker.issue_statuses
|
||||||
end
|
end
|
||||||
@statuses ||= IssueStatus.find(:all, :order => 'position')
|
@statuses ||= IssueStatus.find(:all, :order => 'position')
|
||||||
|
|
||||||
|
if @tracker && @role && @statuses.any?
|
||||||
|
workflows = Workflow.all(:conditions => {:role_id => @role.id, :tracker_id => @tracker.id})
|
||||||
|
@workflows = {}
|
||||||
|
@workflows['always'] = workflows.select {|w| !w.author && !w.assignee}
|
||||||
|
@workflows['author'] = workflows.select {|w| w.author}
|
||||||
|
@workflows['assignee'] = workflows.select {|w| w.assignee}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy
|
def copy
|
||||||
|
|||||||
@@ -20,12 +20,4 @@ module AdminHelper
|
|||||||
options_for_select([[l(:label_all), ''],
|
options_for_select([[l(:label_all), ''],
|
||||||
[l(:status_active), 1]], selected)
|
[l(:status_active), 1]], selected)
|
||||||
end
|
end
|
||||||
|
|
||||||
def css_project_classes(project)
|
|
||||||
s = 'project'
|
|
||||||
s << ' root' if project.root?
|
|
||||||
s << ' child' if project.child?
|
|
||||||
s << (project.leaf? ? ' leaf' : ' parent')
|
|
||||||
s
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
+254
-104
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -32,6 +32,11 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Display a link if user is authorized
|
# Display a link if user is authorized
|
||||||
|
#
|
||||||
|
# @param [String] name Anchor text (passed to link_to)
|
||||||
|
# @param [Hash] options Hash params. This will checked by authorize_for to see if the user is authorized
|
||||||
|
# @param [optional, Hash] html_options Options passed to link_to
|
||||||
|
# @param [optional, Hash] parameters_for_method_reference Extra parameters for link_to
|
||||||
def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
|
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
|
||||||
end
|
end
|
||||||
@@ -58,7 +63,7 @@ module ApplicationHelper
|
|||||||
|
|
||||||
# Displays a link to +issue+ with its subject.
|
# Displays a link to +issue+ with its subject.
|
||||||
# Examples:
|
# Examples:
|
||||||
#
|
#
|
||||||
# link_to_issue(issue) # => Defect #6: This is the subject
|
# link_to_issue(issue) # => Defect #6: This is the subject
|
||||||
# link_to_issue(issue, :truncate => 6) # => Defect #6: This i...
|
# link_to_issue(issue, :truncate => 6) # => Defect #6: This i...
|
||||||
# link_to_issue(issue, :subject => false) # => Defect #6
|
# link_to_issue(issue, :subject => false) # => Defect #6
|
||||||
@@ -75,7 +80,7 @@ module ApplicationHelper
|
|||||||
subject = truncate(subject, :length => options[:truncate])
|
subject = truncate(subject, :length => options[:truncate])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
s = link_to "#{issue.tracker} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue},
|
s = link_to "#{issue.tracker} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue},
|
||||||
:class => issue.css_classes,
|
:class => issue.css_classes,
|
||||||
:title => title
|
:title => title
|
||||||
s << ": #{h subject}" if subject
|
s << ": #{h subject}" if subject
|
||||||
@@ -99,8 +104,41 @@ module ApplicationHelper
|
|||||||
# * :text - Link text (default to the formatted revision)
|
# * :text - Link text (default to the formatted revision)
|
||||||
def link_to_revision(revision, project, options={})
|
def link_to_revision(revision, project, options={})
|
||||||
text = options.delete(:text) || format_revision(revision)
|
text = options.delete(:text) || format_revision(revision)
|
||||||
|
rev = revision.respond_to?(:identifier) ? revision.identifier : revision
|
||||||
|
|
||||||
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision}, :title => l(:label_revision_id, revision))
|
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev},
|
||||||
|
:title => l(:label_revision_id, format_revision(revision)))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Generates a link to a message
|
||||||
|
def link_to_message(message, options={}, html_options = nil)
|
||||||
|
link_to(
|
||||||
|
h(truncate(message.subject, :length => 60)),
|
||||||
|
{ :controller => 'messages', :action => 'show',
|
||||||
|
:board_id => message.board_id,
|
||||||
|
:id => message.root,
|
||||||
|
:r => (message.parent_id && message.id),
|
||||||
|
:anchor => (message.parent_id ? "message-#{message.id}" : nil)
|
||||||
|
}.merge(options),
|
||||||
|
html_options
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Generates a link to a project if active
|
||||||
|
# Examples:
|
||||||
|
#
|
||||||
|
# link_to_project(project) # => link to the specified project overview
|
||||||
|
# link_to_project(project, :action=>'settings') # => link to project settings
|
||||||
|
# link_to_project(project, {:only_path => false}, :class => "project") # => 3rd arg adds html options
|
||||||
|
# link_to_project(project, {}, :class => "project") # => html options with default url (project overview)
|
||||||
|
#
|
||||||
|
def link_to_project(project, options={}, html_options = nil)
|
||||||
|
if project.active?
|
||||||
|
url = {:controller => 'projects', :action => 'show', :id => project}.merge(options)
|
||||||
|
link_to(h(project), url, html_options)
|
||||||
|
else
|
||||||
|
h(project)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def toggle_link(name, id, options={})
|
def toggle_link(name, id, options={})
|
||||||
@@ -122,15 +160,15 @@ module ApplicationHelper
|
|||||||
html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
|
html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
|
||||||
link_to name, {}, html_options
|
link_to name, {}, html_options
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_activity_title(text)
|
def format_activity_title(text)
|
||||||
h(truncate_single_line(text, :length => 100))
|
h(truncate_single_line(text, :length => 100))
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_activity_day(date)
|
def format_activity_day(date)
|
||||||
date == Date.today ? l(:label_today).titleize : format_date(date)
|
date == Date.today ? l(:label_today).titleize : format_date(date)
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_activity_description(text)
|
def format_activity_description(text)
|
||||||
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />")
|
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />")
|
||||||
end
|
end
|
||||||
@@ -142,29 +180,29 @@ module ApplicationHelper
|
|||||||
h("#{version.project} - #{version}")
|
h("#{version.project} - #{version}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def due_date_distance_in_words(date)
|
def due_date_distance_in_words(date)
|
||||||
if date
|
if date
|
||||||
l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
|
l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_page_hierarchy(pages, node=nil)
|
def render_page_hierarchy(pages, node=nil, options={})
|
||||||
content = ''
|
content = ''
|
||||||
if pages[node]
|
if pages[node]
|
||||||
content << "<ul class=\"pages-hierarchy\">\n"
|
content << "<ul class=\"pages-hierarchy\">\n"
|
||||||
pages[node].each do |page|
|
pages[node].each do |page|
|
||||||
content << "<li>"
|
content << "<li>"
|
||||||
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'index', :id => page.project, :page => page.title},
|
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title},
|
||||||
:title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
|
:title => (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
|
||||||
content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id]
|
content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id]
|
||||||
content << "</li>\n"
|
content << "</li>\n"
|
||||||
end
|
end
|
||||||
content << "</ul>\n"
|
content << "</ul>\n"
|
||||||
end
|
end
|
||||||
content
|
content
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders flash messages
|
# Renders flash messages
|
||||||
def render_flash_messages
|
def render_flash_messages
|
||||||
s = ''
|
s = ''
|
||||||
@@ -173,7 +211,7 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders tabs and their content
|
# Renders tabs and their content
|
||||||
def render_tabs(tabs)
|
def render_tabs(tabs)
|
||||||
if tabs.any?
|
if tabs.any?
|
||||||
@@ -182,11 +220,11 @@ module ApplicationHelper
|
|||||||
content_tag 'p', l(:label_no_data), :class => "nodata"
|
content_tag 'p', l(:label_no_data), :class => "nodata"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders the project quick-jump box
|
# Renders the project quick-jump box
|
||||||
def render_project_jump_box
|
def render_project_jump_box
|
||||||
# Retrieve them now to avoid a COUNT query
|
return unless User.current.logged?
|
||||||
projects = User.current.projects.all
|
projects = User.current.memberships.collect(&:project).compact.uniq
|
||||||
if projects.any?
|
if projects.any?
|
||||||
s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
|
s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
|
||||||
"<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
|
"<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
|
||||||
@@ -198,7 +236,7 @@ module ApplicationHelper
|
|||||||
s
|
s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_tree_options_for_select(projects, options = {})
|
def project_tree_options_for_select(projects, options = {})
|
||||||
s = ''
|
s = ''
|
||||||
project_tree(projects) do |project, level|
|
project_tree(projects) do |project, level|
|
||||||
@@ -214,19 +252,14 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Yields the given block for each project with its level in the tree
|
# Yields the given block for each project with its level in the tree
|
||||||
|
#
|
||||||
|
# Wrapper for Project#project_tree
|
||||||
def project_tree(projects, &block)
|
def project_tree(projects, &block)
|
||||||
ancestors = []
|
Project.project_tree(projects, &block)
|
||||||
projects.sort_by(&:lft).each do |project|
|
|
||||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
|
||||||
ancestors.pop
|
|
||||||
end
|
|
||||||
yield project, ancestors.size
|
|
||||||
ancestors << project
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_nested_ul(projects, &block)
|
def project_nested_ul(projects, &block)
|
||||||
s = ''
|
s = ''
|
||||||
if projects.any?
|
if projects.any?
|
||||||
@@ -237,7 +270,7 @@ module ApplicationHelper
|
|||||||
else
|
else
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
s << "</li>"
|
s << "</li>"
|
||||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
s << "</ul></li>\n"
|
s << "</ul></li>\n"
|
||||||
end
|
end
|
||||||
@@ -250,20 +283,20 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
def principals_check_box_tags(name, principals)
|
def principals_check_box_tags(name, principals)
|
||||||
s = ''
|
s = ''
|
||||||
principals.sort.each do |principal|
|
principals.sort.each do |principal|
|
||||||
s << "<label>#{ check_box_tag name, principal.id, false } #{h principal}</label>\n"
|
s << "<label>#{ check_box_tag name, principal.id, false } #{h principal}</label>\n"
|
||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Truncates and returns the string as a single line
|
# Truncates and returns the string as a single line
|
||||||
def truncate_single_line(string, *args)
|
def truncate_single_line(string, *args)
|
||||||
truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ')
|
truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Truncates at line break after 250 characters or options[:length]
|
# Truncates at line break after 250 characters or options[:length]
|
||||||
def truncate_lines(string, options={})
|
def truncate_lines(string, options={})
|
||||||
length = options[:length] || 250
|
length = options[:length] || 250
|
||||||
@@ -281,11 +314,11 @@ module ApplicationHelper
|
|||||||
def authoring(created, author, options={})
|
def authoring(created, author, options={})
|
||||||
l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created))
|
l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created))
|
||||||
end
|
end
|
||||||
|
|
||||||
def time_tag(time)
|
def time_tag(time)
|
||||||
text = distance_of_time_in_words(Time.now, time)
|
text = distance_of_time_in_words(Time.now, time)
|
||||||
if @project
|
if @project
|
||||||
link_to(text, {:controller => 'projects', :action => 'activity', :id => @project, :from => time.to_date}, :title => format_time(time))
|
link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => time.to_date}, :title => format_time(time))
|
||||||
else
|
else
|
||||||
content_tag('acronym', text, :title => format_time(time))
|
content_tag('acronym', text, :title => format_time(time))
|
||||||
end
|
end
|
||||||
@@ -303,20 +336,18 @@ module ApplicationHelper
|
|||||||
page_param = options.delete(:page_param) || :page
|
page_param = options.delete(:page_param) || :page
|
||||||
per_page_links = options.delete(:per_page_links)
|
per_page_links = options.delete(:per_page_links)
|
||||||
url_param = params.dup
|
url_param = params.dup
|
||||||
# don't reuse query params if filters are present
|
|
||||||
url_param.merge!(:fields => nil, :values => nil, :operators => nil) if url_param.delete(:set_filter)
|
|
||||||
|
|
||||||
html = ''
|
html = ''
|
||||||
if paginator.current.previous
|
if paginator.current.previous
|
||||||
html << link_to_remote_content_update('« ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' '
|
html << link_to_content_update('« ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' '
|
||||||
end
|
end
|
||||||
|
|
||||||
html << (pagination_links_each(paginator, options) do |n|
|
html << (pagination_links_each(paginator, options) do |n|
|
||||||
link_to_remote_content_update(n.to_s, url_param.merge(page_param => n))
|
link_to_content_update(n.to_s, url_param.merge(page_param => n))
|
||||||
end || '')
|
end || '')
|
||||||
|
|
||||||
if paginator.current.next
|
if paginator.current.next
|
||||||
html << ' ' + link_to_remote_content_update((l(:label_next) + ' »'), url_param.merge(page_param => paginator.current.next))
|
html << ' ' + link_to_content_update((l(:label_next) + ' »'), url_param.merge(page_param => paginator.current.next))
|
||||||
end
|
end
|
||||||
|
|
||||||
unless count.nil?
|
unless count.nil?
|
||||||
@@ -328,20 +359,14 @@ module ApplicationHelper
|
|||||||
|
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|
||||||
def per_page_links(selected=nil)
|
|
||||||
url_param = params.dup
|
|
||||||
url_param.clear if url_param.has_key?(:set_filter)
|
|
||||||
|
|
||||||
|
def per_page_links(selected=nil)
|
||||||
links = Setting.per_page_options_array.collect do |n|
|
links = Setting.per_page_options_array.collect do |n|
|
||||||
n == selected ? n : link_to_remote(n, {:update => "content",
|
n == selected ? n : link_to_content_update(n, params.merge(:per_page => n))
|
||||||
:url => params.dup.merge(:per_page => n),
|
|
||||||
:method => :get},
|
|
||||||
{:href => url_for(url_param.merge(:per_page => n))})
|
|
||||||
end
|
end
|
||||||
links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
|
links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def reorder_links(name, url)
|
def reorder_links(name, url)
|
||||||
link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)), url.merge({"#{name}[move_to]" => 'highest'}), :method => :post, :title => l(:label_sort_highest)) +
|
link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)), url.merge({"#{name}[move_to]" => 'highest'}), :method => :post, :title => l(:label_sort_highest)) +
|
||||||
link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)), url.merge({"#{name}[move_to]" => 'higher'}), :method => :post, :title => l(:label_sort_higher)) +
|
link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)), url.merge({"#{name}[move_to]" => 'higher'}), :method => :post, :title => l(:label_sort_higher)) +
|
||||||
@@ -353,27 +378,27 @@ module ApplicationHelper
|
|||||||
elements = args.flatten
|
elements = args.flatten
|
||||||
elements.any? ? content_tag('p', args.join(' » ') + ' » ', :class => 'breadcrumb') : nil
|
elements.any? ? content_tag('p', args.join(' » ') + ' » ', :class => 'breadcrumb') : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def other_formats_links(&block)
|
def other_formats_links(&block)
|
||||||
concat('<p class="other-formats">' + l(:label_export_to))
|
concat('<p class="other-formats">' + l(:label_export_to))
|
||||||
yield Redmine::Views::OtherFormatsBuilder.new(self)
|
yield Redmine::Views::OtherFormatsBuilder.new(self)
|
||||||
concat('</p>')
|
concat('</p>')
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_header_title
|
def page_header_title
|
||||||
if @project.nil? || @project.new_record?
|
if @project.nil? || @project.new_record?
|
||||||
h(Setting.app_title)
|
h(Setting.app_title)
|
||||||
else
|
else
|
||||||
b = []
|
b = []
|
||||||
ancestors = (@project.root? ? [] : @project.ancestors.visible)
|
ancestors = (@project.root? ? [] : @project.ancestors.visible.all)
|
||||||
if ancestors.any?
|
if ancestors.any?
|
||||||
root = ancestors.shift
|
root = ancestors.shift
|
||||||
b << link_to(h(root), {:controller => 'projects', :action => 'show', :id => root, :jump => current_menu_item}, :class => 'root')
|
b << link_to_project(root, {:jump => current_menu_item}, :class => 'root')
|
||||||
if ancestors.size > 2
|
if ancestors.size > 2
|
||||||
b << '…'
|
b << '…'
|
||||||
ancestors = ancestors[-2, 2]
|
ancestors = ancestors[-2, 2]
|
||||||
end
|
end
|
||||||
b += ancestors.collect {|p| link_to(h(p), {:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item}, :class => 'ancestor') }
|
b += ancestors.collect {|p| link_to_project(p, {:jump => current_menu_item}, :class => 'ancestor') }
|
||||||
end
|
end
|
||||||
b << h(@project)
|
b << h(@project)
|
||||||
b.join(' » ')
|
b.join(' » ')
|
||||||
@@ -393,6 +418,19 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the theme, controller name, and action as css classes for the
|
||||||
|
# HTML body.
|
||||||
|
def body_css_classes
|
||||||
|
css = []
|
||||||
|
if theme = Redmine::Themes.theme(Setting.ui_theme)
|
||||||
|
css << 'theme-' + theme.name
|
||||||
|
end
|
||||||
|
|
||||||
|
css << 'controller-' + params[:controller]
|
||||||
|
css << 'action-' + params[:action]
|
||||||
|
css.join(' ')
|
||||||
|
end
|
||||||
|
|
||||||
def accesskey(s)
|
def accesskey(s)
|
||||||
Redmine::AccessKeys.key_for s
|
Redmine::AccessKeys.key_for s
|
||||||
end
|
end
|
||||||
@@ -419,14 +457,21 @@ module ApplicationHelper
|
|||||||
only_path = options.delete(:only_path) == false ? false : true
|
only_path = options.delete(:only_path) == false ? false : true
|
||||||
|
|
||||||
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) { |macro, args| exec_macro(macro, obj, args) }
|
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) { |macro, args| exec_macro(macro, obj, args) }
|
||||||
|
|
||||||
parse_non_pre_blocks(text) do |text|
|
@parsed_headings = []
|
||||||
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name|
|
text = parse_non_pre_blocks(text) do |text|
|
||||||
|
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_headings].each do |method_name|
|
||||||
send method_name, text, project, obj, attr, only_path, options
|
send method_name, text, project, obj, attr, only_path, options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @parsed_headings.any?
|
||||||
|
replace_toc(text, @parsed_headings)
|
||||||
|
end
|
||||||
|
|
||||||
|
text
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_non_pre_blocks(text)
|
def parse_non_pre_blocks(text)
|
||||||
s = StringScanner.new(text)
|
s = StringScanner.new(text)
|
||||||
tags = []
|
tags = []
|
||||||
@@ -455,13 +500,13 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
parsed
|
parsed
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_inline_attachments(text, project, obj, attr, only_path, options)
|
def parse_inline_attachments(text, project, obj, attr, only_path, options)
|
||||||
# when using an image link, try to use an attachment, if possible
|
# when using an image link, try to use an attachment, if possible
|
||||||
if options[:attachments] || (obj && obj.respond_to?(:attachments))
|
if options[:attachments] || (obj && obj.respond_to?(:attachments))
|
||||||
attachments = nil
|
attachments = nil
|
||||||
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
|
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
|
||||||
filename, ext, alt, alttext = $1.downcase, $2, $3, $4
|
filename, ext, alt, alttext = $1.downcase, $2, $3, $4
|
||||||
attachments ||= (options[:attachments] || obj.attachments).sort_by(&:created_on).reverse
|
attachments ||= (options[:attachments] || obj.attachments).sort_by(&:created_on).reverse
|
||||||
# search for the picture in attachments
|
# search for the picture in attachments
|
||||||
if found = attachments.detect { |att| att.filename.downcase == filename }
|
if found = attachments.detect { |att| att.filename.downcase == filename }
|
||||||
@@ -494,7 +539,7 @@ module ApplicationHelper
|
|||||||
esc, all, page, title = $1, $2, $3, $5
|
esc, all, page, title = $1, $2, $3, $5
|
||||||
if esc.nil?
|
if esc.nil?
|
||||||
if page =~ /^([^\:]+)\:(.*)$/
|
if page =~ /^([^\:]+)\:(.*)$/
|
||||||
link_project = Project.find_by_name($1) || Project.find_by_identifier($1)
|
link_project = Project.find_by_identifier($1) || Project.find_by_name($1)
|
||||||
page = $2
|
page = $2
|
||||||
title ||= $1 if page.blank?
|
title ||= $1 if page.blank?
|
||||||
end
|
end
|
||||||
@@ -505,14 +550,20 @@ module ApplicationHelper
|
|||||||
if page =~ /^(.+?)\#(.+)$/
|
if page =~ /^(.+?)\#(.+)$/
|
||||||
page, anchor = $1, $2
|
page, anchor = $1, $2
|
||||||
end
|
end
|
||||||
|
anchor = sanitize_anchor_name(anchor) if anchor.present?
|
||||||
# check if page exists
|
# check if page exists
|
||||||
wiki_page = link_project.wiki.find_page(page)
|
wiki_page = link_project.wiki.find_page(page)
|
||||||
url = case options[:wiki_links]
|
url = if anchor.present? && wiki_page.present? && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)) && obj.page == wiki_page
|
||||||
when :local; "#{title}.html"
|
"##{anchor}"
|
||||||
|
else
|
||||||
|
case options[:wiki_links]
|
||||||
|
when :local; "#{page.present? ? Wiki.titleize(page) : ''}.html" + (anchor.present? ? "##{anchor}" : '')
|
||||||
when :anchor; "##{title}" # used for single-file wiki export
|
when :anchor; "##{title}" # used for single-file wiki export
|
||||||
else
|
else
|
||||||
url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => link_project, :page => Wiki.titleize(page), :anchor => anchor)
|
wiki_page_id = page.present? ? Wiki.titleize(page) : nil
|
||||||
|
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, :id => wiki_page_id, :anchor => anchor)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
link_to((title || page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
|
link_to((title || page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
|
||||||
else
|
else
|
||||||
# project or wiki doesn't exist
|
# project or wiki doesn't exist
|
||||||
@@ -523,7 +574,7 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Redmine links
|
# Redmine links
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
@@ -548,16 +599,26 @@ module ApplicationHelper
|
|||||||
# source:some/file#L120 -> Link to line 120 of the file
|
# source:some/file#L120 -> Link to line 120 of the file
|
||||||
# source:some/file@52#L120 -> Link to line 120 of the file's revision 52
|
# source:some/file@52#L120 -> Link to line 120 of the file's revision 52
|
||||||
# export:some/file -> Force the download of the file
|
# export:some/file -> Force the download of the file
|
||||||
# Forum messages:
|
# Forum messages:
|
||||||
# message#1218 -> Link to message with id 1218
|
# message#1218 -> Link to message with id 1218
|
||||||
|
#
|
||||||
|
# Links can refer other objects from other projects, using project identifier:
|
||||||
|
# identifier:r52
|
||||||
|
# identifier:document:"Some document"
|
||||||
|
# identifier:version:1.0.0
|
||||||
|
# identifier:source:some/file
|
||||||
def parse_redmine_links(text, project, obj, attr, only_path, options)
|
def parse_redmine_links(text, project, obj, attr, only_path, options)
|
||||||
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(attachment|document|version|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
|
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-]+):)?(attachment|document|version|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
|
||||||
leading, esc, prefix, sep, identifier = $1, $2, $3, $5 || $7, $6 || $8
|
leading, esc, project_prefix, project_identifier, prefix, sep, identifier = $1, $2, $3, $4, $5, $7 || $9, $8 || $10
|
||||||
link = nil
|
link = nil
|
||||||
|
if project_identifier
|
||||||
|
project = Project.visible.find_by_identifier(project_identifier)
|
||||||
|
end
|
||||||
if esc.nil?
|
if esc.nil?
|
||||||
if prefix.nil? && sep == 'r'
|
if prefix.nil? && sep == 'r'
|
||||||
if project && (changeset = project.changesets.find_by_revision(identifier))
|
# project.changesets.visible raises an SQL error because of a double join on repositories
|
||||||
link = link_to("r#{identifier}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
|
if project && project.repository && (changeset = Changeset.visible.find_by_repository_id_and_revision(project.repository.id, identifier))
|
||||||
|
link = link_to("#{project_prefix}r#{identifier}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
|
||||||
:class => 'changeset',
|
:class => 'changeset',
|
||||||
:title => truncate_single_line(changeset.comments, :length => 100))
|
:title => truncate_single_line(changeset.comments, :length => 100))
|
||||||
end
|
end
|
||||||
@@ -571,29 +632,22 @@ module ApplicationHelper
|
|||||||
:title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
|
:title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
|
||||||
end
|
end
|
||||||
when 'document'
|
when 'document'
|
||||||
if document = Document.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current))
|
if document = Document.visible.find_by_id(oid)
|
||||||
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
||||||
:class => 'document'
|
:class => 'document'
|
||||||
end
|
end
|
||||||
when 'version'
|
when 'version'
|
||||||
if version = Version.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current))
|
if version = Version.visible.find_by_id(oid)
|
||||||
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
||||||
:class => 'version'
|
:class => 'version'
|
||||||
end
|
end
|
||||||
when 'message'
|
when 'message'
|
||||||
if message = Message.find_by_id(oid, :include => [:parent, {:board => :project}], :conditions => Project.visible_by(User.current))
|
if message = Message.visible.find_by_id(oid, :include => :parent)
|
||||||
link = link_to h(truncate(message.subject, :length => 60)), {:only_path => only_path,
|
link = link_to_message(message, {:only_path => only_path}, :class => 'message')
|
||||||
:controller => 'messages',
|
|
||||||
:action => 'show',
|
|
||||||
:board_id => message.board,
|
|
||||||
:id => message.root,
|
|
||||||
:anchor => (message.parent ? "message-#{message.id}" : nil)},
|
|
||||||
:class => 'message'
|
|
||||||
end
|
end
|
||||||
when 'project'
|
when 'project'
|
||||||
if p = Project.visible.find_by_id(oid)
|
if p = Project.visible.find_by_id(oid)
|
||||||
link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p},
|
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
||||||
:class => 'project'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif sep == ':'
|
elsif sep == ':'
|
||||||
@@ -601,26 +655,26 @@ module ApplicationHelper
|
|||||||
name = identifier.gsub(%r{^"(.*)"$}, "\\1")
|
name = identifier.gsub(%r{^"(.*)"$}, "\\1")
|
||||||
case prefix
|
case prefix
|
||||||
when 'document'
|
when 'document'
|
||||||
if project && document = project.documents.find_by_title(name)
|
if project && document = project.documents.visible.find_by_title(name)
|
||||||
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
|
||||||
:class => 'document'
|
:class => 'document'
|
||||||
end
|
end
|
||||||
when 'version'
|
when 'version'
|
||||||
if project && version = project.versions.find_by_name(name)
|
if project && version = project.versions.visible.find_by_name(name)
|
||||||
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
||||||
:class => 'version'
|
:class => 'version'
|
||||||
end
|
end
|
||||||
when 'commit'
|
when 'commit'
|
||||||
if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"]))
|
if project && project.repository && (changeset = Changeset.visible.find(:first, :conditions => ["repository_id = ? AND scmid LIKE ?", project.repository.id, "#{name}%"]))
|
||||||
link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
|
link = link_to h("#{project_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.identifier},
|
||||||
:class => 'changeset',
|
:class => 'changeset',
|
||||||
:title => truncate_single_line(changeset.comments, :length => 100)
|
:title => truncate_single_line(changeset.comments, :length => 100)
|
||||||
end
|
end
|
||||||
when 'source', 'export'
|
when 'source', 'export'
|
||||||
if project && project.repository
|
if project && project.repository && User.current.allowed_to?(:browse_repository, project)
|
||||||
name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$}
|
name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$}
|
||||||
path, rev, anchor = $1, $3, $5
|
path, rev, anchor = $1, $3, $5
|
||||||
link = link_to h("#{prefix}:#{name}"), {:controller => 'repositories', :action => 'entry', :id => project,
|
link = link_to h("#{project_prefix}#{prefix}:#{name}"), {:controller => 'repositories', :action => 'entry', :id => project,
|
||||||
:path => to_path_param(path),
|
:path => to_path_param(path),
|
||||||
:rev => rev,
|
:rev => rev,
|
||||||
:anchor => anchor,
|
:anchor => anchor,
|
||||||
@@ -635,13 +689,61 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
when 'project'
|
when 'project'
|
||||||
if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
|
if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
|
||||||
link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p},
|
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
||||||
:class => 'project'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
leading + (link || "#{prefix}#{sep}#{identifier}")
|
leading + (link || "#{project_prefix}#{prefix}#{sep}#{identifier}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
HEADING_RE = /<h(1|2|3|4)( [^>]+)?>(.+?)<\/h(1|2|3|4)>/i unless const_defined?(:HEADING_RE)
|
||||||
|
|
||||||
|
# Headings and TOC
|
||||||
|
# Adds ids and links to headings unless options[:headings] is set to false
|
||||||
|
def parse_headings(text, project, obj, attr, only_path, options)
|
||||||
|
return if options[:headings] == false
|
||||||
|
|
||||||
|
text.gsub!(HEADING_RE) do
|
||||||
|
level, attrs, content = $1.to_i, $2, $3
|
||||||
|
item = strip_tags(content).strip
|
||||||
|
anchor = sanitize_anchor_name(item)
|
||||||
|
@parsed_headings << [level, anchor, item]
|
||||||
|
"<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">¶</a></h#{level}>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
TOC_RE = /<p>\{\{([<>]?)toc\}\}<\/p>/i unless const_defined?(:TOC_RE)
|
||||||
|
|
||||||
|
# Renders the TOC with given headings
|
||||||
|
def replace_toc(text, headings)
|
||||||
|
text.gsub!(TOC_RE) do
|
||||||
|
if headings.empty?
|
||||||
|
''
|
||||||
|
else
|
||||||
|
div_class = 'toc'
|
||||||
|
div_class << ' right' if $1 == '>'
|
||||||
|
div_class << ' left' if $1 == '<'
|
||||||
|
out = "<ul class=\"#{div_class}\"><li>"
|
||||||
|
root = headings.map(&:first).min
|
||||||
|
current = root
|
||||||
|
started = false
|
||||||
|
headings.each do |level, anchor, item|
|
||||||
|
if level > current
|
||||||
|
out << '<ul><li>' * (level - current)
|
||||||
|
elsif level < current
|
||||||
|
out << "</li></ul>\n" * (current - level) + "</li><li>"
|
||||||
|
elsif started
|
||||||
|
out << '</li><li>'
|
||||||
|
end
|
||||||
|
out << "<a href=\"##{anchor}\">#{item}</a>"
|
||||||
|
current = level
|
||||||
|
started = true
|
||||||
|
end
|
||||||
|
out << '</li></ul>' * (current - root)
|
||||||
|
out << '</li></ul>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -696,19 +798,24 @@ module ApplicationHelper
|
|||||||
), :class => 'progress', :style => "width: #{width};") +
|
), :class => 'progress', :style => "width: #{width};") +
|
||||||
content_tag('p', legend, :class => 'pourcent')
|
content_tag('p', legend, :class => 'pourcent')
|
||||||
end
|
end
|
||||||
|
|
||||||
def checked_image(checked=true)
|
def checked_image(checked=true)
|
||||||
if checked
|
if checked
|
||||||
image_tag 'toggle_check.png'
|
image_tag 'toggle_check.png'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def context_menu(url)
|
def context_menu(url)
|
||||||
unless @context_menu_included
|
unless @context_menu_included
|
||||||
content_for :header_tags do
|
content_for :header_tags do
|
||||||
javascript_include_tag('context_menu') +
|
javascript_include_tag('context_menu') +
|
||||||
stylesheet_link_tag('context_menu')
|
stylesheet_link_tag('context_menu')
|
||||||
end
|
end
|
||||||
|
if l(:direction) == 'rtl'
|
||||||
|
content_for :header_tags do
|
||||||
|
stylesheet_link_tag('context_menu_rtl')
|
||||||
|
end
|
||||||
|
end
|
||||||
@context_menu_included = true
|
@context_menu_included = true
|
||||||
end
|
end
|
||||||
javascript_tag "new ContextMenu('#{ url_for(url) }')"
|
javascript_tag "new ContextMenu('#{ url_for(url) }')"
|
||||||
@@ -745,13 +852,15 @@ module ApplicationHelper
|
|||||||
'Calendar._FD = 1;' # Monday
|
'Calendar._FD = 1;' # Monday
|
||||||
when 7
|
when 7
|
||||||
'Calendar._FD = 0;' # Sunday
|
'Calendar._FD = 0;' # Sunday
|
||||||
|
when 6
|
||||||
|
'Calendar._FD = 6;' # Saturday
|
||||||
else
|
else
|
||||||
'' # use language
|
'' # use language
|
||||||
end
|
end
|
||||||
|
|
||||||
javascript_include_tag('calendar/calendar') +
|
javascript_include_tag('calendar/calendar') +
|
||||||
javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") +
|
javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") +
|
||||||
javascript_tag(start_of_week) +
|
javascript_tag(start_of_week) +
|
||||||
javascript_include_tag('calendar/calendar-setup') +
|
javascript_include_tag('calendar/calendar-setup') +
|
||||||
stylesheet_link_tag('calendar')
|
stylesheet_link_tag('calendar')
|
||||||
end
|
end
|
||||||
@@ -772,7 +881,7 @@ module ApplicationHelper
|
|||||||
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
|
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
|
||||||
def avatar(user, options = { })
|
def avatar(user, options = { })
|
||||||
if Setting.gravatar_enabled?
|
if Setting.gravatar_enabled?
|
||||||
options.merge!({:ssl => Setting.protocol == 'https', :default => Setting.gravatar_default})
|
options.merge!({:ssl => (defined?(request) && request.ssl?), :default => Setting.gravatar_default})
|
||||||
email = nil
|
email = nil
|
||||||
if user.respond_to?(:mail)
|
if user.respond_to?(:mail)
|
||||||
email = user.mail
|
email = user.mail
|
||||||
@@ -780,6 +889,51 @@ module ApplicationHelper
|
|||||||
email = $1
|
email = $1
|
||||||
end
|
end
|
||||||
return gravatar(email.to_s.downcase, options) unless email.blank? rescue nil
|
return gravatar(email.to_s.downcase, options) unless email.blank? rescue nil
|
||||||
|
else
|
||||||
|
''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def sanitize_anchor_name(anchor)
|
||||||
|
anchor.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns the javascript tags that are included in the html layout head
|
||||||
|
def javascript_heads
|
||||||
|
tags = javascript_include_tag(:defaults)
|
||||||
|
unless User.current.pref.warn_on_leaving_unsaved == '0'
|
||||||
|
tags << "\n" + javascript_tag("Event.observe(window, 'load', function(){ new WarnLeavingUnsaved('#{escape_javascript( l(:text_warn_on_leaving_unsaved) )}'); });")
|
||||||
|
end
|
||||||
|
tags
|
||||||
|
end
|
||||||
|
|
||||||
|
def favicon
|
||||||
|
"<link rel='shortcut icon' href='#{image_path('/favicon.ico')}' />"
|
||||||
|
end
|
||||||
|
|
||||||
|
def robot_exclusion_tag
|
||||||
|
'<meta name="robots" content="noindex,follow,noarchive" />'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns true if arg is expected in the API response
|
||||||
|
def include_in_api_response?(arg)
|
||||||
|
unless @included_in_api_response
|
||||||
|
param = params[:include]
|
||||||
|
@included_in_api_response = param.is_a?(Array) ? param.collect(&:to_s) : param.to_s.split(',')
|
||||||
|
@included_in_api_response.collect!(&:strip)
|
||||||
|
end
|
||||||
|
@included_in_api_response.include?(arg.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns options or nil if nometa param or X-Redmine-Nometa header
|
||||||
|
# was set in the request
|
||||||
|
def api_meta(options)
|
||||||
|
if params[:nometa].present? || request.headers['X-Redmine-Nometa']
|
||||||
|
# compatibility mode for activeresource clients that raise
|
||||||
|
# an error when unserializing an array with attributes
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -790,12 +944,8 @@ module ApplicationHelper
|
|||||||
extend helper
|
extend helper
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_remote_content_update(text, url_params)
|
def link_to_content_update(text, url_params = {}, html_options = {})
|
||||||
link_to_remote(text,
|
link_to(text, url_params, html_options)
|
||||||
{:url => url_params, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'},
|
|
||||||
{:href => url_for(:params => url_params)}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -21,14 +21,26 @@ module AttachmentsHelper
|
|||||||
# :author -- author names are not displayed if set to false
|
# :author -- author names are not displayed if set to false
|
||||||
def link_to_attachments(container, options = {})
|
def link_to_attachments(container, options = {})
|
||||||
options.assert_valid_keys(:author)
|
options.assert_valid_keys(:author)
|
||||||
|
|
||||||
if container.attachments.any?
|
if container.attachments.any?
|
||||||
options = {:deletable => container.attachments_deletable?, :author => true}.merge(options)
|
options = {:deletable => container.attachments_deletable?, :author => true}.merge(options)
|
||||||
render :partial => 'attachments/links', :locals => {:attachments => container.attachments, :options => options}
|
render :partial => 'attachments/links', :locals => {:attachments => container.attachments, :options => options}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_utf8(str)
|
def to_utf8(str)
|
||||||
str
|
if str.respond_to?(:force_encoding)
|
||||||
|
str.force_encoding('UTF-8')
|
||||||
|
return str if str.valid_encoding?
|
||||||
|
else
|
||||||
|
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3]
|
||||||
|
rescue Iconv::InvalidEncoding
|
||||||
|
# "UTF-8//IGNORE" is not supported on some OS
|
||||||
|
str
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
module CalendarsHelper
|
||||||
|
def link_to_previous_month(year, month, options={})
|
||||||
|
target_year, target_month = if month == 1
|
||||||
|
[year - 1, 12]
|
||||||
|
else
|
||||||
|
[year, month - 1]
|
||||||
|
end
|
||||||
|
|
||||||
|
name = if target_month == 12
|
||||||
|
"#{month_name(target_month)} #{target_year}"
|
||||||
|
else
|
||||||
|
"#{month_name(target_month)}"
|
||||||
|
end
|
||||||
|
|
||||||
|
link_to_month(('« ' + name), target_year, target_month, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def link_to_next_month(year, month, options={})
|
||||||
|
target_year, target_month = if month == 12
|
||||||
|
[year + 1, 1]
|
||||||
|
else
|
||||||
|
[year, month + 1]
|
||||||
|
end
|
||||||
|
|
||||||
|
name = if target_month == 1
|
||||||
|
"#{month_name(target_month)} #{target_year}"
|
||||||
|
else
|
||||||
|
"#{month_name(target_month)}"
|
||||||
|
end
|
||||||
|
|
||||||
|
link_to_month((name + ' »'), target_year, target_month, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def link_to_month(link_name, year, month, options={})
|
||||||
|
link_to_content_update(link_name, params.merge(:year => year, :month => month))
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -37,7 +37,7 @@ module CustomFieldsHelper
|
|||||||
field_id = "#{name}_custom_field_values_#{custom_field.id}"
|
field_id = "#{name}_custom_field_values_#{custom_field.id}"
|
||||||
|
|
||||||
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
|
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
|
||||||
case field_format.edit_as
|
case field_format.try(:edit_as)
|
||||||
when "date"
|
when "date"
|
||||||
text_field_tag(field_name, custom_value.value, :id => field_id, :size => 10) +
|
text_field_tag(field_name, custom_value.value, :id => field_id, :size => 10) +
|
||||||
calendar_for(field_id)
|
calendar_for(field_id)
|
||||||
@@ -49,7 +49,7 @@ module CustomFieldsHelper
|
|||||||
blank_option = custom_field.is_required? ?
|
blank_option = custom_field.is_required? ?
|
||||||
(custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') :
|
(custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') :
|
||||||
'<option></option>'
|
'<option></option>'
|
||||||
select_tag(field_name, blank_option + options_for_select(custom_field.possible_values, custom_value.value), :id => field_id)
|
select_tag(field_name, blank_option + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value), :id => field_id)
|
||||||
else
|
else
|
||||||
text_field_tag(field_name, custom_value.value, :id => field_id)
|
text_field_tag(field_name, custom_value.value, :id => field_id)
|
||||||
end
|
end
|
||||||
@@ -68,11 +68,11 @@ module CustomFieldsHelper
|
|||||||
custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value)
|
custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_field_tag_for_bulk_edit(name, custom_field)
|
def custom_field_tag_for_bulk_edit(name, custom_field, projects=nil)
|
||||||
field_name = "#{name}[custom_field_values][#{custom_field.id}]"
|
field_name = "#{name}[custom_field_values][#{custom_field.id}]"
|
||||||
field_id = "#{name}_custom_field_values_#{custom_field.id}"
|
field_id = "#{name}_custom_field_values_#{custom_field.id}"
|
||||||
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
|
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
|
||||||
case field_format.edit_as
|
case field_format.try(:edit_as)
|
||||||
when "date"
|
when "date"
|
||||||
text_field_tag(field_name, '', :id => field_id, :size => 10) +
|
text_field_tag(field_name, '', :id => field_id, :size => 10) +
|
||||||
calendar_for(field_id)
|
calendar_for(field_id)
|
||||||
@@ -83,7 +83,7 @@ module CustomFieldsHelper
|
|||||||
[l(:general_text_yes), '1'],
|
[l(:general_text_yes), '1'],
|
||||||
[l(:general_text_no), '0']]), :id => field_id)
|
[l(:general_text_no), '0']]), :id => field_id)
|
||||||
when "list"
|
when "list"
|
||||||
select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values), :id => field_id)
|
select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values_options(projects)), :id => field_id)
|
||||||
else
|
else
|
||||||
text_field_tag(field_name, '', :id => field_id)
|
text_field_tag(field_name, '', :id => field_id)
|
||||||
end
|
end
|
||||||
@@ -101,7 +101,18 @@ module CustomFieldsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Return an array of custom field formats which can be used in select_tag
|
# Return an array of custom field formats which can be used in select_tag
|
||||||
def custom_field_formats_for_select
|
def custom_field_formats_for_select(custom_field)
|
||||||
Redmine::CustomFieldFormat.as_select
|
Redmine::CustomFieldFormat.as_select(custom_field.class.customized_class.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Renders the custom_values in api views
|
||||||
|
def render_api_custom_values(custom_values, api)
|
||||||
|
api.array :custom_fields do
|
||||||
|
custom_values.each do |custom_value|
|
||||||
|
api.custom_field :id => custom_value.custom_field_id, :name => custom_value.custom_field.name do
|
||||||
|
api.value custom_value.value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end unless custom_values.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
module GanttHelper
|
||||||
|
|
||||||
|
def gantt_zoom_link(gantt, in_or_out)
|
||||||
|
case in_or_out
|
||||||
|
when :in
|
||||||
|
if gantt.zoom < 4
|
||||||
|
link_to_content_update l(:text_zoom_in),
|
||||||
|
params.merge(gantt.params.merge(:zoom => (gantt.zoom+1))),
|
||||||
|
:class => 'icon icon-zoom-in'
|
||||||
|
else
|
||||||
|
content_tag('span', l(:text_zoom_in), :class => 'icon icon-zoom-in')
|
||||||
|
end
|
||||||
|
|
||||||
|
when :out
|
||||||
|
if gantt.zoom > 1
|
||||||
|
link_to_content_update l(:text_zoom_out),
|
||||||
|
params.merge(gantt.params.merge(:zoom => (gantt.zoom-1))),
|
||||||
|
:class => 'icon icon-zoom-out'
|
||||||
|
else
|
||||||
|
content_tag('span', l(:text_zoom_out), :class => 'icon icon-zoom-out')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
module IssueMovesHelper
|
||||||
|
end
|
||||||
+112
-51
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -28,33 +28,56 @@ module IssuesHelper
|
|||||||
ancestors << issue unless issue.leaf?
|
ancestors << issue unless issue.leaf?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Renders a HTML/CSS tooltip
|
||||||
|
#
|
||||||
|
# To use, a trigger div is needed. This is a div with the class of "tooltip"
|
||||||
|
# that contains this method wrapped in a span with the class of "tip"
|
||||||
|
#
|
||||||
|
# <div class="tooltip"><%= link_to_issue(issue) %>
|
||||||
|
# <span class="tip"><%= render_issue_tooltip(issue) %></span>
|
||||||
|
# </div>
|
||||||
|
#
|
||||||
def render_issue_tooltip(issue)
|
def render_issue_tooltip(issue)
|
||||||
|
@cached_label_status ||= l(:field_status)
|
||||||
@cached_label_start_date ||= l(:field_start_date)
|
@cached_label_start_date ||= l(:field_start_date)
|
||||||
@cached_label_due_date ||= l(:field_due_date)
|
@cached_label_due_date ||= l(:field_due_date)
|
||||||
@cached_label_assigned_to ||= l(:field_assigned_to)
|
@cached_label_assigned_to ||= l(:field_assigned_to)
|
||||||
@cached_label_priority ||= l(:field_priority)
|
@cached_label_priority ||= l(:field_priority)
|
||||||
|
@cached_label_project ||= l(:field_project)
|
||||||
|
|
||||||
link_to_issue(issue) + "<br /><br />" +
|
link_to_issue(issue) + "<br /><br />" +
|
||||||
|
"<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />" +
|
||||||
|
"<strong>#{@cached_label_status}</strong>: #{issue.status.name}<br />" +
|
||||||
"<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
|
"<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
|
||||||
"<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
|
"<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
|
||||||
"<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
|
"<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
|
||||||
"<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}"
|
"<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def issue_heading(issue)
|
||||||
|
h("#{issue.tracker} ##{issue.id}")
|
||||||
|
end
|
||||||
|
|
||||||
def render_issue_subject_with_tree(issue)
|
def render_issue_subject_with_tree(issue)
|
||||||
s = ''
|
s = ''
|
||||||
issue.ancestors.each do |ancestor|
|
ancestors = issue.root? ? [] : issue.ancestors.visible.all
|
||||||
|
ancestors.each do |ancestor|
|
||||||
s << '<div>' + content_tag('p', link_to_issue(ancestor))
|
s << '<div>' + content_tag('p', link_to_issue(ancestor))
|
||||||
end
|
end
|
||||||
s << '<div>' + content_tag('h3', h(issue.subject))
|
s << '<div>'
|
||||||
s << '</div>' * (issue.ancestors.size + 1)
|
subject = h(issue.subject)
|
||||||
|
if issue.is_private?
|
||||||
|
subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
|
||||||
|
end
|
||||||
|
s << content_tag('h3', subject)
|
||||||
|
s << '</div>' * (ancestors.size + 1)
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_descendants_tree(issue)
|
def render_descendants_tree(issue)
|
||||||
s = '<form><table class="list issues">'
|
s = '<form><table class="list issues">'
|
||||||
issue_list(issue.descendants.sort_by(&:lft)) do |child, level|
|
issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
|
||||||
s << content_tag('tr',
|
s << content_tag('tr',
|
||||||
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
|
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
|
||||||
content_tag('td', link_to_issue(child, :truncate => 60), :class => 'subject') +
|
content_tag('td', link_to_issue(child, :truncate => 60), :class => 'subject') +
|
||||||
@@ -66,7 +89,7 @@ module IssuesHelper
|
|||||||
s << '</form></table>'
|
s << '</form></table>'
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_custom_fields_rows(issue)
|
def render_custom_fields_rows(issue)
|
||||||
return if issue.custom_field_values.empty?
|
return if issue.custom_field_values.empty?
|
||||||
ordered_values = []
|
ordered_values = []
|
||||||
@@ -85,21 +108,58 @@ module IssuesHelper
|
|||||||
s << "</tr>\n"
|
s << "</tr>\n"
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def issues_destroy_confirmation_message(issues)
|
||||||
|
issues = [issues] unless issues.is_a?(Array)
|
||||||
|
message = l(:text_issues_destroy_confirmation)
|
||||||
|
descendant_count = issues.inject(0) {|memo, i| memo += (i.right - i.left - 1)/2}
|
||||||
|
if descendant_count > 0
|
||||||
|
issues.each do |issue|
|
||||||
|
next if issue.root?
|
||||||
|
issues.each do |other_issue|
|
||||||
|
descendant_count -= 1 if issue.is_descendant_of?(other_issue)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if descendant_count > 0
|
||||||
|
message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
message
|
||||||
|
end
|
||||||
|
|
||||||
def sidebar_queries
|
def sidebar_queries
|
||||||
unless @sidebar_queries
|
unless @sidebar_queries
|
||||||
# User can see public queries and his own queries
|
# User can see public queries and his own queries
|
||||||
visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
|
visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
|
||||||
# Project specific queries and global queries
|
# Project specific queries and global queries
|
||||||
visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
|
visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
|
||||||
@sidebar_queries = Query.find(:all,
|
@sidebar_queries = Query.find(:all,
|
||||||
:select => 'id, name',
|
:select => 'id, name, is_public',
|
||||||
:order => "name ASC",
|
:order => "name ASC",
|
||||||
:conditions => visible.conditions)
|
:conditions => visible.conditions)
|
||||||
end
|
end
|
||||||
@sidebar_queries
|
@sidebar_queries
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def query_links(title, queries)
|
||||||
|
# links to #index on issues/show
|
||||||
|
url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
|
||||||
|
|
||||||
|
content_tag('h3', title) +
|
||||||
|
queries.collect {|query|
|
||||||
|
link_to(h(query.name), url_params.merge(:query_id => query))
|
||||||
|
}.join('<br />')
|
||||||
|
end
|
||||||
|
|
||||||
|
def render_sidebar_queries
|
||||||
|
out = ''
|
||||||
|
queries = sidebar_queries.select {|q| !q.is_public?}
|
||||||
|
out << query_links(l(:label_my_queries), queries) if queries.any?
|
||||||
|
queries = sidebar_queries.select {|q| q.is_public?}
|
||||||
|
out << query_links(l(:label_query_plural), queries) if queries.any?
|
||||||
|
out
|
||||||
|
end
|
||||||
|
|
||||||
def show_detail(detail, no_html=false)
|
def show_detail(detail, no_html=false)
|
||||||
case detail.property
|
case detail.property
|
||||||
when 'attr'
|
when 'attr'
|
||||||
@@ -122,6 +182,10 @@ module IssuesHelper
|
|||||||
label = l(:field_parent_issue)
|
label = l(:field_parent_issue)
|
||||||
value = "##{detail.value}" unless detail.value.blank?
|
value = "##{detail.value}" unless detail.value.blank?
|
||||||
old_value = "##{detail.old_value}" unless detail.old_value.blank?
|
old_value = "##{detail.old_value}" unless detail.old_value.blank?
|
||||||
|
|
||||||
|
when detail.prop_key == 'is_private'
|
||||||
|
value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
|
||||||
|
old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
|
||||||
end
|
end
|
||||||
when 'cf'
|
when 'cf'
|
||||||
custom_field = CustomField.find_by_id(detail.prop_key)
|
custom_field = CustomField.find_by_id(detail.prop_key)
|
||||||
@@ -138,7 +202,7 @@ module IssuesHelper
|
|||||||
label ||= detail.prop_key
|
label ||= detail.prop_key
|
||||||
value ||= detail.value
|
value ||= detail.value
|
||||||
old_value ||= detail.old_value
|
old_value ||= detail.old_value
|
||||||
|
|
||||||
unless no_html
|
unless no_html
|
||||||
label = content_tag('strong', label)
|
label = content_tag('strong', label)
|
||||||
old_value = content_tag("i", h(old_value)) if detail.old_value
|
old_value = content_tag("i", h(old_value)) if detail.old_value
|
||||||
@@ -150,8 +214,17 @@ module IssuesHelper
|
|||||||
value = content_tag("i", h(value)) if value
|
value = content_tag("i", h(value)) if value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !detail.value.blank?
|
if detail.property == 'attr' && detail.prop_key == 'description'
|
||||||
|
s = l(:text_journal_changed_no_detail, :label => label)
|
||||||
|
unless no_html
|
||||||
|
diff_link = link_to 'diff',
|
||||||
|
{:controller => 'journals', :action => 'diff', :id => detail.journal_id, :detail_id => detail.id},
|
||||||
|
:title => l(:label_view_diff)
|
||||||
|
s << " (#{ diff_link })"
|
||||||
|
end
|
||||||
|
s
|
||||||
|
elsif !detail.value.blank?
|
||||||
case detail.property
|
case detail.property
|
||||||
when 'attr', 'cf'
|
when 'attr', 'cf'
|
||||||
if !detail.old_value.blank?
|
if !detail.old_value.blank?
|
||||||
@@ -175,14 +248,28 @@ module IssuesHelper
|
|||||||
return record.name if record
|
return record.name if record
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Renders issue children recursively
|
||||||
|
def render_api_issue_children(issue, api)
|
||||||
|
return if issue.leaf?
|
||||||
|
api.array :children do
|
||||||
|
issue.children.each do |child|
|
||||||
|
api.issue(:id => child.id) do
|
||||||
|
api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
|
||||||
|
api.subject child.subject
|
||||||
|
render_api_issue_children(child, api)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def issues_to_csv(issues, project = nil)
|
def issues_to_csv(issues, project = nil)
|
||||||
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||||
decimal_separator = l(:general_csv_decimal_separator)
|
decimal_separator = l(:general_csv_decimal_separator)
|
||||||
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
|
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
|
||||||
# csv header fields
|
# csv header fields
|
||||||
headers = [ "#",
|
headers = [ "#",
|
||||||
l(:field_status),
|
l(:field_status),
|
||||||
l(:field_project),
|
l(:field_project),
|
||||||
l(:field_tracker),
|
l(:field_tracker),
|
||||||
l(:field_priority),
|
l(:field_priority),
|
||||||
@@ -209,9 +296,9 @@ module IssuesHelper
|
|||||||
# csv lines
|
# csv lines
|
||||||
issues.each do |issue|
|
issues.each do |issue|
|
||||||
fields = [issue.id,
|
fields = [issue.id,
|
||||||
issue.status.name,
|
issue.status.name,
|
||||||
issue.project.name,
|
issue.project.name,
|
||||||
issue.tracker.name,
|
issue.tracker.name,
|
||||||
issue.priority.name,
|
issue.priority.name,
|
||||||
issue.subject,
|
issue.subject,
|
||||||
issue.assigned_to,
|
issue.assigned_to,
|
||||||
@@ -223,7 +310,7 @@ module IssuesHelper
|
|||||||
issue.done_ratio,
|
issue.done_ratio,
|
||||||
issue.estimated_hours.to_s.gsub('.', decimal_separator),
|
issue.estimated_hours.to_s.gsub('.', decimal_separator),
|
||||||
issue.parent_id,
|
issue.parent_id,
|
||||||
format_time(issue.created_on),
|
format_time(issue.created_on),
|
||||||
format_time(issue.updated_on)
|
format_time(issue.updated_on)
|
||||||
]
|
]
|
||||||
custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }
|
custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }
|
||||||
@@ -233,30 +320,4 @@ module IssuesHelper
|
|||||||
end
|
end
|
||||||
export
|
export
|
||||||
end
|
end
|
||||||
|
|
||||||
def gantt_zoom_link(gantt, in_or_out)
|
|
||||||
img_attributes = {:style => 'height:1.4em; width:1.4em; margin-left: 3px;'} # em for accessibility
|
|
||||||
|
|
||||||
case in_or_out
|
|
||||||
when :in
|
|
||||||
if gantt.zoom < 4
|
|
||||||
link_to_remote(l(:text_zoom_in) + image_tag('zoom_in.png', img_attributes.merge(:alt => l(:text_zoom_in))),
|
|
||||||
{:url => gantt.params.merge(:zoom => (gantt.zoom+1)), :update => 'content'},
|
|
||||||
{:href => url_for(gantt.params.merge(:zoom => (gantt.zoom+1)))})
|
|
||||||
else
|
|
||||||
l(:text_zoom_in) +
|
|
||||||
image_tag('zoom_in_g.png', img_attributes.merge(:alt => l(:text_zoom_in)))
|
|
||||||
end
|
|
||||||
|
|
||||||
when :out
|
|
||||||
if gantt.zoom > 1
|
|
||||||
link_to_remote(l(:text_zoom_out) + image_tag('zoom_out.png', img_attributes.merge(:alt => l(:text_zoom_out))),
|
|
||||||
{:url => gantt.params.merge(:zoom => (gantt.zoom-1)), :update => 'content'},
|
|
||||||
{:href => url_for(gantt.params.merge(:zoom => (gantt.zoom-1)))})
|
|
||||||
else
|
|
||||||
l(:text_zoom_out) +
|
|
||||||
image_tag('zoom_out_g.png', img_attributes.merge(:alt => l(:text_zoom_out)))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ module JournalsHelper
|
|||||||
links = []
|
links = []
|
||||||
if !journal.notes.blank?
|
if !journal.notes.blank?
|
||||||
links << link_to_remote(image_tag('comment.png'),
|
links << link_to_remote(image_tag('comment.png'),
|
||||||
{ :url => {:controller => 'issues', :action => 'reply', :id => issue, :journal_id => journal} },
|
{ :url => {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal} },
|
||||||
:title => l(:button_quote)) if options[:reply_links]
|
:title => l(:button_quote)) if options[:reply_links]
|
||||||
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
|
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
|
||||||
{ :controller => 'journals', :action => 'edit', :id => journal },
|
{ :controller => 'journals', :action => 'edit', :id => journal },
|
||||||
|
|||||||
@@ -16,14 +16,4 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
module MessagesHelper
|
module MessagesHelper
|
||||||
|
|
||||||
def link_to_message(message)
|
|
||||||
return '' unless message
|
|
||||||
link_to h(truncate(message.subject, :length => 60)), :controller => 'messages',
|
|
||||||
:action => 'show',
|
|
||||||
:board_id => message.board_id,
|
|
||||||
:id => message.root,
|
|
||||||
:r => (message.parent_id && message.id),
|
|
||||||
:anchor => (message.parent_id ? "message-#{message.id}" : nil)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -20,7 +20,7 @@ module ProjectsHelper
|
|||||||
return '' unless version && version.is_a?(Version)
|
return '' unless version && version.is_a?(Version)
|
||||||
link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options
|
link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_settings_tabs
|
def project_settings_tabs
|
||||||
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
|
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
|
||||||
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
|
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
|
||||||
@@ -32,9 +32,9 @@ module ProjectsHelper
|
|||||||
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
|
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
|
||||||
{:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}
|
{:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}
|
||||||
]
|
]
|
||||||
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
|
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def parent_project_select_tag(project)
|
def parent_project_select_tag(project)
|
||||||
selected = project.parent
|
selected = project.parent
|
||||||
# retrieve the requested parent project
|
# retrieve the requested parent project
|
||||||
@@ -42,13 +42,13 @@ module ProjectsHelper
|
|||||||
if parent_id
|
if parent_id
|
||||||
selected = (parent_id.blank? ? nil : Project.find(parent_id))
|
selected = (parent_id.blank? ? nil : Project.find(parent_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
options = ''
|
options = ''
|
||||||
options << "<option value=''></option>" if project.allowed_parents.include?(nil)
|
options << "<option value=''></option>" if project.allowed_parents.include?(nil)
|
||||||
options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
|
options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
|
||||||
content_tag('select', options, :name => 'project[parent_id]', :id => 'project_parent_id')
|
content_tag('select', options, :name => 'project[parent_id]', :id => 'project_parent_id')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders a tree of projects as a nested set of unordered lists
|
# Renders a tree of projects as a nested set of unordered lists
|
||||||
# The given collection may be a subset of the whole project tree
|
# The given collection may be a subset of the whole project tree
|
||||||
# (eg. some intermediate nodes are private and can not be seen)
|
# (eg. some intermediate nodes are private and can not be seen)
|
||||||
@@ -65,14 +65,14 @@ module ProjectsHelper
|
|||||||
else
|
else
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
s << "</li>"
|
s << "</li>"
|
||||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
s << "</ul></li>\n"
|
s << "</ul></li>\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
classes = (ancestors.empty? ? 'root' : 'child')
|
classes = (ancestors.empty? ? 'root' : 'child')
|
||||||
s << "<li class='#{classes}'><div class='#{classes}'>" +
|
s << "<li class='#{classes}'><div class='#{classes}'>" +
|
||||||
link_to(h(project), {:controller => 'projects', :action => 'show', :id => project}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
|
link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
|
||||||
s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank?
|
s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank?
|
||||||
s << "</div>\n"
|
s << "</div>\n"
|
||||||
ancestors << project
|
ancestors << project
|
||||||
@@ -93,7 +93,7 @@ module ProjectsHelper
|
|||||||
if selected && !versions.include?(selected)
|
if selected && !versions.include?(selected)
|
||||||
grouped[selected.project.name] << [selected.name, selected.id]
|
grouped[selected.project.name] << [selected.name, selected.id]
|
||||||
end
|
end
|
||||||
|
|
||||||
if grouped.keys.size > 1
|
if grouped.keys.size > 1
|
||||||
grouped_options_for_select(grouped, selected && selected.id)
|
grouped_options_for_select(grouped, selected && selected.id)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -50,7 +50,7 @@ module QueriesHelper
|
|||||||
when 'User'
|
when 'User'
|
||||||
link_to_user value
|
link_to_user value
|
||||||
when 'Project'
|
when 'Project'
|
||||||
link_to(h(value), :controller => 'projects', :action => 'show', :id => value)
|
link_to_project value
|
||||||
when 'Version'
|
when 'Version'
|
||||||
link_to(h(value), :controller => 'versions', :action => 'show', :id => value)
|
link_to(h(value), :controller => 'versions', :action => 'show', :id => value)
|
||||||
when 'TrueClass'
|
when 'TrueClass'
|
||||||
@@ -70,6 +70,7 @@ module QueriesHelper
|
|||||||
cond = "project_id IS NULL"
|
cond = "project_id IS NULL"
|
||||||
cond << " OR project_id = #{@project.id}" if @project
|
cond << " OR project_id = #{@project.id}" if @project
|
||||||
@query = Query.find(params[:query_id], :conditions => cond)
|
@query = Query.find(params[:query_id], :conditions => cond)
|
||||||
|
raise ::Unauthorized unless @query.visible?
|
||||||
@query.project = @project
|
@query.project = @project
|
||||||
session[:query] = {:id => @query.id, :project_id => @query.project_id}
|
session[:query] = {:id => @query.id, :project_id => @query.project_id}
|
||||||
sort_clear
|
sort_clear
|
||||||
@@ -78,17 +79,16 @@ module QueriesHelper
|
|||||||
# Give it a name, required to be valid
|
# Give it a name, required to be valid
|
||||||
@query = Query.new(:name => "_")
|
@query = Query.new(:name => "_")
|
||||||
@query.project = @project
|
@query.project = @project
|
||||||
if params[:fields] and params[:fields].is_a? Array
|
if params[:fields] || params[:f]
|
||||||
params[:fields].each do |field|
|
@query.filters = {}
|
||||||
@query.add_filter(field, params[:operators][field], params[:values][field])
|
@query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v])
|
||||||
end
|
|
||||||
else
|
else
|
||||||
@query.available_filters.keys.each do |field|
|
@query.available_filters.keys.each do |field|
|
||||||
@query.add_short_filter(field, params[field]) if params[field]
|
@query.add_short_filter(field, params[field]) if params[field]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@query.group_by = params[:group_by]
|
@query.group_by = params[:group_by]
|
||||||
@query.column_names = params[:query] && params[:query][:column_names]
|
@query.column_names = params[:c] || (params[:query] && params[:query][:column_names])
|
||||||
session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
|
session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
|
||||||
else
|
else
|
||||||
@query = Query.find_by_id(session[:query][:id]) if session[:query][:id]
|
@query = Query.find_by_id(session[:query][:id]) if session[:query][:id]
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
module ReportsHelper
|
module ReportsHelper
|
||||||
|
|
||||||
def aggregate(data, criteria)
|
def aggregate(data, criteria)
|
||||||
a = 0
|
a = 0
|
||||||
data.each { |row|
|
data.each { |row|
|
||||||
@@ -28,9 +28,9 @@ module ReportsHelper
|
|||||||
} unless data.nil?
|
} unless data.nil?
|
||||||
a
|
a
|
||||||
end
|
end
|
||||||
|
|
||||||
def aggregate_link(data, criteria, *args)
|
def aggregate_link(data, criteria, *args)
|
||||||
a = aggregate data, criteria
|
a = aggregate data, criteria
|
||||||
a > 0 ? link_to(a, *args) : '-'
|
a > 0 ? link_to(a, *args) : '-'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,33 +1,38 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require 'iconv'
|
require 'iconv'
|
||||||
|
require 'redmine/codeset_util'
|
||||||
|
|
||||||
module RepositoriesHelper
|
module RepositoriesHelper
|
||||||
def format_revision(txt)
|
def format_revision(revision)
|
||||||
txt.to_s[0,8]
|
if revision.respond_to? :format_identifier
|
||||||
|
revision.format_identifier
|
||||||
|
else
|
||||||
|
revision.to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncate_at_line_break(text, length = 255)
|
def truncate_at_line_break(text, length = 255)
|
||||||
if text
|
if text
|
||||||
text.gsub(%r{^(.{#{length}}[^\n]*)\n.+$}m, '\\1...')
|
text.gsub(%r{^(.{#{length}}[^\n]*)\n.+$}m, '\\1...')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_properties(properties)
|
def render_properties(properties)
|
||||||
unless properties.nil? || properties.empty?
|
unless properties.nil? || properties.empty?
|
||||||
content = ''
|
content = ''
|
||||||
@@ -37,14 +42,15 @@ module RepositoriesHelper
|
|||||||
content_tag('ul', content, :class => 'properties')
|
content_tag('ul', content, :class => 'properties')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_changeset_changes
|
def render_changeset_changes
|
||||||
changes = @changeset.changes.find(:all, :limit => 1000, :order => 'path').collect do |change|
|
changes = @changeset.changes.find(:all, :limit => 1000, :order => 'path').collect do |change|
|
||||||
case change.action
|
case change.action
|
||||||
when 'A'
|
when 'A'
|
||||||
# Detects moved/copied files
|
# Detects moved/copied files
|
||||||
if !change.from_path.blank?
|
if !change.from_path.blank?
|
||||||
change.action = @changeset.changes.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C'
|
change.action =
|
||||||
|
@changeset.changes.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C'
|
||||||
end
|
end
|
||||||
change
|
change
|
||||||
when 'D'
|
when 'D'
|
||||||
@@ -52,8 +58,8 @@ module RepositoriesHelper
|
|||||||
else
|
else
|
||||||
change
|
change
|
||||||
end
|
end
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
tree = { }
|
tree = { }
|
||||||
changes.each do |change|
|
changes.each do |change|
|
||||||
p = tree
|
p = tree
|
||||||
@@ -68,13 +74,11 @@ module RepositoriesHelper
|
|||||||
end
|
end
|
||||||
p[:c] = change
|
p[:c] = change
|
||||||
end
|
end
|
||||||
|
|
||||||
render_changes_tree(tree[:s])
|
render_changes_tree(tree[:s])
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_changes_tree(tree)
|
def render_changes_tree(tree)
|
||||||
return '' if tree.nil?
|
return '' if tree.nil?
|
||||||
|
|
||||||
output = ''
|
output = ''
|
||||||
output << '<ul>'
|
output << '<ul>'
|
||||||
tree.keys.sort.each do |file|
|
tree.keys.sort.each do |file|
|
||||||
@@ -87,7 +91,7 @@ module RepositoriesHelper
|
|||||||
:action => 'show',
|
:action => 'show',
|
||||||
:id => @project,
|
:id => @project,
|
||||||
:path => path_param,
|
:path => path_param,
|
||||||
:rev => @changeset.revision)
|
:rev => @changeset.identifier)
|
||||||
output << "<li class='#{style}'>#{text}</li>"
|
output << "<li class='#{style}'>#{text}</li>"
|
||||||
output << render_changes_tree(s)
|
output << render_changes_tree(s)
|
||||||
elsif c = tree[file][:c]
|
elsif c = tree[file][:c]
|
||||||
@@ -97,13 +101,13 @@ module RepositoriesHelper
|
|||||||
:action => 'entry',
|
:action => 'entry',
|
||||||
:id => @project,
|
:id => @project,
|
||||||
:path => path_param,
|
:path => path_param,
|
||||||
:rev => @changeset.revision) unless c.action == 'D'
|
:rev => @changeset.identifier) unless c.action == 'D'
|
||||||
text << " - #{c.revision}" unless c.revision.blank?
|
text << " - #{c.revision}" unless c.revision.blank?
|
||||||
text << ' (' + link_to('diff', :controller => 'repositories',
|
text << ' (' + link_to('diff', :controller => 'repositories',
|
||||||
:action => 'diff',
|
:action => 'diff',
|
||||||
:id => @project,
|
:id => @project,
|
||||||
:path => path_param,
|
:path => path_param,
|
||||||
:rev => @changeset.revision) + ') ' if c.action == 'M'
|
:rev => @changeset.identifier) + ') ' if c.action == 'M'
|
||||||
text << ' ' + content_tag('span', c.from_path, :class => 'copied-from') unless c.from_path.blank?
|
text << ' ' + content_tag('span', c.from_path, :class => 'copied-from') unless c.from_path.blank?
|
||||||
output << "<li class='#{style}'>#{text}</li>"
|
output << "<li class='#{style}'>#{text}</li>"
|
||||||
end
|
end
|
||||||
@@ -111,9 +115,26 @@ module RepositoriesHelper
|
|||||||
output << '</ul>'
|
output << '</ul>'
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_utf8(str)
|
def to_utf8(str)
|
||||||
|
return str if str.nil?
|
||||||
|
str = to_utf8_internal(str)
|
||||||
|
if str.respond_to?(:force_encoding)
|
||||||
|
str.force_encoding('UTF-8')
|
||||||
|
end
|
||||||
|
str
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_utf8_internal(str)
|
||||||
|
return str if str.nil?
|
||||||
|
if str.respond_to?(:force_encoding)
|
||||||
|
str.force_encoding('ASCII-8BIT')
|
||||||
|
end
|
||||||
|
return str if str.empty?
|
||||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
||||||
|
if str.respond_to?(:force_encoding)
|
||||||
|
str.force_encoding('UTF-8')
|
||||||
|
end
|
||||||
@encodings ||= Setting.repositories_encodings.split(',').collect(&:strip)
|
@encodings ||= Setting.repositories_encodings.split(',').collect(&:strip)
|
||||||
@encodings.each do |encoding|
|
@encodings.each do |encoding|
|
||||||
begin
|
begin
|
||||||
@@ -122,67 +143,142 @@ module RepositoriesHelper
|
|||||||
# do nothing here and try the next encoding
|
# do nothing here and try the next encoding
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
str
|
str = Redmine::CodesetUtil.replace_invalid_utf8(str)
|
||||||
end
|
end
|
||||||
|
private :to_utf8_internal
|
||||||
def repository_field_tags(form, repository)
|
|
||||||
|
def repository_field_tags(form, repository)
|
||||||
method = repository.class.name.demodulize.underscore + "_field_tags"
|
method = repository.class.name.demodulize.underscore + "_field_tags"
|
||||||
send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags'
|
if repository.is_a?(Repository) &&
|
||||||
|
respond_to?(method) && method != 'repository_field_tags'
|
||||||
|
send(method, form, repository)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def scm_select_tag(repository)
|
def scm_select_tag(repository)
|
||||||
scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']]
|
scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']]
|
||||||
Redmine::Scm::Base.all.each do |scm|
|
Redmine::Scm::Base.all.each do |scm|
|
||||||
scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm)
|
if Setting.enabled_scm.include?(scm) ||
|
||||||
|
(repository && repository.class.name.demodulize == scm)
|
||||||
|
scm_options << ["Repository::#{scm}".constantize.scm_name, scm]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
select_tag('repository_scm',
|
||||||
select_tag('repository_scm',
|
|
||||||
options_for_select(scm_options, repository.class.name.demodulize),
|
options_for_select(scm_options, repository.class.name.demodulize),
|
||||||
:disabled => (repository && !repository.new_record?),
|
:disabled => (repository && !repository.new_record?),
|
||||||
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")
|
:onchange => remote_function(
|
||||||
)
|
:url => {
|
||||||
|
:controller => 'repositories',
|
||||||
|
:action => 'edit',
|
||||||
|
:id => @project
|
||||||
|
},
|
||||||
|
:method => :get,
|
||||||
|
:with => "Form.serialize(this.form)")
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_leading_slash(path)
|
def with_leading_slash(path)
|
||||||
path.to_s.starts_with?('/') ? path : "/#{path}"
|
path.to_s.starts_with?('/') ? path : "/#{path}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def without_leading_slash(path)
|
def without_leading_slash(path)
|
||||||
path.gsub(%r{^/+}, '')
|
path.gsub(%r{^/+}, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def subversion_field_tags(form, repository)
|
def subversion_field_tags(form, repository)
|
||||||
content_tag('p', form.text_field(:url, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) +
|
content_tag('p', form.text_field(:url, :size => 60, :required => true,
|
||||||
|
:disabled => (repository && !repository.root_url.blank?)) +
|
||||||
'<br />(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
|
'<br />(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
|
||||||
content_tag('p', form.text_field(:login, :size => 30)) +
|
content_tag('p', form.text_field(:login, :size => 30)) +
|
||||||
content_tag('p', form.password_field(:password, :size => 30, :name => 'ignore',
|
content_tag('p', form.password_field(
|
||||||
:value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)),
|
:password, :size => 30, :name => 'ignore',
|
||||||
:onfocus => "this.value=''; this.name='repository[password]';",
|
:value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)),
|
||||||
:onchange => "this.name='repository[password]';"))
|
:onfocus => "this.value=''; this.name='repository[password]';",
|
||||||
|
:onchange => "this.name='repository[password]';"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def darcs_field_tags(form, repository)
|
def darcs_field_tags(form, repository)
|
||||||
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?)))
|
content_tag('p', form.text_field(
|
||||||
|
:url, :label => l(:field_path_to_repository),
|
||||||
|
:size => 60, :required => true,
|
||||||
|
:disabled => (repository && !repository.new_record?))) +
|
||||||
|
content_tag('p', form.select(
|
||||||
|
:log_encoding, [nil] + Setting::ENCODINGS,
|
||||||
|
:label => l(:field_commit_logs_encoding), :required => true))
|
||||||
end
|
end
|
||||||
|
|
||||||
def mercurial_field_tags(form, repository)
|
def mercurial_field_tags(form, repository)
|
||||||
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
|
content_tag('p', form.text_field(
|
||||||
|
:url, :label => l(:field_path_to_repository),
|
||||||
|
:size => 60, :required => true,
|
||||||
|
:disabled => (repository && !repository.root_url.blank?)
|
||||||
|
) +
|
||||||
|
'<br />' + l(:text_mercurial_repository_note)) +
|
||||||
|
content_tag('p', form.select(
|
||||||
|
:path_encoding, [nil] + Setting::ENCODINGS,
|
||||||
|
:label => l(:field_scm_path_encoding)
|
||||||
|
) +
|
||||||
|
'<br />' + l(:text_scm_path_encoding_note))
|
||||||
end
|
end
|
||||||
|
|
||||||
def git_field_tags(form, repository)
|
def git_field_tags(form, repository)
|
||||||
content_tag('p', form.text_field(:url, :label => 'Path to .git directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
|
content_tag('p', form.text_field(
|
||||||
|
:url, :label => l(:field_path_to_repository),
|
||||||
|
:size => 60, :required => true,
|
||||||
|
:disabled => (repository && !repository.root_url.blank?)
|
||||||
|
) +
|
||||||
|
'<br />' + l(:text_git_repository_note)) +
|
||||||
|
content_tag('p', form.select(
|
||||||
|
:path_encoding, [nil] + Setting::ENCODINGS,
|
||||||
|
:label => l(:field_scm_path_encoding)
|
||||||
|
) +
|
||||||
|
'<br />' + l(:text_scm_path_encoding_note)) +
|
||||||
|
content_tag('p', form.check_box(
|
||||||
|
:extra_report_last_commit,
|
||||||
|
:label => l(:label_git_report_last_commit)
|
||||||
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
def cvs_field_tags(form, repository)
|
def cvs_field_tags(form, repository)
|
||||||
content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) +
|
content_tag('p', form.text_field(
|
||||||
content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?))
|
:root_url,
|
||||||
|
:label => l(:field_cvsroot),
|
||||||
|
:size => 60, :required => true,
|
||||||
|
:disabled => !repository.new_record?)) +
|
||||||
|
content_tag('p', form.text_field(
|
||||||
|
:url,
|
||||||
|
:label => l(:field_cvs_module),
|
||||||
|
:size => 30, :required => true,
|
||||||
|
:disabled => !repository.new_record?)) +
|
||||||
|
content_tag('p', form.select(
|
||||||
|
:log_encoding, [nil] + Setting::ENCODINGS,
|
||||||
|
:label => l(:field_commit_logs_encoding), :required => true)) +
|
||||||
|
content_tag('p', form.select(
|
||||||
|
:path_encoding, [nil] + Setting::ENCODINGS,
|
||||||
|
:label => l(:field_scm_path_encoding)
|
||||||
|
) +
|
||||||
|
'<br />' + l(:text_scm_path_encoding_note))
|
||||||
end
|
end
|
||||||
|
|
||||||
def bazaar_field_tags(form, repository)
|
def bazaar_field_tags(form, repository)
|
||||||
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?)))
|
content_tag('p', form.text_field(
|
||||||
|
:url, :label => l(:field_path_to_repository),
|
||||||
|
:size => 60, :required => true,
|
||||||
|
:disabled => (repository && !repository.new_record?))) +
|
||||||
|
content_tag('p', form.select(
|
||||||
|
:log_encoding, [nil] + Setting::ENCODINGS,
|
||||||
|
:label => l(:field_commit_logs_encoding), :required => true))
|
||||||
end
|
end
|
||||||
|
|
||||||
def filesystem_field_tags(form, repository)
|
def filesystem_field_tags(form, repository)
|
||||||
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
|
content_tag('p', form.text_field(
|
||||||
|
:url, :label => l(:field_root_directory),
|
||||||
|
:size => 60, :required => true,
|
||||||
|
:disabled => (repository && !repository.root_url.blank?))) +
|
||||||
|
content_tag('p', form.select(
|
||||||
|
:path_encoding, [nil] + Setting::ENCODINGS,
|
||||||
|
:label => l(:field_scm_path_encoding)
|
||||||
|
) +
|
||||||
|
'<br />' + l(:text_scm_path_encoding_note))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -39,7 +39,7 @@ module SearchHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def type_label(t)
|
def type_label(t)
|
||||||
l("label_#{t.singularize}_plural")
|
l("label_#{t.singularize}_plural", :default => t.to_s.humanize)
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_select_tag
|
def project_select_tag
|
||||||
@@ -57,7 +57,7 @@ module SearchHelper
|
|||||||
c = results_by_type[t]
|
c = results_by_type[t]
|
||||||
next if c == 0
|
next if c == 0
|
||||||
text = "#{type_label(t)} (#{c})"
|
text = "#{type_label(t)} (#{c})"
|
||||||
links << link_to(text, :q => params[:q], :titles_only => params[:title_only], :all_words => params[:all_words], :scope => params[:scope], t => 1)
|
links << link_to(text, :q => params[:q], :titles_only => params[:titles_only], :all_words => params[:all_words], :scope => params[:scope], t => 1)
|
||||||
end
|
end
|
||||||
('<ul>' + links.map {|link| content_tag('li', link)}.join(' ') + '</ul>') unless links.empty?
|
('<ul>' + links.map {|link| content_tag('li', link)}.join(' ') + '</ul>') unless links.empty?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -27,48 +27,65 @@ module SettingsHelper
|
|||||||
{:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
|
{:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def setting_select(setting, choices, options={})
|
def setting_select(setting, choices, options={})
|
||||||
if blank_text = options.delete(:blank)
|
if blank_text = options.delete(:blank)
|
||||||
choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
|
choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
|
||||||
end
|
end
|
||||||
setting_label(setting, options) +
|
setting_label(setting, options) +
|
||||||
select_tag("settings[#{setting}]", options_for_select(choices, Setting.send(setting).to_s), options)
|
select_tag("settings[#{setting}]",
|
||||||
|
options_for_select(choices, Setting.send(setting).to_s),
|
||||||
|
options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setting_multiselect(setting, choices, options={})
|
def setting_multiselect(setting, choices, options={})
|
||||||
setting_values = Setting.send(setting)
|
setting_values = Setting.send(setting)
|
||||||
setting_values = [] unless setting_values.is_a?(Array)
|
setting_values = [] unless setting_values.is_a?(Array)
|
||||||
|
|
||||||
setting_label(setting, options) +
|
setting_label(setting, options) +
|
||||||
hidden_field_tag("settings[#{setting}][]", '') +
|
hidden_field_tag("settings[#{setting}][]", '') +
|
||||||
choices.collect do |choice|
|
choices.collect do |choice|
|
||||||
text, value = (choice.is_a?(Array) ? choice : [choice, choice])
|
text, value = (choice.is_a?(Array) ? choice : [choice, choice])
|
||||||
content_tag('label',
|
content_tag(
|
||||||
check_box_tag("settings[#{setting}][]", value, Setting.send(setting).include?(value)) + text.to_s,
|
'label',
|
||||||
|
check_box_tag(
|
||||||
|
"settings[#{setting}][]",
|
||||||
|
value,
|
||||||
|
Setting.send(setting).include?(value)
|
||||||
|
) + text.to_s,
|
||||||
:class => 'block'
|
:class => 'block'
|
||||||
)
|
)
|
||||||
end.join
|
end.join
|
||||||
end
|
end
|
||||||
|
|
||||||
def setting_text_field(setting, options={})
|
def setting_text_field(setting, options={})
|
||||||
setting_label(setting, options) +
|
setting_label(setting, options) +
|
||||||
text_field_tag("settings[#{setting}]", Setting.send(setting), options)
|
text_field_tag("settings[#{setting}]", Setting.send(setting), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setting_text_area(setting, options={})
|
def setting_text_area(setting, options={})
|
||||||
setting_label(setting, options) +
|
setting_label(setting, options) +
|
||||||
text_area_tag("settings[#{setting}]", Setting.send(setting), options)
|
text_area_tag("settings[#{setting}]", Setting.send(setting), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setting_check_box(setting, options={})
|
def setting_check_box(setting, options={})
|
||||||
setting_label(setting, options) +
|
setting_label(setting, options) +
|
||||||
hidden_field_tag("settings[#{setting}]", 0) +
|
hidden_field_tag("settings[#{setting}]", 0) +
|
||||||
check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options)
|
check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setting_label(setting, options={})
|
def setting_label(setting, options={})
|
||||||
label = options.delete(:label)
|
label = options.delete(:label)
|
||||||
label != false ? content_tag("label", l(label || "setting_#{setting}")) : ''
|
label != false ? content_tag("label", l(label || "setting_#{setting}")) : ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Renders a notification field for a Redmine::Notifiable option
|
||||||
|
def notification_field(notifiable)
|
||||||
|
return content_tag(:label,
|
||||||
|
check_box_tag('settings[notified_events][]',
|
||||||
|
notifiable.name,
|
||||||
|
Setting.notified_events.include?(notifiable.name)) +
|
||||||
|
l_or_humanize(notifiable.name, :prefix => 'label_'),
|
||||||
|
:class => notifiable.parent.present? ? "parent" : '')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -200,16 +200,12 @@ module SortHelper
|
|||||||
caption = column.to_s.humanize unless caption
|
caption = column.to_s.humanize unless caption
|
||||||
|
|
||||||
sort_options = { :sort => @sort_criteria.add(column.to_s, order).to_param }
|
sort_options = { :sort => @sort_criteria.add(column.to_s, order).to_param }
|
||||||
# don't reuse params if filters are present
|
url_options = params.merge(sort_options)
|
||||||
url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
|
|
||||||
|
|
||||||
# Add project_id to url_options
|
# Add project_id to url_options
|
||||||
url_options = url_options.merge(:project_id => params[:project_id]) if params.has_key?(:project_id)
|
url_options = url_options.merge(:project_id => params[:project_id]) if params.has_key?(:project_id)
|
||||||
|
|
||||||
link_to_remote(caption,
|
link_to_content_update(caption, url_options, :class => css)
|
||||||
{:update => "content", :url => url_options, :method => :get},
|
|
||||||
{:href => url_for(url_options),
|
|
||||||
:class => css})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a table header <th> tag with a sort link for the named column
|
# Returns a table header <th> tag with a sort link for the named column
|
||||||
|
|||||||
@@ -33,15 +33,19 @@ module UsersHelper
|
|||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_mail_notification_options(user)
|
||||||
|
user.valid_notification_options.collect {|o| [l(o.last), o.first]}
|
||||||
|
end
|
||||||
|
|
||||||
def change_status_link(user)
|
def change_status_link(user)
|
||||||
url = {:controller => 'users', :action => 'edit', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
|
url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
|
||||||
|
|
||||||
if user.locked?
|
if user.locked?
|
||||||
link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
|
link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
|
||||||
elsif user.registered?
|
elsif user.registered?
|
||||||
link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
|
link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
|
||||||
elsif user != User.current
|
elsif user != User.current
|
||||||
link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
|
link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -17,11 +17,10 @@
|
|||||||
|
|
||||||
module VersionsHelper
|
module VersionsHelper
|
||||||
|
|
||||||
STATUS_BY_CRITERIAS = %w(category tracker priority author assigned_to)
|
STATUS_BY_CRITERIAS = %w(category tracker status priority author assigned_to)
|
||||||
|
|
||||||
def render_issue_status_by(version, criteria)
|
def render_issue_status_by(version, criteria)
|
||||||
criteria ||= 'category'
|
criteria = 'category' unless STATUS_BY_CRITERIAS.include?(criteria)
|
||||||
raise 'Unknown criteria' unless STATUS_BY_CRITERIAS.include?(criteria)
|
|
||||||
|
|
||||||
h = Hash.new {|k,v| k[v] = [0, 0]}
|
h = Hash.new {|k,v| k[v] = [0, 0]}
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -16,28 +16,18 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
module WatchersHelper
|
module WatchersHelper
|
||||||
|
|
||||||
# Valid options
|
def watcher_tag(object, user, options={})
|
||||||
# * :id - the element id
|
content_tag("span", watcher_link(object, user), :class => watcher_css(object))
|
||||||
# * :replace - a string or array of element ids that will be
|
|
||||||
# replaced
|
|
||||||
def watcher_tag(object, user, options={:replace => 'watcher'})
|
|
||||||
id = options[:id]
|
|
||||||
id ||= options[:replace] if options[:replace].is_a? String
|
|
||||||
content_tag("span", watcher_link(object, user, options), :id => id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Valid options
|
def watcher_link(object, user)
|
||||||
# * :replace - a string or array of element ids that will be
|
|
||||||
# replaced
|
|
||||||
def watcher_link(object, user, options={:replace => 'watcher'})
|
|
||||||
return '' unless user && user.logged? && object.respond_to?('watched_by?')
|
return '' unless user && user.logged? && object.respond_to?('watched_by?')
|
||||||
watched = object.watched_by?(user)
|
watched = object.watched_by?(user)
|
||||||
url = {:controller => 'watchers',
|
url = {:controller => 'watchers',
|
||||||
:action => (watched ? 'unwatch' : 'watch'),
|
:action => (watched ? 'unwatch' : 'watch'),
|
||||||
:object_type => object.class.to_s.underscore,
|
:object_type => object.class.to_s.underscore,
|
||||||
:object_id => object.id,
|
:object_id => object.id}
|
||||||
:replace => options[:replace]}
|
|
||||||
link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)),
|
link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)),
|
||||||
{:url => url},
|
{:url => url},
|
||||||
:href => url_for(url),
|
:href => url_for(url),
|
||||||
@@ -45,6 +35,11 @@ module WatchersHelper
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the css class used to identify watch links for a given +object+
|
||||||
|
def watcher_css(object)
|
||||||
|
"#{object.class.to_s.underscore}-#{object.id}-watcher"
|
||||||
|
end
|
||||||
|
|
||||||
# Returns a comma separated list of users watching the given object
|
# Returns a comma separated list of users watching the given object
|
||||||
def watchers_list(object)
|
def watchers_list(object)
|
||||||
remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
|
remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
|
||||||
|
|||||||
+12
-46
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -18,52 +18,18 @@
|
|||||||
module WikiHelper
|
module WikiHelper
|
||||||
|
|
||||||
def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
|
def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
|
||||||
|
pages = pages.group_by(&:parent) unless pages.is_a?(Hash)
|
||||||
s = ''
|
s = ''
|
||||||
pages.select {|p| p.parent == parent}.each do |page|
|
if pages.has_key?(parent)
|
||||||
attrs = "value='#{page.id}'"
|
pages[parent].each do |page|
|
||||||
attrs << " selected='selected'" if selected == page
|
attrs = "value='#{page.id}'"
|
||||||
indent = (level > 0) ? (' ' * level * 2 + '» ') : nil
|
attrs << " selected='selected'" if selected == page
|
||||||
|
indent = (level > 0) ? (' ' * level * 2 + '» ') : nil
|
||||||
s << "<option value='#{page.id}'>#{indent}#{h page.pretty_title}</option>\n" +
|
|
||||||
wiki_page_options_for_select(pages, selected, page, level + 1)
|
s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" +
|
||||||
|
wiki_page_options_for_select(pages, selected, page, level + 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
def html_diff(wdiff)
|
|
||||||
words = wdiff.words.collect{|word| h(word)}
|
|
||||||
words_add = 0
|
|
||||||
words_del = 0
|
|
||||||
dels = 0
|
|
||||||
del_off = 0
|
|
||||||
wdiff.diff.diffs.each do |diff|
|
|
||||||
add_at = nil
|
|
||||||
add_to = nil
|
|
||||||
del_at = nil
|
|
||||||
deleted = ""
|
|
||||||
diff.each do |change|
|
|
||||||
pos = change[1]
|
|
||||||
if change[0] == "+"
|
|
||||||
add_at = pos + dels unless add_at
|
|
||||||
add_to = pos + dels
|
|
||||||
words_add += 1
|
|
||||||
else
|
|
||||||
del_at = pos unless del_at
|
|
||||||
deleted << ' ' + h(change[2])
|
|
||||||
words_del += 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if add_at
|
|
||||||
words[add_at] = '<span class="diff_in">' + words[add_at]
|
|
||||||
words[add_to] = words[add_to] + '</span>'
|
|
||||||
end
|
|
||||||
if del_at
|
|
||||||
words.insert del_at - del_off + dels + words_add, '<span class="diff_out">' + deleted + '</span>'
|
|
||||||
dels += 1
|
|
||||||
del_off += words_del
|
|
||||||
words_del = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
simple_format_without_paragraph(words.join(' '))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
+23
-23
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -20,7 +20,7 @@ require "digest/md5"
|
|||||||
class Attachment < ActiveRecord::Base
|
class Attachment < ActiveRecord::Base
|
||||||
belongs_to :container, :polymorphic => true
|
belongs_to :container, :polymorphic => true
|
||||||
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
||||||
|
|
||||||
validates_presence_of :container, :filename, :author
|
validates_presence_of :container, :filename, :author
|
||||||
validates_length_of :filename, :maximum => 255
|
validates_length_of :filename, :maximum => 255
|
||||||
validates_length_of :disk_filename, :maximum => 255
|
validates_length_of :disk_filename, :maximum => 255
|
||||||
@@ -31,20 +31,20 @@ class Attachment < ActiveRecord::Base
|
|||||||
acts_as_activity_provider :type => 'files',
|
acts_as_activity_provider :type => 'files',
|
||||||
:permission => :view_files,
|
:permission => :view_files,
|
||||||
:author_key => :author_id,
|
:author_key => :author_id,
|
||||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||||
:joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
:joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||||
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )"}
|
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )"}
|
||||||
|
|
||||||
acts_as_activity_provider :type => 'documents',
|
acts_as_activity_provider :type => 'documents',
|
||||||
:permission => :view_documents,
|
:permission => :view_documents,
|
||||||
:author_key => :author_id,
|
:author_key => :author_id,
|
||||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||||
:joins => "LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " +
|
:joins => "LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||||
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"}
|
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"}
|
||||||
|
|
||||||
cattr_accessor :storage_path
|
cattr_accessor :storage_path
|
||||||
@@storage_path = "#{RAILS_ROOT}/files"
|
@@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{RAILS_ROOT}/files"
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
if self.filesize > Setting.attachment_max_size.to_i.kilobytes
|
if self.filesize > Setting.attachment_max_size.to_i.kilobytes
|
||||||
errors.add(:base, :too_long, :count => Setting.attachment_max_size.to_i.kilobytes)
|
errors.add(:base, :too_long, :count => Setting.attachment_max_size.to_i.kilobytes)
|
||||||
@@ -76,7 +76,7 @@ class Attachment < ActiveRecord::Base
|
|||||||
if @temp_file && (@temp_file.size > 0)
|
if @temp_file && (@temp_file.size > 0)
|
||||||
logger.debug("saving '#{self.diskfile}'")
|
logger.debug("saving '#{self.diskfile}'")
|
||||||
md5 = Digest::MD5.new
|
md5 = Digest::MD5.new
|
||||||
File.open(diskfile, "wb") do |f|
|
File.open(diskfile, "wb") do |f|
|
||||||
buffer = ""
|
buffer = ""
|
||||||
while (buffer = @temp_file.read(8192))
|
while (buffer = @temp_file.read(8192))
|
||||||
f.write(buffer)
|
f.write(buffer)
|
||||||
@@ -100,7 +100,7 @@ class Attachment < ActiveRecord::Base
|
|||||||
def diskfile
|
def diskfile
|
||||||
"#{@@storage_path}/#{self.disk_filename}"
|
"#{@@storage_path}/#{self.disk_filename}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def increment_download
|
def increment_download
|
||||||
increment!(:downloads)
|
increment!(:downloads)
|
||||||
end
|
end
|
||||||
@@ -108,27 +108,27 @@ class Attachment < ActiveRecord::Base
|
|||||||
def project
|
def project
|
||||||
container.project
|
container.project
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
container.attachments_visible?(user)
|
container.attachments_visible?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def deletable?(user=User.current)
|
def deletable?(user=User.current)
|
||||||
container.attachments_deletable?(user)
|
container.attachments_deletable?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def image?
|
def image?
|
||||||
self.filename =~ /\.(jpe?g|gif|png)$/i
|
self.filename =~ /\.(jpe?g|gif|png)$/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_text?
|
def is_text?
|
||||||
Redmine::MimeType.is_type?('text', filename)
|
Redmine::MimeType.is_type?('text', filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_diff?
|
def is_diff?
|
||||||
self.filename =~ /\.(patch|diff)$/i
|
self.filename =~ /\.(patch|diff)$/i
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if the file is readable
|
# Returns true if the file is readable
|
||||||
def readable?
|
def readable?
|
||||||
File.readable?(diskfile)
|
File.readable?(diskfile)
|
||||||
@@ -145,7 +145,7 @@ class Attachment < ActiveRecord::Base
|
|||||||
attachments.each_value do |attachment|
|
attachments.each_value do |attachment|
|
||||||
file = attachment['file']
|
file = attachment['file']
|
||||||
next unless file && file.size > 0
|
next unless file && file.size > 0
|
||||||
a = Attachment.create(:container => obj,
|
a = Attachment.create(:container => obj,
|
||||||
:file => file,
|
:file => file,
|
||||||
:description => attachment['description'].to_s.strip,
|
:description => attachment['description'].to_s.strip,
|
||||||
:author => User.current)
|
:author => User.current)
|
||||||
@@ -160,18 +160,18 @@ class Attachment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
{:files => attached, :unsaved => obj.unsaved_attachments}
|
{:files => attached, :unsaved => obj.unsaved_attachments}
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def sanitize_filename(value)
|
def sanitize_filename(value)
|
||||||
# get only the filename, not the whole path
|
# get only the filename, not the whole path
|
||||||
just_filename = value.gsub(/^.*(\\|\/)/, '')
|
just_filename = value.gsub(/^.*(\\|\/)/, '')
|
||||||
# NOTE: File.basename doesn't work right with Windows paths on Unix
|
# NOTE: File.basename doesn't work right with Windows paths on Unix
|
||||||
# INCORRECT: just_filename = File.basename(value.gsub('\\\\', '/'))
|
# INCORRECT: just_filename = File.basename(value.gsub('\\\\', '/'))
|
||||||
|
|
||||||
# Finally, replace all non alphanumeric, hyphens or periods with underscore
|
# Finally, replace all non alphanumeric, hyphens or periods with underscore
|
||||||
@filename = just_filename.gsub(/[^\w\.\-]/,'_')
|
@filename = just_filename.gsub(/[^\w\.\-]/,'_')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an ASCII or hashed filename
|
# Returns an ASCII or hashed filename
|
||||||
def self.disk_filename(filename)
|
def self.disk_filename(filename)
|
||||||
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
|
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class AuthSource < ActiveRecord::Base
|
class AuthSource < ActiveRecord::Base
|
||||||
|
include Redmine::Ciphering
|
||||||
|
|
||||||
has_many :users
|
has_many :users
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
@@ -31,6 +33,14 @@ class AuthSource < ActiveRecord::Base
|
|||||||
def auth_method_name
|
def auth_method_name
|
||||||
"Abstract"
|
"Abstract"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def account_password
|
||||||
|
read_ciphered_attribute(:account_password)
|
||||||
|
end
|
||||||
|
|
||||||
|
def account_password=(arg)
|
||||||
|
write_ciphered_attribute(:account_password, arg)
|
||||||
|
end
|
||||||
|
|
||||||
def allow_password_changes?
|
def allow_password_changes?
|
||||||
self.class.allow_password_changes?
|
self.class.allow_password_changes?
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ require 'iconv'
|
|||||||
|
|
||||||
class AuthSourceLdap < AuthSource
|
class AuthSourceLdap < AuthSource
|
||||||
validates_presence_of :host, :port, :attr_login
|
validates_presence_of :host, :port, :attr_login
|
||||||
validates_length_of :name, :host, :account_password, :maximum => 60, :allow_nil => true
|
validates_length_of :name, :host, :maximum => 60, :allow_nil => true
|
||||||
validates_length_of :account, :base_dn, :maximum => 255, :allow_nil => true
|
validates_length_of :account, :account_password, :base_dn, :maximum => 255, :allow_nil => true
|
||||||
validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true
|
validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true
|
||||||
validates_numericality_of :port, :only_integer => true
|
validates_numericality_of :port, :only_integer => true
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
class Board < ActiveRecord::Base
|
class Board < ActiveRecord::Base
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
|
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
|
||||||
has_many :messages, :dependent => :delete_all, :order => "#{Message.table_name}.created_on DESC"
|
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
|
||||||
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
|
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
|
||||||
acts_as_list :scope => :project_id
|
acts_as_list :scope => :project_id
|
||||||
acts_as_watchable
|
acts_as_watchable
|
||||||
|
|||||||
+15
-9
@@ -1,30 +1,36 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class Change < ActiveRecord::Base
|
class Change < ActiveRecord::Base
|
||||||
belongs_to :changeset
|
belongs_to :changeset
|
||||||
|
|
||||||
validates_presence_of :changeset_id, :action, :path
|
validates_presence_of :changeset_id, :action, :path
|
||||||
|
before_save :init_path
|
||||||
|
|
||||||
def relative_path
|
def relative_path
|
||||||
changeset.repository.relative_path(path)
|
changeset.repository.relative_path(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_save
|
def before_validation
|
||||||
path ||= ""
|
self.path = Redmine::CodesetUtil.replace_invalid_utf8(self.path)
|
||||||
|
self.from_path = Redmine::CodesetUtil.replace_invalid_utf8(self.from_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def init_path
|
||||||
|
self.path ||= ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+188
-98
@@ -1,16 +1,16 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2010 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -23,156 +23,221 @@ class Changeset < ActiveRecord::Base
|
|||||||
has_many :changes, :dependent => :delete_all
|
has_many :changes, :dependent => :delete_all
|
||||||
has_and_belongs_to_many :issues
|
has_and_belongs_to_many :issues
|
||||||
|
|
||||||
acts_as_event :title => Proc.new {|o| "#{l(:label_revision)} #{o.revision}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))},
|
acts_as_event :title => Proc.new {|o| "#{l(:label_revision)} #{o.format_identifier}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))},
|
||||||
:description => :long_comments,
|
:description => :long_comments,
|
||||||
:datetime => :committed_on,
|
:datetime => :committed_on,
|
||||||
:url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project, :rev => o.revision}}
|
:url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project, :rev => o.identifier}}
|
||||||
|
|
||||||
acts_as_searchable :columns => 'comments',
|
acts_as_searchable :columns => 'comments',
|
||||||
:include => {:repository => :project},
|
:include => {:repository => :project},
|
||||||
:project_key => "#{Repository.table_name}.project_id",
|
:project_key => "#{Repository.table_name}.project_id",
|
||||||
:date_column => 'committed_on'
|
:date_column => 'committed_on'
|
||||||
|
|
||||||
acts_as_activity_provider :timestamp => "#{table_name}.committed_on",
|
acts_as_activity_provider :timestamp => "#{table_name}.committed_on",
|
||||||
:author_key => :user_id,
|
:author_key => :user_id,
|
||||||
:find_options => {:include => [:user, {:repository => :project}]}
|
:find_options => {:include => [:user, {:repository => :project}]}
|
||||||
|
|
||||||
validates_presence_of :repository_id, :revision, :committed_on, :commit_date
|
validates_presence_of :repository_id, :revision, :committed_on, :commit_date
|
||||||
validates_uniqueness_of :revision, :scope => :repository_id
|
validates_uniqueness_of :revision, :scope => :repository_id
|
||||||
validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true
|
validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true
|
||||||
|
|
||||||
named_scope :visible, lambda {|*args| { :include => {:repository => :project},
|
named_scope :visible, lambda {|*args| { :include => {:repository => :project},
|
||||||
:conditions => Project.allowed_to_condition(args.first || User.current, :view_changesets) } }
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args) } }
|
||||||
|
|
||||||
def revision=(r)
|
def revision=(r)
|
||||||
write_attribute :revision, (r.nil? ? nil : r.to_s)
|
write_attribute :revision, (r.nil? ? nil : r.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def comments=(comment)
|
# Returns the identifier of this changeset; depending on repository backends
|
||||||
write_attribute(:comments, Changeset.normalize_comments(comment))
|
def identifier
|
||||||
|
if repository.class.respond_to? :changeset_identifier
|
||||||
|
repository.class.changeset_identifier self
|
||||||
|
else
|
||||||
|
revision.to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def committed_on=(date)
|
def committed_on=(date)
|
||||||
self.commit_date = date
|
self.commit_date = date
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def committer=(arg)
|
# Returns the readable identifier
|
||||||
write_attribute(:committer, self.class.to_utf8(arg.to_s))
|
def format_identifier
|
||||||
|
if repository.class.respond_to? :format_changeset_identifier
|
||||||
|
repository.class.format_changeset_identifier self
|
||||||
|
else
|
||||||
|
identifier
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def project
|
def project
|
||||||
repository.project
|
repository.project
|
||||||
end
|
end
|
||||||
|
|
||||||
def author
|
def author
|
||||||
user || committer.to_s.split('<').first
|
user || committer.to_s.split('<').first
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_create
|
def before_create
|
||||||
self.user = repository.find_committer_user(committer)
|
self.committer = self.class.to_utf8(self.committer, repository.repo_log_encoding)
|
||||||
|
self.comments = self.class.normalize_comments(
|
||||||
|
self.comments, repository.repo_log_encoding)
|
||||||
|
self.user = repository.find_committer_user(self.committer)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_create
|
def after_create
|
||||||
scan_comment_for_issue_ids
|
scan_comment_for_issue_ids
|
||||||
end
|
end
|
||||||
require 'pp'
|
|
||||||
|
TIMELOG_RE = /
|
||||||
|
(
|
||||||
|
((\d+)(h|hours?))((\d+)(m|min)?)?
|
||||||
|
|
|
||||||
|
((\d+)(h|hours?|m|min))
|
||||||
|
|
|
||||||
|
(\d+):(\d+)
|
||||||
|
|
|
||||||
|
(\d+([\.,]\d+)?)h?
|
||||||
|
)
|
||||||
|
/x
|
||||||
|
|
||||||
def scan_comment_for_issue_ids
|
def scan_comment_for_issue_ids
|
||||||
return if comments.blank?
|
return if comments.blank?
|
||||||
# keywords used to reference issues
|
# keywords used to reference issues
|
||||||
ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip)
|
ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip)
|
||||||
|
ref_keywords_any = ref_keywords.delete('*')
|
||||||
# keywords used to fix issues
|
# keywords used to fix issues
|
||||||
fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip)
|
fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip)
|
||||||
|
|
||||||
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|")
|
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|")
|
||||||
return if kw_regexp.blank?
|
|
||||||
|
|
||||||
referenced_issues = []
|
referenced_issues = []
|
||||||
|
|
||||||
if ref_keywords.delete('*')
|
comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match|
|
||||||
# find any issue ID in the comments
|
action, refs = match[2], match[3]
|
||||||
target_issue_ids = []
|
next unless action.present? || ref_keywords_any
|
||||||
comments.scan(%r{([\s\(\[,-]|^)#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] }
|
|
||||||
referenced_issues += find_referenced_issues_by_id(target_issue_ids)
|
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
|
||||||
end
|
issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
|
||||||
|
if issue
|
||||||
comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match|
|
referenced_issues << issue
|
||||||
action = match[0]
|
fix_issue(issue) if fix_keywords.include?(action.to_s.downcase)
|
||||||
target_issue_ids = match[1].scan(/\d+/)
|
log_time(issue, hours) if hours && Setting.commit_logtime_enabled?
|
||||||
target_issues = find_referenced_issues_by_id(target_issue_ids)
|
|
||||||
if fix_keywords.include?(action.downcase) && fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id)
|
|
||||||
# update status of issues
|
|
||||||
logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug?
|
|
||||||
target_issues.each do |issue|
|
|
||||||
# the issue may have been updated by the closure of another one (eg. duplicate)
|
|
||||||
issue.reload
|
|
||||||
# don't change the status is the issue is closed
|
|
||||||
next if issue.status.is_closed?
|
|
||||||
csettext = "r#{self.revision}"
|
|
||||||
if self.scmid && (! (csettext =~ /^r[0-9]+$/))
|
|
||||||
csettext = "commit:\"#{self.scmid}\""
|
|
||||||
end
|
|
||||||
journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext))
|
|
||||||
issue.status = fix_status
|
|
||||||
unless Setting.commit_fix_done_ratio.blank?
|
|
||||||
issue.done_ratio = Setting.commit_fix_done_ratio.to_i
|
|
||||||
end
|
|
||||||
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
|
|
||||||
{ :changeset => self, :issue => issue })
|
|
||||||
issue.save
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
referenced_issues += target_issues
|
|
||||||
end
|
end
|
||||||
|
|
||||||
referenced_issues.uniq!
|
referenced_issues.uniq!
|
||||||
self.issues = referenced_issues unless referenced_issues.empty?
|
self.issues = referenced_issues unless referenced_issues.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def short_comments
|
def short_comments
|
||||||
@short_comments || split_comments.first
|
@short_comments || split_comments.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def long_comments
|
def long_comments
|
||||||
@long_comments || split_comments.last
|
@long_comments || split_comments.last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def text_tag
|
||||||
|
if scmid?
|
||||||
|
"commit:#{scmid}"
|
||||||
|
else
|
||||||
|
"r#{revision}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Returns the previous changeset
|
# Returns the previous changeset
|
||||||
def previous
|
def previous
|
||||||
@previous ||= Changeset.find(:first, :conditions => ['id < ? AND repository_id = ?', self.id, self.repository_id], :order => 'id DESC')
|
@previous ||= Changeset.find(:first,
|
||||||
|
:conditions => ['id < ? AND repository_id = ?',
|
||||||
|
self.id, self.repository_id],
|
||||||
|
:order => 'id DESC')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the next changeset
|
# Returns the next changeset
|
||||||
def next
|
def next
|
||||||
@next ||= Changeset.find(:first, :conditions => ['id > ? AND repository_id = ?', self.id, self.repository_id], :order => 'id ASC')
|
@next ||= Changeset.find(:first,
|
||||||
end
|
:conditions => ['id > ? AND repository_id = ?',
|
||||||
|
self.id, self.repository_id],
|
||||||
# Strips and reencodes a commit log before insertion into the database
|
:order => 'id ASC')
|
||||||
def self.normalize_comments(str)
|
|
||||||
to_utf8(str.to_s.strip)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a new Change from it's common parameters
|
# Creates a new Change from it's common parameters
|
||||||
def create_change(change)
|
def create_change(change)
|
||||||
Change.create(:changeset => self,
|
Change.create(:changeset => self,
|
||||||
:action => change[:action],
|
:action => change[:action],
|
||||||
:path => change[:path],
|
:path => change[:path],
|
||||||
:from_path => change[:from_path],
|
:from_path => change[:from_path],
|
||||||
:from_revision => change[:from_revision])
|
:from_revision => change[:from_revision])
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Finds issues that can be referenced by the commit message
|
# Finds an issue that can be referenced by the commit message
|
||||||
# i.e. issues that belong to the repository project, a subproject or a parent project
|
# i.e. an issue that belong to the repository project, a subproject or a parent project
|
||||||
def find_referenced_issues_by_id(ids)
|
def find_referenced_issue_by_id(id)
|
||||||
return [] if ids.compact.empty?
|
return nil if id.blank?
|
||||||
Issue.find_all_by_id(ids, :include => :project).select {|issue|
|
issue = Issue.find_by_id(id.to_i, :include => :project)
|
||||||
project == issue.project || project.is_ancestor_of?(issue.project) || project.is_descendant_of?(issue.project)
|
if issue
|
||||||
}
|
unless issue.project &&
|
||||||
|
(project == issue.project || project.is_ancestor_of?(issue.project) ||
|
||||||
|
project.is_descendant_of?(issue.project))
|
||||||
|
issue = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
issue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fix_issue(issue)
|
||||||
|
status = IssueStatus.find_by_id(Setting.commit_fix_status_id.to_i)
|
||||||
|
if status.nil?
|
||||||
|
logger.warn("No status matches commit_fix_status_id setting (#{Setting.commit_fix_status_id})") if logger
|
||||||
|
return issue
|
||||||
|
end
|
||||||
|
|
||||||
|
# the issue may have been updated by the closure of another one (eg. duplicate)
|
||||||
|
issue.reload
|
||||||
|
# don't change the status is the issue is closed
|
||||||
|
return if issue.status && issue.status.is_closed?
|
||||||
|
|
||||||
|
journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag))
|
||||||
|
issue.status = status
|
||||||
|
unless Setting.commit_fix_done_ratio.blank?
|
||||||
|
issue.done_ratio = Setting.commit_fix_done_ratio.to_i
|
||||||
|
end
|
||||||
|
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
|
||||||
|
{ :changeset => self, :issue => issue })
|
||||||
|
unless issue.save
|
||||||
|
logger.warn("Issue ##{issue.id} could not be saved by changeset #{id}: #{issue.errors.full_messages}") if logger
|
||||||
|
end
|
||||||
|
issue
|
||||||
|
end
|
||||||
|
|
||||||
|
def log_time(issue, hours)
|
||||||
|
time_entry = TimeEntry.new(
|
||||||
|
:user => user,
|
||||||
|
:hours => hours,
|
||||||
|
:issue => issue,
|
||||||
|
:spent_on => commit_date,
|
||||||
|
:comments => l(:text_time_logged_by_changeset, :value => text_tag,
|
||||||
|
:locale => Setting.default_language)
|
||||||
|
)
|
||||||
|
time_entry.activity = log_time_activity unless log_time_activity.nil?
|
||||||
|
|
||||||
|
unless time_entry.save
|
||||||
|
logger.warn("TimeEntry could not be created by changeset #{id}: #{time_entry.errors.full_messages}") if logger
|
||||||
|
end
|
||||||
|
time_entry
|
||||||
|
end
|
||||||
|
|
||||||
|
def log_time_activity
|
||||||
|
if Setting.commit_logtime_activity_id.to_i > 0
|
||||||
|
TimeEntryActivity.find_by_id(Setting.commit_logtime_activity_id.to_i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def split_comments
|
def split_comments
|
||||||
comments =~ /\A(.+?)\r?\n(.*)$/m
|
comments =~ /\A(.+?)\r?\n(.*)$/m
|
||||||
@short_comments = $1 || comments
|
@short_comments = $1 || comments
|
||||||
@@ -180,22 +245,47 @@ class Changeset < ActiveRecord::Base
|
|||||||
return @short_comments, @long_comments
|
return @short_comments, @long_comments
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.to_utf8(str)
|
public
|
||||||
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
|
|
||||||
encoding = Setting.commit_logs_encoding.to_s.strip
|
# Strips and reencodes a commit log before insertion into the database
|
||||||
unless encoding.blank? || encoding == 'UTF-8'
|
def self.normalize_comments(str, encoding)
|
||||||
begin
|
Changeset.to_utf8(str.to_s.strip, encoding)
|
||||||
str = Iconv.conv('UTF-8', encoding, str)
|
end
|
||||||
rescue Iconv::Failure
|
|
||||||
# do nothing here
|
def self.to_utf8(str, encoding)
|
||||||
|
return str if str.nil?
|
||||||
|
str.force_encoding("ASCII-8BIT") if str.respond_to?(:force_encoding)
|
||||||
|
if str.empty?
|
||||||
|
str.force_encoding("UTF-8") if str.respond_to?(:force_encoding)
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
enc = encoding.blank? ? "UTF-8" : encoding
|
||||||
|
if str.respond_to?(:force_encoding)
|
||||||
|
if enc.upcase != "UTF-8"
|
||||||
|
str.force_encoding(enc)
|
||||||
|
str = str.encode("UTF-8", :invalid => :replace,
|
||||||
|
:undef => :replace, :replace => '?')
|
||||||
|
else
|
||||||
|
str.force_encoding("UTF-8")
|
||||||
|
if ! str.valid_encoding?
|
||||||
|
str = str.encode("US-ASCII", :invalid => :replace,
|
||||||
|
:undef => :replace, :replace => '?').encode("UTF-8")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
ic = Iconv.new('UTF-8', enc)
|
||||||
|
txtar = ""
|
||||||
|
begin
|
||||||
|
txtar += ic.iconv(str)
|
||||||
|
rescue Iconv::IllegalSequence
|
||||||
|
txtar += $!.success
|
||||||
|
str = '?' + $!.failed[1,$!.failed.length]
|
||||||
|
retry
|
||||||
|
rescue
|
||||||
|
txtar += $!.success
|
||||||
|
end
|
||||||
|
str = txtar
|
||||||
end
|
end
|
||||||
# removes invalid UTF8 sequences
|
str
|
||||||
begin
|
|
||||||
Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3]
|
|
||||||
rescue Iconv::InvalidEncoding
|
|
||||||
# "UTF-8//IGNORE" is not supported on some OS
|
|
||||||
str
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class CommentObserver < ActiveRecord::Observer
|
||||||
|
def after_create(comment)
|
||||||
|
if comment.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added')
|
||||||
|
Mailer.deliver_news_comment_added(comment)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -23,7 +23,6 @@ class CustomField < ActiveRecord::Base
|
|||||||
validates_presence_of :name, :field_format
|
validates_presence_of :name, :field_format
|
||||||
validates_uniqueness_of :name, :scope => :type
|
validates_uniqueness_of :name, :scope => :type
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
validates_format_of :name, :with => /^[\w\s\.\'\-]*$/i
|
|
||||||
validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
|
validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
|
||||||
|
|
||||||
def initialize(attributes = nil)
|
def initialize(attributes = nil)
|
||||||
@@ -43,12 +42,49 @@ class CustomField < ActiveRecord::Base
|
|||||||
errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
|
errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if regexp.present?
|
||||||
|
begin
|
||||||
|
Regexp.new(regexp)
|
||||||
|
rescue
|
||||||
|
errors.add(:regexp, :invalid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# validate default value
|
# validate default value
|
||||||
v = CustomValue.new(:custom_field => self.clone, :value => default_value, :customized => nil)
|
v = CustomValue.new(:custom_field => self.clone, :value => default_value, :customized => nil)
|
||||||
v.custom_field.is_required = false
|
v.custom_field.is_required = false
|
||||||
errors.add(:default_value, :invalid) unless v.valid?
|
errors.add(:default_value, :invalid) unless v.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def possible_values_options(obj=nil)
|
||||||
|
case field_format
|
||||||
|
when 'user', 'version'
|
||||||
|
if obj.respond_to?(:project) && obj.project
|
||||||
|
case field_format
|
||||||
|
when 'user'
|
||||||
|
obj.project.users.sort.collect {|u| [u.to_s, u.id.to_s]}
|
||||||
|
when 'version'
|
||||||
|
obj.project.shared_versions.sort.collect {|u| [u.to_s, u.id.to_s]}
|
||||||
|
end
|
||||||
|
elsif obj.is_a?(Array)
|
||||||
|
obj.collect {|o| possible_values_options(o)}.inject {|memo, v| memo & v}
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
read_attribute :possible_values
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def possible_values(obj=nil)
|
||||||
|
case field_format
|
||||||
|
when 'user', 'version'
|
||||||
|
possible_values_options(obj).collect(&:last)
|
||||||
|
else
|
||||||
|
read_attribute :possible_values
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Makes possible_values accept a multiline string
|
# Makes possible_values accept a multiline string
|
||||||
def possible_values=(arg)
|
def possible_values=(arg)
|
||||||
if arg.is_a?(Array)
|
if arg.is_a?(Array)
|
||||||
@@ -72,6 +108,8 @@ class CustomField < ActiveRecord::Base
|
|||||||
casted = value.to_i
|
casted = value.to_i
|
||||||
when 'float'
|
when 'float'
|
||||||
casted = value.to_f
|
casted = value.to_f
|
||||||
|
when 'user', 'version'
|
||||||
|
casted = (value.blank? ? nil : field_format.classify.constantize.find_by_id(value.to_i))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
casted
|
casted
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ class CustomValue < ActiveRecord::Base
|
|||||||
custom_field.editable?
|
custom_field.editable?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def visible?
|
||||||
|
custom_field.visible?
|
||||||
|
end
|
||||||
|
|
||||||
def required?
|
def required?
|
||||||
custom_field.is_required?
|
custom_field.is_required?
|
||||||
end
|
end
|
||||||
@@ -58,7 +62,7 @@ protected
|
|||||||
when 'float'
|
when 'float'
|
||||||
begin; Kernel.Float(value); rescue; errors.add(:value, :invalid) end
|
begin; Kernel.Float(value); rescue; errors.add(:value, :invalid) end
|
||||||
when 'date'
|
when 'date'
|
||||||
errors.add(:value, :not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/
|
errors.add(:value, :not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ && begin; value.to_date; rescue; false end
|
||||||
when 'list'
|
when 'list'
|
||||||
errors.add(:value, :inclusion) unless custom_field.possible_values.include?(value)
|
errors.add(:value, :inclusion) unless custom_field.possible_values.include?(value)
|
||||||
end
|
end
|
||||||
|
|||||||
+11
-8
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# RedMine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -25,20 +25,23 @@ class Document < ActiveRecord::Base
|
|||||||
:author => Proc.new {|o| (a = o.attachments.find(:first, :order => "#{Attachment.table_name}.created_on ASC")) ? a.author : nil },
|
:author => Proc.new {|o| (a = o.attachments.find(:first, :order => "#{Attachment.table_name}.created_on ASC")) ? a.author : nil },
|
||||||
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
|
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
|
||||||
acts_as_activity_provider :find_options => {:include => :project}
|
acts_as_activity_provider :find_options => {:include => :project}
|
||||||
|
|
||||||
validates_presence_of :project, :title, :category
|
validates_presence_of :project, :title, :category
|
||||||
validates_length_of :title, :maximum => 60
|
validates_length_of :title, :maximum => 60
|
||||||
|
|
||||||
|
named_scope :visible, lambda {|*args| { :include => :project,
|
||||||
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_documents, *args) } }
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
!user.nil? && user.allowed_to?(:view_documents, project)
|
!user.nil? && user.allowed_to?(:view_documents, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_initialize
|
def after_initialize
|
||||||
if new_record?
|
if new_record?
|
||||||
self.category ||= DocumentCategory.default
|
self.category ||= DocumentCategory.default
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def updated_on
|
def updated_on
|
||||||
unless @updated_on
|
unless @updated_on
|
||||||
a = attachments.find(:first, :order => 'created_on DESC')
|
a = attachments.find(:first, :order => 'created_on DESC')
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -20,4 +20,3 @@ class DocumentCategoryCustomField < CustomField
|
|||||||
:enumeration_doc_categories
|
:enumeration_doc_categories
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class EnabledModule < ActiveRecord::Base
|
class EnabledModule < ActiveRecord::Base
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name, :scope => :project_id
|
validates_uniqueness_of :name, :scope => :project_id
|
||||||
|
|
||||||
after_create :module_enabled
|
after_create :module_enabled
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# after_create callback used to do things when a module is enabled
|
# after_create callback used to do things when a module is enabled
|
||||||
def module_enabled
|
def module_enabled
|
||||||
case name
|
case name
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class Enumeration < ActiveRecord::Base
|
|||||||
|
|
||||||
named_scope :shared, :conditions => { :project_id => nil }
|
named_scope :shared, :conditions => { :project_id => nil }
|
||||||
named_scope :active, :conditions => { :active => true }
|
named_scope :active, :conditions => { :active => true }
|
||||||
|
named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||||
|
|
||||||
def self.default
|
def self.default
|
||||||
# Creates a fake default scope so Enumeration.default will check
|
# Creates a fake default scope so Enumeration.default will check
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class Group < Principal
|
|||||||
|
|
||||||
def user_added(user)
|
def user_added(user)
|
||||||
members.each do |member|
|
members.each do |member|
|
||||||
|
next if member.project.nil?
|
||||||
user_member = Member.find_by_project_id_and_user_id(member.project_id, user.id) || Member.new(:project_id => member.project_id, :user_id => user.id)
|
user_member = Member.find_by_project_id_and_user_id(member.project_id, user.id) || Member.new(:project_id => member.project_id, :user_id => user.id)
|
||||||
member.member_roles.each do |member_role|
|
member.member_roles.each do |member_role|
|
||||||
user_member.member_roles << MemberRole.new(:role => member_role.role, :inherited_from => member_role.id)
|
user_member.member_roles << MemberRole.new(:role => member_role.role, :inherited_from => member_role.id)
|
||||||
|
|||||||
+233
-135
@@ -1,21 +1,23 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class Issue < ActiveRecord::Base
|
class Issue < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :tracker
|
belongs_to :tracker
|
||||||
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
||||||
@@ -28,11 +30,11 @@ class Issue < ActiveRecord::Base
|
|||||||
has_many :journals, :as => :journalized, :dependent => :destroy
|
has_many :journals, :as => :journalized, :dependent => :destroy
|
||||||
has_many :time_entries, :dependent => :delete_all
|
has_many :time_entries, :dependent => :delete_all
|
||||||
has_and_belongs_to_many :changesets, :order => "#{Changeset.table_name}.committed_on ASC, #{Changeset.table_name}.id ASC"
|
has_and_belongs_to_many :changesets, :order => "#{Changeset.table_name}.committed_on ASC, #{Changeset.table_name}.id ASC"
|
||||||
|
|
||||||
has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
|
has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
|
||||||
has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
|
has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
|
||||||
|
|
||||||
acts_as_nested_set :scope => 'root_id'
|
acts_as_nested_set :scope => 'root_id', :dependent => :destroy
|
||||||
acts_as_attachable :after_remove => :attachment_removed
|
acts_as_attachable :after_remove => :attachment_removed
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
acts_as_watchable
|
acts_as_watchable
|
||||||
@@ -43,7 +45,7 @@ class Issue < ActiveRecord::Base
|
|||||||
acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
|
acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
|
||||||
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
|
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
|
||||||
:type => Proc.new {|o| 'issue' + (o.closed? ? ' closed' : '') }
|
:type => Proc.new {|o| 'issue' + (o.closed? ? ' closed' : '') }
|
||||||
|
|
||||||
acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]},
|
acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]},
|
||||||
:author_key => :author_id
|
:author_key => :author_id
|
||||||
|
|
||||||
@@ -58,26 +60,64 @@ class Issue < ActiveRecord::Base
|
|||||||
validates_numericality_of :estimated_hours, :allow_nil => true
|
validates_numericality_of :estimated_hours, :allow_nil => true
|
||||||
|
|
||||||
named_scope :visible, lambda {|*args| { :include => :project,
|
named_scope :visible, lambda {|*args| { :include => :project,
|
||||||
:conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
|
:conditions => Issue.visible_condition(args.shift || User.current, *args) } }
|
||||||
|
|
||||||
named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status
|
named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status
|
||||||
|
|
||||||
named_scope :recently_updated, :order => "#{self.table_name}.updated_on DESC"
|
named_scope :recently_updated, :order => "#{Issue.table_name}.updated_on DESC"
|
||||||
named_scope :with_limit, lambda { |limit| { :limit => limit} }
|
named_scope :with_limit, lambda { |limit| { :limit => limit} }
|
||||||
named_scope :on_active_project, :include => [:status, :project, :tracker],
|
named_scope :on_active_project, :include => [:status, :project, :tracker],
|
||||||
:conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
|
:conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
|
||||||
|
|
||||||
|
named_scope :without_version, lambda {
|
||||||
|
{
|
||||||
|
:conditions => { :fixed_version_id => nil}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
named_scope :with_query, lambda {|query|
|
||||||
|
{
|
||||||
|
:conditions => Query.merge_conditions(query.statement)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
before_create :default_assign
|
before_create :default_assign
|
||||||
before_save :reschedule_following_issues, :close_duplicates, :update_done_ratio_from_issue_status
|
before_save :close_duplicates, :update_done_ratio_from_issue_status
|
||||||
after_save :update_nested_set_attributes, :update_parent_attributes, :create_journal
|
after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
|
||||||
after_destroy :destroy_children
|
|
||||||
after_destroy :update_parent_attributes
|
after_destroy :update_parent_attributes
|
||||||
|
|
||||||
|
# Returns a SQL conditions string used to find all issues visible by the specified user
|
||||||
|
def self.visible_condition(user, options={})
|
||||||
|
Project.allowed_to_condition(user, :view_issues, options) do |role, user|
|
||||||
|
case role.issues_visibility
|
||||||
|
when 'all'
|
||||||
|
nil
|
||||||
|
when 'default'
|
||||||
|
"(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id = #{user.id})"
|
||||||
|
when 'own'
|
||||||
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id = #{user.id})"
|
||||||
|
else
|
||||||
|
'1=0'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Returns true if usr or current user is allowed to view the issue
|
# Returns true if usr or current user is allowed to view the issue
|
||||||
def visible?(usr=nil)
|
def visible?(usr=nil)
|
||||||
(usr || User.current).allowed_to?(:view_issues, self.project)
|
(usr || User.current).allowed_to?(:view_issues, self.project) do |role, user|
|
||||||
|
case role.issues_visibility
|
||||||
|
when 'all'
|
||||||
|
true
|
||||||
|
when 'default'
|
||||||
|
!self.is_private? || self.author == user || self.assigned_to == user
|
||||||
|
when 'own'
|
||||||
|
self.author == user || self.assigned_to == user
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_initialize
|
def after_initialize
|
||||||
if new_record?
|
if new_record?
|
||||||
# set default values for new records only
|
# set default values for new records only
|
||||||
@@ -85,12 +125,12 @@ class Issue < ActiveRecord::Base
|
|||||||
self.priority ||= IssuePriority.default
|
self.priority ||= IssuePriority.default
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
||||||
def available_custom_fields
|
def available_custom_fields
|
||||||
(project && tracker) ? project.all_issue_custom_fields.select {|c| tracker.custom_fields.include? c } : []
|
(project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_from(arg)
|
def copy_from(arg)
|
||||||
issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
|
issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
|
||||||
self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
|
self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
|
||||||
@@ -98,7 +138,7 @@ class Issue < ActiveRecord::Base
|
|||||||
self.status = issue.status
|
self.status = issue.status
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# Moves/copies an issue to a new project and tracker
|
# Moves/copies an issue to a new project and tracker
|
||||||
# Returns the moved/copied issue on success, false on failure
|
# Returns the moved/copied issue on success, false on failure
|
||||||
def move_to_project(*args)
|
def move_to_project(*args)
|
||||||
@@ -106,11 +146,11 @@ class Issue < ActiveRecord::Base
|
|||||||
move_to_project_without_transaction(*args) || raise(ActiveRecord::Rollback)
|
move_to_project_without_transaction(*args) || raise(ActiveRecord::Rollback)
|
||||||
end || false
|
end || false
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_to_project_without_transaction(new_project, new_tracker = nil, options = {})
|
def move_to_project_without_transaction(new_project, new_tracker = nil, options = {})
|
||||||
options ||= {}
|
options ||= {}
|
||||||
issue = options[:copy] ? self.class.new.copy_from(self) : self
|
issue = options[:copy] ? self.class.new.copy_from(self) : self
|
||||||
|
|
||||||
if new_project && issue.project_id != new_project.id
|
if new_project && issue.project_id != new_project.id
|
||||||
# delete issue relations
|
# delete issue relations
|
||||||
unless Setting.cross_project_issue_relations?
|
unless Setting.cross_project_issue_relations?
|
||||||
@@ -135,6 +175,7 @@ class Issue < ActiveRecord::Base
|
|||||||
issue.reset_custom_values!
|
issue.reset_custom_values!
|
||||||
end
|
end
|
||||||
if options[:copy]
|
if options[:copy]
|
||||||
|
issue.author = User.current
|
||||||
issue.custom_field_values = self.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
|
issue.custom_field_values = self.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
|
||||||
issue.status = if options[:attributes] && options[:attributes][:status_id]
|
issue.status = if options[:attributes] && options[:attributes][:status_id]
|
||||||
IssueStatus.find_by_id(options[:attributes][:status_id])
|
IssueStatus.find_by_id(options[:attributes][:status_id])
|
||||||
@@ -147,10 +188,16 @@ class Issue < ActiveRecord::Base
|
|||||||
issue.attributes = options[:attributes]
|
issue.attributes = options[:attributes]
|
||||||
end
|
end
|
||||||
if issue.save
|
if issue.save
|
||||||
unless options[:copy]
|
if options[:copy]
|
||||||
|
if current_journal && current_journal.notes.present?
|
||||||
|
issue.init_journal(current_journal.user, current_journal.notes)
|
||||||
|
issue.current_journal.notify = false
|
||||||
|
issue.save
|
||||||
|
end
|
||||||
|
else
|
||||||
# Manually update project_id on related time entries
|
# Manually update project_id on related time entries
|
||||||
TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
|
TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
|
||||||
|
|
||||||
issue.children.each do |child|
|
issue.children.each do |child|
|
||||||
unless child.move_to_project_without_transaction(new_project)
|
unless child.move_to_project_without_transaction(new_project)
|
||||||
# Move failed and transaction was rollback'd
|
# Move failed and transaction was rollback'd
|
||||||
@@ -168,7 +215,7 @@ class Issue < ActiveRecord::Base
|
|||||||
self.status = nil
|
self.status = nil
|
||||||
write_attribute(:status_id, sid)
|
write_attribute(:status_id, sid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def priority_id=(pid)
|
def priority_id=(pid)
|
||||||
self.priority = nil
|
self.priority = nil
|
||||||
write_attribute(:priority_id, pid)
|
write_attribute(:priority_id, pid)
|
||||||
@@ -181,6 +228,13 @@ class Issue < ActiveRecord::Base
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def description=(arg)
|
||||||
|
if arg.is_a?(String)
|
||||||
|
arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
|
||||||
|
end
|
||||||
|
write_attribute(:description, arg)
|
||||||
|
end
|
||||||
|
|
||||||
# Overrides attributes= so that tracker_id gets assigned first
|
# Overrides attributes= so that tracker_id gets assigned first
|
||||||
def attributes_with_tracker_first=(new_attributes, *args)
|
def attributes_with_tracker_first=(new_attributes, *args)
|
||||||
return if new_attributes.nil?
|
return if new_attributes.nil?
|
||||||
@@ -192,60 +246,81 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
# Do not redefine alias chain on reload (see #4838)
|
# Do not redefine alias chain on reload (see #4838)
|
||||||
alias_method_chain(:attributes=, :tracker_first) unless method_defined?(:attributes_without_tracker_first=)
|
alias_method_chain(:attributes=, :tracker_first) unless method_defined?(:attributes_without_tracker_first=)
|
||||||
|
|
||||||
def estimated_hours=(h)
|
def estimated_hours=(h)
|
||||||
write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
|
write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
|
||||||
end
|
end
|
||||||
|
|
||||||
SAFE_ATTRIBUTES = %w(
|
safe_attributes 'tracker_id',
|
||||||
tracker_id
|
'status_id',
|
||||||
status_id
|
'parent_issue_id',
|
||||||
parent_issue_id
|
'category_id',
|
||||||
category_id
|
'assigned_to_id',
|
||||||
assigned_to_id
|
'priority_id',
|
||||||
priority_id
|
'fixed_version_id',
|
||||||
fixed_version_id
|
'subject',
|
||||||
subject
|
'description',
|
||||||
description
|
'start_date',
|
||||||
start_date
|
'due_date',
|
||||||
due_date
|
'done_ratio',
|
||||||
done_ratio
|
'estimated_hours',
|
||||||
estimated_hours
|
'custom_field_values',
|
||||||
custom_field_values
|
'custom_fields',
|
||||||
lock_version
|
'lock_version',
|
||||||
) unless const_defined?(:SAFE_ATTRIBUTES)
|
:if => lambda {|issue, user| issue.new_record? || user.allowed_to?(:edit_issues, issue.project) }
|
||||||
|
|
||||||
|
safe_attributes 'status_id',
|
||||||
|
'assigned_to_id',
|
||||||
|
'fixed_version_id',
|
||||||
|
'done_ratio',
|
||||||
|
:if => lambda {|issue, user| issue.new_statuses_allowed_to(user).any? }
|
||||||
|
|
||||||
|
safe_attributes 'is_private',
|
||||||
|
:if => lambda {|issue, user|
|
||||||
|
user.allowed_to?(:set_issues_private, issue.project) ||
|
||||||
|
(issue.author == user && user.allowed_to?(:set_own_issues_private, issue.project))
|
||||||
|
}
|
||||||
|
|
||||||
# Safely sets attributes
|
# Safely sets attributes
|
||||||
# Should be called from controllers instead of #attributes=
|
# Should be called from controllers instead of #attributes=
|
||||||
# attr_accessible is too rough because we still want things like
|
# attr_accessible is too rough because we still want things like
|
||||||
# Issue.new(:project => foo) to work
|
# Issue.new(:project => foo) to work
|
||||||
# TODO: move workflow/permission checks from controllers to here
|
# TODO: move workflow/permission checks from controllers to here
|
||||||
def safe_attributes=(attrs, user=User.current)
|
def safe_attributes=(attrs, user=User.current)
|
||||||
return if attrs.nil?
|
return unless attrs.is_a?(Hash)
|
||||||
attrs = attrs.reject {|k,v| !SAFE_ATTRIBUTES.include?(k)}
|
|
||||||
|
# User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
|
||||||
|
attrs = delete_unsafe_attributes(attrs, user)
|
||||||
|
return if attrs.empty?
|
||||||
|
|
||||||
|
# Tracker must be set before since new_statuses_allowed_to depends on it.
|
||||||
|
if t = attrs.delete('tracker_id')
|
||||||
|
self.tracker_id = t
|
||||||
|
end
|
||||||
|
|
||||||
if attrs['status_id']
|
if attrs['status_id']
|
||||||
unless new_statuses_allowed_to(user).collect(&:id).include?(attrs['status_id'].to_i)
|
unless new_statuses_allowed_to(user).collect(&:id).include?(attrs['status_id'].to_i)
|
||||||
attrs.delete('status_id')
|
attrs.delete('status_id')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless leaf?
|
unless leaf?
|
||||||
attrs.reject! {|k,v| %w(priority_id done_ratio start_date due_date estimated_hours).include?(k)}
|
attrs.reject! {|k,v| %w(priority_id done_ratio start_date due_date estimated_hours).include?(k)}
|
||||||
end
|
end
|
||||||
|
|
||||||
if attrs.has_key?('parent_issue_id')
|
if attrs.has_key?('parent_issue_id')
|
||||||
if !user.allowed_to?(:manage_subtasks, project)
|
if !user.allowed_to?(:manage_subtasks, project)
|
||||||
attrs.delete('parent_issue_id')
|
attrs.delete('parent_issue_id')
|
||||||
elsif !attrs['parent_issue_id'].blank?
|
elsif !attrs['parent_issue_id'].blank?
|
||||||
attrs.delete('parent_issue_id') unless Issue.visible(user).exists?(attrs['parent_issue_id'])
|
attrs.delete('parent_issue_id') unless Issue.visible(user).exists?(attrs['parent_issue_id'].to_i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.attributes = attrs
|
self.attributes = attrs
|
||||||
end
|
end
|
||||||
|
|
||||||
def done_ratio
|
def done_ratio
|
||||||
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio?
|
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
|
||||||
status.default_done_ratio
|
status.default_done_ratio
|
||||||
else
|
else
|
||||||
read_attribute(:done_ratio)
|
read_attribute(:done_ratio)
|
||||||
@@ -259,20 +334,20 @@ class Issue < ActiveRecord::Base
|
|||||||
def self.use_field_for_done_ratio?
|
def self.use_field_for_done_ratio?
|
||||||
Setting.issue_done_ratio == 'issue_field'
|
Setting.issue_done_ratio == 'issue_field'
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
|
if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
|
||||||
errors.add :due_date, :not_a_date
|
errors.add :due_date, :not_a_date
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.due_date and self.start_date and self.due_date < self.start_date
|
if self.due_date and self.start_date and self.due_date < self.start_date
|
||||||
errors.add :due_date, :greater_than_start_date
|
errors.add :due_date, :greater_than_start_date
|
||||||
end
|
end
|
||||||
|
|
||||||
if start_date && soonest_start && start_date < soonest_start
|
if start_date && soonest_start && start_date < soonest_start
|
||||||
errors.add :start_date, :invalid
|
errors.add :start_date, :invalid
|
||||||
end
|
end
|
||||||
|
|
||||||
if fixed_version
|
if fixed_version
|
||||||
if !assignable_versions.include?(fixed_version)
|
if !assignable_versions.include?(fixed_version)
|
||||||
errors.add :fixed_version_id, :inclusion
|
errors.add :fixed_version_id, :inclusion
|
||||||
@@ -280,14 +355,14 @@ class Issue < ActiveRecord::Base
|
|||||||
errors.add_to_base I18n.t(:error_can_not_reopen_issue_on_closed_version)
|
errors.add_to_base I18n.t(:error_can_not_reopen_issue_on_closed_version)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks that the issue can not be added/moved to a disabled tracker
|
# Checks that the issue can not be added/moved to a disabled tracker
|
||||||
if project && (tracker_id_changed? || project_id_changed?)
|
if project && (tracker_id_changed? || project_id_changed?)
|
||||||
unless project.trackers.include?(tracker)
|
unless project.trackers.include?(tracker)
|
||||||
errors.add :tracker_id, :inclusion
|
errors.add :tracker_id, :inclusion
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks parent issue assignment
|
# Checks parent issue assignment
|
||||||
if @parent_issue
|
if @parent_issue
|
||||||
if @parent_issue.project_id != project_id
|
if @parent_issue.project_id != project_id
|
||||||
@@ -304,15 +379,15 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set the done_ratio using the status if that setting is set. This will keep the done_ratios
|
# Set the done_ratio using the status if that setting is set. This will keep the done_ratios
|
||||||
# even if the user turns off the setting later
|
# even if the user turns off the setting later
|
||||||
def update_done_ratio_from_issue_status
|
def update_done_ratio_from_issue_status
|
||||||
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio?
|
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
|
||||||
self.done_ratio = status.default_done_ratio
|
self.done_ratio = status.default_done_ratio
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_journal(user, notes = "")
|
def init_journal(user, notes = "")
|
||||||
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
|
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
|
||||||
@issue_before_change = self.clone
|
@issue_before_change = self.clone
|
||||||
@@ -323,12 +398,12 @@ class Issue < ActiveRecord::Base
|
|||||||
updated_on_will_change!
|
updated_on_will_change!
|
||||||
@current_journal
|
@current_journal
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return true if the issue is closed, otherwise false
|
# Return true if the issue is closed, otherwise false
|
||||||
def closed?
|
def closed?
|
||||||
self.status.is_closed?
|
self.status.is_closed?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return true if the issue is being reopened
|
# Return true if the issue is being reopened
|
||||||
def reopened?
|
def reopened?
|
||||||
if !new_record? && status_id_changed?
|
if !new_record? && status_id_changed?
|
||||||
@@ -352,48 +427,69 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if the issue is overdue
|
# Returns true if the issue is overdue
|
||||||
def overdue?
|
def overdue?
|
||||||
!due_date.nil? && (due_date < Date.today) && !status.is_closed?
|
!due_date.nil? && (due_date < Date.today) && !status.is_closed?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Is the amount of work done less than it should for the due date
|
||||||
|
def behind_schedule?
|
||||||
|
return false if start_date.nil? || due_date.nil?
|
||||||
|
done_date = start_date + ((due_date - start_date+1)* done_ratio/100).floor
|
||||||
|
return done_date <= Date.today
|
||||||
|
end
|
||||||
|
|
||||||
|
# Does this issue have children?
|
||||||
|
def children?
|
||||||
|
!leaf?
|
||||||
|
end
|
||||||
|
|
||||||
# Users the issue can be assigned to
|
# Users the issue can be assigned to
|
||||||
def assignable_users
|
def assignable_users
|
||||||
project.assignable_users
|
users = project.assignable_users
|
||||||
|
users << author if author
|
||||||
|
users << assigned_to if assigned_to
|
||||||
|
users.uniq.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# Versions that the issue can be assigned to
|
# Versions that the issue can be assigned to
|
||||||
def assignable_versions
|
def assignable_versions
|
||||||
@assignable_versions ||= (project.shared_versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort
|
@assignable_versions ||= (project.shared_versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if this issue is blocked by another issue that is still open
|
# Returns true if this issue is blocked by another issue that is still open
|
||||||
def blocked?
|
def blocked?
|
||||||
!relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
|
!relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of status that user is able to apply
|
# Returns an array of status that user is able to apply
|
||||||
def new_statuses_allowed_to(user, include_default=false)
|
def new_statuses_allowed_to(user, include_default=false)
|
||||||
statuses = status.find_new_statuses_allowed_to(user.roles_for_project(project), tracker)
|
statuses = status.find_new_statuses_allowed_to(
|
||||||
|
user.roles_for_project(project),
|
||||||
|
tracker,
|
||||||
|
author == user,
|
||||||
|
assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id
|
||||||
|
)
|
||||||
statuses << status unless statuses.empty?
|
statuses << status unless statuses.empty?
|
||||||
statuses << IssueStatus.default if include_default
|
statuses << IssueStatus.default if include_default
|
||||||
statuses = statuses.uniq.sort
|
statuses = statuses.uniq.sort
|
||||||
blocked? ? statuses.reject {|s| s.is_closed?} : statuses
|
blocked? ? statuses.reject {|s| s.is_closed?} : statuses
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the mail adresses of users that should be notified
|
# Returns the mail adresses of users that should be notified
|
||||||
def recipients
|
def recipients
|
||||||
notified = project.notified_users
|
notified = project.notified_users
|
||||||
# Author and assignee are always notified unless they have been locked
|
# Author and assignee are always notified unless they have been
|
||||||
notified << author if author && author.active?
|
# locked or don't want to be notified
|
||||||
notified << assigned_to if assigned_to && assigned_to.active?
|
notified << author if author && author.active? && author.notify_about?(self)
|
||||||
|
notified << assigned_to if assigned_to && assigned_to.active? && assigned_to.notify_about?(self)
|
||||||
notified.uniq!
|
notified.uniq!
|
||||||
# Remove users that can not view the issue
|
# Remove users that can not view the issue
|
||||||
notified.reject! {|user| !visible?(user)}
|
notified.reject! {|user| !visible?(user)}
|
||||||
notified.collect(&:mail)
|
notified.collect(&:mail)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the total number of hours spent on this issue and its descendants
|
# Returns the total number of hours spent on this issue and its descendants
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
@@ -402,47 +498,50 @@ class Issue < ActiveRecord::Base
|
|||||||
def spent_hours
|
def spent_hours
|
||||||
@spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours", :include => :time_entries).to_f || 0.0
|
@spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours", :include => :time_entries).to_f || 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
def relations
|
def relations
|
||||||
(relations_from + relations_to).sort
|
(relations_from + relations_to).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_dependent_issues
|
def all_dependent_issues(except=[])
|
||||||
|
except << self
|
||||||
dependencies = []
|
dependencies = []
|
||||||
relations_from.each do |relation|
|
relations_from.each do |relation|
|
||||||
dependencies << relation.issue_to
|
if relation.issue_to && !except.include?(relation.issue_to)
|
||||||
dependencies += relation.issue_to.all_dependent_issues
|
dependencies << relation.issue_to
|
||||||
|
dependencies += relation.issue_to.all_dependent_issues(except)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
dependencies
|
dependencies
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of issues that duplicate this one
|
# Returns an array of issues that duplicate this one
|
||||||
def duplicates
|
def duplicates
|
||||||
relations_to.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.issue_from}
|
relations_to.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.issue_from}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the due date or the target due date if any
|
# Returns the due date or the target due date if any
|
||||||
# Used on gantt chart
|
# Used on gantt chart
|
||||||
def due_before
|
def due_before
|
||||||
due_date || (fixed_version ? fixed_version.effective_date : nil)
|
due_date || (fixed_version ? fixed_version.effective_date : nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the time scheduled for this issue.
|
# Returns the time scheduled for this issue.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# Start Date: 2/26/09, End Date: 3/04/09
|
# Start Date: 2/26/09, End Date: 3/04/09
|
||||||
# duration => 6
|
# duration => 6
|
||||||
def duration
|
def duration
|
||||||
(start_date && due_date) ? due_date - start_date : 0
|
(start_date && due_date) ? due_date - start_date : 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def soonest_start
|
def soonest_start
|
||||||
@soonest_start ||= (
|
@soonest_start ||= (
|
||||||
relations_to.collect{|relation| relation.successor_soonest_start} +
|
relations_to.collect{|relation| relation.successor_soonest_start} +
|
||||||
ancestors.collect(&:soonest_start)
|
ancestors.collect(&:soonest_start)
|
||||||
).compact.max
|
).compact.max
|
||||||
end
|
end
|
||||||
|
|
||||||
def reschedule_after(date)
|
def reschedule_after(date)
|
||||||
return if date.nil?
|
return if date.nil?
|
||||||
if leaf?
|
if leaf?
|
||||||
@@ -456,7 +555,7 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def <=>(issue)
|
def <=>(issue)
|
||||||
if issue.nil?
|
if issue.nil?
|
||||||
-1
|
-1
|
||||||
@@ -466,16 +565,19 @@ class Issue < ActiveRecord::Base
|
|||||||
(lft || 0) <=> (issue.lft || 0)
|
(lft || 0) <=> (issue.lft || 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"#{tracker} ##{id}: #{subject}"
|
"#{tracker} ##{id}: #{subject}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a string of css classes that apply to the issue
|
# Returns a string of css classes that apply to the issue
|
||||||
def css_classes
|
def css_classes
|
||||||
s = "issue status-#{status.position} priority-#{priority.position}"
|
s = "issue status-#{status.position} priority-#{priority.position}"
|
||||||
s << ' closed' if closed?
|
s << ' closed' if closed?
|
||||||
s << ' overdue' if overdue?
|
s << ' overdue' if overdue?
|
||||||
|
s << ' child' if child?
|
||||||
|
s << ' parent' unless leaf?
|
||||||
|
s << ' private' if is_private?
|
||||||
s << ' created-by-me' if User.current.logged? && author_id == User.current.id
|
s << ' created-by-me' if User.current.logged? && author_id == User.current.id
|
||||||
s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
|
s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
|
||||||
s
|
s
|
||||||
@@ -485,7 +587,7 @@ class Issue < ActiveRecord::Base
|
|||||||
# Returns false if save fails
|
# Returns false if save fails
|
||||||
def save_issue_with_child_records(params, existing_time_entry=nil)
|
def save_issue_with_child_records(params, existing_time_entry=nil)
|
||||||
Issue.transaction do
|
Issue.transaction do
|
||||||
if params[:time_entry] && params[:time_entry][:hours].present? && User.current.allowed_to?(:log_time, project)
|
if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, project)
|
||||||
@time_entry = existing_time_entry || TimeEntry.new
|
@time_entry = existing_time_entry || TimeEntry.new
|
||||||
@time_entry.project = project
|
@time_entry.project = project
|
||||||
@time_entry.issue = self
|
@time_entry.issue = self
|
||||||
@@ -494,10 +596,10 @@ class Issue < ActiveRecord::Base
|
|||||||
@time_entry.attributes = params[:time_entry]
|
@time_entry.attributes = params[:time_entry]
|
||||||
self.time_entries << @time_entry
|
self.time_entries << @time_entry
|
||||||
end
|
end
|
||||||
|
|
||||||
if valid?
|
if valid?
|
||||||
attachments = Attachment.attach_files(self, params[:attachments])
|
attachments = Attachment.attach_files(self, params[:attachments])
|
||||||
|
|
||||||
attachments[:files].each {|a| @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
|
attachments[:files].each {|a| @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
|
||||||
# TODO: Rename hook
|
# TODO: Rename hook
|
||||||
Redmine::Hook.call_hook(:controller_issues_edit_before_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
|
Redmine::Hook.call_hook(:controller_issues_edit_before_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
|
||||||
@@ -522,7 +624,7 @@ class Issue < ActiveRecord::Base
|
|||||||
# Update issues assigned to the version
|
# Update issues assigned to the version
|
||||||
update_versions(["#{Issue.table_name}.fixed_version_id = ?", version.id])
|
update_versions(["#{Issue.table_name}.fixed_version_id = ?", version.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Unassigns issues from versions that are no longer shared
|
# Unassigns issues from versions that are no longer shared
|
||||||
# after +project+ was moved
|
# after +project+ was moved
|
||||||
def self.update_versions_from_hierarchy_change(project)
|
def self.update_versions_from_hierarchy_change(project)
|
||||||
@@ -540,7 +642,7 @@ class Issue < ActiveRecord::Base
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def parent_issue_id
|
def parent_issue_id
|
||||||
if instance_variable_defined? :@parent_issue
|
if instance_variable_defined? :@parent_issue
|
||||||
@parent_issue.nil? ? nil : @parent_issue.id
|
@parent_issue.nil? ? nil : @parent_issue.id
|
||||||
@@ -589,17 +691,19 @@ class Issue < ActiveRecord::Base
|
|||||||
def self.by_subproject(project)
|
def self.by_subproject(project)
|
||||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||||
s.is_closed as closed,
|
s.is_closed as closed,
|
||||||
i.project_id as project_id,
|
#{Issue.table_name}.project_id as project_id,
|
||||||
count(i.id) as total
|
count(#{Issue.table_name}.id) as total
|
||||||
from
|
from
|
||||||
#{Issue.table_name} i, #{IssueStatus.table_name} s
|
#{Issue.table_name}, #{Project.table_name}, #{IssueStatus.table_name} s
|
||||||
where
|
where
|
||||||
i.status_id=s.id
|
#{Issue.table_name}.status_id=s.id
|
||||||
and i.project_id IN (#{project.descendants.active.collect{|p| p.id}.join(',')})
|
and #{Issue.table_name}.project_id = #{Project.table_name}.id
|
||||||
group by s.id, s.is_closed, i.project_id") if project.descendants.active.any?
|
and #{visible_condition(User.current, :project => project, :with_subprojects => true)}
|
||||||
|
and #{Issue.table_name}.project_id <> #{project.id}
|
||||||
|
group by s.id, s.is_closed, #{Issue.table_name}.project_id") if project.descendants.active.any?
|
||||||
end
|
end
|
||||||
# End ReportsController extraction
|
# End ReportsController extraction
|
||||||
|
|
||||||
# Returns an array of projects that current user can move issues to
|
# Returns an array of projects that current user can move issues to
|
||||||
def self.allowed_target_projects_on_move
|
def self.allowed_target_projects_on_move
|
||||||
projects = []
|
projects = []
|
||||||
@@ -615,9 +719,9 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
projects
|
projects
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def update_nested_set_attributes
|
def update_nested_set_attributes
|
||||||
if root_id.nil?
|
if root_id.nil?
|
||||||
# issue was just created
|
# issue was just created
|
||||||
@@ -664,7 +768,7 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
remove_instance_variable(:@parent_issue) if instance_variable_defined?(:@parent_issue)
|
remove_instance_variable(:@parent_issue) if instance_variable_defined?(:@parent_issue)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_parent_attributes
|
def update_parent_attributes
|
||||||
recalculate_attributes_for(parent_id) if parent_id
|
recalculate_attributes_for(parent_id) if parent_id
|
||||||
end
|
end
|
||||||
@@ -675,16 +779,16 @@ class Issue < ActiveRecord::Base
|
|||||||
if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :include => :priority)
|
if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :include => :priority)
|
||||||
p.priority = IssuePriority.find_by_position(priority_position)
|
p.priority = IssuePriority.find_by_position(priority_position)
|
||||||
end
|
end
|
||||||
|
|
||||||
# start/due dates = lowest/highest dates of children
|
# start/due dates = lowest/highest dates of children
|
||||||
p.start_date = p.children.minimum(:start_date)
|
p.start_date = p.children.minimum(:start_date)
|
||||||
p.due_date = p.children.maximum(:due_date)
|
p.due_date = p.children.maximum(:due_date)
|
||||||
if p.start_date && p.due_date && p.due_date < p.start_date
|
if p.start_date && p.due_date && p.due_date < p.start_date
|
||||||
p.start_date, p.due_date = p.due_date, p.start_date
|
p.start_date, p.due_date = p.due_date, p.start_date
|
||||||
end
|
end
|
||||||
|
|
||||||
# done ratio = weighted average ratio of leaves
|
# done ratio = weighted average ratio of leaves
|
||||||
unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio?
|
unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio
|
||||||
leaves_count = p.leaves.count
|
leaves_count = p.leaves.count
|
||||||
if leaves_count > 0
|
if leaves_count > 0
|
||||||
average = p.leaves.average(:estimated_hours).to_f
|
average = p.leaves.average(:estimated_hours).to_f
|
||||||
@@ -696,24 +800,16 @@ class Issue < ActiveRecord::Base
|
|||||||
p.done_ratio = progress.round
|
p.done_ratio = progress.round
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# estimate = sum of leaves estimates
|
# estimate = sum of leaves estimates
|
||||||
p.estimated_hours = p.leaves.sum(:estimated_hours).to_f
|
p.estimated_hours = p.leaves.sum(:estimated_hours).to_f
|
||||||
p.estimated_hours = nil if p.estimated_hours == 0.0
|
p.estimated_hours = nil if p.estimated_hours == 0.0
|
||||||
|
|
||||||
# ancestors will be recursively updated
|
# ancestors will be recursively updated
|
||||||
p.save(false)
|
p.save(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_children
|
|
||||||
unless leaf?
|
|
||||||
children.each do |child|
|
|
||||||
child.destroy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Update issues so their versions are not pointing to a
|
# Update issues so their versions are not pointing to a
|
||||||
# fixed_version that is not shared with the issue's project
|
# fixed_version that is not shared with the issue's project
|
||||||
def self.update_versions(conditions=nil)
|
def self.update_versions(conditions=nil)
|
||||||
@@ -733,7 +829,7 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Callback on attachment deletion
|
# Callback on attachment deletion
|
||||||
def attachment_removed(obj)
|
def attachment_removed(obj)
|
||||||
journal = init_journal(User.current)
|
journal = init_journal(User.current)
|
||||||
@@ -742,7 +838,7 @@ class Issue < ActiveRecord::Base
|
|||||||
:old_value => obj.filename)
|
:old_value => obj.filename)
|
||||||
journal.save
|
journal.save
|
||||||
end
|
end
|
||||||
|
|
||||||
# Default assignment based on category
|
# Default assignment based on category
|
||||||
def default_assign
|
def default_assign
|
||||||
if assigned_to.nil? && category && category.assigned_to
|
if assigned_to.nil? && category && category.assigned_to
|
||||||
@@ -775,27 +871,30 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Saves the changes in a Journal
|
# Saves the changes in a Journal
|
||||||
# Called after_save
|
# Called after_save
|
||||||
def create_journal
|
def create_journal
|
||||||
if @current_journal
|
if @current_journal
|
||||||
# attributes changes
|
# attributes changes
|
||||||
(Issue.column_names - %w(id description root_id lft rgt lock_version created_on updated_on)).each {|c|
|
(Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
|
||||||
|
before = @issue_before_change.send(c)
|
||||||
|
after = send(c)
|
||||||
|
next if before == after || (before.blank? && after.blank?)
|
||||||
@current_journal.details << JournalDetail.new(:property => 'attr',
|
@current_journal.details << JournalDetail.new(:property => 'attr',
|
||||||
:prop_key => c,
|
:prop_key => c,
|
||||||
:old_value => @issue_before_change.send(c),
|
:old_value => @issue_before_change.send(c),
|
||||||
:value => send(c)) unless send(c)==@issue_before_change.send(c)
|
:value => send(c))
|
||||||
}
|
}
|
||||||
# custom fields changes
|
# custom fields changes
|
||||||
custom_values.each {|c|
|
custom_values.each {|c|
|
||||||
next if (@custom_values_before_change[c.custom_field_id]==c.value ||
|
next if (@custom_values_before_change[c.custom_field_id]==c.value ||
|
||||||
(@custom_values_before_change[c.custom_field_id].blank? && c.value.blank?))
|
(@custom_values_before_change[c.custom_field_id].blank? && c.value.blank?))
|
||||||
@current_journal.details << JournalDetail.new(:property => 'cf',
|
@current_journal.details << JournalDetail.new(:property => 'cf',
|
||||||
:prop_key => c.custom_field_id,
|
:prop_key => c.custom_field_id,
|
||||||
:old_value => @custom_values_before_change[c.custom_field_id],
|
:old_value => @custom_values_before_change[c.custom_field_id],
|
||||||
:value => c.value)
|
:value => c.value)
|
||||||
}
|
}
|
||||||
@current_journal.save
|
@current_journal.save
|
||||||
# reset current journal
|
# reset current journal
|
||||||
init_journal @current_journal.user, @current_journal.notes
|
init_journal @current_journal.user, @current_journal.notes
|
||||||
@@ -814,20 +913,19 @@ class Issue < ActiveRecord::Base
|
|||||||
select_field = options.delete(:field)
|
select_field = options.delete(:field)
|
||||||
joins = options.delete(:joins)
|
joins = options.delete(:joins)
|
||||||
|
|
||||||
where = "i.#{select_field}=j.id"
|
where = "#{Issue.table_name}.#{select_field}=j.id"
|
||||||
|
|
||||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||||
s.is_closed as closed,
|
s.is_closed as closed,
|
||||||
j.id as #{select_field},
|
j.id as #{select_field},
|
||||||
count(i.id) as total
|
count(#{Issue.table_name}.id) as total
|
||||||
from
|
from
|
||||||
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{joins} as j
|
#{Issue.table_name}, #{Project.table_name}, #{IssueStatus.table_name} s, #{joins} j
|
||||||
where
|
where
|
||||||
i.status_id=s.id
|
#{Issue.table_name}.status_id=s.id
|
||||||
and #{where}
|
and #{where}
|
||||||
and i.project_id=#{project.id}
|
and #{Issue.table_name}.project_id=#{Project.table_name}.id
|
||||||
|
and #{visible_condition(User.current, :project => project)}
|
||||||
group by s.id, s.is_closed, j.id")
|
group by s.id, s.is_closed, j.id")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -24,6 +24,8 @@ class IssueCategory < ActiveRecord::Base
|
|||||||
validates_uniqueness_of :name, :scope => [:project_id]
|
validates_uniqueness_of :name, :scope => [:project_id]
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
|
|
||||||
|
named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||||
|
|
||||||
alias :destroy_without_reassign :destroy
|
alias :destroy_without_reassign :destroy
|
||||||
|
|
||||||
# Destroy the category
|
# Destroy the category
|
||||||
|
|||||||
@@ -47,7 +47,12 @@ class IssueRelation < ActiveRecord::Base
|
|||||||
if issue_from && issue_to
|
if issue_from && issue_to
|
||||||
errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
|
errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
|
||||||
errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations?
|
errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations?
|
||||||
errors.add_to_base :circular_dependency if issue_to.all_dependent_issues.include? issue_from
|
#detect circular dependencies depending wether the relation should be reversed
|
||||||
|
if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse]
|
||||||
|
errors.add_to_base :circular_dependency if issue_from.all_dependent_issues.include? issue_to
|
||||||
|
else
|
||||||
|
errors.add_to_base :circular_dependency if issue_to.all_dependent_issues.include? issue_from
|
||||||
|
end
|
||||||
errors.add_to_base :cant_link_an_issue_with_a_descendant if issue_from.is_descendant_of?(issue_to) || issue_from.is_ancestor_of?(issue_to)
|
errors.add_to_base :cant_link_an_issue_with_a_descendant if issue_from.is_descendant_of?(issue_to) || issue_from.is_ancestor_of?(issue_to)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -84,14 +89,15 @@ class IssueRelation < ActiveRecord::Base
|
|||||||
|
|
||||||
def set_issue_to_dates
|
def set_issue_to_dates
|
||||||
soonest_start = self.successor_soonest_start
|
soonest_start = self.successor_soonest_start
|
||||||
if soonest_start
|
if soonest_start && issue_to
|
||||||
issue_to.reschedule_after(soonest_start)
|
issue_to.reschedule_after(soonest_start)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def successor_soonest_start
|
def successor_soonest_start
|
||||||
return nil unless (TYPE_PRECEDES == self.relation_type) && (issue_from.start_date || issue_from.due_date)
|
if (TYPE_PRECEDES == self.relation_type) && delay && issue_from && (issue_from.start_date || issue_from.due_date)
|
||||||
(issue_from.due_date || issue_from.start_date) + 1 + delay
|
(issue_from.due_date || issue_from.start_date) + 1 + delay
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def <=>(relation)
|
def <=>(relation)
|
||||||
|
|||||||
+28
-17
@@ -17,14 +17,17 @@
|
|||||||
|
|
||||||
class IssueStatus < ActiveRecord::Base
|
class IssueStatus < ActiveRecord::Base
|
||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
has_many :workflows, :foreign_key => "old_status_id", :dependent => :delete_all
|
has_many :workflows, :foreign_key => "old_status_id"
|
||||||
acts_as_list
|
acts_as_list
|
||||||
|
|
||||||
|
before_destroy :delete_workflows
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name
|
validates_uniqueness_of :name
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
|
||||||
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
|
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
|
||||||
|
|
||||||
|
named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||||
|
|
||||||
def after_save
|
def after_save
|
||||||
IssueStatus.update_all("is_default=#{connection.quoted_false}", ['id <> ?', id]) if self.is_default?
|
IssueStatus.update_all("is_default=#{connection.quoted_false}", ['id <> ?', id]) if self.is_default?
|
||||||
@@ -49,10 +52,15 @@ class IssueStatus < ActiveRecord::Base
|
|||||||
|
|
||||||
# Returns an array of all statuses the given role can switch to
|
# Returns an array of all statuses the given role can switch to
|
||||||
# Uses association cache when called more than one time
|
# Uses association cache when called more than one time
|
||||||
def new_statuses_allowed_to(roles, tracker)
|
def new_statuses_allowed_to(roles, tracker, author=false, assignee=false)
|
||||||
if roles && tracker
|
if roles && tracker
|
||||||
role_ids = roles.collect(&:id)
|
role_ids = roles.collect(&:id)
|
||||||
new_statuses = workflows.select {|w| role_ids.include?(w.role_id) && w.tracker_id == tracker.id}.collect{|w| w.new_status}.compact.sort
|
transitions = workflows.select do |w|
|
||||||
|
role_ids.include?(w.role_id) &&
|
||||||
|
w.tracker_id == tracker.id &&
|
||||||
|
((!w.author && !w.assignee) || (author && w.author) || (assignee && w.assignee))
|
||||||
|
end
|
||||||
|
transitions.collect{|w| w.new_status}.compact.sort
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
@@ -60,24 +68,22 @@ class IssueStatus < ActiveRecord::Base
|
|||||||
|
|
||||||
# Same thing as above but uses a database query
|
# Same thing as above but uses a database query
|
||||||
# More efficient than the previous method if called just once
|
# More efficient than the previous method if called just once
|
||||||
def find_new_statuses_allowed_to(roles, tracker)
|
def find_new_statuses_allowed_to(roles, tracker, author=false, assignee=false)
|
||||||
if roles && tracker
|
if roles.present? && tracker
|
||||||
|
conditions = "(author = :false AND assignee = :false)"
|
||||||
|
conditions << " OR author = :true" if author
|
||||||
|
conditions << " OR assignee = :true" if assignee
|
||||||
|
|
||||||
workflows.find(:all,
|
workflows.find(:all,
|
||||||
:include => :new_status,
|
:include => :new_status,
|
||||||
:conditions => { :role_id => roles.collect(&:id),
|
:conditions => ["role_id IN (:role_ids) AND tracker_id = :tracker_id AND (#{conditions})",
|
||||||
:tracker_id => tracker.id}).collect{ |w| w.new_status }.compact.sort
|
{:role_ids => roles.collect(&:id), :tracker_id => tracker.id, :true => true, :false => false}
|
||||||
|
]
|
||||||
|
).collect{|w| w.new_status}.compact.sort
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_status_allowed_to?(status, roles, tracker)
|
|
||||||
if status && roles && tracker
|
|
||||||
!workflows.find(:first, :conditions => {:new_status_id => status.id, :role_id => roles.collect(&:id), :tracker_id => tracker.id}).nil?
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def <=>(status)
|
def <=>(status)
|
||||||
position <=> status.position
|
position <=> status.position
|
||||||
@@ -89,4 +95,9 @@ private
|
|||||||
def check_integrity
|
def check_integrity
|
||||||
raise "Can't delete status" if Issue.find(:first, :conditions => ["status_id=?", self.id])
|
raise "Can't delete status" if Issue.find(:first, :conditions => ["status_id=?", self.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Deletes associated workflows
|
||||||
|
def delete_workflows
|
||||||
|
Workflow.delete_all(["old_status_id = :id OR new_status_id = :id", {:id => id}])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+23
-3
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -32,12 +32,16 @@ class Journal < ActiveRecord::Base
|
|||||||
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id, :anchor => "change-#{o.id}"}}
|
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id, :anchor => "change-#{o.id}"}}
|
||||||
|
|
||||||
acts_as_activity_provider :type => 'issues',
|
acts_as_activity_provider :type => 'issues',
|
||||||
:permission => :view_issues,
|
|
||||||
:author_key => :user_id,
|
:author_key => :user_id,
|
||||||
:find_options => {:include => [{:issue => :project}, :details, :user],
|
:find_options => {:include => [{:issue => :project}, :details, :user],
|
||||||
:conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" +
|
:conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" +
|
||||||
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"}
|
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"}
|
||||||
|
|
||||||
|
named_scope :visible, lambda {|*args| {
|
||||||
|
:include => {:issue => :project},
|
||||||
|
:conditions => Issue.visible_condition(args.shift || User.current, *args)
|
||||||
|
}}
|
||||||
|
|
||||||
def save(*args)
|
def save(*args)
|
||||||
# Do not save an empty journal
|
# Do not save an empty journal
|
||||||
(details.empty? && notes.blank?) ? false : super
|
(details.empty? && notes.blank?) ? false : super
|
||||||
@@ -65,4 +69,20 @@ class Journal < ActiveRecord::Base
|
|||||||
def attachments
|
def attachments
|
||||||
journalized.respond_to?(:attachments) ? journalized.attachments : nil
|
journalized.respond_to?(:attachments) ? journalized.attachments : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns a string of css classes
|
||||||
|
def css_classes
|
||||||
|
s = 'journal'
|
||||||
|
s << ' has-notes' unless notes.blank?
|
||||||
|
s << ' has-details' unless details.blank?
|
||||||
|
s
|
||||||
|
end
|
||||||
|
|
||||||
|
def notify?
|
||||||
|
@notify != false
|
||||||
|
end
|
||||||
|
|
||||||
|
def notify=(arg)
|
||||||
|
@notify = arg
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -17,9 +17,22 @@
|
|||||||
|
|
||||||
class JournalDetail < ActiveRecord::Base
|
class JournalDetail < ActiveRecord::Base
|
||||||
belongs_to :journal
|
belongs_to :journal
|
||||||
|
before_save :normalize_values
|
||||||
|
|
||||||
def before_save
|
private
|
||||||
self.value = value[0..254] if value && value.is_a?(String)
|
|
||||||
self.old_value = old_value[0..254] if old_value && old_value.is_a?(String)
|
def normalize_values
|
||||||
|
self.value = normalize(value)
|
||||||
|
self.old_value = normalize(old_value)
|
||||||
|
end
|
||||||
|
|
||||||
|
def normalize(v)
|
||||||
|
if v == true
|
||||||
|
"1"
|
||||||
|
elsif v == false
|
||||||
|
"0"
|
||||||
|
else
|
||||||
|
v
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -17,6 +17,13 @@
|
|||||||
|
|
||||||
class JournalObserver < ActiveRecord::Observer
|
class JournalObserver < ActiveRecord::Observer
|
||||||
def after_create(journal)
|
def after_create(journal)
|
||||||
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
|
if journal.notify? &&
|
||||||
|
(Setting.notified_events.include?('issue_updated') ||
|
||||||
|
(Setting.notified_events.include?('issue_note_added') && journal.notes.present?) ||
|
||||||
|
(Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) ||
|
||||||
|
(Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?)
|
||||||
|
)
|
||||||
|
Mailer.deliver_issue_edit(journal)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+108
-78
@@ -1,44 +1,45 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class MailHandler < ActionMailer::Base
|
class MailHandler < ActionMailer::Base
|
||||||
include ActionView::Helpers::SanitizeHelper
|
include ActionView::Helpers::SanitizeHelper
|
||||||
|
include Redmine::I18n
|
||||||
|
|
||||||
class UnauthorizedAction < StandardError; end
|
class UnauthorizedAction < StandardError; end
|
||||||
class MissingInformation < StandardError; end
|
class MissingInformation < StandardError; end
|
||||||
|
|
||||||
attr_reader :email, :user
|
attr_reader :email, :user
|
||||||
|
|
||||||
def self.receive(email, options={})
|
def self.receive(email, options={})
|
||||||
@@handler_options = options.dup
|
@@handler_options = options.dup
|
||||||
|
|
||||||
@@handler_options[:issue] ||= {}
|
@@handler_options[:issue] ||= {}
|
||||||
|
|
||||||
@@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip) if @@handler_options[:allow_override].is_a?(String)
|
@@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip) if @@handler_options[:allow_override].is_a?(String)
|
||||||
@@handler_options[:allow_override] ||= []
|
@@handler_options[:allow_override] ||= []
|
||||||
# Project needs to be overridable if not specified
|
# Project needs to be overridable if not specified
|
||||||
@@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project)
|
@@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project)
|
||||||
# Status overridable by default
|
# Status overridable by default
|
||||||
@@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
|
@@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
|
||||||
|
|
||||||
@@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
|
@@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
|
||||||
super email
|
super email
|
||||||
end
|
end
|
||||||
|
|
||||||
# Processes incoming emails
|
# Processes incoming emails
|
||||||
# Returns the created object (eg. an issue, a message) or false
|
# Returns the created object (eg. an issue, a message) or false
|
||||||
def receive(email)
|
def receive(email)
|
||||||
@@ -77,13 +78,13 @@ class MailHandler < ActionMailer::Base
|
|||||||
User.current = @user
|
User.current = @user
|
||||||
dispatch
|
dispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
|
MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
|
||||||
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
|
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
|
||||||
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
|
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
|
||||||
|
|
||||||
def dispatch
|
def dispatch
|
||||||
headers = [email.in_reply_to, email.references].flatten.compact
|
headers = [email.in_reply_to, email.references].flatten.compact
|
||||||
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
|
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
|
||||||
@@ -99,7 +100,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
elsif m = email.subject.match(MESSAGE_REPLY_SUBJECT_RE)
|
elsif m = email.subject.match(MESSAGE_REPLY_SUBJECT_RE)
|
||||||
receive_message_reply(m[1].to_i)
|
receive_message_reply(m[1].to_i)
|
||||||
else
|
else
|
||||||
receive_issue
|
dispatch_to_default
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
# TODO: send a email to the user
|
# TODO: send a email to the user
|
||||||
@@ -112,40 +113,28 @@ class MailHandler < ActionMailer::Base
|
|||||||
logger.error "MailHandler: unauthorized attempt from #{user}" if logger
|
logger.error "MailHandler: unauthorized attempt from #{user}" if logger
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def dispatch_to_default
|
||||||
|
receive_issue
|
||||||
|
end
|
||||||
|
|
||||||
# Creates a new issue
|
# Creates a new issue
|
||||||
def receive_issue
|
def receive_issue
|
||||||
project = target_project
|
project = target_project
|
||||||
tracker = (get_keyword(:tracker) && project.trackers.find_by_name(get_keyword(:tracker))) || project.trackers.find(:first)
|
|
||||||
category = (get_keyword(:category) && project.issue_categories.find_by_name(get_keyword(:category)))
|
|
||||||
priority = (get_keyword(:priority) && IssuePriority.find_by_name(get_keyword(:priority)))
|
|
||||||
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
|
|
||||||
assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true)))
|
|
||||||
due_date = get_keyword(:due_date, :override => true)
|
|
||||||
start_date = get_keyword(:start_date, :override => true)
|
|
||||||
|
|
||||||
# check permission
|
# check permission
|
||||||
unless @@handler_options[:no_permission_check]
|
unless @@handler_options[:no_permission_check]
|
||||||
raise UnauthorizedAction unless user.allowed_to?(:add_issues, project)
|
raise UnauthorizedAction unless user.allowed_to?(:add_issues, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :due_date => due_date, :start_date => start_date, :assigned_to => assigned_to)
|
issue = Issue.new(:author => user, :project => project)
|
||||||
# check workflow
|
issue.safe_attributes = issue_attributes_from_keywords(issue)
|
||||||
if status && issue.new_statuses_allowed_to(user).include?(status)
|
issue.safe_attributes = {'custom_field_values' => custom_field_values_from_keywords(issue)}
|
||||||
issue.status = status
|
issue.subject = email.subject.to_s.chomp[0,255]
|
||||||
end
|
|
||||||
issue.subject = email.subject.chomp[0,255]
|
|
||||||
if issue.subject.blank?
|
if issue.subject.blank?
|
||||||
issue.subject = '(no subject)'
|
issue.subject = '(no subject)'
|
||||||
end
|
end
|
||||||
# custom fields
|
|
||||||
issue.custom_field_values = issue.available_custom_fields.inject({}) do |h, c|
|
|
||||||
if value = get_keyword(c.name, :override => true)
|
|
||||||
h[c.id] = value
|
|
||||||
end
|
|
||||||
h
|
|
||||||
end
|
|
||||||
issue.description = cleaned_up_text_body
|
issue.description = cleaned_up_text_body
|
||||||
|
|
||||||
# add To and Cc as watchers before saving so the watchers can reply to Redmine
|
# add To and Cc as watchers before saving so the watchers can reply to Redmine
|
||||||
add_watchers(issue)
|
add_watchers(issue)
|
||||||
issue.save!
|
issue.save!
|
||||||
@@ -153,47 +142,29 @@ class MailHandler < ActionMailer::Base
|
|||||||
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
|
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
|
||||||
issue
|
issue
|
||||||
end
|
end
|
||||||
|
|
||||||
def target_project
|
|
||||||
# TODO: other ways to specify project:
|
|
||||||
# * parse the email To field
|
|
||||||
# * specific project (eg. Setting.mail_handler_target_project)
|
|
||||||
target = Project.find_by_identifier(get_keyword(:project))
|
|
||||||
raise MissingInformation.new('Unable to determine target project') if target.nil?
|
|
||||||
target
|
|
||||||
end
|
|
||||||
|
|
||||||
# Adds a note to an existing issue
|
# Adds a note to an existing issue
|
||||||
def receive_issue_reply(issue_id)
|
def receive_issue_reply(issue_id)
|
||||||
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
|
|
||||||
due_date = get_keyword(:due_date, :override => true)
|
|
||||||
start_date = get_keyword(:start_date, :override => true)
|
|
||||||
assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true)))
|
|
||||||
|
|
||||||
issue = Issue.find_by_id(issue_id)
|
issue = Issue.find_by_id(issue_id)
|
||||||
return unless issue
|
return unless issue
|
||||||
# check permission
|
# check permission
|
||||||
unless @@handler_options[:no_permission_check]
|
unless @@handler_options[:no_permission_check]
|
||||||
raise UnauthorizedAction unless user.allowed_to?(:add_issue_notes, issue.project) || user.allowed_to?(:edit_issues, issue.project)
|
raise UnauthorizedAction unless user.allowed_to?(:add_issue_notes, issue.project) || user.allowed_to?(:edit_issues, issue.project)
|
||||||
raise UnauthorizedAction unless status.nil? || user.allowed_to?(:edit_issues, issue.project)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# add the note
|
# ignore CLI-supplied defaults for new issues
|
||||||
journal = issue.init_journal(user, cleaned_up_text_body)
|
@@handler_options[:issue].clear
|
||||||
|
|
||||||
|
journal = issue.init_journal(user)
|
||||||
|
issue.safe_attributes = issue_attributes_from_keywords(issue)
|
||||||
|
issue.safe_attributes = {'custom_field_values' => custom_field_values_from_keywords(issue)}
|
||||||
|
journal.notes = cleaned_up_text_body
|
||||||
add_attachments(issue)
|
add_attachments(issue)
|
||||||
# check workflow
|
|
||||||
if status && issue.new_statuses_allowed_to(user).include?(status)
|
|
||||||
issue.status = status
|
|
||||||
end
|
|
||||||
issue.start_date = start_date if start_date
|
|
||||||
issue.due_date = due_date if due_date
|
|
||||||
issue.assigned_to = assigned_to if assigned_to
|
|
||||||
|
|
||||||
issue.save!
|
issue.save!
|
||||||
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
|
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
|
||||||
journal
|
journal
|
||||||
end
|
end
|
||||||
|
|
||||||
# Reply will be added to the issue
|
# Reply will be added to the issue
|
||||||
def receive_journal_reply(journal_id)
|
def receive_journal_reply(journal_id)
|
||||||
journal = Journal.find_by_id(journal_id)
|
journal = Journal.find_by_id(journal_id)
|
||||||
@@ -201,17 +172,17 @@ class MailHandler < ActionMailer::Base
|
|||||||
receive_issue_reply(journal.journalized_id)
|
receive_issue_reply(journal.journalized_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Receives a reply to a forum message
|
# Receives a reply to a forum message
|
||||||
def receive_message_reply(message_id)
|
def receive_message_reply(message_id)
|
||||||
message = Message.find_by_id(message_id)
|
message = Message.find_by_id(message_id)
|
||||||
if message
|
if message
|
||||||
message = message.root
|
message = message.root
|
||||||
|
|
||||||
unless @@handler_options[:no_permission_check]
|
unless @@handler_options[:no_permission_check]
|
||||||
raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project)
|
raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project)
|
||||||
end
|
end
|
||||||
|
|
||||||
if !message.locked?
|
if !message.locked?
|
||||||
reply = Message.new(:subject => email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
|
reply = Message.new(:subject => email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
|
||||||
:content => cleaned_up_text_body)
|
:content => cleaned_up_text_body)
|
||||||
@@ -225,9 +196,9 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_attachments(obj)
|
def add_attachments(obj)
|
||||||
if email.has_attachments?
|
if email.attachments && email.attachments.any?
|
||||||
email.attachments.each do |attachment|
|
email.attachments.each do |attachment|
|
||||||
Attachment.create(:container => obj,
|
Attachment.create(:container => obj,
|
||||||
:file => attachment,
|
:file => attachment,
|
||||||
@@ -236,7 +207,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds To and Cc as watchers of the given object if the sender has the
|
# Adds To and Cc as watchers of the given object if the sender has the
|
||||||
# appropriate permission
|
# appropriate permission
|
||||||
def add_watchers(obj)
|
def add_watchers(obj)
|
||||||
@@ -248,22 +219,81 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_keyword(attr, options={})
|
def get_keyword(attr, options={})
|
||||||
@keywords ||= {}
|
@keywords ||= {}
|
||||||
if @keywords.has_key?(attr)
|
if @keywords.has_key?(attr)
|
||||||
@keywords[attr]
|
@keywords[attr]
|
||||||
else
|
else
|
||||||
@keywords[attr] = begin
|
@keywords[attr] = begin
|
||||||
if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr.to_s.humanize}[ \t]*:[ \t]*(.+)\s*$/i, '')
|
if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && (v = extract_keyword!(plain_text_body, attr, options[:format]))
|
||||||
$1.strip
|
v
|
||||||
elsif !@@handler_options[:issue][attr].blank?
|
elsif !@@handler_options[:issue][attr].blank?
|
||||||
@@handler_options[:issue][attr]
|
@@handler_options[:issue][attr]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Destructively extracts the value for +attr+ in +text+
|
||||||
|
# Returns nil if no matching keyword found
|
||||||
|
def extract_keyword!(text, attr, format=nil)
|
||||||
|
keys = [attr.to_s.humanize]
|
||||||
|
if attr.is_a?(Symbol)
|
||||||
|
keys << l("field_#{attr}", :default => '', :locale => user.language) if user && user.language.present?
|
||||||
|
keys << l("field_#{attr}", :default => '', :locale => Setting.default_language) if Setting.default_language.present?
|
||||||
|
end
|
||||||
|
keys.reject! {|k| k.blank?}
|
||||||
|
keys.collect! {|k| Regexp.escape(k)}
|
||||||
|
format ||= '.+'
|
||||||
|
text.gsub!(/^(#{keys.join('|')})[ \t]*:[ \t]*(#{format})\s*$/i, '')
|
||||||
|
$2 && $2.strip
|
||||||
|
end
|
||||||
|
|
||||||
|
def target_project
|
||||||
|
# TODO: other ways to specify project:
|
||||||
|
# * parse the email To field
|
||||||
|
# * specific project (eg. Setting.mail_handler_target_project)
|
||||||
|
target = Project.find_by_identifier(get_keyword(:project))
|
||||||
|
raise MissingInformation.new('Unable to determine target project') if target.nil?
|
||||||
|
target
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns a Hash of issue attributes extracted from keywords in the email body
|
||||||
|
def issue_attributes_from_keywords(issue)
|
||||||
|
assigned_to = (k = get_keyword(:assigned_to, :override => true)) && find_user_from_keyword(k)
|
||||||
|
assigned_to = nil if assigned_to && !issue.assignable_users.include?(assigned_to)
|
||||||
|
|
||||||
|
attrs = {
|
||||||
|
'tracker_id' => (k = get_keyword(:tracker)) && issue.project.trackers.named(k).first.try(:id),
|
||||||
|
'status_id' => (k = get_keyword(:status)) && IssueStatus.named(k).first.try(:id),
|
||||||
|
'priority_id' => (k = get_keyword(:priority)) && IssuePriority.named(k).first.try(:id),
|
||||||
|
'category_id' => (k = get_keyword(:category)) && issue.project.issue_categories.named(k).first.try(:id),
|
||||||
|
'assigned_to_id' => assigned_to.try(:id),
|
||||||
|
'fixed_version_id' => (k = get_keyword(:fixed_version, :override => true)) && issue.project.shared_versions.named(k).first.try(:id),
|
||||||
|
'start_date' => get_keyword(:start_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
|
||||||
|
'due_date' => get_keyword(:due_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
|
||||||
|
'estimated_hours' => get_keyword(:estimated_hours, :override => true),
|
||||||
|
'done_ratio' => get_keyword(:done_ratio, :override => true, :format => '(\d|10)?0')
|
||||||
|
}.delete_if {|k, v| v.blank? }
|
||||||
|
|
||||||
|
if issue.new_record? && attrs['tracker_id'].nil?
|
||||||
|
attrs['tracker_id'] = issue.project.trackers.find(:first).try(:id)
|
||||||
|
end
|
||||||
|
|
||||||
|
attrs
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns a Hash of issue custom field values extracted from keywords in the email body
|
||||||
|
def custom_field_values_from_keywords(customized)
|
||||||
|
customized.custom_field_values.inject({}) do |h, v|
|
||||||
|
if value = get_keyword(v.custom_field.name, :override => true)
|
||||||
|
h[v.custom_field.id.to_s] = value
|
||||||
|
end
|
||||||
|
h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Returns the text/plain part of the email
|
# Returns the text/plain part of the email
|
||||||
# If not found (eg. HTML-only email), returns the body with tags removed
|
# If not found (eg. HTML-only email), returns the body with tags removed
|
||||||
def plain_text_body
|
def plain_text_body
|
||||||
@@ -284,7 +314,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
@plain_text_body.strip!
|
@plain_text_body.strip!
|
||||||
@plain_text_body
|
@plain_text_body
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleaned_up_text_body
|
def cleaned_up_text_body
|
||||||
cleanup_body(plain_text_body)
|
cleanup_body(plain_text_body)
|
||||||
end
|
end
|
||||||
@@ -292,19 +322,19 @@ class MailHandler < ActionMailer::Base
|
|||||||
def self.full_sanitizer
|
def self.full_sanitizer
|
||||||
@full_sanitizer ||= HTML::FullSanitizer.new
|
@full_sanitizer ||= HTML::FullSanitizer.new
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a user account for the +email+ sender
|
# Creates a user account for the +email+ sender
|
||||||
def self.create_user_from_email(email)
|
def self.create_user_from_email(email)
|
||||||
addr = email.from_addrs.to_a.first
|
addr = email.from_addrs.to_a.first
|
||||||
if addr && !addr.spec.blank?
|
if addr && !addr.spec.blank?
|
||||||
user = User.new
|
user = User.new
|
||||||
user.mail = addr.spec
|
user.mail = addr.spec
|
||||||
|
|
||||||
names = addr.name.blank? ? addr.spec.gsub(/@.*$/, '').split('.') : addr.name.split
|
names = addr.name.blank? ? addr.spec.gsub(/@.*$/, '').split('.') : addr.name.split
|
||||||
user.firstname = names.shift
|
user.firstname = names.shift
|
||||||
user.lastname = names.join(' ')
|
user.lastname = names.join(' ')
|
||||||
user.lastname = '-' if user.lastname.blank?
|
user.lastname = '-' if user.lastname.blank?
|
||||||
|
|
||||||
user.login = user.mail
|
user.login = user.mail
|
||||||
user.password = ActiveSupport::SecureRandom.hex(5)
|
user.password = ActiveSupport::SecureRandom.hex(5)
|
||||||
user.language = Setting.default_language
|
user.language = Setting.default_language
|
||||||
@@ -313,12 +343,12 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Removes the email body of text after the truncation configurations.
|
# Removes the email body of text after the truncation configurations.
|
||||||
def cleanup_body(body)
|
def cleanup_body(body)
|
||||||
delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).reject(&:blank?).map {|s| Regexp.escape(s)}
|
delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).reject(&:blank?).map {|s| Regexp.escape(s)}
|
||||||
unless delimiters.empty?
|
unless delimiters.empty?
|
||||||
regex = Regexp.new("^(#{ delimiters.join('|') })\s*[\r\n].*", Regexp::MULTILINE)
|
regex = Regexp.new("^[> ]*(#{ delimiters.join('|') })\s*[\r\n].*", Regexp::MULTILINE)
|
||||||
body = body.gsub(regex, '')
|
body = body.gsub(regex, '')
|
||||||
end
|
end
|
||||||
body.strip
|
body.strip
|
||||||
|
|||||||
+56
-33
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -15,6 +15,8 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
require 'ar_condition'
|
||||||
|
|
||||||
class Mailer < ActionMailer::Base
|
class Mailer < ActionMailer::Base
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
helper :application
|
helper :application
|
||||||
@@ -29,7 +31,7 @@ class Mailer < ActionMailer::Base
|
|||||||
h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank?
|
h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank?
|
||||||
{ :host => h, :protocol => Setting.protocol }
|
{ :host => h, :protocol => Setting.protocol }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email recipients of the added issue.
|
# Builds a tmail object used to email recipients of the added issue.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
@@ -80,10 +82,10 @@ class Mailer < ActionMailer::Base
|
|||||||
def reminder(user, issues, days)
|
def reminder(user, issues, days)
|
||||||
set_language_if_valid user.language
|
set_language_if_valid user.language
|
||||||
recipients user.mail
|
recipients user.mail
|
||||||
subject l(:mail_subject_reminder, issues.size)
|
subject l(:mail_subject_reminder, :count => issues.size, :days => days)
|
||||||
body :issues => issues,
|
body :issues => issues,
|
||||||
:days => days,
|
:days => days,
|
||||||
:issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.id, :sort_key => 'due_date', :sort_order => 'asc')
|
:issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.id, :sort => 'due_date:asc')
|
||||||
render_multipart('reminder', body)
|
render_multipart('reminder', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -112,11 +114,11 @@ class Mailer < ActionMailer::Base
|
|||||||
added_to_url = ''
|
added_to_url = ''
|
||||||
case container.class.name
|
case container.class.name
|
||||||
when 'Project'
|
when 'Project'
|
||||||
added_to_url = url_for(:controller => 'projects', :action => 'list_files', :id => container)
|
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
|
||||||
added_to = "#{l(:label_project)}: #{container}"
|
added_to = "#{l(:label_project)}: #{container}"
|
||||||
recipients container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
|
recipients container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
|
||||||
when 'Version'
|
when 'Version'
|
||||||
added_to_url = url_for(:controller => 'projects', :action => 'list_files', :id => container.project_id)
|
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
|
||||||
added_to = "#{l(:label_version)}: #{container.name}"
|
added_to = "#{l(:label_version)}: #{container.name}"
|
||||||
recipients container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
|
recipients container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
|
||||||
when 'Document'
|
when 'Document'
|
||||||
@@ -131,7 +133,7 @@ class Mailer < ActionMailer::Base
|
|||||||
:added_to_url => added_to_url
|
:added_to_url => added_to_url
|
||||||
render_multipart('attachments_added', body)
|
render_multipart('attachments_added', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email recipients of a news' project when a news item is added.
|
# Builds a tmail object used to email recipients of a news' project when a news item is added.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
@@ -147,7 +149,25 @@ class Mailer < ActionMailer::Base
|
|||||||
render_multipart('news_added', body)
|
render_multipart('news_added', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email the recipients of the specified message that was posted.
|
# Builds a tmail object used to email recipients of a news' project when a news comment is added.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# news_comment_added(comment) => tmail object
|
||||||
|
# Mailer.news_comment_added(comment) => sends an email to the news' project recipients
|
||||||
|
def news_comment_added(comment)
|
||||||
|
news = comment.commented
|
||||||
|
redmine_headers 'Project' => news.project.identifier
|
||||||
|
message_id comment
|
||||||
|
recipients news.recipients
|
||||||
|
cc news.watcher_recipients
|
||||||
|
subject "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
||||||
|
body :news => news,
|
||||||
|
:comment => comment,
|
||||||
|
:news_url => url_for(:controller => 'news', :action => 'show', :id => news)
|
||||||
|
render_multipart('news_comment_added', body)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Builds a tmail object used to email the recipients of the specified message that was posted.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# message_posted(message) => tmail object
|
# message_posted(message) => tmail object
|
||||||
@@ -164,8 +184,8 @@ class Mailer < ActionMailer::Base
|
|||||||
:message_url => url_for(message.event_url)
|
:message_url => url_for(message.event_url)
|
||||||
render_multipart('message_posted', body)
|
render_multipart('message_posted', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email the recipients of a project of the specified wiki content was added.
|
# Builds a tmail object used to email the recipients of a project of the specified wiki content was added.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# wiki_content_added(wiki_content) => tmail object
|
# wiki_content_added(wiki_content) => tmail object
|
||||||
@@ -176,13 +196,13 @@ class Mailer < ActionMailer::Base
|
|||||||
message_id wiki_content
|
message_id wiki_content
|
||||||
recipients wiki_content.recipients
|
recipients wiki_content.recipients
|
||||||
cc(wiki_content.page.wiki.watcher_recipients - recipients)
|
cc(wiki_content.page.wiki.watcher_recipients - recipients)
|
||||||
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :page => wiki_content.page.pretty_title)}"
|
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}"
|
||||||
body :wiki_content => wiki_content,
|
body :wiki_content => wiki_content,
|
||||||
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title)
|
:wiki_content_url => url_for(:controller => 'wiki', :action => 'show', :project_id => wiki_content.project, :id => wiki_content.page.title)
|
||||||
render_multipart('wiki_content_added', body)
|
render_multipart('wiki_content_added', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email the recipients of a project of the specified wiki content was updated.
|
# Builds a tmail object used to email the recipients of a project of the specified wiki content was updated.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# wiki_content_updated(wiki_content) => tmail object
|
# wiki_content_updated(wiki_content) => tmail object
|
||||||
@@ -193,10 +213,10 @@ class Mailer < ActionMailer::Base
|
|||||||
message_id wiki_content
|
message_id wiki_content
|
||||||
recipients wiki_content.recipients
|
recipients wiki_content.recipients
|
||||||
cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients)
|
cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients)
|
||||||
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :page => wiki_content.page.pretty_title)}"
|
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}"
|
||||||
body :wiki_content => wiki_content,
|
body :wiki_content => wiki_content,
|
||||||
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title),
|
:wiki_content_url => url_for(:controller => 'wiki', :action => 'show', :project_id => wiki_content.project, :id => wiki_content.page.title),
|
||||||
:wiki_diff_url => url_for(:controller => 'wiki', :action => 'diff', :id => wiki_content.project, :page => wiki_content.page.title, :version => wiki_content.version)
|
:wiki_diff_url => url_for(:controller => 'wiki', :action => 'diff', :project_id => wiki_content.project, :id => wiki_content.page.title, :version => wiki_content.version)
|
||||||
render_multipart('wiki_content_updated', body)
|
render_multipart('wiki_content_updated', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -276,7 +296,7 @@ class Mailer < ActionMailer::Base
|
|||||||
return false if (recipients.nil? || recipients.empty?) &&
|
return false if (recipients.nil? || recipients.empty?) &&
|
||||||
(cc.nil? || cc.empty?) &&
|
(cc.nil? || cc.empty?) &&
|
||||||
(bcc.nil? || bcc.empty?)
|
(bcc.nil? || bcc.empty?)
|
||||||
|
|
||||||
# Set Message-Id and References
|
# Set Message-Id and References
|
||||||
if @message_id_object
|
if @message_id_object
|
||||||
mail.message_id = self.class.message_id_for(@message_id_object)
|
mail.message_id = self.class.message_id_for(@message_id_object)
|
||||||
@@ -284,7 +304,7 @@ class Mailer < ActionMailer::Base
|
|||||||
if @references_objects
|
if @references_objects
|
||||||
mail.references = @references_objects.collect {|o| self.class.message_id_for(o)}
|
mail.references = @references_objects.collect {|o| self.class.message_id_for(o)}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Log errors when raise_delivery_errors is set to false, Rails does not
|
# Log errors when raise_delivery_errors is set to false, Rails does not
|
||||||
raise_errors = self.class.raise_delivery_errors
|
raise_errors = self.class.raise_delivery_errors
|
||||||
self.class.raise_delivery_errors = true
|
self.class.raise_delivery_errors = true
|
||||||
@@ -294,7 +314,7 @@ class Mailer < ActionMailer::Base
|
|||||||
if raise_errors
|
if raise_errors
|
||||||
raise e
|
raise e
|
||||||
elsif mylogger
|
elsif mylogger
|
||||||
mylogger.error "The following error occured while sending email notification: \"#{e.message}\". Check your configuration in config/email.yml."
|
mylogger.error "The following error occured while sending email notification: \"#{e.message}\". Check your configuration in config/configuration.yml."
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
self.class.raise_delivery_errors = raise_errors
|
self.class.raise_delivery_errors = raise_errors
|
||||||
@@ -306,13 +326,16 @@ class Mailer < ActionMailer::Base
|
|||||||
# * :days => how many days in the future to remind about (defaults to 7)
|
# * :days => how many days in the future to remind about (defaults to 7)
|
||||||
# * :tracker => id of tracker for filtering issues (defaults to all trackers)
|
# * :tracker => id of tracker for filtering issues (defaults to all trackers)
|
||||||
# * :project => id or identifier of project to process (defaults to all projects)
|
# * :project => id or identifier of project to process (defaults to all projects)
|
||||||
|
# * :users => array of user ids who should be reminded
|
||||||
def self.reminders(options={})
|
def self.reminders(options={})
|
||||||
days = options[:days] || 7
|
days = options[:days] || 7
|
||||||
project = options[:project] ? Project.find(options[:project]) : nil
|
project = options[:project] ? Project.find(options[:project]) : nil
|
||||||
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
|
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
|
||||||
|
user_ids = options[:users]
|
||||||
|
|
||||||
s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ?", false, days.day.from_now.to_date]
|
s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ?", false, days.day.from_now.to_date]
|
||||||
s << "#{Issue.table_name}.assigned_to_id IS NOT NULL"
|
s << "#{Issue.table_name}.assigned_to_id IS NOT NULL"
|
||||||
|
s << ["#{Issue.table_name}.assigned_to_id IN (?)", user_ids] if user_ids.present?
|
||||||
s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}"
|
s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}"
|
||||||
s << "#{Issue.table_name}.project_id = #{project.id}" if project
|
s << "#{Issue.table_name}.project_id = #{project.id}" if project
|
||||||
s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker
|
s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker
|
||||||
@@ -321,10 +344,10 @@ class Mailer < ActionMailer::Base
|
|||||||
:conditions => s.conditions
|
:conditions => s.conditions
|
||||||
).group_by(&:assigned_to)
|
).group_by(&:assigned_to)
|
||||||
issues_by_assignee.each do |assignee, issues|
|
issues_by_assignee.each do |assignee, issues|
|
||||||
deliver_reminder(assignee, issues, days) unless assignee.nil?
|
deliver_reminder(assignee, issues, days) if assignee && assignee.active?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Activates/desactivates email deliveries during +block+
|
# Activates/desactivates email deliveries during +block+
|
||||||
def self.with_deliveries(enabled = true, &block)
|
def self.with_deliveries(enabled = true, &block)
|
||||||
was_enabled = ActionMailer::Base.perform_deliveries
|
was_enabled = ActionMailer::Base.perform_deliveries
|
||||||
@@ -340,7 +363,7 @@ class Mailer < ActionMailer::Base
|
|||||||
@initial_language = current_language
|
@initial_language = current_language
|
||||||
set_language_if_valid Setting.default_language
|
set_language_if_valid Setting.default_language
|
||||||
from Setting.mail_from
|
from Setting.mail_from
|
||||||
|
|
||||||
# Common headers
|
# Common headers
|
||||||
headers 'X-Mailer' => 'Redmine',
|
headers 'X-Mailer' => 'Redmine',
|
||||||
'X-Redmine-Host' => Setting.host_name,
|
'X-Redmine-Host' => Setting.host_name,
|
||||||
@@ -363,11 +386,11 @@ class Mailer < ActionMailer::Base
|
|||||||
recipients.delete(@author.mail) if recipients
|
recipients.delete(@author.mail) if recipients
|
||||||
cc.delete(@author.mail) if cc
|
cc.delete(@author.mail) if cc
|
||||||
end
|
end
|
||||||
|
|
||||||
notified_users = [recipients, cc].flatten.compact.uniq
|
notified_users = [recipients, cc].flatten.compact.uniq
|
||||||
# Rails would log recipients only, not cc and bcc
|
# Rails would log recipients only, not cc and bcc
|
||||||
mylogger.info "Sending email notification to: #{notified_users.join(', ')}" if mylogger
|
mylogger.info "Sending email notification to: #{notified_users.join(', ')}" if mylogger
|
||||||
|
|
||||||
# Blind carbon copy recipients
|
# Blind carbon copy recipients
|
||||||
if Setting.bcc_recipients?
|
if Setting.bcc_recipients?
|
||||||
bcc(notified_users)
|
bcc(notified_users)
|
||||||
@@ -383,7 +406,7 @@ class Mailer < ActionMailer::Base
|
|||||||
#
|
#
|
||||||
# https://rails.lighthouseapp.com/projects/8994/tickets/2338-actionmailer-mailer-views-and-content-type
|
# https://rails.lighthouseapp.com/projects/8994/tickets/2338-actionmailer-mailer-views-and-content-type
|
||||||
# https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts
|
# https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts
|
||||||
|
|
||||||
def render_multipart(method_name, body)
|
def render_multipart(method_name, body)
|
||||||
if Setting.plain_text_mail?
|
if Setting.plain_text_mail?
|
||||||
content_type "text/plain"
|
content_type "text/plain"
|
||||||
@@ -399,29 +422,29 @@ class Mailer < ActionMailer::Base
|
|||||||
def self.controller_path
|
def self.controller_path
|
||||||
''
|
''
|
||||||
end unless respond_to?('controller_path')
|
end unless respond_to?('controller_path')
|
||||||
|
|
||||||
# Returns a predictable Message-Id for the given object
|
# Returns a predictable Message-Id for the given object
|
||||||
def self.message_id_for(object)
|
def self.message_id_for(object)
|
||||||
# id + timestamp should reduce the odds of a collision
|
# id + timestamp should reduce the odds of a collision
|
||||||
# as far as we don't send multiple emails for the same object
|
# as far as we don't send multiple emails for the same object
|
||||||
timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on)
|
timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on)
|
||||||
hash = "redmine.#{object.class.name.demodulize.underscore}-#{object.id}.#{timestamp.strftime("%Y%m%d%H%M%S")}"
|
hash = "redmine.#{object.class.name.demodulize.underscore}-#{object.id}.#{timestamp.strftime("%Y%m%d%H%M%S")}"
|
||||||
host = Setting.mail_from.to_s.gsub(%r{^.*@}, '')
|
host = Setting.mail_from.to_s.gsub(%r{^.*@}, '')
|
||||||
host = "#{::Socket.gethostname}.redmine" if host.empty?
|
host = "#{::Socket.gethostname}.redmine" if host.empty?
|
||||||
"<#{hash}@#{host}>"
|
"<#{hash}@#{host}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def message_id(object)
|
def message_id(object)
|
||||||
@message_id_object = object
|
@message_id_object = object
|
||||||
end
|
end
|
||||||
|
|
||||||
def references(object)
|
def references(object)
|
||||||
@references_objects ||= []
|
@references_objects ||= []
|
||||||
@references_objects << object
|
@references_objects << object
|
||||||
end
|
end
|
||||||
|
|
||||||
def mylogger
|
def mylogger
|
||||||
RAILS_DEFAULT_LOGGER
|
RAILS_DEFAULT_LOGGER
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class Member < ActiveRecord::Base
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
errors.add_to_base "Role can't be blank" if member_roles.empty? && roles.empty?
|
errors.add_on_empty :role if member_roles.empty? && roles.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
+21
-18
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -21,10 +21,10 @@ class Message < ActiveRecord::Base
|
|||||||
acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
|
acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
|
||||||
acts_as_attachable
|
acts_as_attachable
|
||||||
belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
|
belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
|
||||||
|
|
||||||
acts_as_searchable :columns => ['subject', 'content'],
|
acts_as_searchable :columns => ['subject', 'content'],
|
||||||
:include => {:board => :project},
|
:include => {:board => :project},
|
||||||
:project_key => 'project_id',
|
:project_key => "#{Board.table_name}.project_id",
|
||||||
:date_column => "#{table_name}.created_on"
|
:date_column => "#{table_name}.created_on"
|
||||||
acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
|
acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
|
||||||
:description => :content,
|
:description => :content,
|
||||||
@@ -35,29 +35,32 @@ class Message < ActiveRecord::Base
|
|||||||
acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]},
|
acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]},
|
||||||
:author_key => :author_id
|
:author_key => :author_id
|
||||||
acts_as_watchable
|
acts_as_watchable
|
||||||
|
|
||||||
attr_protected :locked, :sticky
|
attr_protected :locked, :sticky
|
||||||
validates_presence_of :board, :subject, :content
|
validates_presence_of :board, :subject, :content
|
||||||
validates_length_of :subject, :maximum => 255
|
validates_length_of :subject, :maximum => 255
|
||||||
|
|
||||||
after_create :add_author_as_watcher
|
after_create :add_author_as_watcher
|
||||||
|
|
||||||
|
named_scope :visible, lambda {|*args| { :include => {:board => :project},
|
||||||
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
!user.nil? && user.allowed_to?(:view_messages, project)
|
!user.nil? && user.allowed_to?(:view_messages, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_on_create
|
def validate_on_create
|
||||||
# Can not reply to a locked topic
|
# Can not reply to a locked topic
|
||||||
errors.add_to_base 'Topic is locked' if root.locked? && self != root
|
errors.add_to_base 'Topic is locked' if root.locked? && self != root
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_create
|
def after_create
|
||||||
if parent
|
if parent
|
||||||
parent.reload.update_attribute(:last_reply_id, self.id)
|
parent.reload.update_attribute(:last_reply_id, self.id)
|
||||||
end
|
end
|
||||||
board.reset_counters!
|
board.reset_counters!
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_update
|
def after_update
|
||||||
if board_id_changed?
|
if board_id_changed?
|
||||||
Message.update_all("board_id = #{board_id}", ["id = ? OR parent_id = ?", root.id, root.id])
|
Message.update_all("board_id = #{board_id}", ["id = ? OR parent_id = ?", root.id, root.id])
|
||||||
@@ -65,19 +68,19 @@ class Message < ActiveRecord::Base
|
|||||||
Board.reset_counters!(board_id)
|
Board.reset_counters!(board_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy
|
def after_destroy
|
||||||
board.reset_counters!
|
board.reset_counters!
|
||||||
end
|
end
|
||||||
|
|
||||||
def sticky=(arg)
|
def sticky=(arg)
|
||||||
write_attribute :sticky, (arg == true || arg.to_s == '1' ? 1 : 0)
|
write_attribute :sticky, (arg == true || arg.to_s == '1' ? 1 : 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sticky?
|
def sticky?
|
||||||
sticky == 1
|
sticky == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def project
|
def project
|
||||||
board.project
|
board.project
|
||||||
end
|
end
|
||||||
@@ -89,9 +92,9 @@ class Message < ActiveRecord::Base
|
|||||||
def destroyable_by?(usr)
|
def destroyable_by?(usr)
|
||||||
usr && usr.logged? && (usr.allowed_to?(:delete_messages, project) || (self.author == usr && usr.allowed_to?(:delete_own_messages, project)))
|
usr && usr.logged? && (usr.allowed_to?(:delete_messages, project) || (self.author == usr && usr.allowed_to?(:delete_own_messages, project)))
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def add_author_as_watcher
|
def add_author_as_watcher
|
||||||
Watcher.create(:watchable => self.root, :user => author)
|
Watcher.create(:watchable => self.root, :user => author)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|||||||
+20
-6
@@ -1,16 +1,16 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -19,7 +19,7 @@ class News < ActiveRecord::Base
|
|||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
|
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
|
||||||
|
|
||||||
validates_presence_of :title, :description
|
validates_presence_of :title, :description
|
||||||
validates_length_of :title, :maximum => 60
|
validates_length_of :title, :maximum => 60
|
||||||
validates_length_of :summary, :maximum => 255
|
validates_length_of :summary, :maximum => 255
|
||||||
@@ -28,13 +28,27 @@ class News < ActiveRecord::Base
|
|||||||
acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
|
acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
|
||||||
acts_as_activity_provider :find_options => {:include => [:project, :author]},
|
acts_as_activity_provider :find_options => {:include => [:project, :author]},
|
||||||
:author_key => :author_id
|
:author_key => :author_id
|
||||||
|
acts_as_watchable
|
||||||
|
|
||||||
|
after_create :add_author_as_watcher
|
||||||
|
|
||||||
|
named_scope :visible, lambda {|*args| {
|
||||||
|
:include => :project,
|
||||||
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_news, *args)
|
||||||
|
}}
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
!user.nil? && user.allowed_to?(:view_news, project)
|
!user.nil? && user.allowed_to?(:view_news, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns latest news for projects visible by user
|
# returns latest news for projects visible by user
|
||||||
def self.latest(user = User.current, count = 5)
|
def self.latest(user = User.current, count = 5)
|
||||||
find(:all, :limit => count, :conditions => Project.allowed_to_condition(user, :view_news), :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
find(:all, :limit => count, :conditions => Project.allowed_to_condition(user, :view_news), :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def add_author_as_watcher
|
||||||
|
Watcher.create(:watchable => self, :user => author)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ class Principal < ActiveRecord::Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
before_create :set_default_empty_values
|
before_create :set_default_empty_values
|
||||||
|
|
||||||
|
def name(formatter = nil)
|
||||||
|
to_s
|
||||||
|
end
|
||||||
|
|
||||||
def <=>(principal)
|
def <=>(principal)
|
||||||
if self.class.name == principal.class.name
|
if self.class.name == principal.class.name
|
||||||
self.to_s.downcase <=> principal.to_s.downcase
|
self.to_s.downcase <=> principal.to_s.downcase
|
||||||
|
|||||||
+227
-57
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -16,10 +16,15 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class Project < ActiveRecord::Base
|
class Project < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
# Project statuses
|
# Project statuses
|
||||||
STATUS_ACTIVE = 1
|
STATUS_ACTIVE = 1
|
||||||
STATUS_ARCHIVED = 9
|
STATUS_ARCHIVED = 9
|
||||||
|
|
||||||
|
# Maximum length for project identifiers
|
||||||
|
IDENTIFIER_MAX_LENGTH = 100
|
||||||
|
|
||||||
# Specific overidden Activities
|
# Specific overidden Activities
|
||||||
has_many :time_entry_activities
|
has_many :time_entry_activities
|
||||||
has_many :members, :include => [:user, :roles], :conditions => "#{User.table_name}.type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}"
|
has_many :members, :include => [:user, :roles], :conditions => "#{User.table_name}.type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}"
|
||||||
@@ -38,7 +43,7 @@ class Project < ActiveRecord::Base
|
|||||||
has_many :time_entries, :dependent => :delete_all
|
has_many :time_entries, :dependent => :delete_all
|
||||||
has_many :queries, :dependent => :delete_all
|
has_many :queries, :dependent => :delete_all
|
||||||
has_many :documents, :dependent => :destroy
|
has_many :documents, :dependent => :destroy
|
||||||
has_many :news, :dependent => :delete_all, :include => :author
|
has_many :news, :dependent => :destroy, :include => :author
|
||||||
has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name"
|
has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name"
|
||||||
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
||||||
has_one :repository, :dependent => :destroy
|
has_one :repository, :dependent => :destroy
|
||||||
@@ -51,7 +56,7 @@ class Project < ActiveRecord::Base
|
|||||||
:join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
|
:join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
|
||||||
:association_foreign_key => 'custom_field_id'
|
:association_foreign_key => 'custom_field_id'
|
||||||
|
|
||||||
acts_as_nested_set :order => 'name'
|
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||||
acts_as_attachable :view_permission => :view_files,
|
acts_as_attachable :view_permission => :view_files,
|
||||||
:delete_permission => :manage_files
|
:delete_permission => :manage_files
|
||||||
|
|
||||||
@@ -61,25 +66,43 @@ class Project < ActiveRecord::Base
|
|||||||
:url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}},
|
:url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}},
|
||||||
:author => nil
|
:author => nil
|
||||||
|
|
||||||
attr_protected :status, :enabled_module_names
|
attr_protected :status
|
||||||
|
|
||||||
validates_presence_of :name, :identifier
|
validates_presence_of :name, :identifier
|
||||||
validates_uniqueness_of :name, :identifier
|
validates_uniqueness_of :identifier
|
||||||
validates_associated :repository, :wiki
|
validates_associated :repository, :wiki
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 255
|
||||||
validates_length_of :homepage, :maximum => 255
|
validates_length_of :homepage, :maximum => 255
|
||||||
validates_length_of :identifier, :in => 1..20
|
validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH
|
||||||
# donwcase letters, digits, dashes but not digits only
|
# donwcase letters, digits, dashes but not digits only
|
||||||
validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-]*$/, :if => Proc.new { |p| p.identifier_changed? }
|
validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-]*$/, :if => Proc.new { |p| p.identifier_changed? }
|
||||||
# reserved words
|
# reserved words
|
||||||
validates_exclusion_of :identifier, :in => %w( new )
|
validates_exclusion_of :identifier, :in => %w( new )
|
||||||
|
|
||||||
before_destroy :delete_all_members, :destroy_children
|
before_destroy :delete_all_members
|
||||||
|
|
||||||
named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } }
|
named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } }
|
||||||
named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
|
named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
|
||||||
named_scope :all_public, { :conditions => { :is_public => true } }
|
named_scope :all_public, { :conditions => { :is_public => true } }
|
||||||
named_scope :visible, lambda { { :conditions => Project.visible_by(User.current) } }
|
named_scope :visible, lambda {|*args| {:conditions => Project.visible_condition(args.shift || User.current, *args) }}
|
||||||
|
|
||||||
|
def initialize(attributes = nil)
|
||||||
|
super
|
||||||
|
|
||||||
|
initialized = (attributes || {}).stringify_keys
|
||||||
|
if !initialized.key?('identifier') && Setting.sequential_project_identifiers?
|
||||||
|
self.identifier = Project.next_identifier
|
||||||
|
end
|
||||||
|
if !initialized.key?('is_public')
|
||||||
|
self.is_public = Setting.default_projects_public?
|
||||||
|
end
|
||||||
|
if !initialized.key?('enabled_module_names')
|
||||||
|
self.enabled_module_names = Setting.default_projects_modules
|
||||||
|
end
|
||||||
|
if !initialized.key?('trackers') && !initialized.key?('tracker_ids')
|
||||||
|
self.trackers = Tracker.all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def identifier=(identifier)
|
def identifier=(identifier)
|
||||||
super unless identifier_frozen?
|
super unless identifier_frozen?
|
||||||
@@ -92,27 +115,36 @@ class Project < ActiveRecord::Base
|
|||||||
# returns latest created projects
|
# returns latest created projects
|
||||||
# non public projects will be returned only if user is a member of those
|
# non public projects will be returned only if user is a member of those
|
||||||
def self.latest(user=nil, count=5)
|
def self.latest(user=nil, count=5)
|
||||||
find(:all, :limit => count, :conditions => visible_by(user), :order => "created_on DESC")
|
visible(user).find(:all, :limit => count, :order => "created_on DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a SQL :conditions string used to find all active projects for the specified user.
|
# Returns true if the project is visible to +user+ or to the current user.
|
||||||
#
|
def visible?(user=User.current)
|
||||||
# Examples:
|
user.allowed_to?(:view_project, self)
|
||||||
# Projects.visible_by(admin) => "projects.status = 1"
|
|
||||||
# Projects.visible_by(normal_user) => "projects.status = 1 AND projects.is_public = 1"
|
|
||||||
def self.visible_by(user=nil)
|
|
||||||
user ||= User.current
|
|
||||||
if user && user.admin?
|
|
||||||
return "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"
|
|
||||||
elsif user && user.memberships.any?
|
|
||||||
return "#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND (#{Project.table_name}.is_public = #{connection.quoted_true} or #{Project.table_name}.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')}))"
|
|
||||||
else
|
|
||||||
return "#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND #{Project.table_name}.is_public = #{connection.quoted_true}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.visible_by(user=nil)
|
||||||
|
ActiveSupport::Deprecation.warn "Project.visible_by is deprecated and will be removed in Redmine 1.3.0. Use Project.visible_condition instead."
|
||||||
|
visible_condition(user || User.current)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns a SQL conditions string used to find all projects visible by the specified user.
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
# Project.visible_condition(admin) => "projects.status = 1"
|
||||||
|
# Project.visible_condition(normal_user) => "((projects.status = 1) AND (projects.is_public = 1 OR projects.id IN (1,3,4)))"
|
||||||
|
# Project.visible_condition(anonymous) => "((projects.status = 1) AND (projects.is_public = 1))"
|
||||||
|
def self.visible_condition(user, options={})
|
||||||
|
allowed_to_condition(user, :view_project, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns a SQL conditions string used to find all projects for which +user+ has the given +permission+
|
||||||
|
#
|
||||||
|
# Valid options:
|
||||||
|
# * :project => limit the condition to project
|
||||||
|
# * :with_subprojects => limit the condition to project and its subprojects
|
||||||
|
# * :member => limit the condition to the user projects
|
||||||
def self.allowed_to_condition(user, permission, options={})
|
def self.allowed_to_condition(user, permission, options={})
|
||||||
statements = []
|
|
||||||
base_statement = "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"
|
base_statement = "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"
|
||||||
if perm = Redmine::AccessControl.permission(permission)
|
if perm = Redmine::AccessControl.permission(permission)
|
||||||
unless perm.project_module.nil?
|
unless perm.project_module.nil?
|
||||||
@@ -125,24 +157,37 @@ class Project < ActiveRecord::Base
|
|||||||
project_statement << " OR (#{Project.table_name}.lft > #{options[:project].lft} AND #{Project.table_name}.rgt < #{options[:project].rgt})" if options[:with_subprojects]
|
project_statement << " OR (#{Project.table_name}.lft > #{options[:project].lft} AND #{Project.table_name}.rgt < #{options[:project].rgt})" if options[:with_subprojects]
|
||||||
base_statement = "(#{project_statement}) AND (#{base_statement})"
|
base_statement = "(#{project_statement}) AND (#{base_statement})"
|
||||||
end
|
end
|
||||||
|
|
||||||
if user.admin?
|
if user.admin?
|
||||||
# no restriction
|
base_statement
|
||||||
else
|
else
|
||||||
statements << "1=0"
|
statement_by_role = {}
|
||||||
if user.logged?
|
unless options[:member]
|
||||||
if Role.non_member.allowed_to?(permission) && !options[:member]
|
role = user.logged? ? Role.non_member : Role.anonymous
|
||||||
statements << "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
if role.allowed_to?(permission)
|
||||||
|
statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
||||||
end
|
end
|
||||||
allowed_project_ids = user.memberships.select {|m| m.roles.detect {|role| role.allowed_to?(permission)}}.collect {|m| m.project_id}
|
end
|
||||||
statements << "#{Project.table_name}.id IN (#{allowed_project_ids.join(',')})" if allowed_project_ids.any?
|
if user.logged?
|
||||||
|
user.projects_by_role.each do |role, projects|
|
||||||
|
if role.allowed_to?(permission)
|
||||||
|
statement_by_role[role] = "#{Project.table_name}.id IN (#{projects.collect(&:id).join(',')})"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if statement_by_role.empty?
|
||||||
|
"1=0"
|
||||||
else
|
else
|
||||||
if Role.anonymous.allowed_to?(permission) && !options[:member]
|
if block_given?
|
||||||
# anonymous user allowed on public project
|
statement_by_role.each do |role, statement|
|
||||||
statements << "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
if s = yield(role, user)
|
||||||
end
|
statement_by_role[role] = "(#{statement} AND (#{s}))"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
"((#{base_statement}) AND (#{statement_by_role.values.join(' OR ')}))"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
statements.empty? ? base_statement : "((#{base_statement}) AND (#{statements.join(' OR ')}))"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the Systemwide and project specific activities
|
# Returns the Systemwide and project specific activities
|
||||||
@@ -220,6 +265,10 @@ class Project < ActiveRecord::Base
|
|||||||
self.status == STATUS_ACTIVE
|
self.status == STATUS_ACTIVE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def archived?
|
||||||
|
self.status == STATUS_ARCHIVED
|
||||||
|
end
|
||||||
|
|
||||||
# Archives the project and its descendants
|
# Archives the project and its descendants
|
||||||
def archive
|
def archive
|
||||||
# Check that there is no issue of a non descendant project that is assigned
|
# Check that there is no issue of a non descendant project that is assigned
|
||||||
@@ -320,7 +369,7 @@ class Project < ActiveRecord::Base
|
|||||||
# Returns an array of the trackers used by the project and its active sub projects
|
# Returns an array of the trackers used by the project and its active sub projects
|
||||||
def rolled_up_trackers
|
def rolled_up_trackers
|
||||||
@rolled_up_trackers ||=
|
@rolled_up_trackers ||=
|
||||||
Tracker.find(:all, :include => :projects,
|
Tracker.find(:all, :joins => :projects,
|
||||||
:select => "DISTINCT #{Tracker.table_name}.*",
|
:select => "DISTINCT #{Tracker.table_name}.*",
|
||||||
:conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt],
|
:conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt],
|
||||||
:order => "#{Tracker.table_name}.position")
|
:order => "#{Tracker.table_name}.position")
|
||||||
@@ -346,15 +395,17 @@ class Project < ActiveRecord::Base
|
|||||||
|
|
||||||
# Returns a scope of the Versions used by the project
|
# Returns a scope of the Versions used by the project
|
||||||
def shared_versions
|
def shared_versions
|
||||||
@shared_versions ||=
|
@shared_versions ||= begin
|
||||||
|
r = root? ? self : root
|
||||||
Version.scoped(:include => :project,
|
Version.scoped(:include => :project,
|
||||||
:conditions => "#{Project.table_name}.id = #{id}" +
|
:conditions => "#{Project.table_name}.id = #{id}" +
|
||||||
" OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" +
|
" OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" +
|
||||||
" #{Version.table_name}.sharing = 'system'" +
|
" #{Version.table_name}.sharing = 'system'" +
|
||||||
" OR (#{Project.table_name}.lft >= #{root.lft} AND #{Project.table_name}.rgt <= #{root.rgt} AND #{Version.table_name}.sharing = 'tree')" +
|
" OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" +
|
||||||
" OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" +
|
" OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" +
|
||||||
" OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" +
|
" OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" +
|
||||||
"))")
|
"))")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a hash of project users grouped by role
|
# Returns a hash of project users grouped by role
|
||||||
@@ -382,12 +433,13 @@ class Project < ActiveRecord::Base
|
|||||||
|
|
||||||
# Returns the mail adresses of users that should be always notified on project events
|
# Returns the mail adresses of users that should be always notified on project events
|
||||||
def recipients
|
def recipients
|
||||||
members.select {|m| m.mail_notification? || m.user.mail_notification?}.collect {|m| m.user.mail}
|
notified_users.collect {|user| user.mail}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the users that should be notified on project events
|
# Returns the users that should be notified on project events
|
||||||
def notified_users
|
def notified_users
|
||||||
members.select {|m| m.mail_notification? || m.user.mail_notification?}.collect {|m| m.user}
|
# TODO: User part should be extracted to User#notify_about?
|
||||||
|
members.select {|m| m.mail_notification? || m.user.mail_notification == 'all'}.collect {|m| m.user}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of all custom fields enabled for project issues
|
# Returns an array of all custom fields enabled for project issues
|
||||||
@@ -395,6 +447,12 @@ class Project < ActiveRecord::Base
|
|||||||
def all_issue_custom_fields
|
def all_issue_custom_fields
|
||||||
@all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq.sort
|
@all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns an array of all custom fields enabled for project time entries
|
||||||
|
# (explictly associated custom fields and custom fields enabled for all projects)
|
||||||
|
def all_time_entry_custom_fields
|
||||||
|
@all_time_entry_custom_fields ||= (TimeEntryCustomField.for_all + time_entry_custom_fields).uniq.sort
|
||||||
|
end
|
||||||
|
|
||||||
def project
|
def project
|
||||||
self
|
self
|
||||||
@@ -412,6 +470,54 @@ class Project < ActiveRecord::Base
|
|||||||
def short_description(length = 255)
|
def short_description(length = 255)
|
||||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def css_classes
|
||||||
|
s = 'project'
|
||||||
|
s << ' root' if root?
|
||||||
|
s << ' child' if child?
|
||||||
|
s << (leaf? ? ' leaf' : ' parent')
|
||||||
|
s
|
||||||
|
end
|
||||||
|
|
||||||
|
# The earliest start date of a project, based on it's issues and versions
|
||||||
|
def start_date
|
||||||
|
[
|
||||||
|
issues.minimum('start_date'),
|
||||||
|
shared_versions.collect(&:effective_date),
|
||||||
|
shared_versions.collect(&:start_date)
|
||||||
|
].flatten.compact.min
|
||||||
|
end
|
||||||
|
|
||||||
|
# The latest due date of an issue or version
|
||||||
|
def due_date
|
||||||
|
[
|
||||||
|
issues.maximum('due_date'),
|
||||||
|
shared_versions.collect(&:effective_date),
|
||||||
|
shared_versions.collect {|v| v.fixed_issues.maximum('due_date')}
|
||||||
|
].flatten.compact.max
|
||||||
|
end
|
||||||
|
|
||||||
|
def overdue?
|
||||||
|
active? && !due_date.nil? && (due_date < Date.today)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns the percent completed for this project, based on the
|
||||||
|
# progress on it's versions.
|
||||||
|
def completed_percent(options={:include_subprojects => false})
|
||||||
|
if options.delete(:include_subprojects)
|
||||||
|
total = self_and_descendants.collect(&:completed_percent).sum
|
||||||
|
|
||||||
|
total / self_and_descendants.count
|
||||||
|
else
|
||||||
|
if versions.count > 0
|
||||||
|
total = versions.collect(&:completed_pourcent).sum
|
||||||
|
|
||||||
|
total / versions.count
|
||||||
|
else
|
||||||
|
100
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Return true if this project is allowed to do the specified action.
|
# Return true if this project is allowed to do the specified action.
|
||||||
# action can be:
|
# action can be:
|
||||||
@@ -432,16 +538,60 @@ class Project < ActiveRecord::Base
|
|||||||
|
|
||||||
def enabled_module_names=(module_names)
|
def enabled_module_names=(module_names)
|
||||||
if module_names && module_names.is_a?(Array)
|
if module_names && module_names.is_a?(Array)
|
||||||
module_names = module_names.collect(&:to_s)
|
module_names = module_names.collect(&:to_s).reject(&:blank?)
|
||||||
# remove disabled modules
|
self.enabled_modules = module_names.collect {|name| enabled_modules.detect {|mod| mod.name == name} || EnabledModule.new(:name => name)}
|
||||||
enabled_modules.each {|mod| mod.destroy unless module_names.include?(mod.name)}
|
|
||||||
# add new modules
|
|
||||||
module_names.reject {|name| module_enabled?(name)}.each {|name| enabled_modules << EnabledModule.new(:name => name)}
|
|
||||||
else
|
else
|
||||||
enabled_modules.clear
|
enabled_modules.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns an array of the enabled modules names
|
||||||
|
def enabled_module_names
|
||||||
|
enabled_modules.collect(&:name)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Enable a specific module
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
# project.enable_module!(:issue_tracking)
|
||||||
|
# project.enable_module!("issue_tracking")
|
||||||
|
def enable_module!(name)
|
||||||
|
enabled_modules << EnabledModule.new(:name => name.to_s) unless module_enabled?(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Disable a module if it exists
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
# project.disable_module!(:issue_tracking)
|
||||||
|
# project.disable_module!("issue_tracking")
|
||||||
|
# project.disable_module!(project.enabled_modules.first)
|
||||||
|
def disable_module!(target)
|
||||||
|
target = enabled_modules.detect{|mod| target.to_s == mod.name} unless enabled_modules.include?(target)
|
||||||
|
target.destroy unless target.blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
safe_attributes 'name',
|
||||||
|
'description',
|
||||||
|
'homepage',
|
||||||
|
'is_public',
|
||||||
|
'identifier',
|
||||||
|
'custom_field_values',
|
||||||
|
'custom_fields',
|
||||||
|
'tracker_ids',
|
||||||
|
'issue_custom_field_ids'
|
||||||
|
|
||||||
|
safe_attributes 'enabled_module_names',
|
||||||
|
:if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) }
|
||||||
|
|
||||||
|
# Returns an array of projects that are in this project's hierarchy
|
||||||
|
#
|
||||||
|
# Example: parents, children, siblings
|
||||||
|
def hierarchy
|
||||||
|
parents = project.self_and_ancestors || []
|
||||||
|
descendants = project.descendants || []
|
||||||
|
project_hierarchy = parents | descendants # Set union
|
||||||
|
end
|
||||||
|
|
||||||
# Returns an auto-generated project identifier based on the last identifier used
|
# Returns an auto-generated project identifier based on the last identifier used
|
||||||
def self.next_identifier
|
def self.next_identifier
|
||||||
p = Project.find(:first, :order => 'created_on DESC')
|
p = Project.find(:first, :order => 'created_on DESC')
|
||||||
@@ -503,16 +653,21 @@ class Project < ActiveRecord::Base
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
# Yields the given block for each project with its level in the tree
|
||||||
|
def self.project_tree(projects, &block)
|
||||||
# Destroys children before destroying self
|
ancestors = []
|
||||||
def destroy_children
|
projects.sort_by(&:lft).each do |project|
|
||||||
children.each do |child|
|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
||||||
child.destroy
|
ancestors.pop
|
||||||
|
end
|
||||||
|
yield project, ancestors.size
|
||||||
|
ancestors << project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
# Copies wiki from +project+
|
# Copies wiki from +project+
|
||||||
def copy_wiki(project)
|
def copy_wiki(project)
|
||||||
# Check that the source project has a wiki first
|
# Check that the source project has a wiki first
|
||||||
@@ -559,6 +714,7 @@ class Project < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Copies issues from +project+
|
# Copies issues from +project+
|
||||||
|
# Note: issues assigned to a closed version won't be copied due to validation rules
|
||||||
def copy_issues(project)
|
def copy_issues(project)
|
||||||
# Stores the source issue id as a key and the copied issues as the
|
# Stores the source issue id as a key and the copied issues as the
|
||||||
# value. Used to map the two togeather for issue relations.
|
# value. Used to map the two togeather for issue relations.
|
||||||
@@ -588,12 +744,20 @@ class Project < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.issues << new_issue
|
self.issues << new_issue
|
||||||
issues_map[issue.id] = new_issue
|
if new_issue.new_record?
|
||||||
|
logger.info "Project#copy_issues: issue ##{issue.id} could not be copied: #{new_issue.errors.full_messages}" if logger && logger.info
|
||||||
|
else
|
||||||
|
issues_map[issue.id] = new_issue unless new_issue.new_record?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Relations after in case issues related each other
|
# Relations after in case issues related each other
|
||||||
project.issues.each do |issue|
|
project.issues.each do |issue|
|
||||||
new_issue = issues_map[issue.id]
|
new_issue = issues_map[issue.id]
|
||||||
|
unless new_issue
|
||||||
|
# Issue was not copied
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
# Relations
|
# Relations
|
||||||
issue.relations_from.each do |source_relation|
|
issue.relations_from.each do |source_relation|
|
||||||
@@ -620,7 +784,12 @@ class Project < ActiveRecord::Base
|
|||||||
|
|
||||||
# Copies members from +project+
|
# Copies members from +project+
|
||||||
def copy_members(project)
|
def copy_members(project)
|
||||||
project.memberships.each do |member|
|
# Copy users first, then groups to handle members with inherited and given roles
|
||||||
|
members_to_copy = []
|
||||||
|
members_to_copy += project.memberships.select {|m| m.principal.is_a?(User)}
|
||||||
|
members_to_copy += project.memberships.select {|m| !m.principal.is_a?(User)}
|
||||||
|
|
||||||
|
members_to_copy.each do |member|
|
||||||
new_member = Member.new
|
new_member = Member.new
|
||||||
new_member.attributes = member.attributes.dup.except("id", "project_id", "created_on")
|
new_member.attributes = member.attributes.dup.except("id", "project_id", "created_on")
|
||||||
# only copy non inherited roles
|
# only copy non inherited roles
|
||||||
@@ -640,6 +809,7 @@ class Project < ActiveRecord::Base
|
|||||||
new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria")
|
new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria")
|
||||||
new_query.sort_criteria = query.sort_criteria if query.sort_criteria
|
new_query.sort_criteria = query.sort_criteria if query.sort_criteria
|
||||||
new_query.project = self
|
new_query.project = self
|
||||||
|
new_query.user_id = query.user_id
|
||||||
self.queries << new_query
|
self.queries << new_query
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+200
-109
@@ -1,24 +1,24 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class QueryColumn
|
class QueryColumn
|
||||||
attr_accessor :name, :sortable, :groupable, :default_order
|
attr_accessor :name, :sortable, :groupable, :default_order
|
||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
|
|
||||||
def initialize(name, options={})
|
def initialize(name, options={})
|
||||||
self.name = name
|
self.name = name
|
||||||
self.sortable = options[:sortable]
|
self.sortable = options[:sortable]
|
||||||
@@ -29,19 +29,23 @@ class QueryColumn
|
|||||||
self.default_order = options[:default_order]
|
self.default_order = options[:default_order]
|
||||||
@caption_key = options[:caption] || "field_#{name}"
|
@caption_key = options[:caption] || "field_#{name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def caption
|
def caption
|
||||||
l(@caption_key)
|
l(@caption_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if the column is sortable, otherwise false
|
# Returns true if the column is sortable, otherwise false
|
||||||
def sortable?
|
def sortable?
|
||||||
!sortable.nil?
|
!sortable.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def value(issue)
|
def value(issue)
|
||||||
issue.send name
|
issue.send name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def css_classes
|
||||||
|
name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class QueryCustomFieldColumn < QueryColumn
|
class QueryCustomFieldColumn < QueryColumn
|
||||||
@@ -55,37 +59,41 @@ class QueryCustomFieldColumn < QueryColumn
|
|||||||
self.groupable ||= false
|
self.groupable ||= false
|
||||||
@cf = custom_field
|
@cf = custom_field
|
||||||
end
|
end
|
||||||
|
|
||||||
def caption
|
def caption
|
||||||
@cf.name
|
@cf.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_field
|
def custom_field
|
||||||
@cf
|
@cf
|
||||||
end
|
end
|
||||||
|
|
||||||
def value(issue)
|
def value(issue)
|
||||||
cv = issue.custom_values.detect {|v| v.custom_field_id == @cf.id}
|
cv = issue.custom_values.detect {|v| v.custom_field_id == @cf.id}
|
||||||
cv && @cf.cast_value(cv.value)
|
cv && @cf.cast_value(cv.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def css_classes
|
||||||
|
@css_classes ||= "#{name} #{@cf.field_format}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Query < ActiveRecord::Base
|
class Query < ActiveRecord::Base
|
||||||
class StatementInvalid < ::ActiveRecord::StatementInvalid
|
class StatementInvalid < ::ActiveRecord::StatementInvalid
|
||||||
end
|
end
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
serialize :filters
|
serialize :filters
|
||||||
serialize :column_names
|
serialize :column_names
|
||||||
serialize :sort_criteria, Array
|
serialize :sort_criteria, Array
|
||||||
|
|
||||||
attr_protected :project_id, :user_id
|
attr_protected :project_id, :user_id
|
||||||
|
|
||||||
validates_presence_of :name, :on => :save
|
validates_presence_of :name, :on => :save
|
||||||
validates_length_of :name, :maximum => 255
|
validates_length_of :name, :maximum => 255
|
||||||
|
|
||||||
@@operators = { "=" => :label_equals,
|
@@operators = { "=" => :label_equals,
|
||||||
"!" => :label_not_equals,
|
"!" => :label_not_equals,
|
||||||
"o" => :label_open_issues,
|
"o" => :label_open_issues,
|
||||||
"c" => :label_closed_issues,
|
"c" => :label_closed_issues,
|
||||||
@@ -105,7 +113,7 @@ class Query < ActiveRecord::Base
|
|||||||
"!~" => :label_not_contains }
|
"!~" => :label_not_contains }
|
||||||
|
|
||||||
cattr_reader :operators
|
cattr_reader :operators
|
||||||
|
|
||||||
@@operators_by_filter_type = { :list => [ "=", "!" ],
|
@@operators_by_filter_type = { :list => [ "=", "!" ],
|
||||||
:list_status => [ "o", "=", "!", "c", "*" ],
|
:list_status => [ "o", "=", "!", "c", "*" ],
|
||||||
:list_optional => [ "=", "!", "!*", "*" ],
|
:list_optional => [ "=", "!", "!*", "*" ],
|
||||||
@@ -137,27 +145,32 @@ class Query < ActiveRecord::Base
|
|||||||
QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
|
QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
|
||||||
]
|
]
|
||||||
cattr_reader :available_columns
|
cattr_reader :available_columns
|
||||||
|
|
||||||
def initialize(attributes = nil)
|
def initialize(attributes = nil)
|
||||||
super attributes
|
super attributes
|
||||||
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
|
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_initialize
|
def after_initialize
|
||||||
# Store the fact that project is nil (used in #editable_by?)
|
# Store the fact that project is nil (used in #editable_by?)
|
||||||
@is_for_all = project.nil?
|
@is_for_all = project.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
filters.each_key do |field|
|
filters.each_key do |field|
|
||||||
errors.add label_for(field), :blank unless
|
errors.add label_for(field), :blank unless
|
||||||
# filter requires one or more values
|
# filter requires one or more values
|
||||||
(values_for(field) and !values_for(field).first.blank?) or
|
(values_for(field) and !values_for(field).first.blank?) or
|
||||||
# filter doesn't require any value
|
# filter doesn't require any value
|
||||||
["o", "c", "!*", "*", "t", "w"].include? operator_for(field)
|
["o", "c", "!*", "*", "t", "w"].include? operator_for(field)
|
||||||
end if filters
|
end if filters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns true if the query is visible to +user+ or the current user.
|
||||||
|
def visible?(user=User.current)
|
||||||
|
self.is_public? || self.user_id == user.id
|
||||||
|
end
|
||||||
|
|
||||||
def editable_by?(user)
|
def editable_by?(user)
|
||||||
return false unless user
|
return false unless user
|
||||||
# Admin can edit them all and regular users can edit their private queries
|
# Admin can edit them all and regular users can edit their private queries
|
||||||
@@ -165,51 +178,70 @@ class Query < ActiveRecord::Base
|
|||||||
# Members can not edit public queries that are for all project (only admin is allowed to)
|
# Members can not edit public queries that are for all project (only admin is allowed to)
|
||||||
is_public && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
|
is_public && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
def available_filters
|
def available_filters
|
||||||
return @available_filters if @available_filters
|
return @available_filters if @available_filters
|
||||||
|
|
||||||
trackers = project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers
|
trackers = project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers
|
||||||
|
|
||||||
@available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
|
@available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
|
||||||
"tracker_id" => { :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } },
|
"tracker_id" => { :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } },
|
||||||
"priority_id" => { :type => :list, :order => 3, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s] } },
|
"priority_id" => { :type => :list, :order => 3, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s] } },
|
||||||
"subject" => { :type => :text, :order => 8 },
|
"subject" => { :type => :text, :order => 8 },
|
||||||
"created_on" => { :type => :date_past, :order => 9 },
|
"created_on" => { :type => :date_past, :order => 9 },
|
||||||
"updated_on" => { :type => :date_past, :order => 10 },
|
"updated_on" => { :type => :date_past, :order => 10 },
|
||||||
"start_date" => { :type => :date, :order => 11 },
|
"start_date" => { :type => :date, :order => 11 },
|
||||||
"due_date" => { :type => :date, :order => 12 },
|
"due_date" => { :type => :date, :order => 12 },
|
||||||
"estimated_hours" => { :type => :integer, :order => 13 },
|
"estimated_hours" => { :type => :integer, :order => 13 },
|
||||||
"done_ratio" => { :type => :integer, :order => 14 }}
|
"done_ratio" => { :type => :integer, :order => 14 }}
|
||||||
|
|
||||||
user_values = []
|
user_values = []
|
||||||
user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
|
user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
|
||||||
if project
|
if project
|
||||||
user_values += project.users.sort.collect{|s| [s.name, s.id.to_s] }
|
user_values += project.users.sort.collect{|s| [s.name, s.id.to_s] }
|
||||||
else
|
else
|
||||||
project_ids = User.current.projects.collect(&:id)
|
all_projects = Project.visible.all
|
||||||
if project_ids.any?
|
if all_projects.any?
|
||||||
# members of the user's projects
|
# members of visible projects
|
||||||
user_values += User.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", project_ids]).sort.collect{|s| [s.name, s.id.to_s] }
|
user_values += User.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", all_projects.collect(&:id)]).sort.collect{|s| [s.name, s.id.to_s] }
|
||||||
|
|
||||||
|
# project filter
|
||||||
|
project_values = []
|
||||||
|
Project.project_tree(all_projects) do |p, level|
|
||||||
|
prefix = (level > 0 ? ('--' * level + ' ') : '')
|
||||||
|
project_values << ["#{prefix}#{p.name}", p.id.to_s]
|
||||||
|
end
|
||||||
|
@available_filters["project_id"] = { :type => :list, :order => 1, :values => project_values} unless project_values.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
|
@available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
|
||||||
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
|
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
|
||||||
|
|
||||||
|
group_values = Group.all.collect {|g| [g.name, g.id.to_s] }
|
||||||
|
@available_filters["member_of_group"] = { :type => :list_optional, :order => 6, :values => group_values } unless group_values.empty?
|
||||||
|
|
||||||
|
role_values = Role.givable.collect {|r| [r.name, r.id.to_s] }
|
||||||
|
@available_filters["assigned_to_role"] = { :type => :list_optional, :order => 7, :values => role_values } unless role_values.empty?
|
||||||
|
|
||||||
if User.current.logged?
|
if User.current.logged?
|
||||||
@available_filters["watcher_id"] = { :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] }
|
@available_filters["watcher_id"] = { :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] }
|
||||||
end
|
end
|
||||||
|
|
||||||
if project
|
if project
|
||||||
# project specific filters
|
# project specific filters
|
||||||
unless @project.issue_categories.empty?
|
categories = @project.issue_categories.all
|
||||||
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
|
unless categories.empty?
|
||||||
|
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => categories.collect{|s| [s.name, s.id.to_s] } }
|
||||||
end
|
end
|
||||||
unless @project.shared_versions.empty?
|
versions = @project.shared_versions.all
|
||||||
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
|
unless versions.empty?
|
||||||
|
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
|
||||||
end
|
end
|
||||||
unless @project.descendants.active.empty?
|
unless @project.leaf?
|
||||||
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.descendants.visible.collect{|s| [s.name, s.id.to_s] } }
|
subprojects = @project.descendants.visible.all
|
||||||
|
unless subprojects.empty?
|
||||||
|
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => subprojects.collect{|s| [s.name, s.id.to_s] } }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
add_custom_fields_filters(@project.all_issue_custom_fields)
|
add_custom_fields_filters(@project.all_issue_custom_fields)
|
||||||
else
|
else
|
||||||
@@ -222,7 +254,7 @@ class Query < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
@available_filters
|
@available_filters
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_filter(field, operator, values)
|
def add_filter(field, operator, values)
|
||||||
# values must be an array
|
# values must be an array
|
||||||
return unless values and values.is_a? Array # and !values.first.empty?
|
return unless values and values.is_a? Array # and !values.first.empty?
|
||||||
@@ -237,7 +269,7 @@ class Query < ActiveRecord::Base
|
|||||||
filters[field] = {:operator => operator, :values => values }
|
filters[field] = {:operator => operator, :values => values }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_short_filter(field, expression)
|
def add_short_filter(field, expression)
|
||||||
return unless expression
|
return unless expression
|
||||||
parms = expression.scan(/^(o|c|!\*|!|\*)?(.*)$/).first
|
parms = expression.scan(/^(o|c|!\*|!|\*)?(.*)$/).first
|
||||||
@@ -246,23 +278,25 @@ class Query < ActiveRecord::Base
|
|||||||
|
|
||||||
# Add multiple filters using +add_filter+
|
# Add multiple filters using +add_filter+
|
||||||
def add_filters(fields, operators, values)
|
def add_filters(fields, operators, values)
|
||||||
fields.each do |field|
|
if fields.is_a?(Array) && operators.is_a?(Hash) && values.is_a?(Hash)
|
||||||
add_filter(field, operators[field], values[field])
|
fields.each do |field|
|
||||||
|
add_filter(field, operators[field], values[field])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_filter?(field)
|
def has_filter?(field)
|
||||||
filters and filters[field]
|
filters and filters[field]
|
||||||
end
|
end
|
||||||
|
|
||||||
def operator_for(field)
|
def operator_for(field)
|
||||||
has_filter?(field) ? filters[field][:operator] : nil
|
has_filter?(field) ? filters[field][:operator] : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def values_for(field)
|
def values_for(field)
|
||||||
has_filter?(field) ? filters[field][:values] : nil
|
has_filter?(field) ? filters[field][:values] : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def label_for(field)
|
def label_for(field)
|
||||||
label = available_filters[field][:name] if available_filters.has_key?(field)
|
label = available_filters[field][:name] if available_filters.has_key?(field)
|
||||||
label ||= field.gsub(/\_id$/, "")
|
label ||= field.gsub(/\_id$/, "")
|
||||||
@@ -274,17 +308,17 @@ class Query < ActiveRecord::Base
|
|||||||
@available_columns += (project ?
|
@available_columns += (project ?
|
||||||
project.all_issue_custom_fields :
|
project.all_issue_custom_fields :
|
||||||
IssueCustomField.find(:all)
|
IssueCustomField.find(:all)
|
||||||
).collect {|cf| QueryCustomFieldColumn.new(cf) }
|
).collect {|cf| QueryCustomFieldColumn.new(cf) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.available_columns=(v)
|
def self.available_columns=(v)
|
||||||
self.available_columns = (v)
|
self.available_columns = (v)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.add_available_column(column)
|
def self.add_available_column(column)
|
||||||
self.available_columns << (column) if column.is_a?(QueryColumn)
|
self.available_columns << (column) if column.is_a?(QueryColumn)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of columns that can be used to group the results
|
# Returns an array of columns that can be used to group the results
|
||||||
def groupable_columns
|
def groupable_columns
|
||||||
available_columns.select {|c| c.groupable}
|
available_columns.select {|c| c.groupable}
|
||||||
@@ -297,39 +331,42 @@ class Query < ActiveRecord::Base
|
|||||||
h
|
h
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def columns
|
def columns
|
||||||
if has_default_columns?
|
# preserve the column_names order
|
||||||
available_columns.select do |c|
|
(has_default_columns? ? default_columns_names : column_names).collect do |name|
|
||||||
# Adds the project column by default for cross-project lists
|
available_columns.find { |col| col.name == name }
|
||||||
Setting.issue_list_default_columns.include?(c.name.to_s) || (c.name == :project && project.nil?)
|
end.compact
|
||||||
end
|
end
|
||||||
else
|
|
||||||
# preserve the column_names order
|
def default_columns_names
|
||||||
column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact
|
@default_columns_names ||= begin
|
||||||
|
default_columns = Setting.issue_list_default_columns.map(&:to_sym)
|
||||||
|
|
||||||
|
project.present? ? default_columns : [:project] | default_columns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def column_names=(names)
|
def column_names=(names)
|
||||||
if names
|
if names
|
||||||
names = names.select {|n| n.is_a?(Symbol) || !n.blank? }
|
names = names.select {|n| n.is_a?(Symbol) || !n.blank? }
|
||||||
names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym }
|
names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym }
|
||||||
# Set column_names to nil if default columns
|
# Set column_names to nil if default columns
|
||||||
if names.map(&:to_s) == Setting.issue_list_default_columns
|
if names == default_columns_names
|
||||||
names = nil
|
names = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
write_attribute(:column_names, names)
|
write_attribute(:column_names, names)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_column?(column)
|
def has_column?(column)
|
||||||
column_names && column_names.include?(column.name)
|
column_names && column_names.include?(column.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_default_columns?
|
def has_default_columns?
|
||||||
column_names.nil? || column_names.empty?
|
column_names.nil? || column_names.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_criteria=(arg)
|
def sort_criteria=(arg)
|
||||||
c = []
|
c = []
|
||||||
if arg.is_a?(Hash)
|
if arg.is_a?(Hash)
|
||||||
@@ -338,19 +375,19 @@ class Query < ActiveRecord::Base
|
|||||||
c = arg.select {|k,o| !k.to_s.blank?}.slice(0,3).collect {|k,o| [k.to_s, o == 'desc' ? o : 'asc']}
|
c = arg.select {|k,o| !k.to_s.blank?}.slice(0,3).collect {|k,o| [k.to_s, o == 'desc' ? o : 'asc']}
|
||||||
write_attribute(:sort_criteria, c)
|
write_attribute(:sort_criteria, c)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_criteria
|
def sort_criteria
|
||||||
read_attribute(:sort_criteria) || []
|
read_attribute(:sort_criteria) || []
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_criteria_key(arg)
|
def sort_criteria_key(arg)
|
||||||
sort_criteria && sort_criteria[arg] && sort_criteria[arg].first
|
sort_criteria && sort_criteria[arg] && sort_criteria[arg].first
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_criteria_order(arg)
|
def sort_criteria_order(arg)
|
||||||
sort_criteria && sort_criteria[arg] && sort_criteria[arg].last
|
sort_criteria && sort_criteria[arg] && sort_criteria[arg].last
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the SQL sort order that should be prepended for grouping
|
# Returns the SQL sort order that should be prepended for grouping
|
||||||
def group_by_sort_order
|
def group_by_sort_order
|
||||||
if grouped? && (column = group_by_column)
|
if grouped? && (column = group_by_column)
|
||||||
@@ -359,20 +396,20 @@ class Query < ActiveRecord::Base
|
|||||||
"#{column.sortable} #{column.default_order}"
|
"#{column.sortable} #{column.default_order}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if the query is a grouped query
|
# Returns true if the query is a grouped query
|
||||||
def grouped?
|
def grouped?
|
||||||
!group_by.blank?
|
!group_by_column.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_by_column
|
def group_by_column
|
||||||
groupable_columns.detect {|c| c.name.to_s == group_by}
|
groupable_columns.detect {|c| c.groupable && c.name.to_s == group_by}
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_by_statement
|
def group_by_statement
|
||||||
group_by_column.groupable
|
group_by_column.try(:groupable)
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_statement
|
def project_statement
|
||||||
project_clauses = []
|
project_clauses = []
|
||||||
if project && !@project.descendants.active.empty?
|
if project && !@project.descendants.active.empty?
|
||||||
@@ -395,8 +432,7 @@ class Query < ActiveRecord::Base
|
|||||||
elsif project
|
elsif project
|
||||||
project_clauses << "#{Project.table_name}.id = %d" % project.id
|
project_clauses << "#{Project.table_name}.id = %d" % project.id
|
||||||
end
|
end
|
||||||
project_clauses << Project.allowed_to_condition(User.current, :view_issues)
|
project_clauses.any? ? project_clauses.join(' AND ') : nil
|
||||||
project_clauses.join(' AND ')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def statement
|
def statement
|
||||||
@@ -407,12 +443,12 @@ class Query < ActiveRecord::Base
|
|||||||
v = values_for(field).clone
|
v = values_for(field).clone
|
||||||
next unless v and !v.empty?
|
next unless v and !v.empty?
|
||||||
operator = operator_for(field)
|
operator = operator_for(field)
|
||||||
|
|
||||||
# "me" value subsitution
|
# "me" value subsitution
|
||||||
if %w(assigned_to_id author_id watcher_id).include?(field)
|
if %w(assigned_to_id author_id watcher_id).include?(field)
|
||||||
v.push(User.current.logged? ? User.current.id.to_s : "0") if v.delete("me")
|
v.push(User.current.logged? ? User.current.id.to_s : "0") if v.delete("me")
|
||||||
end
|
end
|
||||||
|
|
||||||
sql = ''
|
sql = ''
|
||||||
if field =~ /^cf_(\d+)$/
|
if field =~ /^cf_(\d+)$/
|
||||||
# custom field
|
# custom field
|
||||||
@@ -426,6 +462,47 @@ class Query < ActiveRecord::Base
|
|||||||
db_field = 'user_id'
|
db_field = 'user_id'
|
||||||
sql << "#{Issue.table_name}.id #{ operator == '=' ? 'IN' : 'NOT IN' } (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND "
|
sql << "#{Issue.table_name}.id #{ operator == '=' ? 'IN' : 'NOT IN' } (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND "
|
||||||
sql << sql_for_field(field, '=', v, db_table, db_field) + ')'
|
sql << sql_for_field(field, '=', v, db_table, db_field) + ')'
|
||||||
|
elsif field == "member_of_group" # named field
|
||||||
|
if operator == '*' # Any group
|
||||||
|
groups = Group.all
|
||||||
|
operator = '=' # Override the operator since we want to find by assigned_to
|
||||||
|
elsif operator == "!*"
|
||||||
|
groups = Group.all
|
||||||
|
operator = '!' # Override the operator since we want to find by assigned_to
|
||||||
|
else
|
||||||
|
groups = Group.find_all_by_id(v)
|
||||||
|
end
|
||||||
|
groups ||= []
|
||||||
|
|
||||||
|
members_of_groups = groups.inject([]) {|user_ids, group|
|
||||||
|
if group && group.user_ids.present?
|
||||||
|
user_ids << group.user_ids
|
||||||
|
end
|
||||||
|
user_ids.flatten.uniq.compact
|
||||||
|
}.sort.collect(&:to_s)
|
||||||
|
|
||||||
|
sql << '(' + sql_for_field("assigned_to_id", operator, members_of_groups, Issue.table_name, "assigned_to_id", false) + ')'
|
||||||
|
|
||||||
|
elsif field == "assigned_to_role" # named field
|
||||||
|
if operator == "*" # Any Role
|
||||||
|
roles = Role.givable
|
||||||
|
operator = '=' # Override the operator since we want to find by assigned_to
|
||||||
|
elsif operator == "!*" # No role
|
||||||
|
roles = Role.givable
|
||||||
|
operator = '!' # Override the operator since we want to find by assigned_to
|
||||||
|
else
|
||||||
|
roles = Role.givable.find_all_by_id(v)
|
||||||
|
end
|
||||||
|
roles ||= []
|
||||||
|
|
||||||
|
members_of_roles = roles.inject([]) {|user_ids, role|
|
||||||
|
if role && role.members
|
||||||
|
user_ids << role.members.collect(&:user_id)
|
||||||
|
end
|
||||||
|
user_ids.flatten.uniq.compact
|
||||||
|
}.sort.collect(&:to_s)
|
||||||
|
|
||||||
|
sql << '(' + sql_for_field("assigned_to_id", operator, members_of_roles, Issue.table_name, "assigned_to_id", false) + ')'
|
||||||
else
|
else
|
||||||
# regular field
|
# regular field
|
||||||
db_table = Issue.table_name
|
db_table = Issue.table_name
|
||||||
@@ -433,26 +510,29 @@ class Query < ActiveRecord::Base
|
|||||||
sql << '(' + sql_for_field(field, operator, v, db_table, db_field) + ')'
|
sql << '(' + sql_for_field(field, operator, v, db_table, db_field) + ')'
|
||||||
end
|
end
|
||||||
filters_clauses << sql
|
filters_clauses << sql
|
||||||
|
|
||||||
end if filters and valid?
|
end if filters and valid?
|
||||||
|
|
||||||
(filters_clauses << project_statement).join(' AND ')
|
filters_clauses << project_statement
|
||||||
|
filters_clauses.reject!(&:blank?)
|
||||||
|
|
||||||
|
filters_clauses.any? ? filters_clauses.join(' AND ') : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the issue count
|
# Returns the issue count
|
||||||
def issue_count
|
def issue_count
|
||||||
Issue.count(:include => [:status, :project], :conditions => statement)
|
Issue.visible.count(:include => [:status, :project], :conditions => statement)
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the issue count by group or nil if query is not grouped
|
# Returns the issue count by group or nil if query is not grouped
|
||||||
def issue_count_by_group
|
def issue_count_by_group
|
||||||
r = nil
|
r = nil
|
||||||
if grouped?
|
if grouped?
|
||||||
begin
|
begin
|
||||||
# Rails will raise an (unexpected) RecordNotFound if there's only a nil group value
|
# Rails will raise an (unexpected) RecordNotFound if there's only a nil group value
|
||||||
r = Issue.count(:group => group_by_statement, :include => [:status, :project], :conditions => statement)
|
r = Issue.visible.count(:group => group_by_statement, :include => [:status, :project], :conditions => statement)
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
r = {nil => issue_count}
|
r = {nil => issue_count}
|
||||||
end
|
end
|
||||||
@@ -465,14 +545,14 @@ class Query < ActiveRecord::Base
|
|||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the issues
|
# Returns the issues
|
||||||
# Valid options are :order, :offset, :limit, :include, :conditions
|
# Valid options are :order, :offset, :limit, :include, :conditions
|
||||||
def issues(options={})
|
def issues(options={})
|
||||||
order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
|
order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
|
||||||
order_option = nil if order_option.blank?
|
order_option = nil if order_option.blank?
|
||||||
|
|
||||||
Issue.find :all, :include => ([:status, :project] + (options[:include] || [])).uniq,
|
Issue.visible.find :all, :include => ([:status, :project] + (options[:include] || [])).uniq,
|
||||||
:conditions => Query.merge_conditions(statement, options[:conditions]),
|
:conditions => Query.merge_conditions(statement, options[:conditions]),
|
||||||
:order => order_option,
|
:order => order_option,
|
||||||
:limit => options[:limit],
|
:limit => options[:limit],
|
||||||
@@ -484,7 +564,7 @@ class Query < ActiveRecord::Base
|
|||||||
# Returns the journals
|
# Returns the journals
|
||||||
# Valid options are :order, :offset, :limit
|
# Valid options are :order, :offset, :limit
|
||||||
def journals(options={})
|
def journals(options={})
|
||||||
Journal.find :all, :include => [:details, :user, {:issue => [:project, :author, :tracker, :status]}],
|
Journal.visible.find :all, :include => [:details, :user, {:issue => [:project, :author, :tracker, :status]}],
|
||||||
:conditions => statement,
|
:conditions => statement,
|
||||||
:order => options[:order],
|
:order => options[:order],
|
||||||
:limit => options[:limit],
|
:limit => options[:limit],
|
||||||
@@ -492,26 +572,36 @@ class Query < ActiveRecord::Base
|
|||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the versions
|
# Returns the versions
|
||||||
# Valid options are :conditions
|
# Valid options are :conditions
|
||||||
def versions(options={})
|
def versions(options={})
|
||||||
Version.find :all, :include => :project,
|
Version.visible.find :all, :include => :project,
|
||||||
:conditions => Query.merge_conditions(project_statement, options[:conditions])
|
:conditions => Query.merge_conditions(project_statement, options[:conditions])
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Helper method to generate the WHERE sql for a +field+, +operator+ and a +value+
|
# Helper method to generate the WHERE sql for a +field+, +operator+ and a +value+
|
||||||
def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)
|
def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)
|
||||||
sql = ''
|
sql = ''
|
||||||
case operator
|
case operator
|
||||||
when "="
|
when "="
|
||||||
sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
|
if value.any?
|
||||||
|
sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
|
||||||
|
else
|
||||||
|
# IN an empty set
|
||||||
|
sql = "1=0"
|
||||||
|
end
|
||||||
when "!"
|
when "!"
|
||||||
sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))"
|
if value.any?
|
||||||
|
sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))"
|
||||||
|
else
|
||||||
|
# NOT IN an empty set
|
||||||
|
sql = "1=1"
|
||||||
|
end
|
||||||
when "!*"
|
when "!*"
|
||||||
sql = "#{db_table}.#{db_field} IS NULL"
|
sql = "#{db_table}.#{db_field} IS NULL"
|
||||||
sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter
|
sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter
|
||||||
@@ -541,24 +631,22 @@ class Query < ActiveRecord::Base
|
|||||||
when "t"
|
when "t"
|
||||||
sql = date_range_clause(db_table, db_field, 0, 0)
|
sql = date_range_clause(db_table, db_field, 0, 0)
|
||||||
when "w"
|
when "w"
|
||||||
from = l(:general_first_day_of_week) == '7' ?
|
first_day_of_week = l(:general_first_day_of_week).to_i
|
||||||
# week starts on sunday
|
day_of_week = Date.today.cwday
|
||||||
((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) :
|
days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)
|
||||||
# week starts on monday (Rails default)
|
sql = date_range_clause(db_table, db_field, - days_ago, - days_ago + 6)
|
||||||
Time.now.at_beginning_of_week
|
|
||||||
sql = "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]
|
|
||||||
when "~"
|
when "~"
|
||||||
sql = "LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
|
sql = "LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
|
||||||
when "!~"
|
when "!~"
|
||||||
sql = "LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
|
sql = "LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
|
||||||
end
|
end
|
||||||
|
|
||||||
return sql
|
return sql
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_custom_fields_filters(custom_fields)
|
def add_custom_fields_filters(custom_fields)
|
||||||
@available_filters ||= {}
|
@available_filters ||= {}
|
||||||
|
|
||||||
custom_fields.select(&:is_filter?).each do |field|
|
custom_fields.select(&:is_filter?).each do |field|
|
||||||
case field.field_format
|
case field.field_format
|
||||||
when "text"
|
when "text"
|
||||||
@@ -569,13 +657,16 @@ class Query < ActiveRecord::Base
|
|||||||
options = { :type => :date, :order => 20 }
|
options = { :type => :date, :order => 20 }
|
||||||
when "bool"
|
when "bool"
|
||||||
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
||||||
|
when "user", "version"
|
||||||
|
next unless project
|
||||||
|
options = { :type => :list_optional, :values => field.possible_values_options(project), :order => 20}
|
||||||
else
|
else
|
||||||
options = { :type => :string, :order => 20 }
|
options = { :type => :string, :order => 20 }
|
||||||
end
|
end
|
||||||
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a SQL clause for a date or datetime field.
|
# Returns a SQL clause for a date or datetime field.
|
||||||
def date_range_clause(table, field, from, to)
|
def date_range_clause(table, field, from, to)
|
||||||
s = []
|
s = []
|
||||||
|
|||||||
+148
-43
@@ -1,52 +1,89 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class Repository < ActiveRecord::Base
|
class Repository < ActiveRecord::Base
|
||||||
|
include Redmine::Ciphering
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
|
has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
|
||||||
has_many :changes, :through => :changesets
|
has_many :changes, :through => :changesets
|
||||||
|
|
||||||
|
serialize :extra_info
|
||||||
|
|
||||||
# Raw SQL to delete changesets and changes in the database
|
# Raw SQL to delete changesets and changes in the database
|
||||||
# has_many :changesets, :dependent => :destroy is too slow for big repositories
|
# has_many :changesets, :dependent => :destroy is too slow for big repositories
|
||||||
before_destroy :clear_changesets
|
before_destroy :clear_changesets
|
||||||
|
|
||||||
|
validates_length_of :password, :maximum => 255, :allow_nil => true
|
||||||
# Checks if the SCM is enabled when creating a repository
|
# Checks if the SCM is enabled when creating a repository
|
||||||
validate_on_create { |r| r.errors.add(:type, :invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
|
validate_on_create { |r| r.errors.add(:type, :invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
|
||||||
|
|
||||||
|
def self.human_attribute_name(attribute_key_name)
|
||||||
|
attr_name = attribute_key_name
|
||||||
|
if attr_name == "log_encoding"
|
||||||
|
attr_name = "commit_logs_encoding"
|
||||||
|
end
|
||||||
|
super(attr_name)
|
||||||
|
end
|
||||||
|
|
||||||
# Removes leading and trailing whitespace
|
# Removes leading and trailing whitespace
|
||||||
def url=(arg)
|
def url=(arg)
|
||||||
write_attribute(:url, arg ? arg.to_s.strip : nil)
|
write_attribute(:url, arg ? arg.to_s.strip : nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Removes leading and trailing whitespace
|
# Removes leading and trailing whitespace
|
||||||
def root_url=(arg)
|
def root_url=(arg)
|
||||||
write_attribute(:root_url, arg ? arg.to_s.strip : nil)
|
write_attribute(:root_url, arg ? arg.to_s.strip : nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def password
|
||||||
|
read_ciphered_attribute(:password)
|
||||||
|
end
|
||||||
|
|
||||||
|
def password=(arg)
|
||||||
|
write_ciphered_attribute(:password, arg)
|
||||||
|
end
|
||||||
|
|
||||||
|
def scm_adapter
|
||||||
|
self.class.scm_adapter_class
|
||||||
|
end
|
||||||
|
|
||||||
def scm
|
def scm
|
||||||
@scm ||= self.scm_adapter.new url, root_url, login, password
|
@scm ||= self.scm_adapter.new(url, root_url,
|
||||||
|
login, password, path_encoding)
|
||||||
update_attribute(:root_url, @scm.root_url) if root_url.blank?
|
update_attribute(:root_url, @scm.root_url) if root_url.blank?
|
||||||
@scm
|
@scm
|
||||||
end
|
end
|
||||||
|
|
||||||
def scm_name
|
def scm_name
|
||||||
self.class.scm_name
|
self.class.scm_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def merge_extra_info(arg)
|
||||||
|
h = extra_info || {}
|
||||||
|
return h if arg.nil?
|
||||||
|
h.merge!(arg)
|
||||||
|
write_attribute(:extra_info, h)
|
||||||
|
end
|
||||||
|
|
||||||
|
def report_last_commit
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def supports_cat?
|
def supports_cat?
|
||||||
scm.supports_cat?
|
scm.supports_cat?
|
||||||
end
|
end
|
||||||
@@ -54,11 +91,19 @@ class Repository < ActiveRecord::Base
|
|||||||
def supports_annotate?
|
def supports_annotate?
|
||||||
scm.supports_annotate?
|
scm.supports_annotate?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def supports_all_revisions?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def supports_directory_revisions?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def entry(path=nil, identifier=nil)
|
def entry(path=nil, identifier=nil)
|
||||||
scm.entry(path, identifier)
|
scm.entry(path, identifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
def entries(path=nil, identifier=nil)
|
def entries(path=nil, identifier=nil)
|
||||||
scm.entries(path, identifier)
|
scm.entries(path, identifier)
|
||||||
end
|
end
|
||||||
@@ -72,31 +117,40 @@ class Repository < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def default_branch
|
def default_branch
|
||||||
scm.default_branch
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def properties(path, identifier=nil)
|
def properties(path, identifier=nil)
|
||||||
scm.properties(path, identifier)
|
scm.properties(path, identifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cat(path, identifier=nil)
|
def cat(path, identifier=nil)
|
||||||
scm.cat(path, identifier)
|
scm.cat(path, identifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff(path, rev, rev_to)
|
def diff(path, rev, rev_to)
|
||||||
scm.diff(path, rev, rev_to)
|
scm.diff(path, rev, rev_to)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def diff_format_revisions(cs, cs_to, sep=':')
|
||||||
|
text = ""
|
||||||
|
text << cs_to.format_identifier + sep if cs_to
|
||||||
|
text << cs.format_identifier if cs
|
||||||
|
text
|
||||||
|
end
|
||||||
|
|
||||||
# Returns a path relative to the url of the repository
|
# Returns a path relative to the url of the repository
|
||||||
def relative_path(path)
|
def relative_path(path)
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Finds and returns a revision with a number or the beginning of a hash
|
# Finds and returns a revision with a number or the beginning of a hash
|
||||||
def find_changeset_by_name(name)
|
def find_changeset_by_name(name)
|
||||||
changesets.find(:first, :conditions => (name.match(/^\d*$/) ? ["revision = ?", name.to_s] : ["revision LIKE ?", name + '%']))
|
return nil if name.blank?
|
||||||
|
changesets.find(:first, :conditions => (name.match(/^\d*$/) ?
|
||||||
|
["revision = ?", name.to_s] : ["revision LIKE ?", name + '%']))
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest_changeset
|
def latest_changeset
|
||||||
@latest_changeset ||= changesets.find(:first)
|
@latest_changeset ||= changesets.find(:first)
|
||||||
end
|
end
|
||||||
@@ -105,26 +159,32 @@ class Repository < ActiveRecord::Base
|
|||||||
# Default behaviour is to search in cached changesets
|
# Default behaviour is to search in cached changesets
|
||||||
def latest_changesets(path, rev, limit=10)
|
def latest_changesets(path, rev, limit=10)
|
||||||
if path.blank?
|
if path.blank?
|
||||||
changesets.find(:all, :include => :user,
|
changesets.find(
|
||||||
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
|
:all,
|
||||||
:limit => limit)
|
:include => :user,
|
||||||
|
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
|
||||||
|
:limit => limit)
|
||||||
else
|
else
|
||||||
changes.find(:all, :include => {:changeset => :user},
|
changes.find(
|
||||||
:conditions => ["path = ?", path.with_leading_slash],
|
:all,
|
||||||
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
|
:include => {:changeset => :user},
|
||||||
:limit => limit).collect(&:changeset)
|
:conditions => ["path = ?", path.with_leading_slash],
|
||||||
|
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
|
||||||
|
:limit => limit
|
||||||
|
).collect(&:changeset)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def scan_changesets_for_issue_ids
|
def scan_changesets_for_issue_ids
|
||||||
self.changesets.each(&:scan_comment_for_issue_ids)
|
self.changesets.each(&:scan_comment_for_issue_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of committers usernames and associated user_id
|
# Returns an array of committers usernames and associated user_id
|
||||||
def committers
|
def committers
|
||||||
@committers ||= Changeset.connection.select_rows("SELECT DISTINCT committer, user_id FROM #{Changeset.table_name} WHERE repository_id = #{id}")
|
@committers ||= Changeset.connection.select_rows(
|
||||||
|
"SELECT DISTINCT committer, user_id FROM #{Changeset.table_name} WHERE repository_id = #{id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Maps committers username to a user ids
|
# Maps committers username to a user ids
|
||||||
def committer_ids=(h)
|
def committer_ids=(h)
|
||||||
if h.is_a?(Hash)
|
if h.is_a?(Hash)
|
||||||
@@ -132,17 +192,19 @@ class Repository < ActiveRecord::Base
|
|||||||
new_user_id = h[committer]
|
new_user_id = h[committer]
|
||||||
if new_user_id && (new_user_id.to_i != user_id.to_i)
|
if new_user_id && (new_user_id.to_i != user_id.to_i)
|
||||||
new_user_id = (new_user_id.to_i > 0 ? new_user_id.to_i : nil)
|
new_user_id = (new_user_id.to_i > 0 ? new_user_id.to_i : nil)
|
||||||
Changeset.update_all("user_id = #{ new_user_id.nil? ? 'NULL' : new_user_id }", ["repository_id = ? AND committer = ?", id, committer])
|
Changeset.update_all(
|
||||||
|
"user_id = #{ new_user_id.nil? ? 'NULL' : new_user_id }",
|
||||||
|
["repository_id = ? AND committer = ?", id, committer])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@committers = nil
|
@committers = nil
|
||||||
@found_committer_users = nil
|
@found_committer_users = nil
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the Redmine User corresponding to the given +committer+
|
# Returns the Redmine User corresponding to the given +committer+
|
||||||
# It will return nil if the committer is not yet mapped and if no User
|
# It will return nil if the committer is not yet mapped and if no User
|
||||||
# with the same username or email was found
|
# with the same username or email was found
|
||||||
@@ -150,7 +212,7 @@ class Repository < ActiveRecord::Base
|
|||||||
unless committer.blank?
|
unless committer.blank?
|
||||||
@found_committer_users ||= {}
|
@found_committer_users ||= {}
|
||||||
return @found_committer_users[committer] if @found_committer_users.has_key?(committer)
|
return @found_committer_users[committer] if @found_committer_users.has_key?(committer)
|
||||||
|
|
||||||
user = nil
|
user = nil
|
||||||
c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user)
|
c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user)
|
||||||
if c && c.user
|
if c && c.user
|
||||||
@@ -165,18 +227,27 @@ class Repository < ActiveRecord::Base
|
|||||||
user
|
user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def repo_log_encoding
|
||||||
|
encoding = log_encoding.to_s.strip
|
||||||
|
encoding.blank? ? 'UTF-8' : encoding
|
||||||
|
end
|
||||||
|
|
||||||
# Fetches new changesets for all repositories of active projects
|
# Fetches new changesets for all repositories of active projects
|
||||||
# Can be called periodically by an external script
|
# Can be called periodically by an external script
|
||||||
# eg. ruby script/runner "Repository.fetch_changesets"
|
# eg. ruby script/runner "Repository.fetch_changesets"
|
||||||
def self.fetch_changesets
|
def self.fetch_changesets
|
||||||
Project.active.has_module(:repository).find(:all, :include => :repository).each do |project|
|
Project.active.has_module(:repository).find(:all, :include => :repository).each do |project|
|
||||||
if project.repository
|
if project.repository
|
||||||
project.repository.fetch_changesets
|
begin
|
||||||
|
project.repository.fetch_changesets
|
||||||
|
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||||
|
logger.error "scm: error during fetching changesets: #{e.message}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# scan changeset comments to find related and fixed issues for all repositories
|
# scan changeset comments to find related and fixed issues for all repositories
|
||||||
def self.scan_changesets_for_issue_ids
|
def self.scan_changesets_for_issue_ids
|
||||||
find(:all).each(&:scan_changesets_for_issue_ids)
|
find(:all).each(&:scan_changesets_for_issue_ids)
|
||||||
@@ -185,27 +256,61 @@ class Repository < ActiveRecord::Base
|
|||||||
def self.scm_name
|
def self.scm_name
|
||||||
'Abstract'
|
'Abstract'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.available_scm
|
def self.available_scm
|
||||||
subclasses.collect {|klass| [klass.scm_name, klass.name]}
|
subclasses.collect {|klass| [klass.scm_name, klass.name]}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.factory(klass_name, *args)
|
def self.factory(klass_name, *args)
|
||||||
klass = "Repository::#{klass_name}".constantize
|
klass = "Repository::#{klass_name}".constantize
|
||||||
klass.new(*args)
|
klass.new(*args)
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.scm_adapter_class
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_command
|
||||||
|
ret = ""
|
||||||
|
begin
|
||||||
|
ret = self.scm_adapter_class.client_command if self.scm_adapter_class
|
||||||
|
rescue Exception => e
|
||||||
|
logger.error "scm: error during get command: #{e.message}"
|
||||||
|
end
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_version_string
|
||||||
|
ret = ""
|
||||||
|
begin
|
||||||
|
ret = self.scm_adapter_class.client_version_string if self.scm_adapter_class
|
||||||
|
rescue Exception => e
|
||||||
|
logger.error "scm: error during get version string: #{e.message}"
|
||||||
|
end
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_available
|
||||||
|
ret = false
|
||||||
|
begin
|
||||||
|
ret = self.scm_adapter_class.client_available if self.scm_adapter_class
|
||||||
|
rescue Exception => e
|
||||||
|
logger.error "scm: error during get scm available: #{e.message}"
|
||||||
|
end
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def before_save
|
def before_save
|
||||||
# Strips url and root_url
|
# Strips url and root_url
|
||||||
url.strip!
|
url.strip!
|
||||||
root_url.strip!
|
root_url.strip!
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_changesets
|
def clear_changesets
|
||||||
cs, ch, ci = Changeset.table_name, Change.table_name, "#{table_name_prefix}changesets_issues#{table_name_suffix}"
|
cs, ch, ci = Changeset.table_name, Change.table_name, "#{table_name_prefix}changesets_issues#{table_name_suffix}"
|
||||||
connection.delete("DELETE FROM #{ch} WHERE #{ch}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
connection.delete("DELETE FROM #{ch} WHERE #{ch}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -19,16 +19,24 @@ require 'redmine/scm/adapters/bazaar_adapter'
|
|||||||
|
|
||||||
class Repository::Bazaar < Repository
|
class Repository::Bazaar < Repository
|
||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url, :log_encoding
|
||||||
|
|
||||||
def scm_adapter
|
def self.human_attribute_name(attribute_key_name)
|
||||||
|
attr_name = attribute_key_name
|
||||||
|
if attr_name == "url"
|
||||||
|
attr_name = "path_to_repository"
|
||||||
|
end
|
||||||
|
super(attr_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::BazaarAdapter
|
Redmine::Scm::Adapters::BazaarAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_name
|
def self.scm_name
|
||||||
'Bazaar'
|
'Bazaar'
|
||||||
end
|
end
|
||||||
|
|
||||||
def entries(path=nil, identifier=nil)
|
def entries(path=nil, identifier=nil)
|
||||||
entries = scm.entries(path, identifier)
|
entries = scm.entries(path, identifier)
|
||||||
if entries
|
if entries
|
||||||
@@ -39,19 +47,24 @@ class Repository::Bazaar < Repository
|
|||||||
full_path = File.join(root_url, e.path)
|
full_path = File.join(root_url, e.path)
|
||||||
e.size = File.stat(full_path).size if File.file?(full_path)
|
e.size = File.stat(full_path).size if File.file?(full_path)
|
||||||
end
|
end
|
||||||
c = Change.find(:first,
|
c = Change.find(
|
||||||
:include => :changeset,
|
:first,
|
||||||
:conditions => ["#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?", e.lastrev.revision, id],
|
:include => :changeset,
|
||||||
:order => "#{Changeset.table_name}.revision DESC")
|
:conditions => [
|
||||||
|
"#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?",
|
||||||
|
e.lastrev.revision,
|
||||||
|
id
|
||||||
|
],
|
||||||
|
:order => "#{Changeset.table_name}.revision DESC")
|
||||||
if c
|
if c
|
||||||
e.lastrev.identifier = c.changeset.revision
|
e.lastrev.identifier = c.changeset.revision
|
||||||
e.lastrev.name = c.changeset.revision
|
e.lastrev.name = c.changeset.revision
|
||||||
e.lastrev.author = c.changeset.committer
|
e.lastrev.author = c.changeset.committer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_changesets
|
def fetch_changesets
|
||||||
scm_info = scm.info
|
scm_info = scm.info
|
||||||
if scm_info
|
if scm_info
|
||||||
@@ -68,18 +81,18 @@ class Repository::Bazaar < Repository
|
|||||||
revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
|
revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
|
||||||
transaction do
|
transaction do
|
||||||
revisions.reverse_each do |revision|
|
revisions.reverse_each do |revision|
|
||||||
changeset = Changeset.create(:repository => self,
|
changeset = Changeset.create(:repository => self,
|
||||||
:revision => revision.identifier,
|
:revision => revision.identifier,
|
||||||
:committer => revision.author,
|
:committer => revision.author,
|
||||||
:committed_on => revision.time,
|
:committed_on => revision.time,
|
||||||
:scmid => revision.scmid,
|
:scmid => revision.scmid,
|
||||||
:comments => revision.message)
|
:comments => revision.message)
|
||||||
|
|
||||||
revision.paths.each do |change|
|
revision.paths.each do |change|
|
||||||
Change.create(:changeset => changeset,
|
Change.create(:changeset => changeset,
|
||||||
:action => change[:action],
|
:action => change[:action],
|
||||||
:path => change[:path],
|
:path => change[:path],
|
||||||
:revision => change[:revision])
|
:revision => change[:revision])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end unless revisions.nil?
|
end unless revisions.nil?
|
||||||
|
|||||||
+118
-74
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -19,67 +19,95 @@ require 'redmine/scm/adapters/cvs_adapter'
|
|||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
|
|
||||||
class Repository::Cvs < Repository
|
class Repository::Cvs < Repository
|
||||||
validates_presence_of :url, :root_url
|
validates_presence_of :url, :root_url, :log_encoding
|
||||||
|
|
||||||
def scm_adapter
|
def self.human_attribute_name(attribute_key_name)
|
||||||
|
attr_name = attribute_key_name
|
||||||
|
if attr_name == "root_url"
|
||||||
|
attr_name = "cvsroot"
|
||||||
|
elsif attr_name == "url"
|
||||||
|
attr_name = "cvs_module"
|
||||||
|
end
|
||||||
|
super(attr_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::CvsAdapter
|
Redmine::Scm::Adapters::CvsAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_name
|
def self.scm_name
|
||||||
'CVS'
|
'CVS'
|
||||||
end
|
end
|
||||||
|
|
||||||
def entry(path=nil, identifier=nil)
|
def entry(path=nil, identifier=nil)
|
||||||
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
||||||
scm.entry(path, rev.nil? ? nil : rev.committed_on)
|
scm.entry(path, rev.nil? ? nil : rev.committed_on)
|
||||||
end
|
end
|
||||||
|
|
||||||
def entries(path=nil, identifier=nil)
|
def entries(path=nil, identifier=nil)
|
||||||
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
rev = nil
|
||||||
|
if ! identifier.nil?
|
||||||
|
rev = changesets.find_by_revision(identifier)
|
||||||
|
return nil if rev.nil?
|
||||||
|
end
|
||||||
entries = scm.entries(path, rev.nil? ? nil : rev.committed_on)
|
entries = scm.entries(path, rev.nil? ? nil : rev.committed_on)
|
||||||
if entries
|
if entries
|
||||||
entries.each() do |entry|
|
entries.each() do |entry|
|
||||||
unless entry.lastrev.nil? || entry.lastrev.identifier
|
if ( ! entry.lastrev.nil? ) && ( ! entry.lastrev.revision.nil? )
|
||||||
change=changes.find_by_revision_and_path( entry.lastrev.revision, scm.with_leading_slash(entry.path) )
|
change=changes.find_by_revision_and_path(
|
||||||
|
entry.lastrev.revision,
|
||||||
|
scm.with_leading_slash(entry.path) )
|
||||||
if change
|
if change
|
||||||
entry.lastrev.identifier=change.changeset.revision
|
entry.lastrev.identifier = change.changeset.revision
|
||||||
entry.lastrev.author=change.changeset.committer
|
entry.lastrev.revision = change.changeset.revision
|
||||||
entry.lastrev.revision=change.revision
|
entry.lastrev.author = change.changeset.committer
|
||||||
entry.lastrev.branch=change.branch
|
# entry.lastrev.branch = change.branch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
entries
|
entries
|
||||||
end
|
end
|
||||||
|
|
||||||
def cat(path, identifier=nil)
|
def cat(path, identifier=nil)
|
||||||
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
rev = nil
|
||||||
|
if ! identifier.nil?
|
||||||
|
rev = changesets.find_by_revision(identifier)
|
||||||
|
return nil if rev.nil?
|
||||||
|
end
|
||||||
scm.cat(path, rev.nil? ? nil : rev.committed_on)
|
scm.cat(path, rev.nil? ? nil : rev.committed_on)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def annotate(path, identifier=nil)
|
||||||
|
rev = nil
|
||||||
|
if ! identifier.nil?
|
||||||
|
rev = changesets.find_by_revision(identifier)
|
||||||
|
return nil if rev.nil?
|
||||||
|
end
|
||||||
|
scm.annotate(path, rev.nil? ? nil : rev.committed_on)
|
||||||
|
end
|
||||||
|
|
||||||
def diff(path, rev, rev_to)
|
def diff(path, rev, rev_to)
|
||||||
#convert rev to revision. CVS can't handle changesets here
|
# convert rev to revision. CVS can't handle changesets here
|
||||||
diff=[]
|
diff=[]
|
||||||
changeset_from=changesets.find_by_revision(rev)
|
changeset_from = changesets.find_by_revision(rev)
|
||||||
if rev_to.to_i > 0
|
if rev_to.to_i > 0
|
||||||
changeset_to=changesets.find_by_revision(rev_to)
|
changeset_to = changesets.find_by_revision(rev_to)
|
||||||
end
|
end
|
||||||
changeset_from.changes.each() do |change_from|
|
changeset_from.changes.each() do |change_from|
|
||||||
|
revision_from = nil
|
||||||
revision_from=nil
|
revision_to = nil
|
||||||
revision_to=nil
|
if path.nil? || (change_from.path.starts_with? scm.with_leading_slash(path))
|
||||||
|
revision_from = change_from.revision
|
||||||
revision_from=change_from.revision if path.nil? || (change_from.path.starts_with? scm.with_leading_slash(path))
|
end
|
||||||
|
|
||||||
if revision_from
|
if revision_from
|
||||||
if changeset_to
|
if changeset_to
|
||||||
changeset_to.changes.each() do |change_to|
|
changeset_to.changes.each() do |change_to|
|
||||||
revision_to=change_to.revision if change_to.path==change_from.path
|
revision_to = change_to.revision if change_to.path == change_from.path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless revision_to
|
unless revision_to
|
||||||
revision_to=scm.get_previous_revision(revision_from)
|
revision_to = scm.get_previous_revision(revision_from)
|
||||||
end
|
end
|
||||||
file_diff = scm.diff(change_from.path, revision_from, revision_to)
|
file_diff = scm.diff(change_from.path, revision_from, revision_to)
|
||||||
diff = diff + file_diff unless file_diff.nil?
|
diff = diff + file_diff unless file_diff.nil?
|
||||||
@@ -87,75 +115,91 @@ class Repository::Cvs < Repository
|
|||||||
end
|
end
|
||||||
return diff
|
return diff
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_changesets
|
def fetch_changesets
|
||||||
# some nifty bits to introduce a commit-id with cvs
|
# some nifty bits to introduce a commit-id with cvs
|
||||||
# natively cvs doesn't provide any kind of changesets, there is only a revision per file.
|
# natively cvs doesn't provide any kind of changesets,
|
||||||
|
# there is only a revision per file.
|
||||||
# we now take a guess using the author, the commitlog and the commit-date.
|
# we now take a guess using the author, the commitlog and the commit-date.
|
||||||
|
|
||||||
# last one is the next step to take. the commit-date is not equal for all
|
# last one is the next step to take. the commit-date is not equal for all
|
||||||
# commits in one changeset. cvs update the commit-date when the *,v file was touched. so
|
# commits in one changeset. cvs update the commit-date when the *,v file was touched. so
|
||||||
# we use a small delta here, to merge all changes belonging to _one_ changeset
|
# we use a small delta here, to merge all changes belonging to _one_ changeset
|
||||||
time_delta=10.seconds
|
time_delta = 10.seconds
|
||||||
|
|
||||||
fetch_since = latest_changeset ? latest_changeset.committed_on : nil
|
fetch_since = latest_changeset ? latest_changeset.committed_on : nil
|
||||||
transaction do
|
transaction do
|
||||||
tmp_rev_num = 1
|
tmp_rev_num = 1
|
||||||
scm.revisions('', fetch_since, nil, :with_paths => true) do |revision|
|
scm.revisions('', fetch_since, nil, :log_encoding => repo_log_encoding) do |revision|
|
||||||
# only add the change to the database, if it doen't exists. the cvs log
|
# only add the change to the database, if it doen't exists. the cvs log
|
||||||
# is not exclusive at all.
|
# is not exclusive at all.
|
||||||
unless changes.find_by_path_and_revision(scm.with_leading_slash(revision.paths[0][:path]), revision.paths[0][:revision])
|
tmp_time = revision.time.clone
|
||||||
revision
|
unless changes.find_by_path_and_revision(
|
||||||
cs = changesets.find(:first, :conditions=>{
|
scm.with_leading_slash(revision.paths[0][:path]),
|
||||||
:committed_on=>revision.time-time_delta..revision.time+time_delta,
|
revision.paths[0][:revision]
|
||||||
:committer=>revision.author,
|
)
|
||||||
:comments=>Changeset.normalize_comments(revision.message)
|
cmt = Changeset.normalize_comments(revision.message, repo_log_encoding)
|
||||||
})
|
author_utf8 = Changeset.to_utf8(revision.author, repo_log_encoding)
|
||||||
|
cs = changesets.find(
|
||||||
# create a new changeset....
|
:first,
|
||||||
|
:conditions => {
|
||||||
|
:committed_on => tmp_time - time_delta .. tmp_time + time_delta,
|
||||||
|
:committer => author_utf8,
|
||||||
|
:comments => cmt
|
||||||
|
}
|
||||||
|
)
|
||||||
|
# create a new changeset....
|
||||||
unless cs
|
unless cs
|
||||||
# we use a temporaray revision number here (just for inserting)
|
# we use a temporaray revision number here (just for inserting)
|
||||||
# later on, we calculate a continous positive number
|
# later on, we calculate a continous positive number
|
||||||
latest = changesets.find(:first, :order => 'id DESC')
|
tmp_time2 = tmp_time.clone.gmtime
|
||||||
cs = Changeset.create(:repository => self,
|
branch = revision.paths[0][:branch]
|
||||||
:revision => "_#{tmp_rev_num}",
|
scmid = branch + "-" + tmp_time2.strftime("%Y%m%d-%H%M%S")
|
||||||
:committer => revision.author,
|
cs = Changeset.create(:repository => self,
|
||||||
:committed_on => revision.time,
|
:revision => "tmp#{tmp_rev_num}",
|
||||||
:comments => revision.message)
|
:scmid => scmid,
|
||||||
|
:committer => revision.author,
|
||||||
|
:committed_on => tmp_time,
|
||||||
|
:comments => revision.message)
|
||||||
tmp_rev_num += 1
|
tmp_rev_num += 1
|
||||||
end
|
end
|
||||||
|
# convert CVS-File-States to internal Action-abbrevations
|
||||||
#convert CVS-File-States to internal Action-abbrevations
|
# default action is (M)odified
|
||||||
#default action is (M)odified
|
action = "M"
|
||||||
action="M"
|
if revision.paths[0][:action] == "Exp" && revision.paths[0][:revision] == "1.1"
|
||||||
if revision.paths[0][:action]=="Exp" && revision.paths[0][:revision]=="1.1"
|
action = "A" # add-action always at first revision (= 1.1)
|
||||||
action="A" #add-action always at first revision (= 1.1)
|
elsif revision.paths[0][:action] == "dead"
|
||||||
elsif revision.paths[0][:action]=="dead"
|
action = "D" # dead-state is similar to Delete
|
||||||
action="D" #dead-state is similar to Delete
|
|
||||||
end
|
end
|
||||||
|
Change.create(
|
||||||
Change.create(:changeset => cs,
|
:changeset => cs,
|
||||||
:action => action,
|
:action => action,
|
||||||
:path => scm.with_leading_slash(revision.paths[0][:path]),
|
:path => scm.with_leading_slash(revision.paths[0][:path]),
|
||||||
:revision => revision.paths[0][:revision],
|
:revision => revision.paths[0][:revision],
|
||||||
:branch => revision.paths[0][:branch]
|
:branch => revision.paths[0][:branch]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renumber new changesets in chronological order
|
# Renumber new changesets in chronological order
|
||||||
changesets.find(:all, :order => 'committed_on ASC, id ASC', :conditions => "revision LIKE '_%'").each do |changeset|
|
changesets.find(
|
||||||
|
:all,
|
||||||
|
:order => 'committed_on ASC, id ASC',
|
||||||
|
:conditions => "revision LIKE 'tmp%'"
|
||||||
|
).each do |changeset|
|
||||||
changeset.update_attribute :revision, next_revision_number
|
changeset.update_attribute :revision, next_revision_number
|
||||||
end
|
end
|
||||||
end # transaction
|
end # transaction
|
||||||
|
@current_revision_number = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Returns the next revision number to assign to a CVS changeset
|
# Returns the next revision number to assign to a CVS changeset
|
||||||
def next_revision_number
|
def next_revision_number
|
||||||
# Need to retrieve existing revision numbers to sort them as integers
|
# Need to retrieve existing revision numbers to sort them as integers
|
||||||
@current_revision_number ||= (connection.select_values("SELECT revision FROM #{Changeset.table_name} WHERE repository_id = #{id} AND revision NOT LIKE '_%'").collect(&:to_i).max || 0)
|
sql = "SELECT revision FROM #{Changeset.table_name} "
|
||||||
|
sql << "WHERE repository_id = #{id} AND revision NOT LIKE 'tmp%'"
|
||||||
|
@current_revision_number ||= (connection.select_values(sql).collect(&:to_i).max || 0)
|
||||||
@current_revision_number += 1
|
@current_revision_number += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -18,44 +18,62 @@
|
|||||||
require 'redmine/scm/adapters/darcs_adapter'
|
require 'redmine/scm/adapters/darcs_adapter'
|
||||||
|
|
||||||
class Repository::Darcs < Repository
|
class Repository::Darcs < Repository
|
||||||
validates_presence_of :url
|
validates_presence_of :url, :log_encoding
|
||||||
|
|
||||||
def scm_adapter
|
def self.human_attribute_name(attribute_key_name)
|
||||||
|
attr_name = attribute_key_name
|
||||||
|
if attr_name == "url"
|
||||||
|
attr_name = "path_to_repository"
|
||||||
|
end
|
||||||
|
super(attr_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::DarcsAdapter
|
Redmine::Scm::Adapters::DarcsAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_name
|
def self.scm_name
|
||||||
'Darcs'
|
'Darcs'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def supports_directory_revisions?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def entry(path=nil, identifier=nil)
|
def entry(path=nil, identifier=nil)
|
||||||
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
||||||
scm.entry(path, patch.nil? ? nil : patch.scmid)
|
scm.entry(path, patch.nil? ? nil : patch.scmid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def entries(path=nil, identifier=nil)
|
def entries(path=nil, identifier=nil)
|
||||||
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
|
patch = nil
|
||||||
|
if ! identifier.nil?
|
||||||
|
patch = changesets.find_by_revision(identifier)
|
||||||
|
return nil if patch.nil?
|
||||||
|
end
|
||||||
entries = scm.entries(path, patch.nil? ? nil : patch.scmid)
|
entries = scm.entries(path, patch.nil? ? nil : patch.scmid)
|
||||||
if entries
|
if entries
|
||||||
entries.each do |entry|
|
entries.each do |entry|
|
||||||
# Search the DB for the entry's last change
|
# Search the DB for the entry's last change
|
||||||
changeset = changesets.find_by_scmid(entry.lastrev.scmid) if entry.lastrev && !entry.lastrev.scmid.blank?
|
if entry.lastrev && !entry.lastrev.scmid.blank?
|
||||||
|
changeset = changesets.find_by_scmid(entry.lastrev.scmid)
|
||||||
|
end
|
||||||
if changeset
|
if changeset
|
||||||
entry.lastrev.identifier = changeset.revision
|
entry.lastrev.identifier = changeset.revision
|
||||||
entry.lastrev.name = changeset.revision
|
entry.lastrev.name = changeset.revision
|
||||||
entry.lastrev.time = changeset.committed_on
|
entry.lastrev.time = changeset.committed_on
|
||||||
entry.lastrev.author = changeset.committer
|
entry.lastrev.author = changeset.committer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
entries
|
entries
|
||||||
end
|
end
|
||||||
|
|
||||||
def cat(path, identifier=nil)
|
def cat(path, identifier=nil)
|
||||||
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier.to_s)
|
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier.to_s)
|
||||||
scm.cat(path, patch.nil? ? nil : patch.scmid)
|
scm.cat(path, patch.nil? ? nil : patch.scmid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff(path, rev, rev_to)
|
def diff(path, rev, rev_to)
|
||||||
patch_from = changesets.find_by_revision(rev)
|
patch_from = changesets.find_by_revision(rev)
|
||||||
return nil if patch_from.nil?
|
return nil if patch_from.nil?
|
||||||
@@ -65,25 +83,24 @@ class Repository::Darcs < Repository
|
|||||||
end
|
end
|
||||||
patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil
|
patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_changesets
|
def fetch_changesets
|
||||||
scm_info = scm.info
|
scm_info = scm.info
|
||||||
if scm_info
|
if scm_info
|
||||||
db_last_id = latest_changeset ? latest_changeset.scmid : nil
|
db_last_id = latest_changeset ? latest_changeset.scmid : nil
|
||||||
next_rev = latest_changeset ? latest_changeset.revision.to_i + 1 : 1
|
next_rev = latest_changeset ? latest_changeset.revision.to_i + 1 : 1
|
||||||
# latest revision in the repository
|
# latest revision in the repository
|
||||||
scm_revision = scm_info.lastrev.scmid
|
scm_revision = scm_info.lastrev.scmid
|
||||||
unless changesets.find_by_scmid(scm_revision)
|
unless changesets.find_by_scmid(scm_revision)
|
||||||
revisions = scm.revisions('', db_last_id, nil, :with_path => true)
|
revisions = scm.revisions('', db_last_id, nil, :with_path => true)
|
||||||
transaction do
|
transaction do
|
||||||
revisions.reverse_each do |revision|
|
revisions.reverse_each do |revision|
|
||||||
changeset = Changeset.create(:repository => self,
|
changeset = Changeset.create(:repository => self,
|
||||||
:revision => next_rev,
|
:revision => next_rev,
|
||||||
:scmid => revision.scmid,
|
:scmid => revision.scmid,
|
||||||
:committer => revision.author,
|
:committer => revision.author,
|
||||||
:committed_on => revision.time,
|
:committed_on => revision.time,
|
||||||
:comments => revision.message)
|
:comments => revision.message)
|
||||||
|
|
||||||
revision.paths.each do |change|
|
revision.paths.each do |change|
|
||||||
changeset.create_change(change)
|
changeset.create_change(change)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# FileSystem adapter
|
# FileSystem adapter
|
||||||
# File written by Paul Rivier, at Demotera.
|
# File written by Paul Rivier, at Demotera.
|
||||||
@@ -8,12 +8,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -24,14 +24,26 @@ class Repository::Filesystem < Repository
|
|||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
|
|
||||||
def scm_adapter
|
def self.human_attribute_name(attribute_key_name)
|
||||||
|
attr_name = attribute_key_name
|
||||||
|
if attr_name == "url"
|
||||||
|
attr_name = "root_directory"
|
||||||
|
end
|
||||||
|
super(attr_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::FilesystemAdapter
|
Redmine::Scm::Adapters::FilesystemAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_name
|
def self.scm_name
|
||||||
'Filesystem'
|
'Filesystem'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def supports_all_revisions?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def entries(path=nil, identifier=nil)
|
def entries(path=nil, identifier=nil)
|
||||||
scm.entries(path, identifier)
|
scm.entries(path, identifier)
|
||||||
end
|
end
|
||||||
@@ -39,5 +51,4 @@ class Repository::Filesystem < Repository
|
|||||||
def fetch_changesets
|
def fetch_changesets
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
+141
-31
@@ -1,16 +1,17 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
# Copyright (C) 2007 Patrick Aljord patcito@ŋmail.com
|
# Copyright (C) 2007 Patrick Aljord patcito@ŋmail.com
|
||||||
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@@ -21,14 +22,51 @@ class Repository::Git < Repository
|
|||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
|
|
||||||
def scm_adapter
|
def self.human_attribute_name(attribute_key_name)
|
||||||
|
attr_name = attribute_key_name
|
||||||
|
if attr_name == "url"
|
||||||
|
attr_name = "path_to_repository"
|
||||||
|
end
|
||||||
|
super(attr_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::GitAdapter
|
Redmine::Scm::Adapters::GitAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_name
|
def self.scm_name
|
||||||
'Git'
|
'Git'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def report_last_commit
|
||||||
|
extra_report_last_commit
|
||||||
|
end
|
||||||
|
|
||||||
|
def extra_report_last_commit
|
||||||
|
return false if extra_info.nil?
|
||||||
|
v = extra_info["extra_report_last_commit"]
|
||||||
|
return false if v.nil?
|
||||||
|
v.to_s != '0'
|
||||||
|
end
|
||||||
|
|
||||||
|
def supports_directory_revisions?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def repo_log_encoding
|
||||||
|
'UTF-8'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns the identifier for the given git changeset
|
||||||
|
def self.changeset_identifier(changeset)
|
||||||
|
changeset.scmid
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns the readable identifier for the given git changeset
|
||||||
|
def self.format_changeset_identifier(changeset)
|
||||||
|
changeset.revision[0, 8]
|
||||||
|
end
|
||||||
|
|
||||||
def branches
|
def branches
|
||||||
scm.branches
|
scm.branches
|
||||||
end
|
end
|
||||||
@@ -37,42 +75,114 @@ class Repository::Git < Repository
|
|||||||
scm.tags
|
scm.tags
|
||||||
end
|
end
|
||||||
|
|
||||||
# With SCM's that have a sequential commit numbering, redmine is able to be
|
def default_branch
|
||||||
# clever and only fetch changesets going forward from the most recent one
|
scm.default_branch
|
||||||
# it knows about. However, with git, you never know if people have merged
|
end
|
||||||
# commits into the middle of the repository history, so we should parse
|
|
||||||
# the entire log. Since it's way too slow for large repositories, we only
|
def find_changeset_by_name(name)
|
||||||
# parse 1 week before the last known commit.
|
return nil if name.nil? || name.empty?
|
||||||
|
e = changesets.find(:first, :conditions => ['revision = ?', name.to_s])
|
||||||
|
return e if e
|
||||||
|
changesets.find(:first, :conditions => ['scmid LIKE ?', "#{name}%"])
|
||||||
|
end
|
||||||
|
|
||||||
|
def entries(path=nil, identifier=nil)
|
||||||
|
scm.entries(path,
|
||||||
|
identifier,
|
||||||
|
options = {:report_last_commit => extra_report_last_commit})
|
||||||
|
end
|
||||||
|
|
||||||
|
# With SCMs that have a sequential commit numbering,
|
||||||
|
# such as Subversion and Mercurial,
|
||||||
|
# Redmine is able to be clever and only fetch changesets
|
||||||
|
# going forward from the most recent one it knows about.
|
||||||
|
#
|
||||||
|
# However, Git does not have a sequential commit numbering.
|
||||||
|
#
|
||||||
|
# In order to fetch only new adding revisions,
|
||||||
|
# Redmine needs to parse revisions per branch.
|
||||||
|
# Branch "last_scmid" is for this requirement.
|
||||||
|
#
|
||||||
|
# In Git and Mercurial, revisions are not in date order.
|
||||||
|
# Redmine Mercurial fixed issues.
|
||||||
|
# * Redmine Takes Too Long On Large Mercurial Repository
|
||||||
|
# http://www.redmine.org/issues/3449
|
||||||
|
# * Sorting for changesets might go wrong on Mercurial repos
|
||||||
|
# http://www.redmine.org/issues/3567
|
||||||
|
#
|
||||||
|
# Database revision column is text, so Redmine can not sort by revision.
|
||||||
|
# Mercurial has revision number, and revision number guarantees revision order.
|
||||||
|
# Redmine Mercurial model stored revisions ordered by database id to database.
|
||||||
|
# So, Redmine Mercurial model can use correct ordering revisions.
|
||||||
|
#
|
||||||
|
# Redmine Mercurial adapter uses "hg log -r 0:tip --limit 10"
|
||||||
|
# to get limited revisions from old to new.
|
||||||
|
# But, Git 1.7.3.4 does not support --reverse with -n or --skip.
|
||||||
|
#
|
||||||
# The repository can still be fully reloaded by calling #clear_changesets
|
# The repository can still be fully reloaded by calling #clear_changesets
|
||||||
# before fetching changesets (eg. for offline resync)
|
# before fetching changesets (eg. for offline resync)
|
||||||
def fetch_changesets
|
def fetch_changesets
|
||||||
c = changesets.find(:first, :order => 'committed_on DESC')
|
scm_brs = branches
|
||||||
since = (c ? c.committed_on - 7.days : nil)
|
return if scm_brs.nil? || scm_brs.empty?
|
||||||
|
h1 = extra_info || {}
|
||||||
revisions = scm.revisions('', nil, nil, :all => true, :since => since)
|
h = h1.dup
|
||||||
return if revisions.nil? || revisions.empty?
|
h["branches"] ||= {}
|
||||||
|
h["db_consistent"] ||= {}
|
||||||
recent_changesets = changesets.find(:all, :conditions => ['committed_on >= ?', since])
|
if changesets.count == 0
|
||||||
|
h["db_consistent"]["ordering"] = 1
|
||||||
# Clean out revisions that are no longer in git
|
merge_extra_info(h)
|
||||||
recent_changesets.each {|c| c.destroy unless revisions.detect {|r| r.scmid.to_s == c.scmid.to_s }}
|
self.save
|
||||||
|
elsif ! h["db_consistent"].has_key?("ordering")
|
||||||
# Subtract revisions that redmine already knows about
|
h["db_consistent"]["ordering"] = 0
|
||||||
recent_revisions = recent_changesets.map{|c| c.scmid}
|
merge_extra_info(h)
|
||||||
revisions.reject!{|r| recent_revisions.include?(r.scmid)}
|
self.save
|
||||||
|
end
|
||||||
# Save the remaining ones to the database
|
scm_brs.each do |br|
|
||||||
revisions.each{|r| r.save(self)} unless revisions.nil?
|
from_scmid = nil
|
||||||
|
from_scmid = h["branches"][br]["last_scmid"] if h["branches"][br]
|
||||||
|
h["branches"][br] ||= {}
|
||||||
|
scm.revisions('', from_scmid, br, {:reverse => true}) do |rev|
|
||||||
|
db_rev = find_changeset_by_name(rev.revision)
|
||||||
|
transaction do
|
||||||
|
if db_rev.nil?
|
||||||
|
save_revision(rev)
|
||||||
|
end
|
||||||
|
h["branches"][br]["last_scmid"] = rev.scmid
|
||||||
|
merge_extra_info(h)
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def save_revision(rev)
|
||||||
|
changeset = Changeset.new(
|
||||||
|
:repository => self,
|
||||||
|
:revision => rev.identifier,
|
||||||
|
:scmid => rev.scmid,
|
||||||
|
:committer => rev.author,
|
||||||
|
:committed_on => rev.time,
|
||||||
|
:comments => rev.message
|
||||||
|
)
|
||||||
|
if changeset.save
|
||||||
|
rev.paths.each do |file|
|
||||||
|
Change.create(
|
||||||
|
:changeset => changeset,
|
||||||
|
:action => file[:action],
|
||||||
|
:path => file[:path])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
private :save_revision
|
||||||
|
|
||||||
def latest_changesets(path,rev,limit=10)
|
def latest_changesets(path,rev,limit=10)
|
||||||
revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false)
|
revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false)
|
||||||
return [] if revisions.nil? || revisions.empty?
|
return [] if revisions.nil? || revisions.empty?
|
||||||
|
|
||||||
changesets.find(
|
changesets.find(
|
||||||
:all,
|
:all,
|
||||||
:conditions => [
|
:conditions => [
|
||||||
"scmid IN (?)",
|
"scmid IN (?)",
|
||||||
revisions.map!{|c| c.scmid}
|
revisions.map!{|c| c.scmid}
|
||||||
],
|
],
|
||||||
:order => 'committed_on DESC'
|
:order => 'committed_on DESC'
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user