Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72716d0e01 | ||
|
|
e2f00792a8 | ||
|
|
9ed998af9b | ||
|
|
1881706df4 | ||
|
|
a3bf12ab9f | ||
|
|
668981b8cd | ||
|
|
b303dddbe3 | ||
|
|
933e96116e | ||
|
|
10711fda6d | ||
|
|
b3b829c025 | ||
|
|
8cd0baf773 | ||
|
|
033aa68427 | ||
|
|
1eb20d42bd | ||
|
|
a9dbecd5a5 | ||
|
|
a13218e9f4 | ||
|
|
57b0faf128 | ||
|
|
ba3828b49f | ||
|
|
fe1a152e02 | ||
|
|
69709a2513 | ||
|
|
7b7bca0b59 | ||
|
|
64b0cb336d | ||
|
|
79b7b32980 | ||
|
|
1e1517e6ab | ||
|
|
70b0d5722b | ||
|
|
3883d5e2db | ||
|
|
bca6c447cb | ||
|
|
b230429a61 | ||
|
|
a06462548c | ||
|
|
e62a40a719 | ||
|
|
5a1be1d8df | ||
|
|
81c207b193 | ||
|
|
60cdcd5522 | ||
|
|
da293fdfd8 | ||
|
|
9cfb7e1c87 | ||
|
|
78c185abde | ||
|
|
3266265cad | ||
|
|
d9304e062a | ||
|
|
40af0a2cbf | ||
|
|
eb53d600c9 | ||
|
|
fa4fdf91a4 | ||
|
|
e9ac98b249 | ||
|
|
9db20cd02c | ||
|
|
b0951bff54 | ||
|
|
0a09984954 | ||
|
|
9b7105465e | ||
|
|
45683d9c2a | ||
|
|
dcba6f0400 | ||
|
|
f11e9eb2d6 | ||
|
|
095d99cf9e | ||
|
|
163ac957ba | ||
|
|
04a8a72491 | ||
|
|
a1a6dcffca | ||
|
|
d31402734b | ||
|
|
5180ca0cdd | ||
|
|
e5802895ce | ||
|
|
da1a3449ce | ||
|
|
2b2f721ef4 | ||
|
|
62114336cf | ||
|
|
4f48d1b4dd | ||
|
|
d6d064f875 | ||
|
|
6d8649b9d3 | ||
|
|
39deb03855 | ||
|
|
70036a7ad0 | ||
|
|
68d421b978 | ||
|
|
268a9db47e | ||
|
|
a35b81b9fa | ||
|
|
fd450fd2da | ||
|
|
2c0ba78f70 | ||
|
|
f0f01d370e | ||
|
|
4c330a1241 | ||
|
|
baa4ebd05f | ||
|
|
59f14478ed | ||
|
|
8fefb7c05b | ||
|
|
1feb373c89 | ||
|
|
32fd503cbb | ||
|
|
cf31aeaf81 | ||
|
|
83ea66fd2c | ||
|
|
ef2c5cab2d | ||
|
|
dee6f6b138 | ||
|
|
a4c0c18e3d | ||
|
|
4c82fbb6f8 | ||
|
|
68ded50edc | ||
|
|
72ecb80dc7 | ||
|
|
86ee285eb4 | ||
|
|
c229ea6386 | ||
|
|
687fca170e | ||
|
|
26564b06f7 | ||
|
|
34016c38bd | ||
|
|
15ff361894 | ||
|
|
b45b5f4322 | ||
|
|
8addbc537a | ||
|
|
87eeacba80 | ||
|
|
a7250c41e2 | ||
|
|
7c45396d92 | ||
|
|
c1f98c835c | ||
|
|
6a9e16deda | ||
|
|
7993f2f329 | ||
|
|
b4975862d6 | ||
|
|
331cf23345 | ||
|
|
f05f84a2ea | ||
|
|
dd5b091321 | ||
|
|
bac7dff5bb | ||
|
|
f1cae4f7af | ||
|
|
e964135b62 | ||
|
|
8828c0f13e | ||
|
|
f277f127c6 | ||
|
|
b88586b56d | ||
|
|
c1dd88b015 | ||
|
|
d36d64f664 | ||
|
|
ddce7ef142 | ||
|
|
9aefe8b1e9 | ||
|
|
72590ea997 | ||
|
|
a5b480c62e | ||
|
|
b96710fb57 | ||
|
|
f0f7158d87 | ||
|
|
bc2a22e17f | ||
|
|
186f9400d0 | ||
|
|
1a87912b06 | ||
|
|
29782860b7 | ||
|
|
cd250714e5 | ||
|
|
4df99674ff | ||
|
|
f93261a7ea | ||
|
|
aaa8232a27 | ||
|
|
c11dc925de | ||
|
|
f800d2185e | ||
|
|
90bd015467 | ||
|
|
dd5c702e11 | ||
|
|
f9d123c08f | ||
|
|
0e7a2dd688 | ||
|
|
b054ccf9c7 | ||
|
|
f0936aaf18 | ||
|
|
3db1fa6b83 | ||
|
|
3b6be9ca4e | ||
|
|
fc71741101 | ||
|
|
3847223841 | ||
|
|
db110ba35e | ||
|
|
a81927361e | ||
|
|
be04f1dd62 | ||
|
|
0098c7b128 | ||
|
|
f36eb54141 | ||
|
|
cdb7ea8b91 | ||
|
|
b2a2cb68dd | ||
|
|
76435033e7 | ||
|
|
27dca22c91 | ||
|
|
d2c80656f1 | ||
|
|
5232d379f9 | ||
|
|
9b333e1c87 | ||
|
|
3e11f9abfe | ||
|
|
fbe959b2a8 | ||
|
|
2145b650a6 | ||
|
|
5f37d0d1c8 | ||
|
|
5c9dd16295 | ||
|
|
274566f13b | ||
|
|
706f8b1691 | ||
|
|
6115a079ec | ||
|
|
1294f72175 | ||
|
|
5663ca89fa | ||
|
|
ee8002b0c9 | ||
|
|
f071b39d26 | ||
|
|
bb36fa5d12 | ||
|
|
fae5250e52 | ||
|
|
e2bb8721d9 | ||
|
|
103cd46f78 | ||
|
|
8bc638f404 | ||
|
|
27c390bb62 | ||
|
|
c8af69342b | ||
|
|
aeef75d49d | ||
|
|
13b13089ea | ||
|
|
e55c8f6b67 | ||
|
|
b17b673039 | ||
|
|
fec3e6c84b | ||
|
|
7c5635f6c6 | ||
|
|
77314ebe8f | ||
|
|
fdeb398c5e | ||
|
|
ef77825f10 | ||
|
|
224331dacb | ||
|
|
ae5edac243 | ||
|
|
95b10f3bd3 | ||
|
|
dd1b2876b1 | ||
|
|
60e6a623bd | ||
|
|
a8e392c0e5 | ||
|
|
71e636ff71 | ||
|
|
bd47af098f | ||
|
|
81185a8d93 | ||
|
|
16fbb3664c | ||
|
|
30829e73ac | ||
|
|
592fd5dcf8 | ||
|
|
6cb1eace43 | ||
|
|
27f14b86ce | ||
|
|
78731c2577 | ||
|
|
3aa894392e | ||
|
|
0dd11fc6a6 | ||
|
|
d26300bd45 | ||
|
|
2f04b443c0 | ||
|
|
dec1447816 | ||
|
|
fd2af060a9 | ||
|
|
ea2e5d959f | ||
|
|
7d60e70709 | ||
|
|
fe6d37812d | ||
|
|
d131cf88c1 | ||
|
|
0773d24a87 | ||
|
|
41875368cd | ||
|
|
d34396fd08 | ||
|
|
358ee48112 | ||
|
|
9c77a39a00 | ||
|
|
73c8ea65dc | ||
|
|
c86c07e22f | ||
|
|
d9c9814d31 | ||
|
|
8268e5b704 | ||
|
|
d0d1754a5d | ||
|
|
bd31e2ee26 | ||
|
|
517139dade | ||
|
|
a999bd4074 | ||
|
|
7558f82407 | ||
|
|
af2c20273d | ||
|
|
de263d460d | ||
|
|
1e1ccfab3f | ||
|
|
a825d0fd35 | ||
|
|
f4ea7827d2 | ||
|
|
a65f1e09e4 | ||
|
|
0be826d93a | ||
|
|
4b2aff84d5 | ||
|
|
40cb7435a0 | ||
|
|
e691fd682d | ||
|
|
ad90ffd9b3 | ||
|
|
8a4fb95d8e | ||
|
|
1c09aa9901 | ||
|
|
99b7cc7b16 | ||
|
|
018a6a92a1 | ||
|
|
b68a7cdf20 | ||
|
|
a220bd7429 | ||
|
|
c3afc8d3a6 | ||
|
|
0b9826b995 | ||
|
|
e065f9a35a | ||
|
|
abea976214 | ||
|
|
a74e86ddce | ||
|
|
dbda62849d | ||
|
|
8612fa2fc1 | ||
|
|
934dd07fa7 | ||
|
|
33cb9c87a9 | ||
|
|
125f5e1710 | ||
|
|
aebaaad85a | ||
|
|
25620a7429 | ||
|
|
24bd39d8ed | ||
|
|
2de9e782ad | ||
|
|
d849d06b56 | ||
|
|
e7dd193a76 | ||
|
|
cfdef5e11a | ||
|
|
099759eda1 | ||
|
|
839ac5105c | ||
|
|
17fabcad8e | ||
|
|
2e6ccfa95c | ||
|
|
036b81abfd | ||
|
|
67e8d1113e | ||
|
|
0cbbb9fda8 | ||
|
|
999a4ba30d | ||
|
|
bcba955456 | ||
|
|
f0987e4b8f | ||
|
|
374c2aa705 | ||
|
|
2bcf9f2871 | ||
|
|
87356648f6 | ||
|
|
efddab48be | ||
|
|
fef2e4b672 | ||
|
|
1ec2d98c14 | ||
|
|
0ee1de5686 | ||
|
|
d0356fe935 | ||
|
|
286bda14f1 | ||
|
|
2c6ad7525a | ||
|
|
460239d1f9 | ||
|
|
809d35d34b | ||
|
|
bdf6e90f05 | ||
|
|
6aad82e524 | ||
|
|
b7555bd1ff | ||
|
|
89dc7bb60b | ||
|
|
d906ff8d7b | ||
|
|
aa9238912b | ||
|
|
97ca65d1b2 | ||
|
|
d4372ab747 | ||
|
|
9bb056e54d | ||
|
|
d8b0981330 | ||
|
|
2f1d6cd94d | ||
|
|
1214365611 | ||
|
|
12ad36f474 | ||
|
|
ee54720556 | ||
|
|
865c2b02e5 | ||
|
|
5756ef2941 | ||
|
|
3e0c70a6f5 | ||
|
|
d92dbc3dd5 | ||
|
|
6b47cad8ce | ||
|
|
dc50edae5e | ||
|
|
5803bf9fc4 | ||
|
|
df89c24e37 | ||
|
|
67d52acb84 | ||
|
|
fa12fad4f2 | ||
|
|
8071b71c5d | ||
|
|
80663e694d | ||
|
|
a6992aa6fc | ||
|
|
3aaf2b9ed0 | ||
|
|
b1d5f42237 | ||
|
|
9b576d7d0a | ||
|
|
45e2e57afb | ||
|
|
7ec8a9a100 | ||
|
|
b06223738e | ||
|
|
d862843c9d | ||
|
|
1b923819e8 | ||
|
|
7dbc3e4774 | ||
|
|
bcd8c64384 | ||
|
|
c30a6dffe0 | ||
|
|
60b0a6c4b8 | ||
|
|
bf05656c36 | ||
|
|
64d843a4d7 | ||
|
|
858e317e6e | ||
|
|
af75583b23 | ||
|
|
8db9ffbd8b | ||
|
|
a0de4c1576 | ||
|
|
d13ae4604c | ||
|
|
70ced2f2af | ||
|
|
eb5a9f83c9 | ||
|
|
c7b1a42d19 | ||
|
|
c474d59b0b | ||
|
|
739820141a | ||
|
|
b4f22b93e9 | ||
|
|
b3866b05c1 | ||
|
|
bf8f854546 | ||
|
|
41fffe1b97 | ||
|
|
7edf345fbe | ||
|
|
9c4014f446 | ||
|
|
1c0988cad3 | ||
|
|
fe481453c4 | ||
|
|
9634fe054a | ||
|
|
9ffccf5304 | ||
|
|
8fda77dc40 | ||
|
|
4eb7ac1107 | ||
|
|
53f9979696 | ||
|
|
55bbfa19b6 | ||
|
|
f1358200d6 | ||
|
|
2009a9ff25 | ||
|
|
7448e0dbc4 | ||
|
|
ac46497f1a | ||
|
|
60741b3e1c | ||
|
|
ab46c52d4a | ||
|
|
2df6c99e67 | ||
|
|
30ce0cd8fb | ||
|
|
7cdce2aeac | ||
|
|
e70f7ba75c | ||
|
|
fd18bcef95 | ||
|
|
41217ffea0 | ||
|
|
12ba0ba1c5 | ||
|
|
e1d1a3a0c2 | ||
|
|
df3c2466f8 | ||
|
|
c0048f7954 | ||
|
|
c3d079aeb8 | ||
|
|
586661caad | ||
|
|
c7e81dfa9b | ||
|
|
774e5f3b5e | ||
|
|
e6b9ddad18 | ||
|
|
7056649a4b | ||
|
|
81554eae5a | ||
|
|
fba7789bb1 | ||
|
|
4384db597c | ||
|
|
0d2a22f37a | ||
|
|
7c568cccaf | ||
|
|
9c264a7e66 | ||
|
|
ad2036aaba | ||
|
|
39aa4cac86 | ||
|
|
65b4d8a649 | ||
|
|
3363e4f790 | ||
|
|
aa0935c13b | ||
|
|
8e899d9677 | ||
|
|
33d4821923 | ||
|
|
4f153083ac | ||
|
|
4f31027f08 | ||
|
|
62c8ad4df4 | ||
|
|
888287c602 | ||
|
|
10a37f4b6b | ||
|
|
2b12146e81 | ||
|
|
b6742bda3d | ||
|
|
cf9154f924 | ||
|
|
0cc60f3631 | ||
|
|
21607751c9 | ||
|
|
56a5f598f1 | ||
|
|
231683e8d7 | ||
|
|
a98b65c2d4 | ||
|
|
f01b97eb06 | ||
|
|
b795bd5ace | ||
|
|
61b14f6391 | ||
|
|
9964e20a03 | ||
|
|
28503d83cb | ||
|
|
f1b26008b8 | ||
|
|
36fa1ff9a9 | ||
|
|
b4630c03f7 | ||
|
|
b7ead65fde | ||
|
|
f04c7a7680 | ||
|
|
30282f20da | ||
|
|
7ad40e22fe | ||
|
|
4a6de486ba | ||
|
|
d04b4aafb6 | ||
|
|
cc19635b6e | ||
|
|
430477d4d6 | ||
|
|
492cce7975 | ||
|
|
67d816705d | ||
|
|
528735b955 | ||
|
|
55a8087f67 | ||
|
|
ebb109b67e | ||
|
|
e6916cf72f | ||
|
|
7100ca61ba | ||
|
|
e5bcac1572 | ||
|
|
565ac00b70 | ||
|
|
cd9b62d734 | ||
|
|
a4ee104bd7 | ||
|
|
1f2f32f58c | ||
|
|
e323a0c20c | ||
|
|
41c16ecb2f | ||
|
|
c5ed7bbce5 | ||
|
|
beb3b23fb6 | ||
|
|
ca9e41280a | ||
|
|
d004d83183 | ||
|
|
4a7de0cd63 | ||
|
|
9f581b9eeb | ||
|
|
b73d5d7ecc | ||
|
|
873e57dc86 | ||
|
|
c0cdde6506 | ||
|
|
34d14500c9 | ||
|
|
77aab5c468 | ||
|
|
71c83e1155 | ||
|
|
8cfc080470 | ||
|
|
0bb9579088 | ||
|
|
3be511cdab | ||
|
|
0a8b35718a | ||
|
|
3762a92a35 | ||
|
|
c49ef8e543 | ||
|
|
e6a64aa00b | ||
|
|
95811c8e4c | ||
|
|
0f721f6f7b | ||
|
|
8f24aa6c67 | ||
|
|
3871cbc75c | ||
|
|
707ce0beef | ||
|
|
4f217618af | ||
|
|
435a634ac7 | ||
|
|
4669c41e51 | ||
|
|
6bdc2c36f1 | ||
|
|
7e347069d5 | ||
|
|
9774782cab | ||
|
|
844d904426 | ||
|
|
10a37e2769 | ||
|
|
afa6c1a9a7 | ||
|
|
09d243f4e1 | ||
|
|
a261006666 | ||
|
|
5033a155b3 | ||
|
|
cc79bc6ffe | ||
|
|
77626ef6fb | ||
|
|
d086683b17 | ||
|
|
00ec4e189f | ||
|
|
1e7340b448 | ||
|
|
08811bd259 | ||
|
|
21cb2ee817 | ||
|
|
aa286a8e3f | ||
|
|
d7692b2575 | ||
|
|
4fcac7d3b1 | ||
|
|
652871d4c3 | ||
|
|
f5c4607769 | ||
|
|
77287d1f0b | ||
|
|
5b48e4ae58 | ||
|
|
a9161a3fde | ||
|
|
148bc9448b | ||
|
|
dedfdefcf3 | ||
|
|
21617889e8 | ||
|
|
3e3d7c8d4f | ||
|
|
59c2530001 | ||
|
|
cd9412fe52 | ||
|
|
97075c85e8 | ||
|
|
d7f0919277 | ||
|
|
28338a6f4a | ||
|
|
9315039e0a | ||
|
|
37575f27fe | ||
|
|
e484eb2dc8 | ||
|
|
421db739c5 | ||
|
|
ff65babd1c | ||
|
|
5e08a0bc9d | ||
|
|
f6e7daaf18 | ||
|
|
c495dba18a | ||
|
|
b455ac2a27 | ||
|
|
4c090e869e | ||
|
|
d4e6355eb3 | ||
|
|
a8f98bb749 | ||
|
|
fc7b71b334 | ||
|
|
a6bad4a47d | ||
|
|
8c6a68ba4c | ||
|
|
84dd4ecbd4 | ||
|
|
f7618160ad | ||
|
|
9599875f48 | ||
|
|
8792131e03 | ||
|
|
6a290cc281 | ||
|
|
f84273ca91 | ||
|
|
4cf6901057 | ||
|
|
9f71ca95d9 | ||
|
|
3c75601976 | ||
|
|
5c3ac1a40e | ||
|
|
6aae25209a | ||
|
|
008557581d | ||
|
|
bd2581e7c9 | ||
|
|
0729ee143b | ||
|
|
a5037783d4 | ||
|
|
4ccb898360 | ||
|
|
ad668f4277 | ||
|
|
6437e7f366 | ||
|
|
75f8c152ce | ||
|
|
d8fed7d515 | ||
|
|
c5317a14ac | ||
|
|
cccfed7006 | ||
|
|
7fa18cad57 | ||
|
|
d289619c75 | ||
|
|
10a462369b | ||
|
|
83458ee824 | ||
|
|
0ede069d2c | ||
|
|
e14a9f5503 | ||
|
|
96757857c4 | ||
|
|
58996e891e | ||
|
|
2fa19441a7 | ||
|
|
804482ef2b | ||
|
|
8ddcc4caf5 | ||
|
|
9678e335a4 | ||
|
|
2da8e97268 | ||
|
|
ec537f6ea4 | ||
|
|
1ad977f712 | ||
|
|
627754366c | ||
|
|
b5fabd052b | ||
|
|
8f92121606 | ||
|
|
17d5118de6 | ||
|
|
60b9e59d15 | ||
|
|
2ec55c5337 | ||
|
|
004968caf3 | ||
|
|
1e66a0c069 | ||
|
|
686430ee36 | ||
|
|
165327a074 | ||
|
|
1e5f16722f | ||
|
|
c2943ffd29 | ||
|
|
d90cdb1b10 | ||
|
|
c5c8cd43c0 | ||
|
|
c0491d298b | ||
|
|
71f3589238 | ||
|
|
a2c362a88d | ||
|
|
4d5d51e322 | ||
|
|
2cfdb8306d | ||
|
|
30a9cf0f03 | ||
|
|
daacea11dc | ||
|
|
e1072a3c4f | ||
|
|
8c38510ee5 | ||
|
|
8b3ed4175d | ||
|
|
07a93c2731 | ||
|
|
5e0c1cc5ce | ||
|
|
de7c49c6ca | ||
|
|
c94426d21e | ||
|
|
7f70d2faaa | ||
|
|
e34dab7443 | ||
|
|
a9ad2a4dcc | ||
|
|
f4de82510a | ||
|
|
19909bc4c8 | ||
|
|
693191e8bf | ||
|
|
34b3a9851f | ||
|
|
adb81b1ff6 | ||
|
|
f319409abc | ||
|
|
40a37b194d | ||
|
|
186abba94b | ||
|
|
ed8f988a9b | ||
|
|
1489623584 | ||
|
|
75dd5084f6 | ||
|
|
a3f9209379 | ||
|
|
cdcf813fa7 | ||
|
|
dfbab5d61e | ||
|
|
6f1d553cff | ||
|
|
fd4071fadb | ||
|
|
be246de161 | ||
|
|
c5665276b7 | ||
|
|
942651ecdf | ||
|
|
d2216bfe54 | ||
|
|
2ef86a2f0a | ||
|
|
d360ca4e14 | ||
|
|
297d4f8bab | ||
|
|
e0b0f1315b | ||
|
|
adbe4097b3 | ||
|
|
78bd24c6f7 | ||
|
|
229b2f8d2a | ||
|
|
001b255b08 | ||
|
|
6c27093a8b | ||
|
|
967f42aa98 | ||
|
|
f52f18c281 | ||
|
|
4128a8bfd0 | ||
|
|
9f6496b0bc | ||
|
|
d57fbc9512 | ||
|
|
232fca78a2 | ||
|
|
a00f04886f | ||
|
|
1d4ef8964d | ||
|
|
c4ea429acb | ||
|
|
ddc3814d45 | ||
|
|
fb3b904b8f | ||
|
|
b9c26d6ddc | ||
|
|
be050be5e5 | ||
|
|
06f8c4b27a | ||
|
|
333a6cc370 | ||
|
|
2789cf2506 | ||
|
|
af50c1e13e | ||
|
|
3b75e9f90a | ||
|
|
8f2888e228 | ||
|
|
7574ab730d | ||
|
|
46ab7b45d7 | ||
|
|
e4ef0b04ef | ||
|
|
b47c5af0b8 | ||
|
|
73f9b825f0 | ||
|
|
d02f6a8e32 | ||
|
|
3dc73dcb88 | ||
|
|
b13f85e456 | ||
|
|
2808adf99f | ||
|
|
0154d7477b | ||
|
|
5dd08133ef | ||
|
|
7b600cdb91 | ||
|
|
bcef0de43b | ||
|
|
406633491f | ||
|
|
65a1f54f71 | ||
|
|
be9f1c592e | ||
|
|
7abaa570c6 | ||
|
|
682efe399d | ||
|
|
fbe351287a | ||
|
|
7409963c9a | ||
|
|
2664693ae8 | ||
|
|
3d27bf5318 | ||
|
|
a03c585a84 | ||
|
|
a749e788ab | ||
|
|
967e6413e5 | ||
|
|
2c6edb9f3c | ||
|
|
e8cfa65155 | ||
|
|
24138187eb | ||
|
|
992aebf6df | ||
|
|
79b12c73d9 | ||
|
|
0cd62a3c77 | ||
|
|
cd4a19241a | ||
|
|
f84688687b | ||
|
|
8d5f932660 | ||
|
|
cd6db6a3cb | ||
|
|
0c5af16e14 | ||
|
|
64b59f1502 | ||
|
|
f49d8d8c5f | ||
|
|
83e7ee6729 | ||
|
|
d4d27bd2d8 | ||
|
|
189bc0f7c8 | ||
|
|
24d73d4644 | ||
|
|
84e2822e27 | ||
|
|
adf77fa6c2 | ||
|
|
2fabe0797f | ||
|
|
490eff8524 | ||
|
|
9fbb235d81 | ||
|
|
9d372ce6f5 | ||
|
|
ffbd3c0522 | ||
|
|
30579e6619 | ||
|
|
cdbbe8fd42 | ||
|
|
73b175df8f | ||
|
|
564653167e | ||
|
|
09c305d29f | ||
|
|
6714d69767 | ||
|
|
1fa341df1c | ||
|
|
af0fcd22e4 | ||
|
|
858bd8dc40 | ||
|
|
669a8c68a7 | ||
|
|
7f4e3771d8 | ||
|
|
22317105f9 | ||
|
|
f2e7aa596b | ||
|
|
13f28858ba | ||
|
|
41e82c4598 | ||
|
|
41eab6615b | ||
|
|
94b621a99f | ||
|
|
f2a7f83c82 | ||
|
|
45e3dafa8f | ||
|
|
1d07bb91a7 | ||
|
|
11725be278 | ||
|
|
4d6596e534 | ||
|
|
3fc9a606eb | ||
|
|
58ece4b887 | ||
|
|
f8d9254b64 | ||
|
|
fdd79c0448 | ||
|
|
ef086beed1 | ||
|
|
80f3834159 | ||
|
|
83e45cad9f | ||
|
|
fbf30eec7c | ||
|
|
8a3623733f | ||
|
|
e347fba11a | ||
|
|
f92b2cb7b5 | ||
|
|
8135b3c730 | ||
|
|
2dd183b808 | ||
|
|
4c7bca296b | ||
|
|
b4cf4fca9d | ||
|
|
8b994475c4 | ||
|
|
0c6830f8e0 | ||
|
|
24c8a76b9e | ||
|
|
141630e771 | ||
|
|
346fccf782 | ||
|
|
f8e401b475 | ||
|
|
44a898a210 | ||
|
|
dfe26befdd | ||
|
|
ad1330c780 | ||
|
|
0dcc879b3c | ||
|
|
61bd06dde7 | ||
|
|
34d1683087 | ||
|
|
fef82e44a6 | ||
|
|
276e647779 | ||
|
|
c102fa6cac | ||
|
|
83bb41d3a3 | ||
|
|
abc0b0ea3e | ||
|
|
cba13a21e9 | ||
|
|
5f7995f977 | ||
|
|
1bd5e58c84 | ||
|
|
d996cc0584 | ||
|
|
fb1a2fd7cd | ||
|
|
6f462d373f | ||
|
|
54c0b531e1 | ||
|
|
002081f224 | ||
|
|
18ea835739 | ||
|
|
a6a627f445 | ||
|
|
dc7a0ebcf2 | ||
|
|
08bb5e0c0a | ||
|
|
51030fbe25 | ||
|
|
980b6db5c0 | ||
|
|
919d0a68c3 | ||
|
|
1054237d82 | ||
|
|
e545285ffe | ||
|
|
41312d1a1d | ||
|
|
3f33692cb3 | ||
|
|
3c75d6036f | ||
|
|
0bbbaa0dbd | ||
|
|
0367266f66 | ||
|
|
9daa667d0a | ||
|
|
8eef72aa1a | ||
|
|
4fc8c11cc0 | ||
|
|
a8b9f4d7e3 | ||
|
|
00c5ce3b12 | ||
|
|
e817d20376 | ||
|
|
38445c1e73 | ||
|
|
a08de7d629 | ||
|
|
5409595e60 | ||
|
|
7620a6d4af | ||
|
|
73c26d830f | ||
|
|
2f2c9800de | ||
|
|
a134f256ad | ||
|
|
b4872624c9 | ||
|
|
c9e0601ba3 | ||
|
|
107d2fb59c | ||
|
|
460bbd88de | ||
|
|
c2ac58ad8a | ||
|
|
f9b0cfb63e | ||
|
|
04df8dcb39 | ||
|
|
ad47832960 | ||
|
|
e5b2be3b3d | ||
|
|
f6d7ff7168 | ||
|
|
b0824ea5a4 | ||
|
|
35a5369473 | ||
|
|
e2e872dc72 | ||
|
|
413b0cc324 | ||
|
|
54b0b70737 | ||
|
|
79314863cf | ||
|
|
f6f583a33a | ||
|
|
4e5490ddef | ||
|
|
c131a38d7c | ||
|
|
919e686e93 | ||
|
|
087186ef34 | ||
|
|
c23e497c42 | ||
|
|
1b1c510ff9 | ||
|
|
c22f60271f | ||
|
|
61acd53af4 | ||
|
|
602b245ad9 | ||
|
|
1022ca0574 | ||
|
|
d27f6b754f | ||
|
|
528c7f4f30 | ||
|
|
40ec912caa | ||
|
|
9b6282c064 | ||
|
|
857307cde8 | ||
|
|
74d8ca531b | ||
|
|
7550b091f1 | ||
|
|
8829cafd59 | ||
|
|
a146d9e477 | ||
|
|
7c9fd45b50 | ||
|
|
6c929d1a2d | ||
|
|
1f8a86d07f | ||
|
|
ce075327b3 | ||
|
|
abd7d82af7 | ||
|
|
6063d71adf | ||
|
|
5835648290 | ||
|
|
417219bfc4 | ||
|
|
381319c4e8 | ||
|
|
839daae8d0 | ||
|
|
0960f5e4c6 | ||
|
|
c93f4723d0 | ||
|
|
f56949af8b | ||
|
|
d5a00cc29b | ||
|
|
20f9c98de2 | ||
|
|
32b91e685e | ||
|
|
f1b93601b5 | ||
|
|
3ed0c93857 | ||
|
|
89b06fa75d | ||
|
|
1fd824f0c1 | ||
|
|
a66718239f | ||
|
|
31149700cb | ||
|
|
906fcd290c | ||
|
|
2a55d37619 | ||
|
|
121bc44cc5 | ||
|
|
f134eeef45 | ||
|
|
6e290b7251 | ||
|
|
b6c920a976 | ||
|
|
917d42733a | ||
|
|
c5f41baa94 | ||
|
|
03e10cbc8f | ||
|
|
b151e0eba9 | ||
|
|
df5551a4e5 | ||
|
|
5e27e32dae | ||
|
|
f7e1ed71fc | ||
|
|
48fecd6285 | ||
|
|
59789c7997 | ||
|
|
1653735758 | ||
|
|
065376c160 | ||
|
|
464cef8643 | ||
|
|
d29638845a | ||
|
|
dc8fcbaf03 | ||
|
|
c164211c3f | ||
|
|
14267311aa | ||
|
|
6539d04622 | ||
|
|
81cf6b2343 | ||
|
|
3dd97a87c6 | ||
|
|
61f7d37a9d | ||
|
|
bc3c151236 | ||
|
|
6d974eb018 | ||
|
|
f3a2c8d7f7 | ||
|
|
ca1958972e | ||
|
|
b3c678da87 | ||
|
|
266521a1d3 | ||
|
|
206c7eca78 | ||
|
|
16cb0ce1c9 | ||
|
|
f01dc24877 | ||
|
|
d7856a4b74 | ||
|
|
c3c1d4c7ec | ||
|
|
93a0daa383 | ||
|
|
e97db2589d | ||
|
|
05e897896a | ||
|
|
077ddfbea3 | ||
|
|
0bd651330b | ||
|
|
a6a9670fe9 | ||
|
|
bca5808d59 | ||
|
|
022f1a2f79 | ||
|
|
a5ed9c7e2d | ||
|
|
87b51d847c | ||
|
|
9b27e1cd83 | ||
|
|
091de63f30 | ||
|
|
f7aa6d4198 | ||
|
|
fd07cb8c54 | ||
|
|
50a2a1321d | ||
|
|
f25aa90490 | ||
|
|
8d9dcfa39b | ||
|
|
cda307dfd2 | ||
|
|
6e17b5dccf | ||
|
|
5636228f79 | ||
|
|
1812e68198 | ||
|
|
25477e452c | ||
|
|
4786706591 | ||
|
|
27731d637f | ||
|
|
9073a70b27 | ||
|
|
86a52eaedf | ||
|
|
ce45b03732 | ||
|
|
b1504ceb43 | ||
|
|
bbe1ff3ec9 | ||
|
|
818988c419 | ||
|
|
610a92c4d1 | ||
|
|
3d562490d8 | ||
|
|
27828590d1 | ||
|
|
bddd2a740d | ||
|
|
737655cebc | ||
|
|
4cc2731996 | ||
|
|
d5030c8b81 | ||
|
|
6b5f75bb1d | ||
|
|
131f258f5f | ||
|
|
395fe0d777 | ||
|
|
606ca39d10 | ||
|
|
bbba385198 | ||
|
|
f488ee8b0a | ||
|
|
65959100f4 | ||
|
|
888f9fd5e1 | ||
|
|
a9f25961af | ||
|
|
313bfa5408 | ||
|
|
2ab7dba964 | ||
|
|
1b61fbf739 | ||
|
|
e7de511bbc | ||
|
|
be5169249a | ||
|
|
8364f86af1 | ||
|
|
53d5ff299a | ||
|
|
13dca2fd3d | ||
|
|
84f8245abb | ||
|
|
ed1320f3c9 | ||
|
|
1f6764e2af | ||
|
|
cd256fe89f | ||
|
|
d84660c823 | ||
|
|
979a4ecb22 | ||
|
|
c86cb730f1 | ||
|
|
b67353fdb5 | ||
|
|
56ca36ede1 | ||
|
|
29edbd605b | ||
|
|
2b2eeb0192 | ||
|
|
48fae14403 | ||
|
|
09e4fd0500 | ||
|
|
5340a48253 | ||
|
|
0fe8a4248d | ||
|
|
25ead5fd42 | ||
|
|
d17b4c8e4f | ||
|
|
ab60ce54f5 | ||
|
|
e5cc53c19c | ||
|
|
dd769d2af8 | ||
|
|
561f7090c8 | ||
|
|
dbc78746d2 | ||
|
|
5127f3dcbc | ||
|
|
49ceb577ec | ||
|
|
1a8338dbaf | ||
|
|
11946ecd87 | ||
|
|
96de4a0822 | ||
|
|
ff3230bd9a | ||
|
|
9835f4b800 | ||
|
|
1b252d68f3 | ||
|
|
ba44548332 | ||
|
|
5b71790843 | ||
|
|
f00c851fc5 | ||
|
|
510647e864 | ||
|
|
f099ddb301 | ||
|
|
1951cbd236 | ||
|
|
23c4ceca9d | ||
|
|
2e1601cf27 | ||
|
|
e754883df2 | ||
|
|
4ac7e94ad7 | ||
|
|
50848da16c | ||
|
|
eca7bab6fe | ||
|
|
77c08c8d5d | ||
|
|
037ccaf46d | ||
|
|
6c3987bbe6 | ||
|
|
f2b8672f08 | ||
|
|
c4c4931c6b | ||
|
|
fac50f1143 | ||
|
|
2be616b931 | ||
|
|
02c7772cd0 | ||
|
|
aac01fbf22 | ||
|
|
d6378fe395 | ||
|
|
0b83c7cb98 | ||
|
|
3e42f2685d | ||
|
|
0d630a3937 | ||
|
|
45a492df2b | ||
|
|
02cf2b3826 | ||
|
|
6178780a3d | ||
|
|
ac51ab12f0 | ||
|
|
50d320a35e | ||
|
|
d9425b8229 | ||
|
|
984c7da785 | ||
|
|
e70f5ac581 | ||
|
|
49c20b03cc | ||
|
|
46ba995341 | ||
|
|
e3742a9ed5 | ||
|
|
79da00dc40 | ||
|
|
e015a4a527 | ||
|
|
15ab1d2628 | ||
|
|
040d00ffae | ||
|
|
38843eb7aa | ||
|
|
eb931d4998 | ||
|
|
852dee37ec | ||
|
|
a76045d792 | ||
|
|
4f9f68046c | ||
|
|
0c2e4a72ca | ||
|
|
bd42536d31 | ||
|
|
a03432cbe6 | ||
|
|
b20598d755 | ||
|
|
f8cb06bff2 | ||
|
|
0d2b35dbb4 | ||
|
|
adf8d0144e | ||
|
|
adfb4f4b4c | ||
|
|
78904346ca | ||
|
|
748410c876 | ||
|
|
f581ea0aa6 | ||
|
|
bca1d2b93f | ||
|
|
7785ad191a | ||
|
|
08df9335f8 | ||
|
|
a84baf92e7 | ||
|
|
431e98c999 | ||
|
|
ecd2b75ba4 | ||
|
|
f655fe35a7 | ||
|
|
14760e7a5b | ||
|
|
27dee8eff4 | ||
|
|
3ae98e0b8d | ||
|
|
b01c02c5b8 | ||
|
|
2d7b57809d | ||
|
|
a33b51eeee | ||
|
|
720e97c2f8 | ||
|
|
0bfdf7d5b7 | ||
|
|
73123df4be | ||
|
|
39aabb2b4b | ||
|
|
79c0b8bade | ||
|
|
216ffa05bc | ||
|
|
e48d90a294 | ||
|
|
2fc1a83e6f | ||
|
|
86ba999486 | ||
|
|
3995ead92b | ||
|
|
4b8ceb51e2 | ||
|
|
cf2ad74ec7 | ||
|
|
6d3bbd4933 | ||
|
|
213978161b | ||
|
|
b19ea60b97 | ||
|
|
79d227d34e | ||
|
|
20ead6d8f7 | ||
|
|
8f23043851 | ||
|
|
bc7ed1e156 | ||
|
|
904ec537b2 | ||
|
|
ed933a28da | ||
|
|
c7d96d1441 | ||
|
|
ceaaf6d3a2 | ||
|
|
1a626bcacd | ||
|
|
b6d6f5e382 | ||
|
|
dedbff3653 | ||
|
|
e9ec49a705 | ||
|
|
f37ee781fb | ||
|
|
dd312d294a | ||
|
|
bb7854923d | ||
|
|
b5dd07781c | ||
|
|
ff1418e2d3 | ||
|
|
23bafda164 | ||
|
|
f6a9cf4326 | ||
|
|
fbf323bf51 | ||
|
|
c18d24434a | ||
|
|
50b6ab9de2 | ||
|
|
e5275453db | ||
|
|
413d98ca43 | ||
|
|
260bc487aa | ||
|
|
df2d2f3cf7 | ||
|
|
a8186713ba | ||
|
|
40eb962166 | ||
|
|
4df7460ce6 | ||
|
|
3153897fde | ||
|
|
3fbbd6bc50 | ||
|
|
d10028ec06 | ||
|
|
6c7ead508f | ||
|
|
4ee2193112 | ||
|
|
28d2896f90 | ||
|
|
fddfd4b413 | ||
|
|
e2b36d1c8a | ||
|
|
ab1137159f | ||
|
|
0d5df3a73e | ||
|
|
576d333c2c | ||
|
|
427aca9f90 | ||
|
|
16365b5ce9 | ||
|
|
d249989257 | ||
|
|
cb4abb115d | ||
|
|
87fd636313 | ||
|
|
182932560a | ||
|
|
647e91059d | ||
|
|
7d46c43884 | ||
|
|
5293ba2323 | ||
|
|
9518cea3dd | ||
|
|
16e8818d9e | ||
|
|
3ce595b806 | ||
|
|
aec1828fc7 | ||
|
|
f5987a5ca0 | ||
|
|
14ea087edc | ||
|
|
b7ceb3c333 | ||
|
|
b8ce888d98 | ||
|
|
e75549cc8e | ||
|
|
9e83ee2ddf | ||
|
|
062fbeae80 | ||
|
|
5eed64b848 | ||
|
|
2a0257e8af | ||
|
|
76ad136b2a | ||
|
|
f29b57088a | ||
|
|
8a563e8f57 | ||
|
|
a79357bc28 | ||
|
|
b549523e4b | ||
|
|
914f9b603e | ||
|
|
aadf6da468 | ||
|
|
eed1a5dfbd | ||
|
|
cf5dba2beb | ||
|
|
3717ff34af | ||
|
|
2cf2f4964c | ||
|
|
08c4b22988 | ||
|
|
97efee2f08 | ||
|
|
7fdb74530c | ||
|
|
b59d092e91 | ||
|
|
8269e9a990 | ||
|
|
a42ea3ccbb | ||
|
|
8677f069ec | ||
|
|
bb0cd34f4e | ||
|
|
199eaff14e | ||
|
|
92e4708ee3 | ||
|
|
b4af45537a | ||
|
|
849463558d | ||
|
|
606c5f3093 | ||
|
|
06c8bbd342 | ||
|
|
a59e857d51 | ||
|
|
6147a29a68 | ||
|
|
83aad1dc04 | ||
|
|
15f4e56c9d | ||
|
|
dcce70095b | ||
|
|
c8066879db | ||
|
|
17d08a939f | ||
|
|
1f90b6fc94 | ||
|
|
b86ca61b49 | ||
|
|
f443c01ba5 | ||
|
|
9b1e831fa6 | ||
|
|
ad25e3807d | ||
|
|
14b931eb4a | ||
|
|
bc548368e8 | ||
|
|
5cfa9e735a | ||
|
|
0ef34804e8 | ||
|
|
bfad07cd15 | ||
|
|
e2de7f2529 | ||
|
|
5a33d7292f | ||
|
|
b49f83a22a | ||
|
|
b6612ea8bb | ||
|
|
a36904c9ee | ||
|
|
34087c4178 | ||
|
|
2e6b13a5e9 | ||
|
|
b99c2f4dee | ||
|
|
f27d426347 | ||
|
|
a61c9d53eb | ||
|
|
4f5e7d678e | ||
|
|
08e309ea46 | ||
|
|
f6dd3c5484 | ||
|
|
77e8a76af3 | ||
|
|
b6e6f557f0 | ||
|
|
31f2e848b5 | ||
|
|
a6f6511372 | ||
|
|
f303000580 | ||
|
|
f92141decb | ||
|
|
64129a68cd | ||
|
|
6248689b89 | ||
|
|
f968acbfac | ||
|
|
4d2a832fb6 | ||
|
|
64e960ae97 | ||
|
|
f0dd0acbf0 | ||
|
|
8ac56d13d7 | ||
|
|
f70a5397f2 | ||
|
|
6c91e1420a | ||
|
|
7c00a4a11f | ||
|
|
7d2298f39c | ||
|
|
840ef94b46 | ||
|
|
e43df59168 | ||
|
|
f1fec5eee0 | ||
|
|
befb5081f4 | ||
|
|
8eaa63ccbf | ||
|
|
90010d1f3b | ||
|
|
08e8567e93 | ||
|
|
98fb0dd565 | ||
|
|
e499904e3a | ||
|
|
a61d7d053f | ||
|
|
0b4aed008c | ||
|
|
7d501eaf81 | ||
|
|
59c1141e08 | ||
|
|
cd0113a287 | ||
|
|
e1f885feda | ||
|
|
4c469f9646 | ||
|
|
ed5f487cf5 | ||
|
|
e13a763ab4 | ||
|
|
804108a87f | ||
|
|
f9b6e57d24 | ||
|
|
f1994ea9c0 | ||
|
|
4f8ed70813 | ||
|
|
0471de41ff | ||
|
|
1ad16c2238 | ||
|
|
2bbb7a8e95 | ||
|
|
8be46ff0b2 | ||
|
|
10e3045d8a | ||
|
|
86d2b223cc | ||
|
|
805c65f55d | ||
|
|
eb15c9eaad | ||
|
|
83deaad8e4 | ||
|
|
bbdd5f8676 | ||
|
|
a8982ec281 | ||
|
|
22574ed74f | ||
|
|
ae876eb27b | ||
|
|
be687f6c0b | ||
|
|
b1bb26b1e0 | ||
|
|
02893a17ad | ||
|
|
3507707325 | ||
|
|
6030740b00 | ||
|
|
3d66717c8d | ||
|
|
dc204174c0 | ||
|
|
7ba57e517b | ||
|
|
eb789b147a | ||
|
|
4cedb0b628 | ||
|
|
ec50101db1 | ||
|
|
24c804a70a | ||
|
|
467503fd4b | ||
|
|
7dc8cf9340 | ||
|
|
52a7fa6176 | ||
|
|
a1ae0aed23 | ||
|
|
ac6e404547 | ||
|
|
8d6af1fcb0 | ||
|
|
3dcd71a082 | ||
|
|
532a76f78c | ||
|
|
b127f9157d | ||
|
|
877fbc15da | ||
|
|
ede9a03405 | ||
|
|
9636882c1e | ||
|
|
312ffe43c7 | ||
|
|
2afe5bdf57 | ||
|
|
85382514f9 | ||
|
|
8e5242ef63 | ||
|
|
7aba81dbe7 | ||
|
|
66b49c634d | ||
|
|
caf9edf2c1 | ||
|
|
63d27a5389 | ||
|
|
c8556330c1 | ||
|
|
42d2bf0baf | ||
|
|
d75bc5774f | ||
|
|
f385a3e3da | ||
|
|
3976e2d15d | ||
|
|
aa127ebd4e | ||
|
|
740b54f55b | ||
|
|
15bb2fefa4 | ||
|
|
d9699adce5 | ||
|
|
c585d224d8 | ||
|
|
b1996b38b4 | ||
|
|
6d805cfca2 | ||
|
|
12077a4d44 | ||
|
|
24317f617e | ||
|
|
fd32f7446d | ||
|
|
8ec5ed27db | ||
|
|
fd175470db | ||
|
|
72eebe1ce1 | ||
|
|
a63027e175 | ||
|
|
9333853f23 | ||
|
|
9cc1cb5281 | ||
|
|
62fb6e0f4b | ||
|
|
5ca558f191 | ||
|
|
c562d79e4f | ||
|
|
fe4c7237fb | ||
|
|
e5bea933a8 | ||
|
|
6a1830e9e3 | ||
|
|
81afd9d0c7 | ||
|
|
3f79a914d9 | ||
|
|
afbdc51e01 | ||
|
|
4485745dc6 | ||
|
|
0a92e382fa | ||
|
|
b9e02477e9 | ||
|
|
1050993348 | ||
|
|
9e5ed4208b | ||
|
|
ff0f141126 | ||
|
|
f52410be19 | ||
|
|
b9900661f4 | ||
|
|
9412091d0d | ||
|
|
9f1c59e9d0 | ||
|
|
68149f8c73 | ||
|
|
cad148cb5c | ||
|
|
2cca4938cf | ||
|
|
e77046ba4e | ||
|
|
6d498a3c46 | ||
|
|
bddd19c1e6 | ||
|
|
93603f383a | ||
|
|
32ed138c53 | ||
|
|
420e70180c | ||
|
|
1de2c1c2af | ||
|
|
747afd8088 | ||
|
|
a0a6571be3 | ||
|
|
7362cd2e10 | ||
|
|
a398faa5d7 | ||
|
|
81bcb4d999 | ||
|
|
937a954013 | ||
|
|
443bc4bf90 | ||
|
|
7c0a05360e | ||
|
|
3fd504e545 | ||
|
|
997995397e | ||
|
|
7a5d6f61c7 | ||
|
|
1337fcb3d9 | ||
|
|
ee5d3ab19b | ||
|
|
036c3a56b4 | ||
|
|
30bc5873e0 | ||
|
|
e67afc8886 | ||
|
|
a08fa696d4 | ||
|
|
4eb14ab85c | ||
|
|
f660d5f183 | ||
|
|
e2e3af4f0d | ||
|
|
23fd43374d | ||
|
|
3d1e6f5b96 | ||
|
|
a2d515adce | ||
|
|
66cc0fe7ab | ||
|
|
1fbcd1051e | ||
|
|
582574bace | ||
|
|
39ae7b66f8 | ||
|
|
7e62d02abb | ||
|
|
fd18c51938 | ||
|
|
8bbb5d9686 | ||
|
|
666830cca0 | ||
|
|
b6b77c438a | ||
|
|
8066aa5eb1 | ||
|
|
10ae93826e | ||
|
|
3eb534818a | ||
|
|
655dc18d71 | ||
|
|
040cfa4ad5 | ||
|
|
77fc113273 | ||
|
|
4fdceb8613 | ||
|
|
69a2431dd0 | ||
|
|
caf898d7d1 | ||
|
|
da140238e7 | ||
|
|
20f3dde0dd | ||
|
|
3d379c4d07 | ||
|
|
6475fe6474 | ||
|
|
2967023a0e | ||
|
|
1cb7de5b5a | ||
|
|
63b7d7e4ac | ||
|
|
526736dedc | ||
|
|
2507fd1cd4 | ||
|
|
652fb58b2b | ||
|
|
be3ff78a29 | ||
|
|
96bccd4666 | ||
|
|
c3c2a4afe0 | ||
|
|
1a28bd8e7e | ||
|
|
7a68ae27b0 | ||
|
|
33e25255e3 | ||
|
|
e25caff16f | ||
|
|
afb84b6823 | ||
|
|
f20212bc04 | ||
|
|
e210c5613f | ||
|
|
6372688edd |
@@ -21,6 +21,7 @@
|
|||||||
/tmp/sessions/*
|
/tmp/sessions/*
|
||||||
/tmp/sockets/*
|
/tmp/sockets/*
|
||||||
/tmp/test/*
|
/tmp/test/*
|
||||||
|
/vendor/cache
|
||||||
/vendor/rails
|
/vendor/rails
|
||||||
*.rbc
|
*.rbc
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ tmp/cache/*
|
|||||||
tmp/sessions/*
|
tmp/sessions/*
|
||||||
tmp/sockets/*
|
tmp/sockets/*
|
||||||
tmp/test/*
|
tmp/test/*
|
||||||
|
vendor/cache
|
||||||
vendor/rails
|
vendor/rails
|
||||||
*.rbc
|
*.rbc
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
source :rubygems
|
||||||
|
|
||||||
|
gem "rails", "2.3.14"
|
||||||
|
gem "i18n", "~> 0.4.2"
|
||||||
|
gem "coderay", "~> 1.0.6"
|
||||||
|
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
|
||||||
|
gem "tzinfo", "~> 0.3.31"
|
||||||
|
|
||||||
|
# Optional gem for LDAP authentication
|
||||||
|
group :ldap do
|
||||||
|
gem "net-ldap", "~> 0.3.1"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Optional gem for OpenID authentication
|
||||||
|
group :openid do
|
||||||
|
gem "ruby-openid", "~> 2.1.4", :require => "openid"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Optional gem for exporting the gantt to a PNG file, not supported with jruby
|
||||||
|
platforms :mri, :mingw do
|
||||||
|
group :rmagick do
|
||||||
|
# RMagick 2 supports ruby 1.9
|
||||||
|
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support
|
||||||
|
# different requirements for the same gem on different platforms
|
||||||
|
gem "rmagick", ">= 2.0.0"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Database gems
|
||||||
|
platforms :mri, :mingw do
|
||||||
|
group :postgresql do
|
||||||
|
gem "pg", ">= 0.11.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
group :sqlite do
|
||||||
|
gem "sqlite3"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
platforms :mri_18, :mingw_18 do
|
||||||
|
group :mysql do
|
||||||
|
gem "mysql"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
platforms :mri_19, :mingw_19 do
|
||||||
|
group :mysql do
|
||||||
|
gem "mysql2", "~> 0.2.7"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
platforms :jruby do
|
||||||
|
gem "jruby-openssl"
|
||||||
|
|
||||||
|
group :mysql do
|
||||||
|
gem "activerecord-jdbcmysql-adapter"
|
||||||
|
end
|
||||||
|
|
||||||
|
group :postgresql do
|
||||||
|
gem "activerecord-jdbcpostgresql-adapter"
|
||||||
|
end
|
||||||
|
|
||||||
|
group :sqlite do
|
||||||
|
gem "activerecord-jdbcsqlite3-adapter"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
group :development do
|
||||||
|
gem "rdoc", ">= 2.4.2"
|
||||||
|
end
|
||||||
|
|
||||||
|
group :test do
|
||||||
|
gem "shoulda", "~> 2.10.3"
|
||||||
|
gem "edavis10-object_daddy", :require => "object_daddy"
|
||||||
|
gem "mocha"
|
||||||
|
end
|
||||||
|
|
||||||
|
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
|
||||||
|
if File.exists?(local_gemfile)
|
||||||
|
puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
|
||||||
|
instance_eval File.read(local_gemfile)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Load plugins' Gemfiles
|
||||||
|
Dir.glob File.expand_path("../vendor/plugins/*/Gemfile", __FILE__) do |file|
|
||||||
|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
|
||||||
|
instance_eval File.read(file)
|
||||||
|
end
|
||||||
@@ -29,6 +29,9 @@ class AccountController < ApplicationController
|
|||||||
else
|
else
|
||||||
authenticate_user
|
authenticate_user
|
||||||
end
|
end
|
||||||
|
rescue AuthSourceException => e
|
||||||
|
logger.error "An error occured when authenticating #{params[:username]}: #{e.message}"
|
||||||
|
render_error :message => e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
# Log out current user and redirect to welcome page
|
# Log out current user and redirect to welcome page
|
||||||
@@ -81,7 +84,8 @@ class AccountController < ApplicationController
|
|||||||
session[:auth_source_registration] = nil
|
session[:auth_source_registration] = nil
|
||||||
@user = User.new(:language => Setting.default_language)
|
@user = User.new(:language => Setting.default_language)
|
||||||
else
|
else
|
||||||
@user = User.new(params[:user])
|
@user = User.new
|
||||||
|
@user.safe_attributes = params[:user]
|
||||||
@user.admin = false
|
@user.admin = false
|
||||||
@user.register
|
@user.register
|
||||||
if session[:auth_source_registration]
|
if session[:auth_source_registration]
|
||||||
@@ -96,7 +100,7 @@ class AccountController < ApplicationController
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
@user.login = params[:user][:login]
|
@user.login = params[:user][:login]
|
||||||
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
|
@user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation]
|
||||||
|
|
||||||
case Setting.self_registration
|
case Setting.self_registration
|
||||||
when '1'
|
when '1'
|
||||||
@@ -127,14 +131,6 @@ class AccountController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def logout_user
|
|
||||||
if User.current.logged?
|
|
||||||
cookies.delete :autologin
|
|
||||||
Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
|
|
||||||
self.logged_user = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def authenticate_user
|
def authenticate_user
|
||||||
if Setting.openid? && using_open_id?
|
if Setting.openid? && using_open_id?
|
||||||
open_id_authenticate(params[:openid_url])
|
open_id_authenticate(params[:openid_url])
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
class AdminController < ApplicationController
|
class AdminController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
menu_item :projects, :only => :projects
|
||||||
|
menu_item :plugins, :only => :plugins
|
||||||
|
menu_item :info, :only => :info
|
||||||
|
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
@@ -26,14 +30,12 @@ class AdminController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def projects
|
def projects
|
||||||
@status = params[:status] ? params[:status].to_i : 1
|
@status = params[:status] || 1
|
||||||
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
|
|
||||||
unless params[:name].blank?
|
scope = Project.status(@status)
|
||||||
name = "%#{params[:name].strip.downcase}%"
|
scope = scope.like(params[:name]) if params[:name].present?
|
||||||
c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name]
|
|
||||||
end
|
@projects = scope.all(:order => 'lft')
|
||||||
@projects = Project.find :all, :order => 'lft',
|
|
||||||
:conditions => c.conditions
|
|
||||||
|
|
||||||
render :action => "projects", :layout => false if request.xhr?
|
render :action => "projects", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
@@ -61,7 +63,7 @@ class AdminController < ApplicationController
|
|||||||
# Force ActionMailer to raise delivery errors so we can catch it
|
# Force ActionMailer to raise delivery errors so we can catch it
|
||||||
ActionMailer::Base.raise_delivery_errors = true
|
ActionMailer::Base.raise_delivery_errors = true
|
||||||
begin
|
begin
|
||||||
@test = Mailer.deliver_test(User.current)
|
@test = Mailer.deliver_test_email(User.current)
|
||||||
flash[:notice] = l(:notice_email_sent, User.current.mail)
|
flash[:notice] = l(:notice_email_sent, User.current.mail)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
flash[:error] = l(:notice_email_error, e.message)
|
flash[:error] = l(:notice_email_error, e.message)
|
||||||
@@ -73,11 +75,9 @@ class AdminController < ApplicationController
|
|||||||
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,
|
[:text_default_administrator_account_changed, User.default_admin_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?(Redmine::Plugin.public_directory)],
|
||||||
[:text_rmagick_available, Object.const_defined?(:Magick)]
|
[:text_rmagick_available, Object.const_defined?(:Magick)]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,19 +31,32 @@ class ApplicationController < ActionController::Base
|
|||||||
super
|
super
|
||||||
cookies.delete(:autologin)
|
cookies.delete(:autologin)
|
||||||
end
|
end
|
||||||
# Remove broken cookie after upgrade from 0.8.x (#4292)
|
|
||||||
# See https://rails.lighthouseapp.com/projects/8994/tickets/3360
|
# FIXME: Remove this when all of Rack and Rails have learned how to
|
||||||
# TODO: remove it when Rails is fixed
|
# properly use encodings
|
||||||
before_filter :delete_broken_cookies
|
before_filter :params_filter
|
||||||
def delete_broken_cookies
|
|
||||||
if cookies['_redmine_session'] && cookies['_redmine_session'] !~ /--/
|
def params_filter
|
||||||
cookies.delete '_redmine_session'
|
if RUBY_VERSION >= '1.9' && defined?(Rails) && Rails::VERSION::MAJOR < 3
|
||||||
redirect_to home_path
|
self.utf8nize!(params)
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before_filter :user_setup, :check_if_login_required, :set_localization
|
def utf8nize!(obj)
|
||||||
|
if obj.frozen?
|
||||||
|
obj
|
||||||
|
elsif obj.is_a? String
|
||||||
|
obj.respond_to?(:force_encoding) ? obj.force_encoding("UTF-8") : obj
|
||||||
|
elsif obj.is_a? Hash
|
||||||
|
obj.each {|k, v| obj[k] = self.utf8nize!(v)}
|
||||||
|
elsif obj.is_a? Array
|
||||||
|
obj.each {|v| self.utf8nize!(v)}
|
||||||
|
else
|
||||||
|
obj
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
|
||||||
filter_parameter_logging :password
|
filter_parameter_logging :password
|
||||||
|
|
||||||
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
||||||
@@ -57,6 +70,38 @@ class ApplicationController < ActionController::Base
|
|||||||
require_dependency "repository/#{scm.underscore}"
|
require_dependency "repository/#{scm.underscore}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def session_expiration
|
||||||
|
if session[:user_id]
|
||||||
|
if session_expired? && !try_to_autologin
|
||||||
|
reset_session
|
||||||
|
flash[:error] = l(:error_session_expired)
|
||||||
|
redirect_to signin_url
|
||||||
|
else
|
||||||
|
session[:atime] = Time.now.utc.to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def session_expired?
|
||||||
|
if Setting.session_lifetime?
|
||||||
|
unless session[:ctime] && (Time.now.utc.to_i - session[:ctime].to_i <= Setting.session_lifetime.to_i * 60)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if Setting.session_timeout?
|
||||||
|
unless session[:atime] && (Time.now.utc.to_i - session[:atime].to_i <= Setting.session_timeout.to_i * 60)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_user_session(user)
|
||||||
|
session[:user_id] = user.id
|
||||||
|
session[:ctime] = Time.now.utc.to_i
|
||||||
|
session[:atime] = Time.now.utc.to_i
|
||||||
|
end
|
||||||
|
|
||||||
def user_setup
|
def user_setup
|
||||||
# Check the settings cache for each request
|
# Check the settings cache for each request
|
||||||
Setting.check_cache
|
Setting.check_cache
|
||||||
@@ -70,10 +115,7 @@ class ApplicationController < ActionController::Base
|
|||||||
if session[:user_id]
|
if session[:user_id]
|
||||||
# existing session
|
# existing session
|
||||||
(User.active.find(session[:user_id]) rescue nil)
|
(User.active.find(session[:user_id]) rescue nil)
|
||||||
elsif cookies[:autologin] && Setting.autologin?
|
elsif user = try_to_autologin
|
||||||
# auto-login feature starts a new session
|
|
||||||
user = User.try_to_autologin(cookies[:autologin])
|
|
||||||
session[:user_id] = user.id if user
|
|
||||||
user
|
user
|
||||||
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?
|
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
|
||||||
@@ -91,17 +133,38 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def try_to_autologin
|
||||||
|
if cookies[:autologin] && Setting.autologin?
|
||||||
|
# auto-login feature starts a new session
|
||||||
|
user = User.try_to_autologin(cookies[:autologin])
|
||||||
|
if user
|
||||||
|
reset_session
|
||||||
|
start_user_session(user)
|
||||||
|
end
|
||||||
|
user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Sets the logged in user
|
# Sets the logged in user
|
||||||
def logged_user=(user)
|
def logged_user=(user)
|
||||||
reset_session
|
reset_session
|
||||||
if user && user.is_a?(User)
|
if user && user.is_a?(User)
|
||||||
User.current = user
|
User.current = user
|
||||||
session[:user_id] = user.id
|
start_user_session(user)
|
||||||
else
|
else
|
||||||
User.current = User.anonymous
|
User.current = User.anonymous
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Logs out current user
|
||||||
|
def logout_user
|
||||||
|
if User.current.logged?
|
||||||
|
cookies.delete :autologin
|
||||||
|
Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
|
||||||
|
self.logged_user = nil
|
||||||
|
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
|
||||||
@@ -236,20 +299,11 @@ class ApplicationController < ActionController::Base
|
|||||||
render_404
|
render_404
|
||||||
end
|
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
|
||||||
if @project && @project.active?
|
if @project && @project.active?
|
||||||
if @project.is_public? || User.current.member_of?(@project) || User.current.admin?
|
if @project.visible?
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
deny_access
|
deny_access
|
||||||
@@ -349,18 +403,6 @@ class ApplicationController < ActionController::Base
|
|||||||
:content_type => 'application/atom+xml'
|
:content_type => 'application/atom+xml'
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: remove in Redmine 1.4
|
|
||||||
def self.accept_key_auth(*actions)
|
|
||||||
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."
|
|
||||||
accept_rss_auth(*actions)
|
|
||||||
end
|
|
||||||
|
|
||||||
# TODO: remove in Redmine 1.4
|
|
||||||
def 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
|
|
||||||
|
|
||||||
def self.accept_rss_auth(*actions)
|
def self.accept_rss_auth(*actions)
|
||||||
if actions.any?
|
if actions.any?
|
||||||
write_inheritable_attribute('accept_rss_auth_actions', actions)
|
write_inheritable_attribute('accept_rss_auth_actions', actions)
|
||||||
@@ -457,9 +499,9 @@ class ApplicationController < ActionController::Base
|
|||||||
# Returns the API key present in the request
|
# Returns the API key present in the request
|
||||||
def api_key_from_request
|
def api_key_from_request
|
||||||
if params[:key].present?
|
if params[:key].present?
|
||||||
params[:key]
|
params[:key].to_s
|
||||||
elsif request.headers["X-Redmine-API-Key"].present?
|
elsif request.headers["X-Redmine-API-Key"].present?
|
||||||
request.headers["X-Redmine-API-Key"]
|
request.headers["X-Redmine-API-Key"].to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -492,16 +534,13 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Renders API response on validation failure
|
# Renders API response on validation failure
|
||||||
def render_validation_errors(object)
|
def render_validation_errors(objects)
|
||||||
options = { :status => :unprocessable_entity, :layout => false }
|
if objects.is_a?(Array)
|
||||||
options.merge!(case params[:format]
|
@error_messages = objects.map {|object| object.errors.full_messages}.flatten
|
||||||
when 'xml'; { :xml => object.errors }
|
else
|
||||||
when 'json'; { :json => {'errors' => object.errors} } # ActiveResource client compliance
|
@error_messages = objects.errors.full_messages
|
||||||
else
|
end
|
||||||
raise "Unknown format #{params[:format]} in #render_validation_errors"
|
render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => false
|
||||||
end
|
|
||||||
)
|
|
||||||
render options
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overrides #default_template so that the api template
|
# Overrides #default_template so that the api template
|
||||||
|
|||||||
@@ -16,11 +16,12 @@
|
|||||||
# 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 AttachmentsController < ApplicationController
|
class AttachmentsController < ApplicationController
|
||||||
before_filter :find_project
|
before_filter :find_project, :except => :upload
|
||||||
before_filter :file_readable, :read_authorize, :except => :destroy
|
before_filter :file_readable, :read_authorize, :only => [:show, :download]
|
||||||
before_filter :delete_authorize, :only => :destroy
|
before_filter :delete_authorize, :only => :destroy
|
||||||
|
before_filter :authorize_global, :only => :upload
|
||||||
|
|
||||||
accept_api_auth :show, :download
|
accept_api_auth :show, :download, :upload
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -58,8 +59,33 @@ class AttachmentsController < ApplicationController
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy
|
def upload
|
||||||
|
# Make sure that API users get used to set this content type
|
||||||
|
# as it won't trigger Rails' automatic parsing of the request body for parameters
|
||||||
|
unless request.content_type == 'application/octet-stream'
|
||||||
|
render :nothing => true, :status => 406
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@attachment = Attachment.new(:file => request.raw_post)
|
||||||
|
@attachment.author = User.current
|
||||||
|
@attachment.filename = Redmine::Utils.random_hex(16)
|
||||||
|
|
||||||
|
if @attachment.save
|
||||||
|
respond_to do |format|
|
||||||
|
format.api { render :action => 'upload', :status => :created }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.api { render_validation_errors(@attachment) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
if @attachment.container.respond_to?(:init_journal)
|
||||||
|
@attachment.container.init_journal(User.current)
|
||||||
|
end
|
||||||
# Make sure association callbacks are called
|
# Make sure association callbacks are called
|
||||||
@attachment.container.attachments.delete(@attachment)
|
@attachment.container.attachments.delete(@attachment)
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
|
|||||||
@@ -17,36 +17,31 @@
|
|||||||
|
|
||||||
class AuthSourcesController < ApplicationController
|
class AuthSourcesController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
menu_item :ldap_authentication
|
||||||
|
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
|
||||||
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
|
|
||||||
verify :method => :post, :only => [ :destroy, :create, :update ],
|
|
||||||
:redirect_to => { :template => :index }
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@auth_source_pages, @auth_sources = paginate auth_source_class.name.tableize, :per_page => 10
|
@auth_source_pages, @auth_sources = paginate AuthSource, :per_page => 10
|
||||||
render "auth_sources/index"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@auth_source = auth_source_class.new
|
klass_name = params[:type] || 'AuthSourceLdap'
|
||||||
render 'auth_sources/new'
|
@auth_source = AuthSource.new_subclass_instance(klass_name, params[:auth_source])
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@auth_source = auth_source_class.new(params[:auth_source])
|
@auth_source = AuthSource.new_subclass_instance(params[:type], params[:auth_source])
|
||||||
if @auth_source.save
|
if @auth_source.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
else
|
else
|
||||||
render 'auth_sources/new'
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@auth_source = AuthSource.find(params[:id])
|
@auth_source = AuthSource.find(params[:id])
|
||||||
render 'auth_sources/edit'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@@ -55,17 +50,17 @@ class AuthSourcesController < ApplicationController
|
|||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
else
|
else
|
||||||
render 'auth_sources/edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_connection
|
def test_connection
|
||||||
@auth_method = AuthSource.find(params[:id])
|
@auth_source = AuthSource.find(params[:id])
|
||||||
begin
|
begin
|
||||||
@auth_method.test_connection
|
@auth_source.test_connection
|
||||||
flash[:notice] = l(:notice_successful_connection)
|
flash[:notice] = l(:notice_successful_connection)
|
||||||
rescue => text
|
rescue Exception => e
|
||||||
flash[:error] = l(:error_unable_to_connect, text.message)
|
flash[:error] = l(:error_unable_to_connect, e.message)
|
||||||
end
|
end
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
@@ -78,10 +73,4 @@ class AuthSourcesController < ApplicationController
|
|||||||
end
|
end
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def auth_source_class
|
|
||||||
AuthSource
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,15 +17,12 @@
|
|||||||
|
|
||||||
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_by_project_id, :find_board_if_available, :authorize
|
||||||
accept_rss_auth :index, :show
|
accept_rss_auth :index, :show
|
||||||
|
|
||||||
helper :messages
|
|
||||||
include MessagesHelper
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
helper :watchers
|
helper :watchers
|
||||||
include WatchersHelper
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@boards = @project.boards
|
@boards = @project.boards
|
||||||
@@ -50,7 +47,7 @@ class BoardsController < ApplicationController
|
|||||||
:include => [:author, {:last_reply => :author}],
|
:include => [:author, {:last_reply => :author}],
|
||||||
:limit => @topic_pages.items_per_page,
|
:limit => @topic_pages.items_per_page,
|
||||||
:offset => @topic_pages.current.offset
|
:offset => @topic_pages.current.offset
|
||||||
@message = Message.new
|
@message = Message.new(:board => @board)
|
||||||
render :action => 'show', :layout => !request.xhr?
|
render :action => 'show', :layout => !request.xhr?
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
@@ -62,20 +59,31 @@ class BoardsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index }
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@board = Board.new(params[:board])
|
@board = @project.boards.build
|
||||||
@board.project = @project
|
@board.safe_attributes = params[:board]
|
||||||
if request.post? && @board.save
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@board = @project.boards.build
|
||||||
|
@board.safe_attributes = params[:board]
|
||||||
|
if @board.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to_settings_in_projects
|
redirect_to_settings_in_projects
|
||||||
|
else
|
||||||
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if request.post? && @board.update_attributes(params[:board])
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@board.safe_attributes = params[:board]
|
||||||
|
if @board.save
|
||||||
redirect_to_settings_in_projects
|
redirect_to_settings_in_projects
|
||||||
|
else
|
||||||
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -89,12 +97,6 @@ private
|
|||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_project
|
|
||||||
@project = Project.find(params[:project_id])
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
render_404
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_board_if_available
|
def find_board_if_available
|
||||||
@board = @project.boards.find(params[:id]) if params[:id]
|
@board = @project.boards.find(params[:id]) if params[:id]
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2012 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 CommentsController < ApplicationController
|
class CommentsController < ApplicationController
|
||||||
default_search_scope :news
|
default_search_scope :news
|
||||||
model_object News
|
model_object News
|
||||||
@@ -5,9 +22,11 @@ class CommentsController < ApplicationController
|
|||||||
before_filter :find_project_from_association
|
before_filter :find_project_from_association
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
|
|
||||||
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def create
|
def create
|
||||||
@comment = Comment.new(params[:comment])
|
raise Unauthorized unless @news.commentable?
|
||||||
|
|
||||||
|
@comment = Comment.new
|
||||||
|
@comment.safe_attributes = params[:comment]
|
||||||
@comment.author = User.current
|
@comment.author = User.current
|
||||||
if @news.comments << @comment
|
if @news.comments << @comment
|
||||||
flash[:notice] = l(:label_comment_added)
|
flash[:notice] = l(:label_comment_added)
|
||||||
@@ -16,7 +35,6 @@ class CommentsController < ApplicationController
|
|||||||
redirect_to :controller => 'news', :action => 'show', :id => @news
|
redirect_to :controller => 'news', :action => 'show', :id => @news
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def destroy
|
def destroy
|
||||||
@news.comments.find(params[:comment_id]).destroy
|
@news.comments.find(params[:comment_id]).destroy
|
||||||
redirect_to :controller => 'news', :action => 'show', :id => @news
|
redirect_to :controller => 'news', :action => 'show', :id => @news
|
||||||
@@ -32,5 +50,4 @@ class CommentsController < ApplicationController
|
|||||||
@comment = nil
|
@comment = nil
|
||||||
@news
|
@news
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,17 +4,11 @@ class ContextMenusController < ApplicationController
|
|||||||
|
|
||||||
def issues
|
def issues
|
||||||
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
|
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
|
||||||
|
|
||||||
if (@issues.size == 1)
|
if (@issues.size == 1)
|
||||||
@issue = @issues.first
|
@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
|
end
|
||||||
|
|
||||||
|
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
||||||
@projects = @issues.collect(&:project).compact.uniq
|
@projects = @issues.collect(&:project).compact.uniq
|
||||||
@project = @projects.first if @projects.size == 1
|
@project = @projects.first if @projects.size == 1
|
||||||
|
|
||||||
@@ -34,14 +28,26 @@ class ContextMenusController < ApplicationController
|
|||||||
@trackers = @project.trackers
|
@trackers = @project.trackers
|
||||||
else
|
else
|
||||||
#when multiple projects, we only keep the intersection of each set
|
#when multiple projects, we only keep the intersection of each set
|
||||||
@assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a}
|
@assignables = @projects.map(&:assignable_users).reduce(:&)
|
||||||
@trackers = @projects.map(&:trackers).inject{|memo,t| memo & t}
|
@trackers = @projects.map(&:trackers).reduce(:&)
|
||||||
end
|
end
|
||||||
|
|
||||||
@priorities = IssuePriority.active.reverse
|
@priorities = IssuePriority.active.reverse
|
||||||
@statuses = IssueStatus.find(:all, :order => 'position')
|
|
||||||
@back = back_url
|
@back = back_url
|
||||||
|
|
||||||
|
@options_by_custom_field = {}
|
||||||
|
if @can[:edit]
|
||||||
|
custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f|
|
||||||
|
%w(bool list user version).include?(f.field_format) && !f.multiple?
|
||||||
|
end
|
||||||
|
custom_fields.each do |field|
|
||||||
|
values = field.possible_values_options(@projects)
|
||||||
|
if values.any?
|
||||||
|
@options_by_custom_field[field] = values
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class CustomFieldsController < ApplicationController
|
|||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
before_filter :build_new_custom_field, :only => [:new, :create]
|
||||||
|
before_filter :find_custom_field, :only => [:edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name }
|
@custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name }
|
||||||
@@ -26,39 +28,51 @@ class CustomFieldsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@custom_field = begin
|
end
|
||||||
if params[:type].to_s.match(/.+CustomField$/)
|
|
||||||
params[:type].to_s.constantize.new(params[:custom_field])
|
|
||||||
end
|
|
||||||
rescue
|
|
||||||
end
|
|
||||||
(redirect_to(:action => 'index'); return) unless @custom_field.is_a?(CustomField)
|
|
||||||
|
|
||||||
|
def create
|
||||||
if request.post? and @custom_field.save
|
if request.post? and @custom_field.save
|
||||||
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
|
else
|
||||||
@trackers = Tracker.find(:all, :order => 'position')
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@custom_field = CustomField.find(params[:id])
|
end
|
||||||
if request.post? and @custom_field.update_attributes(params[:custom_field])
|
|
||||||
|
def update
|
||||||
|
if request.put? and @custom_field.update_attributes(params[:custom_field])
|
||||||
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
|
else
|
||||||
@trackers = Tracker.find(:all, :order => 'position')
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@custom_field = CustomField.find(params[:id]).destroy
|
@custom_field.destroy
|
||||||
redirect_to :action => 'index', :tab => @custom_field.class.name
|
redirect_to :action => 'index', :tab => @custom_field.class.name
|
||||||
rescue
|
rescue
|
||||||
flash[:error] = l(:error_can_not_delete_custom_field)
|
flash[:error] = l(:error_can_not_delete_custom_field)
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def build_new_custom_field
|
||||||
|
@custom_field = CustomField.new_subclass_instance(params[:type], params[:custom_field])
|
||||||
|
if @custom_field.nil?
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_custom_field
|
||||||
|
@custom_field = CustomField.find(params[:id])
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
class DocumentsController < ApplicationController
|
class DocumentsController < ApplicationController
|
||||||
default_search_scope :documents
|
default_search_scope :documents
|
||||||
model_object Document
|
model_object Document
|
||||||
before_filter :find_project, :only => [:index, :new]
|
before_filter :find_project_by_project_id, :only => [:index, :new, :create]
|
||||||
before_filter :find_model_object, :except => [:index, :new]
|
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||||
before_filter :find_project_from_association, :except => [:index, :new]
|
before_filter :find_project_from_association, :except => [:index, :new, :create]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
|
|
||||||
helper :attachments
|
helper :attachments
|
||||||
@@ -47,25 +47,38 @@ class DocumentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@document = @project.documents.build(params[:document])
|
@document = @project.documents.build
|
||||||
if request.post? and @document.save
|
@document.safe_attributes = params[:document]
|
||||||
attachments = Attachment.attach_files(@document, params[:attachments])
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@document = @project.documents.build
|
||||||
|
@document.safe_attributes = params[:document]
|
||||||
|
@document.save_attachments(params[:attachments])
|
||||||
|
if @document.save
|
||||||
render_attachment_warning_if_needed(@document)
|
render_attachment_warning_if_needed(@document)
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'index', :project_id => @project
|
redirect_to :action => 'index', :project_id => @project
|
||||||
|
else
|
||||||
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@categories = DocumentCategory.active #TODO: use it in the views
|
end
|
||||||
if request.post? and @document.update_attributes(params[:document])
|
|
||||||
|
def update
|
||||||
|
@document.safe_attributes = params[:document]
|
||||||
|
if request.put? and @document.save
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'show', :id => @document
|
redirect_to :action => 'show', :id => @document
|
||||||
|
else
|
||||||
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@document.destroy
|
@document.destroy if request.delete?
|
||||||
redirect_to :controller => 'documents', :action => 'index', :project_id => @project
|
redirect_to :controller => 'documents', :action => 'index', :project_id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -76,11 +89,4 @@ class DocumentsController < ApplicationController
|
|||||||
Mailer.deliver_attachments_added(attachments[:files]) if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
|
Mailer.deliver_attachments_added(attachments[:files]) if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
|
||||||
redirect_to :action => 'show', :id => @document
|
redirect_to :action => 'show', :id => @document
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
def find_project
|
|
||||||
@project = Project.find(params[:project_id])
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
render_404
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,28 +19,19 @@ class EnumerationsController < ApplicationController
|
|||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
before_filter :build_new_enumeration, :only => [:new, :create]
|
||||||
|
before_filter :find_enumeration, :only => [:edit, :update, :destroy]
|
||||||
|
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
include CustomFieldsHelper
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :post, :only => [ :destroy, :create, :update ],
|
|
||||||
:redirect_to => { :action => :index }
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
begin
|
|
||||||
@enumeration = params[:type].constantize.new
|
|
||||||
rescue NameError
|
|
||||||
@enumeration = Enumeration.new
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@enumeration = Enumeration.new(params[:enumeration])
|
if request.post? && @enumeration.save
|
||||||
@enumeration.type = params[:enumeration][:type]
|
|
||||||
if @enumeration.save
|
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'index', :type => @enumeration.type
|
redirect_to :action => 'index', :type => @enumeration.type
|
||||||
else
|
else
|
||||||
@@ -49,13 +40,10 @@ class EnumerationsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@enumeration = Enumeration.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@enumeration = Enumeration.find(params[:id])
|
if request.put? && @enumeration.update_attributes(params[:enumeration])
|
||||||
@enumeration.type = params[:enumeration][:type] if params[:enumeration][:type]
|
|
||||||
if @enumeration.update_attributes(params[:enumeration])
|
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'index', :type => @enumeration.type
|
redirect_to :action => 'index', :type => @enumeration.type
|
||||||
else
|
else
|
||||||
@@ -64,7 +52,6 @@ class EnumerationsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@enumeration = Enumeration.find(params[:id])
|
|
||||||
if !@enumeration.in_use?
|
if !@enumeration.in_use?
|
||||||
# No associated objects
|
# No associated objects
|
||||||
@enumeration.destroy
|
@enumeration.destroy
|
||||||
@@ -77,9 +64,22 @@ class EnumerationsController < ApplicationController
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@enumerations = @enumeration.class.find(:all) - [@enumeration]
|
@enumerations = @enumeration.class.all - [@enumeration]
|
||||||
#rescue
|
end
|
||||||
# flash[:error] = 'Unable to delete enumeration'
|
|
||||||
# redirect_to :action => 'index'
|
private
|
||||||
|
|
||||||
|
def build_new_enumeration
|
||||||
|
class_name = params[:enumeration] && params[:enumeration][:type] || params[:type]
|
||||||
|
@enumeration = Enumeration.new_subclass_instance(class_name, params[:enumeration])
|
||||||
|
if @enumeration.nil?
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_enumeration
|
||||||
|
@enumeration = Enumeration.find(params[:id])
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class IssueCategoriesController < ApplicationController
|
|||||||
model_object IssueCategory
|
model_object IssueCategory
|
||||||
before_filter :find_model_object, :except => [:index, :new, :create]
|
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||||
before_filter :find_project_from_association, :except => [:index, :new, :create]
|
before_filter :find_project_from_association, :except => [:index, :new, :create]
|
||||||
before_filter :find_project, :only => [:index, :new, :create]
|
before_filter :find_project_by_project_id, :only => [:index, :new, :create]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
accept_api_auth :index, :show, :create, :update, :destroy
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
@@ -39,12 +39,13 @@ class IssueCategoriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@category = @project.issue_categories.build(params[:issue_category])
|
@category = @project.issue_categories.build
|
||||||
|
@category.safe_attributes = params[:issue_category]
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :post, :only => :create
|
|
||||||
def create
|
def create
|
||||||
@category = @project.issue_categories.build(params[:issue_category])
|
@category = @project.issue_categories.build
|
||||||
|
@category.safe_attributes = params[:issue_category]
|
||||||
if @category.save
|
if @category.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
@@ -54,7 +55,7 @@ class IssueCategoriesController < ApplicationController
|
|||||||
format.js do
|
format.js do
|
||||||
# IE doesn't support the replace_html rjs method for select box options
|
# IE doesn't support the replace_html rjs method for select box options
|
||||||
render(:update) {|page| page.replace "issue_category_id",
|
render(:update) {|page| page.replace "issue_category_id",
|
||||||
content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
|
content_tag('select', content_tag('option') + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
|
format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
|
||||||
@@ -73,9 +74,9 @@ class IssueCategoriesController < ApplicationController
|
|||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :put, :only => :update
|
|
||||||
def update
|
def update
|
||||||
if @category.update_attributes(params[:issue_category])
|
@category.safe_attributes = params[:issue_category]
|
||||||
|
if @category.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
@@ -91,7 +92,6 @@ class IssueCategoriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy
|
|
||||||
def destroy
|
def destroy
|
||||||
@issue_count = @category.issues.size
|
@issue_count = @category.issues.size
|
||||||
if @issue_count == 0 || params[:todo] || api_request?
|
if @issue_count == 0 || params[:todo] || api_request?
|
||||||
@@ -116,10 +116,4 @@ private
|
|||||||
super
|
super
|
||||||
@category = @object
|
@category = @object
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_project
|
|
||||||
@project = Project.find(params[:project_id])
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
render_404
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
# 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 IssueMovesController < ApplicationController
|
|
||||||
menu_item :issues
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -39,11 +39,10 @@ class IssueRelationsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def create
|
def create
|
||||||
@relation = IssueRelation.new(params[:relation])
|
@relation = IssueRelation.new(params[:relation])
|
||||||
@relation.issue_from = @issue
|
@relation.issue_from = @issue
|
||||||
if params[:relation] && m = params[:relation][:issue_to_id].to_s.match(/^#?(\d+)$/)
|
if params[:relation] && m = params[:relation][:issue_to_id].to_s.strip.match(/^#?(\d+)$/)
|
||||||
@relation.issue_to = Issue.visible.find_by_id(m[1].to_i)
|
@relation.issue_to = Issue.visible.find_by_id(m[1].to_i)
|
||||||
end
|
end
|
||||||
saved = @relation.save
|
saved = @relation.save
|
||||||
@@ -70,13 +69,12 @@ class IssueRelationsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def destroy
|
def destroy
|
||||||
raise Unauthorized unless @relation.deletable?
|
raise Unauthorized unless @relation.deletable?
|
||||||
@relation.destroy
|
@relation.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
format.html { redirect_to issue_path } # TODO : does this really work since @issue is always nil? What is it useful to?
|
||||||
format.js { render(:update) {|page| page.remove "relation-#{@relation.id}"} }
|
format.js { render(:update) {|page| page.remove "relation-#{@relation.id}"} }
|
||||||
format.api { head :ok }
|
format.api { head :ok }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ class IssueStatusesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy, :redirect_to => { :action => :index }
|
|
||||||
def destroy
|
def destroy
|
||||||
IssueStatus.find(params[:id]).destroy
|
IssueStatus.find(params[:id]).destroy
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ class IssuesController < ApplicationController
|
|||||||
default_search_scope :issues
|
default_search_scope :issues
|
||||||
|
|
||||||
before_filter :find_issue, :only => [:show, :edit, :update]
|
before_filter :find_issue, :only => [:show, :edit, :update]
|
||||||
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
|
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||||
before_filter :check_project_uniqueness, :only => [:move, :perform_move]
|
|
||||||
before_filter :find_project, :only => [:new, :create]
|
before_filter :find_project, :only => [:new, :create]
|
||||||
before_filter :authorize, :except => [:index]
|
before_filter :authorize, :except => [:index]
|
||||||
before_filter :find_optional_project, :only => [:index]
|
before_filter :find_optional_project, :only => [:index]
|
||||||
@@ -54,14 +53,6 @@ class IssuesController < ApplicationController
|
|||||||
helper :gantt
|
helper :gantt
|
||||||
include Redmine::Export::PDF
|
include Redmine::Export::PDF
|
||||||
|
|
||||||
verify :method => [:post, :delete],
|
|
||||||
:only => :destroy,
|
|
||||||
: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 }
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -113,10 +104,8 @@ class IssuesController < ApplicationController
|
|||||||
@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?
|
||||||
|
|
||||||
if User.current.allowed_to?(:view_changesets, @project)
|
@changesets = @issue.changesets.visible.all
|
||||||
@changesets = @issue.changesets.visible.all
|
@changesets.reverse! if User.current.wants_comments_in_reverse_order?
|
||||||
@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? }
|
@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)
|
||||||
@@ -124,7 +113,10 @@ class IssuesController < ApplicationController
|
|||||||
@priorities = IssuePriority.active
|
@priorities = IssuePriority.active
|
||||||
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :template => 'issues/show' }
|
format.html {
|
||||||
|
retrieve_previous_and_next_issue_ids
|
||||||
|
render :template => 'issues/show'
|
||||||
|
}
|
||||||
format.api
|
format.api
|
||||||
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
|
format.atom { render :template => 'journals/index', :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") }
|
||||||
@@ -136,20 +128,30 @@ class IssuesController < ApplicationController
|
|||||||
def new
|
def new
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'new', :layout => !request.xhr? }
|
format.html { render :action => 'new', :layout => !request.xhr? }
|
||||||
format.js { render :partial => 'attributes' }
|
format.js {
|
||||||
|
render(:update) { |page|
|
||||||
|
if params[:project_change]
|
||||||
|
page.replace_html 'all_attributes', :partial => 'form'
|
||||||
|
else
|
||||||
|
page.replace_html 'attributes', :partial => 'attributes'
|
||||||
|
end
|
||||||
|
m = User.current.allowed_to?(:log_time, @issue.project) ? 'show' : 'hide'
|
||||||
|
page << "if ($('log_time')) {Element.#{m}('log_time');}"
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
|
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
|
||||||
|
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
|
||||||
if @issue.save
|
if @issue.save
|
||||||
attachments = Attachment.attach_files(@issue, params[:attachments])
|
|
||||||
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 {
|
||||||
render_attachment_warning_if_needed(@issue)
|
render_attachment_warning_if_needed(@issue)
|
||||||
flash[:notice] = l(:notice_issue_successful_create, :id => "<a href='#{issue_path(@issue)}'>##{@issue.id}</a>")
|
flash[:notice] = l(:notice_issue_successful_create, :id => "<a href='#{issue_path(@issue)}'>##{@issue.id}</a>")
|
||||||
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?} } :
|
redirect_to(params[:continue] ? { :action => 'new', :project_id => @issue.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.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
|
format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
|
||||||
@@ -164,9 +166,7 @@ class IssuesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
update_issue_from_params
|
return unless update_issue_from_params
|
||||||
|
|
||||||
@journal = @issue.current_journal
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { }
|
format.html { }
|
||||||
@@ -175,9 +175,24 @@ class IssuesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
update_issue_from_params
|
return unless update_issue_from_params
|
||||||
|
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
|
||||||
|
saved = false
|
||||||
|
begin
|
||||||
|
saved = @issue.save_issue_with_child_records(params, @time_entry)
|
||||||
|
rescue ActiveRecord::StaleObjectError
|
||||||
|
@conflict = true
|
||||||
|
if params[:last_journal_id]
|
||||||
|
if params[:last_journal_id].present?
|
||||||
|
last_journal_id = params[:last_journal_id].to_i
|
||||||
|
@conflict_journals = @issue.journals.all(:conditions => ["#{Journal.table_name}.id > ?", last_journal_id])
|
||||||
|
else
|
||||||
|
@conflict_journals = @issue.journals.all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if @issue.save_issue_with_child_records(params, @time_entry)
|
if saved
|
||||||
render_attachment_warning_if_needed(@issue)
|
render_attachment_warning_if_needed(@issue)
|
||||||
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
|
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
|
||||||
|
|
||||||
@@ -186,10 +201,6 @@ class IssuesController < ApplicationController
|
|||||||
format.api { head :ok }
|
format.api { head :ok }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render_attachment_warning_if_needed(@issue)
|
|
||||||
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
|
|
||||||
@journal = @issue.current_journal
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'edit' }
|
format.html { render :action => 'edit' }
|
||||||
format.api { render_validation_errors(@issue) }
|
format.api { render_validation_errors(@issue) }
|
||||||
@@ -197,32 +208,74 @@ class IssuesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bulk edit a set of issues
|
# Bulk edit/copy a set of issues
|
||||||
def bulk_edit
|
def bulk_edit
|
||||||
@issues.sort!
|
@issues.sort!
|
||||||
@available_statuses = @projects.map{|p|Workflow.available_statuses(p)}.inject{|memo,w|memo & w}
|
@copy = params[:copy].present?
|
||||||
@custom_fields = @projects.map{|p|p.all_issue_custom_fields}.inject{|memo,c|memo & c}
|
@notes = params[:notes]
|
||||||
@assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a}
|
|
||||||
@trackers = @projects.map(&:trackers).inject{|memo,t| memo & t}
|
if User.current.allowed_to?(:move_issues, @projects)
|
||||||
|
@allowed_projects = Issue.allowed_target_projects_on_move
|
||||||
|
if params[:issue]
|
||||||
|
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
|
||||||
|
if @target_project
|
||||||
|
target_projects = [@target_project]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
target_projects ||= @projects
|
||||||
|
|
||||||
|
if @copy
|
||||||
|
@available_statuses = [IssueStatus.default]
|
||||||
|
else
|
||||||
|
@available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
||||||
|
end
|
||||||
|
@custom_fields = target_projects.map{|p|p.all_issue_custom_fields}.reduce(:&)
|
||||||
|
@assignables = target_projects.map(&:assignable_users).reduce(:&)
|
||||||
|
@trackers = target_projects.map(&:trackers).reduce(:&)
|
||||||
|
@versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
|
||||||
|
@categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
|
||||||
|
if @copy
|
||||||
|
@attachments_present = @issues.detect {|i| i.attachments.any?}.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
|
||||||
|
render :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def bulk_update
|
def bulk_update
|
||||||
@issues.sort!
|
@issues.sort!
|
||||||
|
@copy = params[:copy].present?
|
||||||
attributes = parse_params_for_bulk_issue_attributes(params)
|
attributes = parse_params_for_bulk_issue_attributes(params)
|
||||||
|
|
||||||
unsaved_issue_ids = []
|
unsaved_issue_ids = []
|
||||||
|
moved_issues = []
|
||||||
@issues.each do |issue|
|
@issues.each do |issue|
|
||||||
issue.reload
|
issue.reload
|
||||||
|
if @copy
|
||||||
|
issue = issue.copy({}, :attachments => params[:copy_attachments].present?)
|
||||||
|
end
|
||||||
journal = issue.init_journal(User.current, params[:notes])
|
journal = issue.init_journal(User.current, params[:notes])
|
||||||
issue.safe_attributes = attributes
|
issue.safe_attributes = attributes
|
||||||
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
|
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
|
||||||
unless issue.save
|
if issue.save
|
||||||
|
moved_issues << issue
|
||||||
|
else
|
||||||
# Keep unsaved issue ids to display them in flash error
|
# Keep unsaved issue ids to display them in flash error
|
||||||
unsaved_issue_ids << issue.id
|
unsaved_issue_ids << issue.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
|
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
|
||||||
redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
|
|
||||||
|
if params[:follow]
|
||||||
|
if @issues.size == 1 && moved_issues.size == 1
|
||||||
|
redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first
|
||||||
|
elsif moved_issues.map(&:project).uniq.size == 1
|
||||||
|
redirect_to :controller => 'issues', :action => 'index', :project_id => moved_issues.map(&:project).first
|
||||||
|
end
|
||||||
|
else
|
||||||
|
redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@@ -274,25 +327,58 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
def find_project
|
def find_project
|
||||||
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
|
project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id])
|
||||||
@project = Project.find(project_id)
|
@project = Project.find(project_id)
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def retrieve_previous_and_next_issue_ids
|
||||||
|
retrieve_query_from_session
|
||||||
|
if @query
|
||||||
|
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
|
||||||
|
sort_update(@query.sortable_columns, 'issues_index_sort')
|
||||||
|
limit = 500
|
||||||
|
issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
|
||||||
|
if (idx = issue_ids.index(@issue.id)) && idx < limit
|
||||||
|
if issue_ids.size < 500
|
||||||
|
@issue_position = idx + 1
|
||||||
|
@issue_count = issue_ids.size
|
||||||
|
end
|
||||||
|
@prev_issue_id = issue_ids[idx - 1] if idx > 0
|
||||||
|
@next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
|
||||||
|
end
|
||||||
|
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
|
||||||
def update_issue_from_params
|
def update_issue_from_params
|
||||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
|
||||||
@priorities = IssuePriority.active
|
|
||||||
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||||||
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
||||||
@time_entry.attributes = params[:time_entry]
|
@time_entry.attributes = params[:time_entry]
|
||||||
|
|
||||||
@notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
|
@notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
|
||||||
@issue.init_journal(User.current, @notes)
|
@issue.init_journal(User.current, @notes)
|
||||||
@issue.safe_attributes = params[:issue]
|
|
||||||
|
issue_attributes = params[:issue]
|
||||||
|
if issue_attributes && params[:conflict_resolution]
|
||||||
|
case params[:conflict_resolution]
|
||||||
|
when 'overwrite'
|
||||||
|
issue_attributes = issue_attributes.dup
|
||||||
|
issue_attributes.delete(:lock_version)
|
||||||
|
when 'add_notes'
|
||||||
|
issue_attributes = {}
|
||||||
|
when 'cancel'
|
||||||
|
redirect_to issue_path(@issue)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@issue.safe_attributes = issue_attributes
|
||||||
|
@priorities = IssuePriority.active
|
||||||
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Refactor, lots of extra code in here
|
# TODO: Refactor, lots of extra code in here
|
||||||
@@ -300,7 +386,16 @@ private
|
|||||||
def build_new_issue_from_params
|
def build_new_issue_from_params
|
||||||
if params[:id].blank?
|
if params[:id].blank?
|
||||||
@issue = Issue.new
|
@issue = Issue.new
|
||||||
@issue.copy_from(params[:copy_from]) if params[:copy_from]
|
if params[:copy_from]
|
||||||
|
begin
|
||||||
|
@copy_from = Issue.visible.find(params[:copy_from])
|
||||||
|
@copy_attachments = params[:copy_attachments].present? || request.get?
|
||||||
|
@issue.copy_from(@copy_from, :attachments => @copy_attachments)
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
@issue.project = @project
|
@issue.project = @project
|
||||||
else
|
else
|
||||||
@issue = @project.issues.visible.find(params[:id])
|
@issue = @project.issues.visible.find(params[:id])
|
||||||
@@ -315,14 +410,11 @@ private
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
|
@issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
|
||||||
if params[:issue].is_a?(Hash)
|
@issue.safe_attributes = params[:issue]
|
||||||
@issue.safe_attributes = params[:issue]
|
|
||||||
if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record?
|
|
||||||
@issue.watcher_user_ids = params[:issue]['watcher_user_ids']
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@priorities = IssuePriority.active
|
@priorities = IssuePriority.active
|
||||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
|
||||||
|
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_for_default_issue_status
|
def check_for_default_issue_status
|
||||||
@@ -335,7 +427,16 @@ private
|
|||||||
def parse_params_for_bulk_issue_attributes(params)
|
def parse_params_for_bulk_issue_attributes(params)
|
||||||
attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
|
attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
|
||||||
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
|
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
|
||||||
attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values]
|
if custom = attributes[:custom_field_values]
|
||||||
|
custom.reject! {|k,v| v.blank?}
|
||||||
|
custom.keys.each do |k|
|
||||||
|
if custom[k].is_a?(Array)
|
||||||
|
custom[k] << '' if custom[k].delete('__none__')
|
||||||
|
else
|
||||||
|
custom[k] = '' if custom[k] == '__none__'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
attributes
|
attributes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,10 +18,6 @@
|
|||||||
class MailHandlerController < ActionController::Base
|
class MailHandlerController < ActionController::Base
|
||||||
before_filter :check_credential
|
before_filter :check_credential
|
||||||
|
|
||||||
verify :method => :post,
|
|
||||||
:only => :index,
|
|
||||||
: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
|
||||||
|
|||||||
@@ -17,29 +17,54 @@
|
|||||||
|
|
||||||
class MembersController < ApplicationController
|
class MembersController < ApplicationController
|
||||||
model_object Member
|
model_object Member
|
||||||
before_filter :find_model_object, :except => [:new, :autocomplete_for_member]
|
before_filter :find_model_object, :except => [:index, :create, :autocomplete]
|
||||||
before_filter :find_project_from_association, :except => [:new, :autocomplete_for_member]
|
before_filter :find_project_from_association, :except => [:index, :create, :autocomplete]
|
||||||
before_filter :find_project, :only => [:new, :autocomplete_for_member]
|
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
def new
|
def index
|
||||||
|
@offset, @limit = api_offset_and_limit
|
||||||
|
@member_count = @project.member_principals.count
|
||||||
|
@member_pages = Paginator.new self, @member_count, @limit, params['page']
|
||||||
|
@offset ||= @member_pages.current.offset
|
||||||
|
@members = @project.member_principals.all(
|
||||||
|
:order => "#{Member.table_name}.id",
|
||||||
|
:limit => @limit,
|
||||||
|
:offset => @offset
|
||||||
|
)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { head 406 }
|
||||||
|
format.api
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { head 406 }
|
||||||
|
format.api
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
members = []
|
members = []
|
||||||
if params[:member] && request.post?
|
if params[:membership]
|
||||||
attrs = params[:member].dup
|
if params[:membership][:user_ids]
|
||||||
if (user_ids = attrs.delete(:user_ids))
|
attrs = params[:membership].dup
|
||||||
|
user_ids = attrs.delete(:user_ids)
|
||||||
user_ids.each do |user_id|
|
user_ids.each do |user_id|
|
||||||
members << Member.new(attrs.merge(:user_id => user_id))
|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
members << Member.new(attrs)
|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
||||||
end
|
end
|
||||||
@project.members << members
|
@project.members << members
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if members.present? && members.all? {|m| m.valid? }
|
if members.present? && members.all? {|m| m.valid? }
|
||||||
|
|
||||||
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
||||||
|
|
||||||
format.js {
|
format.js {
|
||||||
render(:update) {|page|
|
render(:update) {|page|
|
||||||
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
|
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
|
||||||
@@ -47,8 +72,11 @@ class MembersController < ApplicationController
|
|||||||
members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") }
|
members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
format.api {
|
||||||
|
@member = members.first
|
||||||
|
render :action => 'show', :status => :created, :location => membership_url(@member)
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
|
||||||
format.js {
|
format.js {
|
||||||
render(:update) {|page|
|
render(:update) {|page|
|
||||||
errors = members.collect {|m|
|
errors = members.collect {|m|
|
||||||
@@ -58,28 +86,37 @@ class MembersController < ApplicationController
|
|||||||
page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', ')))
|
page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', ')))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
format.api { render_validation_errors(members.first) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def update
|
||||||
if request.post? and @member.update_attributes(params[:member])
|
if params[:membership]
|
||||||
respond_to do |format|
|
@member.role_ids = params[:membership][:role_ids]
|
||||||
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
end
|
||||||
format.js {
|
saved = @member.save
|
||||||
render(:update) {|page|
|
respond_to do |format|
|
||||||
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
||||||
page << 'hideOnLoad()'
|
format.js {
|
||||||
page.visual_effect(:highlight, "member-#{@member.id}")
|
render(:update) {|page|
|
||||||
}
|
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
|
||||||
|
page << 'hideOnLoad()'
|
||||||
|
page.visual_effect(:highlight, "member-#{@member.id}")
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
|
format.api {
|
||||||
|
if saved
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
render_validation_errors(@member)
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if request.post? && @member.deletable?
|
if request.delete? && @member.deletable?
|
||||||
@member.destroy
|
@member.destroy
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -89,11 +126,18 @@ class MembersController < ApplicationController
|
|||||||
page << 'hideOnLoad()'
|
page << 'hideOnLoad()'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
format.api {
|
||||||
|
if @member.destroyed?
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
head :unprocessable_entity
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def autocomplete_for_member
|
def autocomplete
|
||||||
@principals = Principal.active.like(params[:q]).find(:all, :limit => 100) - @project.principals
|
@principals = Principal.active.not_member_of(@project).like(params[:q]).all(:limit => 100)
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ class MessagesController < ApplicationController
|
|||||||
before_filter :find_message, :except => [:new, :preview]
|
before_filter :find_message, :except => [:new, :preview]
|
||||||
before_filter :authorize, :except => [:preview, :edit, :destroy]
|
before_filter :authorize, :except => [:preview, :edit, :destroy]
|
||||||
|
|
||||||
verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show }
|
|
||||||
verify :xhr => true, :only => :quote
|
|
||||||
|
|
||||||
helper :watchers
|
helper :watchers
|
||||||
helper :attachments
|
helper :attachments
|
||||||
include AttachmentsHelper
|
include AttachmentsHelper
|
||||||
@@ -53,26 +50,26 @@ class MessagesController < ApplicationController
|
|||||||
|
|
||||||
# Create a new topic
|
# Create a new topic
|
||||||
def new
|
def new
|
||||||
@message = Message.new(params[:message])
|
@message = Message.new
|
||||||
@message.author = User.current
|
@message.author = User.current
|
||||||
@message.board = @board
|
@message.board = @board
|
||||||
if params[:message] && User.current.allowed_to?(:edit_messages, @project)
|
@message.safe_attributes = params[:message]
|
||||||
@message.locked = params[:message]['locked']
|
if request.post?
|
||||||
@message.sticky = params[:message]['sticky']
|
@message.save_attachments(params[:attachments])
|
||||||
end
|
if @message.save
|
||||||
if request.post? && @message.save
|
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
||||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
render_attachment_warning_if_needed(@message)
|
||||||
attachments = Attachment.attach_files(@message, params[:attachments])
|
redirect_to :action => 'show', :id => @message
|
||||||
render_attachment_warning_if_needed(@message)
|
end
|
||||||
redirect_to :action => 'show', :id => @message
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Reply to a topic
|
# Reply to a topic
|
||||||
def reply
|
def reply
|
||||||
@reply = Message.new(params[:reply])
|
@reply = Message.new
|
||||||
@reply.author = User.current
|
@reply.author = User.current
|
||||||
@reply.board = @board
|
@reply.board = @board
|
||||||
|
@reply.safe_attributes = params[:reply]
|
||||||
@topic.children << @reply
|
@topic.children << @reply
|
||||||
if !@reply.new_record?
|
if !@reply.new_record?
|
||||||
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
|
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
|
||||||
@@ -85,11 +82,8 @@ class MessagesController < ApplicationController
|
|||||||
# Edit a message
|
# Edit a message
|
||||||
def edit
|
def edit
|
||||||
(render_403; return false) unless @message.editable_by?(User.current)
|
(render_403; return false) unless @message.editable_by?(User.current)
|
||||||
if params[:message]
|
@message.safe_attributes = params[:message]
|
||||||
@message.locked = params[:message]['locked']
|
if request.post? && @message.save
|
||||||
@message.sticky = params[:message]['sticky']
|
|
||||||
end
|
|
||||||
if request.post? && @message.update_attributes(params[:message])
|
|
||||||
attachments = Attachment.attach_files(@message, params[:attachments])
|
attachments = Attachment.attach_files(@message, params[:attachments])
|
||||||
render_attachment_warning_if_needed(@message)
|
render_attachment_warning_if_needed(@message)
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
|||||||
@@ -35,9 +35,6 @@ class MyController < ApplicationController
|
|||||||
'right' => ['issuesreportedbyme']
|
'right' => ['issuesreportedbyme']
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
verify :xhr => true,
|
|
||||||
:only => [:add_block, :remove_block, :order_blocks]
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
page
|
page
|
||||||
render :action => 'page'
|
render :action => 'page'
|
||||||
@@ -68,6 +65,24 @@ class MyController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Destroys user's account
|
||||||
|
def destroy
|
||||||
|
@user = User.current
|
||||||
|
unless @user.own_account_deletable?
|
||||||
|
redirect_to :action => 'account'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if request.post? && params[:confirm]
|
||||||
|
@user.destroy
|
||||||
|
if @user.destroyed?
|
||||||
|
logout_user
|
||||||
|
flash[:notice] = l(:notice_account_deleted)
|
||||||
|
end
|
||||||
|
redirect_to home_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Manage user's password
|
# Manage user's password
|
||||||
def password
|
def password
|
||||||
@user = User.current
|
@user = User.current
|
||||||
|
|||||||
@@ -20,13 +20,14 @@ class NewsController < ApplicationController
|
|||||||
model_object News
|
model_object News
|
||||||
before_filter :find_model_object, :except => [:new, :create, :index]
|
before_filter :find_model_object, :except => [:new, :create, :index]
|
||||||
before_filter :find_project_from_association, :except => [:new, :create, :index]
|
before_filter :find_project_from_association, :except => [:new, :create, :index]
|
||||||
before_filter :find_project, :only => [:new, :create]
|
before_filter :find_project_by_project_id, :only => [:new, :create]
|
||||||
before_filter :authorize, :except => [:index]
|
before_filter :authorize, :except => [:index]
|
||||||
before_filter :find_optional_project, :only => :index
|
before_filter :find_optional_project, :only => :index
|
||||||
accept_rss_auth :index
|
accept_rss_auth :index
|
||||||
accept_api_auth :index
|
accept_api_auth :index
|
||||||
|
|
||||||
helper :watchers
|
helper :watchers
|
||||||
|
helper :attachments
|
||||||
|
|
||||||
def index
|
def index
|
||||||
case params[:format]
|
case params[:format]
|
||||||
@@ -67,14 +68,14 @@ class NewsController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@news = News.new(:project => @project, :author => User.current)
|
@news = News.new(:project => @project, :author => User.current)
|
||||||
if request.post?
|
@news.safe_attributes = params[:news]
|
||||||
@news.attributes = params[:news]
|
@news.save_attachments(params[:attachments])
|
||||||
if @news.save
|
if @news.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
render_attachment_warning_if_needed(@news)
|
||||||
redirect_to :controller => 'news', :action => 'index', :project_id => @project
|
flash[:notice] = l(:notice_successful_create)
|
||||||
else
|
redirect_to :controller => 'news', :action => 'index', :project_id => @project
|
||||||
render :action => 'new'
|
else
|
||||||
end
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -82,7 +83,10 @@ class NewsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if request.put? and @news.update_attributes(params[:news])
|
@news.safe_attributes = params[:news]
|
||||||
|
@news.save_attachments(params[:attachments])
|
||||||
|
if @news.save
|
||||||
|
render_attachment_warning_if_needed(@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
|
||||||
else
|
else
|
||||||
@@ -95,12 +99,7 @@ class NewsController < ApplicationController
|
|||||||
redirect_to :action => 'index', :project_id => @project
|
redirect_to :action => 'index', :project_id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
|
||||||
@project = Project.find(params[:project_id])
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
render_404
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_optional_project
|
def find_optional_project
|
||||||
return true unless params[:project_id]
|
return true unless params[:project_id]
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class ProjectsController < ApplicationController
|
|||||||
|
|
||||||
after_filter :only => [:create, :edit, :update, :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'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -66,10 +66,10 @@ class ProjectsController < ApplicationController
|
|||||||
def new
|
def new
|
||||||
@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
|
||||||
|
@project.safe_attributes = params[:project]
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def create
|
def create
|
||||||
@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
|
||||||
@@ -176,15 +176,12 @@ class ProjectsController < ApplicationController
|
|||||||
@issue_category ||= IssueCategory.new
|
@issue_category ||= IssueCategory.new
|
||||||
@member ||= @project.members.new
|
@member ||= @project.members.new
|
||||||
@trackers = Tracker.all
|
@trackers = Tracker.all
|
||||||
@repository ||= @project.repository
|
|
||||||
@wiki ||= @project.wiki
|
@wiki ||= @project.wiki
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: convert to PUT only
|
|
||||||
verify :method => [:post, :put], :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def update
|
def update
|
||||||
@project.safe_attributes = params[:project]
|
@project.safe_attributes = params[:project]
|
||||||
if validate_parent_id && @project.save
|
if validate_parent_id && @project.save
|
||||||
@@ -207,7 +204,6 @@ class ProjectsController < ApplicationController
|
|||||||
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_module_names]
|
@project.enabled_module_names = params[:enabled_module_names]
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
@@ -231,29 +227,18 @@ class ProjectsController < ApplicationController
|
|||||||
# Delete @project
|
# Delete @project
|
||||||
def destroy
|
def destroy
|
||||||
@project_to_destroy = @project
|
@project_to_destroy = @project
|
||||||
if request.get?
|
if api_request? || params[:confirm]
|
||||||
# display confirmation view
|
@project_to_destroy.destroy
|
||||||
else
|
respond_to do |format|
|
||||||
if api_request? || params[:confirm]
|
format.html { redirect_to :controller => 'admin', :action => 'projects' }
|
||||||
@project_to_destroy.destroy
|
format.api { head :ok }
|
||||||
respond_to do |format|
|
|
||||||
format.html { redirect_to :controller => 'admin', :action => 'projects' }
|
|
||||||
format.api { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# hide project in layout
|
# hide project in layout
|
||||||
@project = nil
|
@project = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_optional_project
|
|
||||||
return true unless params[:id]
|
|
||||||
@project = Project.find(params[:id])
|
|
||||||
authorize
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
render_404
|
|
||||||
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
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ class QueriesController < ApplicationController
|
|||||||
build_query_from_params
|
build_query_from_params
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def create
|
def create
|
||||||
@query = Query.new(params[:query])
|
@query = Query.new(params[:query])
|
||||||
@query.user = User.current
|
@query.user = User.current
|
||||||
@@ -70,7 +69,6 @@ class QueriesController < ApplicationController
|
|||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def update
|
def update
|
||||||
@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]
|
||||||
@@ -86,7 +84,6 @@ class QueriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def destroy
|
def destroy
|
||||||
@query.destroy
|
@query.destroy
|
||||||
redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1
|
redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
# Copyright (C) 2006-2012 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,44 +24,46 @@ class InvalidRevisionParam < Exception; end
|
|||||||
|
|
||||||
class RepositoriesController < ApplicationController
|
class RepositoriesController < ApplicationController
|
||||||
menu_item :repository
|
menu_item :repository
|
||||||
menu_item :settings, :only => :edit
|
menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers]
|
||||||
default_search_scope :changesets
|
default_search_scope :changesets
|
||||||
|
|
||||||
before_filter :find_repository, :except => :edit
|
before_filter :find_project_by_project_id, :only => [:new, :create]
|
||||||
before_filter :find_project, :only => :edit
|
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
|
||||||
|
before_filter :find_project_repository, :except => [:new, :create, :edit, :update, :destroy, :committers]
|
||||||
|
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
accept_rss_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 new
|
||||||
|
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
|
||||||
|
@repository = Repository.factory(scm)
|
||||||
|
@repository.is_default = @project.repository.nil?
|
||||||
|
@repository.project = @project
|
||||||
|
render :layout => !request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@repository = Repository.factory(params[:repository_scm], params[:repository])
|
||||||
|
@repository.project = @project
|
||||||
|
if request.post? && @repository.save
|
||||||
|
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||||
|
else
|
||||||
|
render :action => 'new'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@repository = @project.repository
|
end
|
||||||
if !@repository && !params[:repository_scm].blank?
|
|
||||||
@repository = Repository.factory(params[:repository_scm])
|
def update
|
||||||
@repository.project = @project if @repository
|
@repository.attributes = params[:repository]
|
||||||
end
|
@repository.project = @project
|
||||||
if request.post? && @repository
|
if request.put? && @repository.save
|
||||||
p1 = params[:repository]
|
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||||
p = {}
|
else
|
||||||
p_extra = {}
|
render :action => 'edit'
|
||||||
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
|
|
||||||
end
|
|
||||||
render(:update) do |page|
|
|
||||||
page.replace_html "tab-content-repository",
|
|
||||||
:partial => 'projects/settings/repository'
|
|
||||||
if @repository && !@project.repository
|
|
||||||
@project.reload # needed to reload association
|
|
||||||
page.replace_html "main-menu", render_main_menu(@project)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -76,16 +78,13 @@ class RepositoriesController < ApplicationController
|
|||||||
# Build a hash with repository usernames as keys and corresponding user ids as values
|
# Build a hash with repository usernames as keys and corresponding user ids as values
|
||||||
@repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h}
|
@repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h}
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'committers', :id => @project
|
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@repository.destroy
|
@repository.destroy if request.delete?
|
||||||
redirect_to :controller => 'projects',
|
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||||
:action => 'settings',
|
|
||||||
:id => @project,
|
|
||||||
:tab => 'repository'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@@ -99,6 +98,7 @@ class RepositoriesController < ApplicationController
|
|||||||
(show_error_not_found; return) unless @entries
|
(show_error_not_found; return) unless @entries
|
||||||
@changesets = @repository.latest_changesets(@path, @rev)
|
@changesets = @repository.latest_changesets(@path, @rev)
|
||||||
@properties = @repository.properties(@path, @rev)
|
@properties = @repository.properties(@path, @rev)
|
||||||
|
@repositories = @project.repositories
|
||||||
render :action => 'show'
|
render :action => 'show'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -186,16 +186,56 @@ class RepositoriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def revision
|
def revision
|
||||||
raise ChangesetNotFound if @rev.blank?
|
|
||||||
@changeset = @repository.find_changeset_by_name(@rev)
|
|
||||||
raise ChangesetNotFound unless @changeset
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.js {render :layout => false}
|
format.js {render :layout => false}
|
||||||
end
|
end
|
||||||
rescue ChangesetNotFound
|
end
|
||||||
show_error_not_found
|
|
||||||
|
# Adds a related issue to a changeset
|
||||||
|
# POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues
|
||||||
|
def add_related_issue
|
||||||
|
@issue = @changeset.find_referenced_issue_by_id(params[:issue_id])
|
||||||
|
if @issue && (!@issue.visible? || @changeset.issues.include?(@issue))
|
||||||
|
@issue = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if @issue
|
||||||
|
@changeset.issues << @issue
|
||||||
|
respond_to do |format|
|
||||||
|
format.js {
|
||||||
|
render :update do |page|
|
||||||
|
page.replace_html "related-issues", :partial => "related_issues"
|
||||||
|
page.visual_effect :highlight, "related-issue-#{@issue.id}"
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.js {
|
||||||
|
render :update do |page|
|
||||||
|
page.alert(l(:label_issue) + ' ' + l('activerecord.errors.messages.invalid'))
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Removes a related issue from a changeset
|
||||||
|
# DELETE /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues/:issue_id
|
||||||
|
def remove_related_issue
|
||||||
|
@issue = Issue.visible.find_by_id(params[:issue_id])
|
||||||
|
if @issue
|
||||||
|
@changeset.issues.delete(@issue)
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js {
|
||||||
|
render :update do |page|
|
||||||
|
page.remove "related-issue-#{@issue.id}"
|
||||||
|
end if @issue
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff
|
def diff
|
||||||
@@ -250,11 +290,22 @@ class RepositoriesController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def find_repository
|
||||||
|
@repository = Repository.find(params[:id])
|
||||||
|
@project = @repository.project
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i
|
REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i
|
||||||
|
|
||||||
def find_repository
|
def find_project_repository
|
||||||
@project = Project.find(params[:id])
|
@project = Project.find(params[:id])
|
||||||
@repository = @project.repository
|
if params[:repository_id].present?
|
||||||
|
@repository = @project.repositories.find_by_identifier_param(params[:repository_id])
|
||||||
|
else
|
||||||
|
@repository = @project.repository
|
||||||
|
end
|
||||||
(render_404; return false) unless @repository
|
(render_404; return false) unless @repository
|
||||||
@path = params[:path].join('/') unless params[:path].nil?
|
@path = params[:path].join('/') unless params[:path].nil?
|
||||||
@path ||= ''
|
@path ||= ''
|
||||||
@@ -272,6 +323,13 @@ class RepositoriesController < ApplicationController
|
|||||||
show_error_not_found
|
show_error_not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_changeset
|
||||||
|
if @rev.present?
|
||||||
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||||||
|
end
|
||||||
|
show_error_not_found unless @changeset
|
||||||
|
end
|
||||||
|
|
||||||
def show_error_not_found
|
def show_error_not_found
|
||||||
render_error :message => l(:error_scm_not_found), :status => 404
|
render_error :message => l(:error_scm_not_found), :status => 404
|
||||||
end
|
end
|
||||||
@@ -366,18 +424,3 @@ class RepositoriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Date
|
|
||||||
def months_ago(date = Date.today)
|
|
||||||
(date.year - self.year)*12 + (date.month - self.month)
|
|
||||||
end
|
|
||||||
|
|
||||||
def weeks_ago(date = Date.today)
|
|
||||||
(date.year - self.year)*52 + (date.cweek - self.cweek)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class String
|
|
||||||
def with_leading_slash
|
|
||||||
starts_with?('/') ? self : "/#{self}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -18,19 +18,31 @@
|
|||||||
class RolesController < ApplicationController
|
class RolesController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
|
||||||
before_filter :require_admin
|
before_filter :require_admin, :except => :index
|
||||||
|
before_filter :require_admin_or_api_request, :only => :index
|
||||||
verify :method => :post, :only => [ :destroy ],
|
before_filter :find_role, :only => [:edit, :update, :destroy]
|
||||||
:redirect_to => { :action => :index }
|
accept_api_auth :index
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position'
|
respond_to do |format|
|
||||||
render :action => "index", :layout => false if request.xhr?
|
format.html {
|
||||||
|
@role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position'
|
||||||
|
render :action => "index", :layout => false if request.xhr?
|
||||||
|
}
|
||||||
|
format.api {
|
||||||
|
@roles = Role.givable.all
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
# Prefills the form with 'Non member' role permissions
|
# Prefills the form with 'Non member' role permissions
|
||||||
@role = Role.new(params[:role] || {:permissions => Role.non_member.permissions})
|
@role = Role.new(params[:role] || {:permissions => Role.non_member.permissions})
|
||||||
|
@roles = Role.sorted.all
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@role = Role.new(params[:role])
|
||||||
if request.post? && @role.save
|
if request.post? && @role.save
|
||||||
# workflow copy
|
# workflow copy
|
||||||
if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
|
if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
|
||||||
@@ -39,23 +51,24 @@ class RolesController < ApplicationController
|
|||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
else
|
else
|
||||||
@permissions = @role.setable_permissions
|
@roles = Role.sorted.all
|
||||||
@roles = Role.find :all, :order => 'builtin, position'
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@role = Role.find(params[:id])
|
end
|
||||||
if request.post? and @role.update_attributes(params[:role])
|
|
||||||
|
def update
|
||||||
|
if request.put? 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
|
else
|
||||||
@permissions = @role.setable_permissions
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@role = Role.find(params[:id])
|
|
||||||
@role.destroy
|
@role.destroy
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
rescue
|
rescue
|
||||||
@@ -63,8 +76,8 @@ class RolesController < ApplicationController
|
|||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def report
|
def permissions
|
||||||
@roles = Role.find(:all, :order => 'builtin, position')
|
@roles = Role.sorted.all
|
||||||
@permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
|
@permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
|
||||||
if request.post?
|
if request.post?
|
||||||
@roles.each do |role|
|
@roles.each do |role|
|
||||||
@@ -75,4 +88,12 @@ class RolesController < ApplicationController
|
|||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_role
|
||||||
|
@role = Role.find(params[:id])
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class SearchController < ApplicationController
|
|||||||
when 'my_projects'
|
when 'my_projects'
|
||||||
User.current.memberships.collect(&:project)
|
User.current.memberships.collect(&:project)
|
||||||
when 'subprojects'
|
when 'subprojects'
|
||||||
@project ? (@project.self_and_descendants.active) : nil
|
@project ? (@project.self_and_descendants.active.all) : nil
|
||||||
else
|
else
|
||||||
@project
|
@project
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class SettingsController < ApplicationController
|
class SettingsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
menu_item :plugins, :only => :plugin
|
||||||
|
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
|
||||||
@@ -51,12 +52,12 @@ class SettingsController < ApplicationController
|
|||||||
def plugin
|
def plugin
|
||||||
@plugin = Redmine::Plugin.find(params[:id])
|
@plugin = Redmine::Plugin.find(params[:id])
|
||||||
if request.post?
|
if request.post?
|
||||||
Setting["plugin_#{@plugin.id}"] = params[:settings]
|
Setting.send "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
|
else
|
||||||
@partial = @plugin.settings[:partial]
|
@partial = @plugin.settings[:partial]
|
||||||
@settings = Setting["plugin_#{@plugin.id}"]
|
@settings = Setting.send "plugin_#{@plugin.id}"
|
||||||
end
|
end
|
||||||
rescue Redmine::PluginNotFound
|
rescue Redmine::PluginNotFound
|
||||||
render_404
|
render_404
|
||||||
|
|||||||
@@ -19,9 +19,16 @@ class SysController < ActionController::Base
|
|||||||
before_filter :check_enabled
|
before_filter :check_enabled
|
||||||
|
|
||||||
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 => "#{Project.table_name}.identifier"
|
||||||
|
)
|
||||||
# extra_info attribute from repository breaks activeresource client
|
# 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]}})
|
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
|
||||||
@@ -30,9 +37,10 @@ class SysController < ActionController::Base
|
|||||||
render :nothing => true, :status => 409
|
render :nothing => true, :status => 409
|
||||||
else
|
else
|
||||||
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])
|
repository = Repository.factory(params[:vendor], params[:repository])
|
||||||
if project.repository && project.repository.save
|
repository.project = project
|
||||||
render :xml => project.repository.to_xml(:only => [:id, :url]), :status => 201
|
if repository.save
|
||||||
|
render :xml => {repository.class.name.underscore.gsub('/', '-') => {:id => repository.id, :url => repository.url}}, :status => 201
|
||||||
else
|
else
|
||||||
render :nothing => true, :status => 422
|
render :nothing => true, :status => 422
|
||||||
end
|
end
|
||||||
@@ -41,14 +49,22 @@ class SysController < ActionController::Base
|
|||||||
|
|
||||||
def fetch_changesets
|
def fetch_changesets
|
||||||
projects = []
|
projects = []
|
||||||
|
scope = Project.active.has_module(:repository)
|
||||||
if params[:id]
|
if params[:id]
|
||||||
projects << Project.active.has_module(:repository).find(params[:id])
|
project = nil
|
||||||
|
if params[:id].to_s =~ /^\d*$/
|
||||||
|
project = scope.find(params[:id])
|
||||||
|
else
|
||||||
|
project = scope.find_by_identifier(params[:id])
|
||||||
|
end
|
||||||
|
raise ActiveRecord::RecordNotFound unless project
|
||||||
|
projects << project
|
||||||
else
|
else
|
||||||
projects = Project.active.has_module(:repository).find(:all, :include => :repository)
|
projects = scope.all
|
||||||
end
|
end
|
||||||
projects.each do |project|
|
projects.each do |project|
|
||||||
if project.repository
|
project.repositories.each do |repository|
|
||||||
project.repository.fetch_changesets
|
repository.fetch_changesets
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
render :nothing => true, :status => 200
|
render :nothing => true, :status => 200
|
||||||
|
|||||||
@@ -1,209 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -17,11 +17,16 @@
|
|||||||
|
|
||||||
class TimelogController < ApplicationController
|
class TimelogController < ApplicationController
|
||||||
menu_item :issues
|
menu_item :issues
|
||||||
before_filter :find_project, :only => [:new, :create]
|
|
||||||
|
before_filter :find_project_for_new_time_entry, :only => [:create]
|
||||||
before_filter :find_time_entry, :only => [:show, :edit, :update]
|
before_filter :find_time_entry, :only => [:show, :edit, :update]
|
||||||
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
|
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||||
before_filter :authorize, :except => [:index]
|
before_filter :authorize, :except => [:new, :index, :report]
|
||||||
before_filter :find_optional_project, :only => [:index]
|
|
||||||
|
before_filter :find_optional_project, :only => [:index, :report]
|
||||||
|
before_filter :find_optional_project_for_new_time_entry, :only => [:new]
|
||||||
|
before_filter :authorize_global, :only => [:new, :index, :report]
|
||||||
|
|
||||||
accept_rss_auth :index
|
accept_rss_auth :index
|
||||||
accept_api_auth :index, :show, :create, :update, :destroy
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
@@ -34,67 +39,76 @@ class TimelogController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
sort_init 'spent_on', 'desc'
|
sort_init 'spent_on', 'desc'
|
||||||
sort_update 'spent_on' => 'spent_on',
|
sort_update 'spent_on' => ['spent_on', "#{TimeEntry.table_name}.created_on"],
|
||||||
'user' => 'user_id',
|
'user' => 'user_id',
|
||||||
'activity' => 'activity_id',
|
'activity' => 'activity_id',
|
||||||
'project' => "#{Project.table_name}.name",
|
'project' => "#{Project.table_name}.name",
|
||||||
'issue' => 'issue_id',
|
'issue' => 'issue_id',
|
||||||
'hours' => 'hours'
|
'hours' => 'hours'
|
||||||
|
|
||||||
cond = ARCondition.new
|
|
||||||
if @issue
|
|
||||||
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
|
|
||||||
|
|
||||||
retrieve_date_range
|
retrieve_date_range
|
||||||
cond << ['spent_on BETWEEN ? AND ?', @from, @to]
|
|
||||||
|
scope = TimeEntry.visible.spent_between(@from, @to)
|
||||||
|
if @issue
|
||||||
|
scope = scope.on_issue(@issue)
|
||||||
|
elsif @project
|
||||||
|
scope = scope.on_project(@project, Setting.display_subprojects_issues?)
|
||||||
|
end
|
||||||
|
|
||||||
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 = scope.count
|
||||||
@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 = scope.all(
|
||||||
:include => [:project, :activity, :user, {:issue => :tracker}],
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
: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 = scope.sum(:hours).to_f
|
||||||
|
|
||||||
render :layout => !request.xhr?
|
render :layout => !request.xhr?
|
||||||
}
|
}
|
||||||
format.api {
|
format.api {
|
||||||
@entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions)
|
@entry_count = scope.count
|
||||||
@offset, @limit = api_offset_and_limit
|
@offset, @limit = api_offset_and_limit
|
||||||
@entries = TimeEntry.visible.find(:all,
|
@entries = scope.all(
|
||||||
:include => [:project, :activity, :user, {:issue => :tracker}],
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
:conditions => cond.conditions,
|
:order => sort_clause,
|
||||||
:order => sort_clause,
|
:limit => @limit,
|
||||||
:limit => @limit,
|
:offset => @offset
|
||||||
:offset => @offset)
|
)
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
entries = TimeEntry.visible.find(:all,
|
entries = scope.all(
|
||||||
:include => [:project, :activity, :user, {:issue => :tracker}],
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
:conditions => cond.conditions,
|
:order => "#{TimeEntry.table_name}.created_on DESC",
|
||||||
:order => "#{TimeEntry.table_name}.created_on DESC",
|
:limit => Setting.feeds_limit.to_i
|
||||||
:limit => Setting.feeds_limit.to_i)
|
)
|
||||||
render_feed(entries, :title => l(:label_spent_time))
|
render_feed(entries, :title => l(:label_spent_time))
|
||||||
}
|
}
|
||||||
format.csv {
|
format.csv {
|
||||||
# Export all entries
|
# Export all entries
|
||||||
@entries = TimeEntry.visible.find(:all,
|
@entries = scope.all(
|
||||||
:include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}],
|
:include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}],
|
||||||
:conditions => cond.conditions,
|
:order => sort_clause
|
||||||
:order => sort_clause)
|
)
|
||||||
send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv')
|
send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv')
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def report
|
||||||
|
retrieve_date_range
|
||||||
|
@report = Redmine::Helpers::TimeReport.new(@project, @issue, params[:criteria], params[:columns], @from, @to)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :layout => !request.xhr? }
|
||||||
|
format.csv { send_data(report_to_csv(@report), :type => 'text/csv; header=present', :filename => 'timelog.csv') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
# TODO: Implement html response
|
# TODO: Implement html response
|
||||||
@@ -105,44 +119,49 @@ class TimelogController < ApplicationController
|
|||||||
|
|
||||||
def new
|
def new
|
||||||
@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.safe_attributes = params[:time_entry]
|
||||||
|
|
||||||
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
|
|
||||||
render :action => 'edit'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def create
|
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.safe_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 @time_entry.save
|
if @time_entry.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_back_or_default :action => 'index', :project_id => @time_entry.project
|
if params[:continue]
|
||||||
|
if params[:project_id]
|
||||||
|
redirect_to :action => 'new', :project_id => @time_entry.project, :issue_id => @time_entry.issue,
|
||||||
|
:time_entry => {:issue_id => @time_entry.issue_id, :activity_id => @time_entry.activity_id},
|
||||||
|
:back_url => params[:back_url]
|
||||||
|
else
|
||||||
|
redirect_to :action => 'new',
|
||||||
|
:time_entry => {:project_id => @time_entry.project_id, :issue_id => @time_entry.issue_id, :activity_id => @time_entry.activity_id},
|
||||||
|
:back_url => params[:back_url]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
redirect_back_or_default :action => 'index', :project_id => @time_entry.project
|
||||||
|
end
|
||||||
}
|
}
|
||||||
format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) }
|
format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'edit' }
|
format.html { render :action => 'new' }
|
||||||
format.api { render_validation_errors(@time_entry) }
|
format.api { render_validation_errors(@time_entry) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@time_entry.attributes = params[:time_entry]
|
@time_entry.safe_attributes = params[:time_entry]
|
||||||
|
|
||||||
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def update
|
def update
|
||||||
@time_entry.attributes = params[:time_entry]
|
@time_entry.safe_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 })
|
||||||
|
|
||||||
@@ -173,7 +192,7 @@ class TimelogController < ApplicationController
|
|||||||
unsaved_time_entry_ids = []
|
unsaved_time_entry_ids = []
|
||||||
@time_entries.each do |time_entry|
|
@time_entries.each do |time_entry|
|
||||||
time_entry.reload
|
time_entry.reload
|
||||||
time_entry.attributes = attributes
|
time_entry.safe_attributes = attributes
|
||||||
call_hook(:controller_time_entries_bulk_edit_before_save, { :params => params, :time_entry => time_entry })
|
call_hook(:controller_time_entries_bulk_edit_before_save, { :params => params, :time_entry => time_entry })
|
||||||
unless time_entry.save
|
unless time_entry.save
|
||||||
# Keep unsaved time_entry ids to display them in flash error
|
# Keep unsaved time_entry ids to display them in flash error
|
||||||
@@ -184,32 +203,31 @@ class TimelogController < ApplicationController
|
|||||||
redirect_back_or_default({:controller => 'timelog', :action => 'index', :project_id => @projects.first})
|
redirect_back_or_default({:controller => 'timelog', :action => 'index', :project_id => @projects.first})
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def destroy
|
def destroy
|
||||||
@time_entries.each do |t|
|
destroyed = TimeEntry.transaction do
|
||||||
begin
|
@time_entries.each do |t|
|
||||||
unless t.destroy && t.destroyed?
|
unless t.destroy && t.destroyed?
|
||||||
respond_to do |format|
|
raise ActiveRecord::Rollback
|
||||||
format.html {
|
|
||||||
flash[:error] = l(:notice_unable_delete_time_entry)
|
|
||||||
redirect_to :back
|
|
||||||
}
|
|
||||||
format.api { render_validation_errors(t) }
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
rescue ::ActionController::RedirectBackError
|
|
||||||
redirect_to :action => 'index', :project_id => @projects.first
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash[:notice] = l(:notice_successful_delete)
|
if destroyed
|
||||||
|
flash[:notice] = l(:notice_successful_delete)
|
||||||
|
else
|
||||||
|
flash[:error] = l(:notice_unable_delete_time_entry)
|
||||||
|
end
|
||||||
redirect_back_or_default(:action => 'index', :project_id => @projects.first)
|
redirect_back_or_default(:action => 'index', :project_id => @projects.first)
|
||||||
}
|
}
|
||||||
format.api { head :ok }
|
format.api {
|
||||||
|
if destroyed
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
render_validation_errors(@time_entries)
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -245,20 +263,25 @@ private
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_project
|
def find_optional_project_for_new_time_entry
|
||||||
|
if (project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])).present?
|
||||||
|
@project = Project.find(project_id)
|
||||||
|
end
|
||||||
if (issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id])).present?
|
if (issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id])).present?
|
||||||
@issue = Issue.find(issue_id)
|
@issue = Issue.find(issue_id)
|
||||||
@project = @issue.project
|
@project ||= @issue.project
|
||||||
elsif (project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])).present?
|
|
||||||
@project = Project.find(project_id)
|
|
||||||
else
|
|
||||||
render_404
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_project_for_new_time_entry
|
||||||
|
find_optional_project_for_new_time_entry
|
||||||
|
if @project.nil?
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def find_optional_project
|
def find_optional_project
|
||||||
if !params[:issue_id].blank?
|
if !params[:issue_id].blank?
|
||||||
@issue = Issue.find(params[:issue_id])
|
@issue = Issue.find(params[:issue_id])
|
||||||
@@ -266,7 +289,6 @@ private
|
|||||||
elsif !params[:project_id].blank?
|
elsif !params[:project_id].blank?
|
||||||
@project = Project.find(params[:project_id])
|
@project = Project.find(params[:project_id])
|
||||||
end
|
end
|
||||||
deny_access unless User.current.allowed_to?(:view_time_entries, @project, :global => true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Retrieves the date range based on predefined ranges or specific from/to param dates
|
# Retrieves the date range based on predefined ranges or specific from/to param dates
|
||||||
@@ -311,8 +333,6 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
@from, @to = @to, @from if @from && @to && @from > @to
|
@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
|
end
|
||||||
|
|
||||||
def parse_params_for_bulk_time_entry_attributes(params)
|
def parse_params_for_bulk_time_entry_attributes(params)
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ class TrackersController < ApplicationController
|
|||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy, :redirect_to => { :action => :index }
|
|
||||||
def destroy
|
def destroy
|
||||||
@tracker = Tracker.find(params[:id])
|
@tracker = Tracker.find(params[:id])
|
||||||
unless @tracker.issues.empty?
|
unless @tracker.issues.empty?
|
||||||
|
|||||||
@@ -38,23 +38,17 @@ class UsersController < ApplicationController
|
|||||||
@limit = per_page_option
|
@limit = per_page_option
|
||||||
end
|
end
|
||||||
|
|
||||||
scope = User
|
@status = params[:status] || 1
|
||||||
scope = scope.in_group(params[:group_id].to_i) if params[:group_id].present?
|
|
||||||
|
|
||||||
@status = params[:status] ? params[:status].to_i : 1
|
scope = User.logged.status(@status)
|
||||||
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
|
scope = scope.like(params[:name]) if params[:name].present?
|
||||||
|
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||||
|
|
||||||
unless params[:name].blank?
|
@user_count = scope.count
|
||||||
name = "%#{params[:name].strip.downcase}%"
|
|
||||||
c << ["LOWER(login) LIKE ? OR LOWER(firstname) LIKE ? OR LOWER(lastname) LIKE ? OR LOWER(mail) LIKE ?", name, name, name, name]
|
|
||||||
end
|
|
||||||
|
|
||||||
@user_count = scope.count(:conditions => c.conditions)
|
|
||||||
@user_pages = Paginator.new self, @user_count, @limit, params['page']
|
@user_pages = Paginator.new self, @user_count, @limit, params['page']
|
||||||
@offset ||= @user_pages.current.offset
|
@offset ||= @user_pages.current.offset
|
||||||
@users = scope.find :all,
|
@users = scope.find :all,
|
||||||
:order => sort_clause,
|
:order => sort_clause,
|
||||||
:conditions => c.conditions,
|
|
||||||
:limit => @limit,
|
:limit => @limit,
|
||||||
:offset => @offset
|
:offset => @offset
|
||||||
|
|
||||||
@@ -92,7 +86,6 @@ class UsersController < ApplicationController
|
|||||||
@auth_sources = AuthSource.find(:all)
|
@auth_sources = AuthSource.find(:all)
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def create
|
def create
|
||||||
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
||||||
@user.safe_attributes = params[:user]
|
@user.safe_attributes = params[:user]
|
||||||
@@ -100,11 +93,9 @@ class UsersController < ApplicationController
|
|||||||
@user.login = params[:user][:login]
|
@user.login = params[:user][:login]
|
||||||
@user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation] unless @user.auth_source_id
|
@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
|
if @user.save
|
||||||
|
@user.pref.attributes = params[:pref]
|
||||||
|
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
||||||
@user.pref.save
|
@user.pref.save
|
||||||
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
|
|
||||||
@@ -137,7 +128,6 @@ class UsersController < ApplicationController
|
|||||||
@membership ||= Member.new
|
@membership ||= Member.new
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def update
|
def update
|
||||||
@user.admin = params[:user][:admin] if params[:user][:admin]
|
@user.admin = params[:user][:admin] if params[:user][:admin]
|
||||||
@user.login = params[:user][:login] if params[:user][:login]
|
@user.login = params[:user][:login] if params[:user][:login]
|
||||||
@@ -183,18 +173,19 @@ class UsersController < ApplicationController
|
|||||||
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
|
def destroy
|
||||||
@user.destroy
|
@user.destroy
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to(users_url) }
|
format.html { redirect_to :back }
|
||||||
format.api { head :ok }
|
format.api { head :ok }
|
||||||
end
|
end
|
||||||
|
rescue ::ActionController::RedirectBackError
|
||||||
|
redirect_to(users_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_membership
|
def edit_membership
|
||||||
@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
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @membership.valid?
|
if @membership.valid?
|
||||||
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
|
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
|
||||||
@@ -216,7 +207,7 @@ class UsersController < ApplicationController
|
|||||||
|
|
||||||
def destroy_membership
|
def destroy_membership
|
||||||
@membership = Member.find(params[:membership_id])
|
@membership = Member.find(params[:membership_id])
|
||||||
if request.post? && @membership.deletable?
|
if @membership.deletable?
|
||||||
@membership.destroy
|
@membership.destroy
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class VersionsController < ApplicationController
|
|||||||
before_filter :find_project, :only => [:index, :new, :create, :close_completed]
|
before_filter :find_project, :only => [:index, :new, :create, :close_completed]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
|
|
||||||
accept_api_auth :index, :create, :update, :destroy
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
helper :projects
|
helper :projects
|
||||||
@@ -39,17 +39,19 @@ class VersionsController < ApplicationController
|
|||||||
@versions = @project.shared_versions || []
|
@versions = @project.shared_versions || []
|
||||||
@versions += @project.rolled_up_versions.visible if @with_subprojects
|
@versions += @project.rolled_up_versions.visible if @with_subprojects
|
||||||
@versions = @versions.uniq.sort
|
@versions = @versions.uniq.sort
|
||||||
@versions.reject! {|version| version.closed? || version.completed? } unless params[:completed]
|
unless params[:completed]
|
||||||
|
@completed_versions = @versions.select {|version| version.closed? || version.completed? }
|
||||||
|
@versions -= @completed_versions
|
||||||
|
end
|
||||||
|
|
||||||
@issues_by_version = {}
|
@issues_by_version = {}
|
||||||
unless @selected_tracker_ids.empty?
|
if @selected_tracker_ids.any? && @versions.any?
|
||||||
@versions.each do |version|
|
issues = Issue.visible.all(
|
||||||
issues = version.fixed_issues.visible.find(:all,
|
:include => [:project, :status, :tracker, :priority, :fixed_version],
|
||||||
:include => [:project, :status, :tracker, :priority],
|
:conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids, :fixed_version_id => @versions.map(&:id)},
|
||||||
:conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids},
|
:order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id"
|
||||||
:order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
|
)
|
||||||
@issues_by_version[version] = issues
|
@issues_by_version = issues.group_by(&:fixed_version)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
|
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
|
||||||
}
|
}
|
||||||
@@ -72,20 +74,26 @@ class VersionsController < ApplicationController
|
|||||||
|
|
||||||
def new
|
def new
|
||||||
@version = @project.versions.build
|
@version = @project.versions.build
|
||||||
if params[:version]
|
@version.safe_attributes = params[:version]
|
||||||
attributes = params[:version].dup
|
|
||||||
attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
|
respond_to do |format|
|
||||||
@version.attributes = attributes
|
format.html
|
||||||
|
format.js do
|
||||||
|
render :update do |page|
|
||||||
|
page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
|
||||||
|
page << "showModal('ajax-modal', '600px');"
|
||||||
|
page << "Form.Element.focus('version_name');"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
# TODO: refactor with code above in #new
|
|
||||||
@version = @project.versions.build
|
@version = @project.versions.build
|
||||||
if params[:version]
|
if params[:version]
|
||||||
attributes = params[:version].dup
|
attributes = params[:version].dup
|
||||||
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.safe_attributes = attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
if request.post?
|
if request.post?
|
||||||
@@ -96,9 +104,11 @@ class VersionsController < ApplicationController
|
|||||||
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
end
|
end
|
||||||
format.js do
|
format.js do
|
||||||
# IE doesn't support the replace_html rjs method for select box options
|
render(:update) {|page|
|
||||||
render(:update) {|page| page.replace "issue_fixed_version_id",
|
page << 'hideModal();'
|
||||||
content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]')
|
# IE doesn't support the replace_html rjs method for select box options
|
||||||
|
page.replace "issue_fixed_version_id",
|
||||||
|
content_tag('select', content_tag('option') + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]')
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
format.api do
|
format.api do
|
||||||
@@ -109,7 +119,10 @@ class VersionsController < ApplicationController
|
|||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'new' }
|
format.html { render :action => 'new' }
|
||||||
format.js do
|
format.js do
|
||||||
render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) }
|
render :update do |page|
|
||||||
|
page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
|
||||||
|
page << "Form.Element.focus('version_name');"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
format.api { render_validation_errors(@version) }
|
format.api { render_validation_errors(@version) }
|
||||||
end
|
end
|
||||||
@@ -124,7 +137,8 @@ class VersionsController < ApplicationController
|
|||||||
if request.put? && params[:version]
|
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)
|
@version.safe_attributes = attributes
|
||||||
|
if @version.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
@@ -148,7 +162,6 @@ class VersionsController < ApplicationController
|
|||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
def destroy
|
def destroy
|
||||||
if @version.fixed_issues.empty?
|
if @version.fixed_issues.empty?
|
||||||
@version.destroy
|
@version.destroy
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ class WatchersController < ApplicationController
|
|||||||
before_filter :require_login, :check_project_privacy, :only => [:watch, :unwatch]
|
before_filter :require_login, :check_project_privacy, :only => [:watch, :unwatch]
|
||||||
before_filter :authorize, :only => [:new, :destroy]
|
before_filter :authorize, :only => [:new, :destroy]
|
||||||
|
|
||||||
verify :method => :post,
|
|
||||||
:only => [ :watch, :unwatch ],
|
|
||||||
:render => { :nothing => true, :status => :method_not_allowed }
|
|
||||||
|
|
||||||
def watch
|
def watch
|
||||||
if @watched.respond_to?(:visible?) && !@watched.visible?(User.current)
|
if @watched.respond_to?(:visible?) && !@watched.visible?(User.current)
|
||||||
render_403
|
render_403
|
||||||
@@ -37,13 +33,29 @@ class WatchersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@watcher = Watcher.new(params[:watcher])
|
respond_to do |format|
|
||||||
@watcher.watchable = @watched
|
format.js do
|
||||||
@watcher.save if request.post?
|
render :update do |page|
|
||||||
|
page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched}
|
||||||
|
page << "showModal('ajax-modal', '400px');"
|
||||||
|
page << "$('ajax-modal').addClassName('new-watcher');"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
if params[:watcher].is_a?(Hash) && request.post?
|
||||||
|
user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]]
|
||||||
|
user_ids.each do |user_id|
|
||||||
|
Watcher.create(:watchable => @watched, :user_id => user_id)
|
||||||
|
end
|
||||||
|
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|
|
||||||
|
page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched}
|
||||||
page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
|
page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -52,6 +64,25 @@ class WatchersController < ApplicationController
|
|||||||
render :text => 'Watcher added.', :layout => true
|
render :text => 'Watcher added.', :layout => true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def append
|
||||||
|
if params[:watcher].is_a?(Hash)
|
||||||
|
user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]]
|
||||||
|
users = User.active.find_all_by_id(user_ids)
|
||||||
|
respond_to do |format|
|
||||||
|
format.js do
|
||||||
|
render :update do |page|
|
||||||
|
users.each do |user|
|
||||||
|
page.select("#issue_watcher_user_ids_#{user.id}").each do |item|
|
||||||
|
page.remove item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
page.insert_html :bottom, 'watchers_inputs', :text => watchers_checkboxes(nil, users, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@watched.set_watcher(User.find(params[:user_id]), false) if request.post?
|
@watched.set_watcher(User.find(params[:user_id]), false) if request.post?
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -64,12 +95,24 @@ class WatchersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def autocomplete_for_user
|
||||||
|
@users = User.active.like(params[:q]).find(:all, :limit => 100)
|
||||||
|
if @watched
|
||||||
|
@users -= @watched.watcher_users
|
||||||
|
end
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
klass = Object.const_get(params[:object_type].camelcase)
|
if params[:object_type] && params[:object_id]
|
||||||
return false unless klass.respond_to?('watched_by')
|
klass = Object.const_get(params[:object_type].camelcase)
|
||||||
@watched = klass.find(params[:object_id])
|
return false unless klass.respond_to?('watched_by')
|
||||||
@project = @watched.project
|
@watched = klass.find(params[:object_id])
|
||||||
|
@project = @watched.project
|
||||||
|
elsif params[:project_id]
|
||||||
|
@project = Project.visible.find(params[:project_id])
|
||||||
|
end
|
||||||
rescue
|
rescue
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class WikiController < ApplicationController
|
|||||||
@content = @page.content_for_version(params[:version])
|
@content = @page.content_for_version(params[:version])
|
||||||
if User.current.allowed_to?(:export_wiki_pages, @project)
|
if User.current.allowed_to?(:export_wiki_pages, @project)
|
||||||
if params[:format] == 'pdf'
|
if params[:format] == 'pdf'
|
||||||
send_data(wiki_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf")
|
send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf")
|
||||||
return
|
return
|
||||||
elsif params[:format] == 'html'
|
elsif params[:format] == 'html'
|
||||||
export = render_to_string :action => 'export', :layout => false
|
export = render_to_string :action => 'export', :layout => false
|
||||||
@@ -95,7 +95,12 @@ class WikiController < ApplicationController
|
|||||||
# edit an existing page or a new one
|
# edit an existing page or a new one
|
||||||
def edit
|
def edit
|
||||||
return render_403 unless editable?
|
return render_403 unless editable?
|
||||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
if @page.new_record?
|
||||||
|
@page.content = WikiContent.new(:page => @page)
|
||||||
|
if params[:parent].present?
|
||||||
|
@page.parent = @page.wiki.find_page(params[:parent].to_s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@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?
|
||||||
@@ -113,11 +118,11 @@ class WikiController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
|
|
||||||
# Creates a new page or updates an existing one
|
# Creates a new page or updates an existing one
|
||||||
def update
|
def update
|
||||||
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?
|
||||||
|
@page.safe_attributes = params[:wiki_page]
|
||||||
|
|
||||||
@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?
|
||||||
@@ -127,11 +132,12 @@ class WikiController < ApplicationController
|
|||||||
if !@page.new_record? && params[:content].present? && @content.text == params[:content][:text]
|
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)
|
||||||
# don't save if text wasn't changed
|
# don't save content if text wasn't changed
|
||||||
|
@page.save
|
||||||
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@content.comments = params[:content][:comments]
|
@content.comments = params[:content][:comments]
|
||||||
@text = params[:content][:text]
|
@text = params[:content][:text]
|
||||||
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
|
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
|
||||||
@@ -143,8 +149,8 @@ class WikiController < ApplicationController
|
|||||||
@content.text = @text
|
@content.text = @text
|
||||||
end
|
end
|
||||||
@content.author = User.current
|
@content.author = User.current
|
||||||
# if page is new @page.save will also save content, but not if page isn't a new record
|
@page.content = @content
|
||||||
if (@page.new_record? ? @page.save : @content.save)
|
if @page.save
|
||||||
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})
|
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
|
||||||
@@ -171,7 +177,6 @@ class WikiController < ApplicationController
|
|||||||
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 => 'show', :project_id => @project, :id => @page.title
|
redirect_to :action => 'show', :project_id => @project, :id => @page.title
|
||||||
@@ -201,7 +206,6 @@ class WikiController < ApplicationController
|
|||||||
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
|
||||||
@@ -231,14 +235,17 @@ class WikiController < ApplicationController
|
|||||||
redirect_to :action => 'index', :project_id => @project
|
redirect_to :action => 'index', :project_id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
# Export wiki to a single html file
|
# Export wiki to a single pdf or html file
|
||||||
def export
|
def export
|
||||||
if User.current.allowed_to?(:export_wiki_pages, @project)
|
@pages = @wiki.pages.all(:order => 'title', :include => [:content, :attachments], :limit => 75)
|
||||||
@pages = @wiki.pages.find :all, :order => 'title'
|
respond_to do |format|
|
||||||
export = render_to_string :action => 'export_multiple', :layout => false
|
format.html {
|
||||||
send_data(export, :type => 'text/html', :filename => "wiki.html")
|
export = render_to_string :action => 'export_multiple', :layout => false
|
||||||
else
|
send_data(export, :type => 'text/html', :filename => "wiki.html")
|
||||||
redirect_to :action => 'show', :project_id => @project, :id => nil
|
}
|
||||||
|
format.pdf {
|
||||||
|
send_data(wiki_pages_to_pdf(@pages, @project), :type => 'application/pdf', :filename => "#{@project.identifier}.pdf")
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class WikisController < ApplicationController
|
|||||||
# Create or update a project's wiki
|
# Create or update a project's wiki
|
||||||
def edit
|
def edit
|
||||||
@wiki = @project.wiki || Wiki.new(:project => @project)
|
@wiki = @project.wiki || Wiki.new(:project => @project)
|
||||||
@wiki.attributes = params[:wiki]
|
@wiki.safe_attributes = params[:wiki]
|
||||||
@wiki.save if request.post?
|
@wiki.save if request.post?
|
||||||
render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'}
|
render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,6 +20,6 @@
|
|||||||
module AdminHelper
|
module AdminHelper
|
||||||
def project_status_options_for_select(selected)
|
def project_status_options_for_select(selected)
|
||||||
options_for_select([[l(:label_all), ''],
|
options_for_select([[l(:label_all), ''],
|
||||||
[l(:status_active), 1]], selected)
|
[l(:status_active), '1']], selected.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ module ApplicationHelper
|
|||||||
s = link_to "#{h(issue.tracker)} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue},
|
s = link_to "#{h(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
|
||||||
s = "#{h issue.project} - " + s if options[:project]
|
s = h("#{issue.project} - ") + s if options[:project]
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -97,21 +97,29 @@ module ApplicationHelper
|
|||||||
def link_to_attachment(attachment, options={})
|
def link_to_attachment(attachment, options={})
|
||||||
text = options.delete(:text) || attachment.filename
|
text = options.delete(:text) || attachment.filename
|
||||||
action = options.delete(:download) ? 'download' : 'show'
|
action = options.delete(:download) ? 'download' : 'show'
|
||||||
|
opt_only_path = {}
|
||||||
|
opt_only_path[:only_path] = (options[:only_path] == false ? false : true)
|
||||||
|
options.delete(:only_path)
|
||||||
link_to(h(text),
|
link_to(h(text),
|
||||||
{:controller => 'attachments', :action => action,
|
{:controller => 'attachments', :action => action,
|
||||||
:id => attachment, :filename => attachment.filename },
|
:id => attachment, :filename => attachment.filename}.merge(opt_only_path),
|
||||||
options)
|
options)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a link to a SCM revision
|
# Generates a link to a SCM revision
|
||||||
# Options:
|
# Options:
|
||||||
# * :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, repository, options={})
|
||||||
|
if repository.is_a?(Project)
|
||||||
|
repository = repository.repository
|
||||||
|
end
|
||||||
text = options.delete(:text) || format_revision(revision)
|
text = options.delete(:text) || format_revision(revision)
|
||||||
rev = revision.respond_to?(:identifier) ? revision.identifier : revision
|
rev = revision.respond_to?(:identifier) ? revision.identifier : revision
|
||||||
|
link_to(
|
||||||
link_to(h(text), {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev},
|
h(text),
|
||||||
:title => l(:label_revision_id, format_revision(revision)))
|
{:controller => 'repositories', :action => 'revision', :id => repository.project, :repository_id => repository.identifier_param, :rev => rev},
|
||||||
|
:title => l(:label_revision_id, format_revision(revision))
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a link to a message
|
# Generates a link to a message
|
||||||
@@ -174,7 +182,8 @@ module ApplicationHelper
|
|||||||
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 />").html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_version_name(version)
|
def format_version_name(version)
|
||||||
@@ -211,7 +220,7 @@ module ApplicationHelper
|
|||||||
def render_flash_messages
|
def render_flash_messages
|
||||||
s = ''
|
s = ''
|
||||||
flash.each do |k,v|
|
flash.each do |k,v|
|
||||||
s << content_tag('div', v, :class => "flash #{k}")
|
s << (content_tag('div', v.html_safe, :class => "flash #{k}"))
|
||||||
end
|
end
|
||||||
s.html_safe
|
s.html_safe
|
||||||
end
|
end
|
||||||
@@ -244,7 +253,7 @@ module ApplicationHelper
|
|||||||
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|
|
||||||
name_prefix = (level > 0 ? (' ' * 2 * level + '» ') : '')
|
name_prefix = (level > 0 ? (' ' * 2 * level + '» ').html_safe : '')
|
||||||
tag_options = {:value => project.id}
|
tag_options = {:value => project.id}
|
||||||
if project == options[:selected] || (options[:selected].respond_to?(:include?) && options[:selected].include?(project))
|
if project == options[:selected] || (options[:selected].respond_to?(:include?) && options[:selected].include?(project))
|
||||||
tag_options[:selected] = 'selected'
|
tag_options[:selected] = 'selected'
|
||||||
@@ -299,6 +308,9 @@ module ApplicationHelper
|
|||||||
# Returns a string for users/groups option tags
|
# Returns a string for users/groups option tags
|
||||||
def principals_options_for_select(collection, selected=nil)
|
def principals_options_for_select(collection, selected=nil)
|
||||||
s = ''
|
s = ''
|
||||||
|
if collection.include?(User.current)
|
||||||
|
s << content_tag('option', "<< #{l(:label_me)} >>".html_safe, :value => User.current.id)
|
||||||
|
end
|
||||||
groups = ''
|
groups = ''
|
||||||
collection.sort.each do |element|
|
collection.sort.each do |element|
|
||||||
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected)
|
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected)
|
||||||
@@ -325,6 +337,10 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def anchor(text)
|
||||||
|
text.to_s.gsub(' ', '_')
|
||||||
|
end
|
||||||
|
|
||||||
def html_hours(text)
|
def html_hours(text)
|
||||||
text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>').html_safe
|
text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>').html_safe
|
||||||
end
|
end
|
||||||
@@ -342,6 +358,12 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def syntax_highlight_lines(name, content)
|
||||||
|
lines = []
|
||||||
|
syntax_highlight(name, content).each_line { |line| lines << line }
|
||||||
|
lines
|
||||||
|
end
|
||||||
|
|
||||||
def syntax_highlight(name, content)
|
def syntax_highlight(name, content)
|
||||||
Redmine::SyntaxHighlighting.highlight_by_filename(content, name)
|
Redmine::SyntaxHighlighting.highlight_by_filename(content, name)
|
||||||
end
|
end
|
||||||
@@ -457,8 +479,8 @@ module ApplicationHelper
|
|||||||
css << 'theme-' + theme.name
|
css << 'theme-' + theme.name
|
||||||
end
|
end
|
||||||
|
|
||||||
css << 'controller-' + params[:controller]
|
css << 'controller-' + controller_name
|
||||||
css << 'action-' + params[:action]
|
css << 'action-' + action_name
|
||||||
css.join(' ')
|
css.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -490,18 +512,22 @@ module ApplicationHelper
|
|||||||
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)
|
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)
|
||||||
|
|
||||||
@parsed_headings = []
|
@parsed_headings = []
|
||||||
|
@heading_anchors = {}
|
||||||
@current_section = 0 if options[:edit_section_links]
|
@current_section = 0 if options[:edit_section_links]
|
||||||
|
|
||||||
|
parse_sections(text, project, obj, attr, only_path, options)
|
||||||
text = parse_non_pre_blocks(text) do |text|
|
text = parse_non_pre_blocks(text) do |text|
|
||||||
[:parse_sections, :parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros, :parse_headings].each do |method_name|
|
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros].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
|
||||||
|
parse_headings(text, project, obj, attr, only_path, options)
|
||||||
|
|
||||||
if @parsed_headings.any?
|
if @parsed_headings.any?
|
||||||
replace_toc(text, @parsed_headings)
|
replace_toc(text, @parsed_headings)
|
||||||
end
|
end
|
||||||
|
|
||||||
text
|
text.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_non_pre_blocks(text)
|
def parse_non_pre_blocks(text)
|
||||||
@@ -530,7 +556,7 @@ module ApplicationHelper
|
|||||||
while tag = tags.pop
|
while tag = tags.pop
|
||||||
parsed << "</#{tag}>"
|
parsed << "</#{tag}>"
|
||||||
end
|
end
|
||||||
parsed.html_safe
|
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)
|
||||||
@@ -547,9 +573,9 @@ module ApplicationHelper
|
|||||||
if !desc.blank? && alttext.blank?
|
if !desc.blank? && alttext.blank?
|
||||||
alt = " title=\"#{desc}\" alt=\"#{desc}\""
|
alt = " title=\"#{desc}\" alt=\"#{desc}\""
|
||||||
end
|
end
|
||||||
"src=\"#{image_url}\"#{alt}".html_safe
|
"src=\"#{image_url}\"#{alt}"
|
||||||
else
|
else
|
||||||
m.html_safe
|
m
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -593,16 +619,18 @@ module ApplicationHelper
|
|||||||
when :anchor; "##{page.present? ? Wiki.titleize(page) : title}" + (anchor.present? ? "_#{anchor}" : '') # used for single-file wiki export
|
when :anchor; "##{page.present? ? Wiki.titleize(page) : title}" + (anchor.present? ? "_#{anchor}" : '') # used for single-file wiki export
|
||||||
else
|
else
|
||||||
wiki_page_id = page.present? ? Wiki.titleize(page) : nil
|
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)
|
parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil
|
||||||
|
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
|
||||||
|
:id => wiki_page_id, :anchor => anchor, :parent => parent)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
link_to(title.present? ? title.html_safe : h(page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
|
link_to(title.present? ? title.html_safe : h(page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
|
||||||
else
|
else
|
||||||
# project or wiki doesn't exist
|
# project or wiki doesn't exist
|
||||||
all.html_safe
|
all
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
all.html_safe
|
all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -640,26 +668,35 @@ module ApplicationHelper
|
|||||||
# identifier:version:1.0.0
|
# identifier:version:1.0.0
|
||||||
# identifier:source:some/file
|
# 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\(,\-\[\>]|^)(!)?(([a-z0-9\-]+):)?(attachment|document|version|forum|news|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
|
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
|
||||||
leading, esc, project_prefix, project_identifier, prefix, sep, identifier = $1, $2, $3, $4, $5, $7 || $9, $8 || $10
|
leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17
|
||||||
link = nil
|
link = nil
|
||||||
if project_identifier
|
if project_identifier
|
||||||
project = Project.visible.find_by_identifier(project_identifier)
|
project = Project.visible.find_by_identifier(project_identifier)
|
||||||
end
|
end
|
||||||
if esc.nil?
|
if esc.nil?
|
||||||
if prefix.nil? && sep == 'r'
|
if prefix.nil? && sep == 'r'
|
||||||
# project.changesets.visible raises an SQL error because of a double join on repositories
|
if project
|
||||||
if project && project.repository && (changeset = Changeset.visible.find_by_repository_id_and_revision(project.repository.id, identifier))
|
repository = nil
|
||||||
link = link_to(h("#{project_prefix}r#{identifier}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
|
if repo_identifier
|
||||||
:class => 'changeset',
|
repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
|
||||||
:title => truncate_single_line(changeset.comments, :length => 100))
|
else
|
||||||
|
repository = project.repository
|
||||||
|
end
|
||||||
|
# project.changesets.visible raises an SQL error because of a double join on repositories
|
||||||
|
if repository && (changeset = Changeset.visible.find_by_repository_id_and_revision(repository.id, identifier))
|
||||||
|
link = link_to(h("#{project_prefix}#{repo_prefix}r#{identifier}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.revision},
|
||||||
|
:class => 'changeset',
|
||||||
|
:title => truncate_single_line(changeset.comments, :length => 100))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elsif sep == '#'
|
elsif sep == '#'
|
||||||
oid = identifier.to_i
|
oid = identifier.to_i
|
||||||
case prefix
|
case prefix
|
||||||
when nil
|
when nil
|
||||||
if issue = Issue.visible.find_by_id(oid, :include => :status)
|
if issue = Issue.visible.find_by_id(oid, :include => :status)
|
||||||
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid},
|
anchor = comment_id ? "note-#{comment_id}" : nil
|
||||||
|
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
|
||||||
:class => issue.css_classes,
|
:class => issue.css_classes,
|
||||||
:title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
|
:title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
|
||||||
end
|
end
|
||||||
@@ -716,22 +753,34 @@ module ApplicationHelper
|
|||||||
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
||||||
:class => 'news'
|
:class => 'news'
|
||||||
end
|
end
|
||||||
when 'commit'
|
when 'commit', 'source', 'export'
|
||||||
if project && project.repository && (changeset = Changeset.visible.find(:first, :conditions => ["repository_id = ? AND scmid LIKE ?", project.repository.id, "#{name}%"]))
|
if project
|
||||||
link = link_to h("#{project_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.identifier},
|
repository = nil
|
||||||
:class => 'changeset',
|
if name =~ %r{^(([a-z0-9\-]+)\|)(.+)$}
|
||||||
:title => truncate_single_line(h(changeset.comments), :length => 100)
|
repo_prefix, repo_identifier, name = $1, $2, $3
|
||||||
end
|
repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
|
||||||
when 'source', 'export'
|
else
|
||||||
if project && project.repository && User.current.allowed_to?(:browse_repository, project)
|
repository = project.repository
|
||||||
name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$}
|
end
|
||||||
path, rev, anchor = $1, $3, $5
|
if prefix == 'commit'
|
||||||
link = link_to h("#{project_prefix}#{prefix}:#{name}"), {:controller => 'repositories', :action => 'entry', :id => project,
|
if repository && (changeset = Changeset.visible.find(:first, :conditions => ["repository_id = ? AND scmid LIKE ?", repository.id, "#{name}%"]))
|
||||||
:path => to_path_param(path),
|
link = link_to h("#{project_prefix}#{repo_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.identifier},
|
||||||
:rev => rev,
|
:class => 'changeset',
|
||||||
:anchor => anchor,
|
:title => truncate_single_line(h(changeset.comments), :length => 100)
|
||||||
:format => (prefix == 'export' ? 'raw' : nil)},
|
end
|
||||||
:class => (prefix == 'export' ? 'source download' : 'source')
|
else
|
||||||
|
if repository && User.current.allowed_to?(:browse_repository, project)
|
||||||
|
name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$}
|
||||||
|
path, rev, anchor = $1, $3, $5
|
||||||
|
link = link_to h("#{project_prefix}#{prefix}:#{repo_prefix}#{name}"), {:controller => 'repositories', :action => 'entry', :id => project, :repository_id => repository.identifier_param,
|
||||||
|
:path => to_path_param(path),
|
||||||
|
:rev => rev,
|
||||||
|
:anchor => anchor,
|
||||||
|
:format => (prefix == 'export' ? 'raw' : nil)},
|
||||||
|
:class => (prefix == 'export' ? 'source download' : 'source')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
repo_prefix = nil
|
||||||
end
|
end
|
||||||
when 'attachment'
|
when 'attachment'
|
||||||
attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
|
attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
|
||||||
@@ -746,7 +795,7 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
(leading + (link || "#{project_prefix}#{prefix}#{sep}#{identifier}")).html_safe
|
(leading + (link || "#{project_prefix}#{prefix}#{repo_prefix}#{sep}#{identifier}#{comment_suffix}"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -755,14 +804,15 @@ module ApplicationHelper
|
|||||||
def parse_sections(text, project, obj, attr, only_path, options)
|
def parse_sections(text, project, obj, attr, only_path, options)
|
||||||
return unless options[:edit_section_links]
|
return unless options[:edit_section_links]
|
||||||
text.gsub!(HEADING_RE) do
|
text.gsub!(HEADING_RE) do
|
||||||
|
heading = $1
|
||||||
@current_section += 1
|
@current_section += 1
|
||||||
if @current_section > 1
|
if @current_section > 1
|
||||||
content_tag('div',
|
content_tag('div',
|
||||||
link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
|
link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
|
||||||
:class => 'contextual',
|
:class => 'contextual',
|
||||||
:title => l(:button_edit_section)) + $1
|
:title => l(:button_edit_section)) + heading.html_safe
|
||||||
else
|
else
|
||||||
$1
|
heading
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -778,6 +828,11 @@ module ApplicationHelper
|
|||||||
anchor = sanitize_anchor_name(item)
|
anchor = sanitize_anchor_name(item)
|
||||||
# used for single-file wiki export
|
# used for single-file wiki export
|
||||||
anchor = "#{obj.page.title}_#{anchor}" if options[:wiki_links] == :anchor && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version))
|
anchor = "#{obj.page.title}_#{anchor}" if options[:wiki_links] == :anchor && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version))
|
||||||
|
@heading_anchors[anchor] ||= 0
|
||||||
|
idx = (@heading_anchors[anchor] += 1)
|
||||||
|
if idx > 1
|
||||||
|
anchor = "#{anchor}-#{idx}"
|
||||||
|
end
|
||||||
@parsed_headings << [level, anchor, item]
|
@parsed_headings << [level, anchor, item]
|
||||||
"<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">¶</a></h#{level}>"
|
"<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">¶</a></h#{level}>"
|
||||||
end
|
end
|
||||||
@@ -863,25 +918,54 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def labelled_tabular_form_for(*args, &proc)
|
def labelled_tabular_form_for(*args, &proc)
|
||||||
|
ActiveSupport::Deprecation.warn "ApplicationHelper#labelled_tabular_form_for is deprecated and will be removed in Redmine 1.5. Use #labelled_form_for instead."
|
||||||
args << {} unless args.last.is_a?(Hash)
|
args << {} unless args.last.is_a?(Hash)
|
||||||
options = args.last
|
options = args.last
|
||||||
options[:html] ||= {}
|
options[:html] ||= {}
|
||||||
options[:html][:class] = 'tabular' unless options[:html].has_key?(:class)
|
options[:html][:class] = 'tabular' unless options[:html].has_key?(:class)
|
||||||
options.merge!({:builder => TabularFormBuilder})
|
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
|
||||||
form_for(*args, &proc)
|
form_for(*args, &proc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def labelled_form_for(*args, &proc)
|
def labelled_form_for(*args, &proc)
|
||||||
args << {} unless args.last.is_a?(Hash)
|
args << {} unless args.last.is_a?(Hash)
|
||||||
options = args.last
|
options = args.last
|
||||||
options.merge!({:builder => TabularFormBuilder})
|
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
|
||||||
form_for(*args, &proc)
|
form_for(*args, &proc)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def labelled_fields_for(*args, &proc)
|
||||||
|
args << {} unless args.last.is_a?(Hash)
|
||||||
|
options = args.last
|
||||||
|
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
|
||||||
|
fields_for(*args, &proc)
|
||||||
|
end
|
||||||
|
|
||||||
|
def labelled_remote_form_for(*args, &proc)
|
||||||
|
args << {} unless args.last.is_a?(Hash)
|
||||||
|
options = args.last
|
||||||
|
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
|
||||||
|
remote_form_for(*args, &proc)
|
||||||
|
end
|
||||||
|
|
||||||
|
def error_messages_for(*objects)
|
||||||
|
html = ""
|
||||||
|
objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact
|
||||||
|
errors = objects.map {|o| o.errors.full_messages}.flatten
|
||||||
|
if errors.any?
|
||||||
|
html << "<div id='errorExplanation'><ul>\n"
|
||||||
|
errors.each do |error|
|
||||||
|
html << "<li>#{h error}</li>\n"
|
||||||
|
end
|
||||||
|
html << "</ul></div>\n"
|
||||||
|
end
|
||||||
|
html.html_safe
|
||||||
|
end
|
||||||
|
|
||||||
def back_url_hidden_field_tag
|
def back_url_hidden_field_tag
|
||||||
back_url = params[:back_url] || request.env['HTTP_REFERER']
|
back_url = params[:back_url] || request.env['HTTP_REFERER']
|
||||||
back_url = CGI.unescape(back_url.to_s)
|
back_url = CGI.unescape(back_url.to_s)
|
||||||
hidden_field_tag('back_url', CGI.escape(back_url)) unless back_url.blank?
|
hidden_field_tag('back_url', CGI.escape(back_url), :id => nil) unless back_url.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_all_links(form_name)
|
def check_all_links(form_name)
|
||||||
@@ -928,22 +1012,6 @@ module ApplicationHelper
|
|||||||
javascript_tag "new ContextMenu('#{ url_for(url) }')"
|
javascript_tag "new ContextMenu('#{ url_for(url) }')"
|
||||||
end
|
end
|
||||||
|
|
||||||
def context_menu_link(name, url, options={})
|
|
||||||
options[:class] ||= ''
|
|
||||||
if options.delete(:selected)
|
|
||||||
options[:class] << ' icon-checked disabled'
|
|
||||||
options[:disabled] = true
|
|
||||||
end
|
|
||||||
if options.delete(:disabled)
|
|
||||||
options.delete(:method)
|
|
||||||
options.delete(:confirm)
|
|
||||||
options.delete(:onclick)
|
|
||||||
options[:class] << ' disabled'
|
|
||||||
url = '#'
|
|
||||||
end
|
|
||||||
link_to h(name), url, options
|
|
||||||
end
|
|
||||||
|
|
||||||
def calendar_for(field_id)
|
def calendar_for(field_id)
|
||||||
include_calendar_headers_tags
|
include_calendar_headers_tags
|
||||||
image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
|
image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
|
||||||
|
|||||||
@@ -18,4 +18,7 @@
|
|||||||
# 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 AuthSourcesHelper
|
module AuthSourcesHelper
|
||||||
|
def auth_source_partial_name(auth_source)
|
||||||
|
"form_#{auth_source.class.name.underscore}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
#
|
||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2012 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 ContextMenusHelper
|
||||||
|
def context_menu_link(name, url, options={})
|
||||||
|
options[:class] ||= ''
|
||||||
|
if options.delete(:selected)
|
||||||
|
options[:class] << ' icon-checked disabled'
|
||||||
|
options[:disabled] = true
|
||||||
|
end
|
||||||
|
if options.delete(:disabled)
|
||||||
|
options.delete(:method)
|
||||||
|
options.delete(:confirm)
|
||||||
|
options.delete(:onclick)
|
||||||
|
options[:class] << ' disabled'
|
||||||
|
url = '#'
|
||||||
|
end
|
||||||
|
link_to h(name), url, options
|
||||||
|
end
|
||||||
|
|
||||||
|
def bulk_update_custom_field_context_menu_link(field, text, value)
|
||||||
|
context_menu_link h(text),
|
||||||
|
{:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'custom_field_values' => {field.id => value}}, :back_url => @back},
|
||||||
|
:method => :post,
|
||||||
|
:selected => (@issue && @issue.custom_field_value(field) == value)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
# Copyright (C) 2006-2012 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
|
||||||
@@ -36,6 +36,7 @@ module CustomFieldsHelper
|
|||||||
def custom_field_tag(name, custom_value)
|
def custom_field_tag(name, custom_value)
|
||||||
custom_field = custom_value.custom_field
|
custom_field = custom_value.custom_field
|
||||||
field_name = "#{name}[custom_field_values][#{custom_field.id}]"
|
field_name = "#{name}[custom_field_values][#{custom_field.id}]"
|
||||||
|
field_name << "[]" if custom_field.multiple?
|
||||||
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)
|
||||||
@@ -48,10 +49,22 @@ module CustomFieldsHelper
|
|||||||
when "bool"
|
when "bool"
|
||||||
hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, :id => field_id)
|
hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, :id => field_id)
|
||||||
when "list"
|
when "list"
|
||||||
blank_option = custom_field.is_required? ?
|
blank_option = ''
|
||||||
(custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') :
|
unless custom_field.multiple?
|
||||||
'<option></option>'
|
if custom_field.is_required?
|
||||||
select_tag(field_name, blank_option + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value), :id => field_id)
|
unless custom_field.default_value.present?
|
||||||
|
blank_option = "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
blank_option = '<option></option>'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
s = select_tag(field_name, blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value),
|
||||||
|
:id => field_id, :multiple => custom_field.multiple?)
|
||||||
|
if custom_field.multiple?
|
||||||
|
s << hidden_field_tag(field_name, '')
|
||||||
|
end
|
||||||
|
s
|
||||||
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
|
||||||
@@ -61,8 +74,7 @@ module CustomFieldsHelper
|
|||||||
def custom_field_label_tag(name, custom_value)
|
def custom_field_label_tag(name, custom_value)
|
||||||
content_tag "label", h(custom_value.custom_field.name) +
|
content_tag "label", h(custom_value.custom_field.name) +
|
||||||
(custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>".html_safe : ""),
|
(custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>".html_safe : ""),
|
||||||
:for => "#{name}_custom_field_values_#{custom_value.custom_field.id}",
|
:for => "#{name}_custom_field_values_#{custom_value.custom_field.id}"
|
||||||
:class => (custom_value.errors.empty? ? nil : "error" )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return custom field tag with its label tag
|
# Return custom field tag with its label tag
|
||||||
@@ -72,6 +84,7 @@ module CustomFieldsHelper
|
|||||||
|
|
||||||
def custom_field_tag_for_bulk_edit(name, custom_field, projects=nil)
|
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_name << "[]" if custom_field.multiple?
|
||||||
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.try(:edit_as)
|
case field_format.try(:edit_as)
|
||||||
@@ -85,7 +98,12 @@ 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_options(projects)), :id => field_id)
|
options = []
|
||||||
|
options << [l(:label_no_change_option), ''] unless custom_field.multiple?
|
||||||
|
options << [l(:label_none), '__none__'] unless custom_field.is_required?
|
||||||
|
options += custom_field.possible_values_options(projects)
|
||||||
|
select_tag(field_name, options_for_select(options),
|
||||||
|
:id => field_id, :multiple => custom_field.multiple?)
|
||||||
else
|
else
|
||||||
text_field_tag(field_name, '', :id => field_id)
|
text_field_tag(field_name, '', :id => field_id)
|
||||||
end
|
end
|
||||||
@@ -99,7 +117,11 @@ module CustomFieldsHelper
|
|||||||
|
|
||||||
# Return a string used to display a custom value
|
# Return a string used to display a custom value
|
||||||
def format_value(value, field_format)
|
def format_value(value, field_format)
|
||||||
Redmine::CustomFieldFormat.format_value(value, field_format) # Proxy
|
if value.is_a?(Array)
|
||||||
|
value.collect {|v| format_value(v, field_format)}.compact.sort.join(', ')
|
||||||
|
else
|
||||||
|
Redmine::CustomFieldFormat.format_value(value, field_format)
|
||||||
|
end
|
||||||
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
|
||||||
@@ -111,8 +133,18 @@ module CustomFieldsHelper
|
|||||||
def render_api_custom_values(custom_values, api)
|
def render_api_custom_values(custom_values, api)
|
||||||
api.array :custom_fields do
|
api.array :custom_fields do
|
||||||
custom_values.each do |custom_value|
|
custom_values.each do |custom_value|
|
||||||
api.custom_field :id => custom_value.custom_field_id, :name => custom_value.custom_field.name do
|
attrs = {:id => custom_value.custom_field_id, :name => custom_value.custom_field.name}
|
||||||
api.value custom_value.value
|
attrs.merge!(:multiple => true) if custom_value.custom_field.multiple?
|
||||||
|
api.custom_field attrs do
|
||||||
|
if custom_value.value.is_a?(Array)
|
||||||
|
api.array :value do
|
||||||
|
custom_value.value.each do |value|
|
||||||
|
api.value value unless value.blank?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
api.value custom_value.value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end unless custom_values.empty?
|
end unless custom_values.empty?
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
# encoding: utf-8
|
|
||||||
#
|
|
||||||
module IssueMovesHelper
|
|
||||||
end
|
|
||||||
@@ -48,13 +48,13 @@ module IssuesHelper
|
|||||||
@cached_label_priority ||= l(:field_priority)
|
@cached_label_priority ||= l(:field_priority)
|
||||||
@cached_label_project ||= l(:field_project)
|
@cached_label_project ||= l(:field_project)
|
||||||
|
|
||||||
(link_to_issue(issue) + "<br /><br />" +
|
link_to_issue(issue) + "<br /><br />".html_safe +
|
||||||
"<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />" +
|
"<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />" +
|
"<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
|
"<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
|
"<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />" +
|
"<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
|
||||||
"<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}").html_safe
|
"<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def issue_heading(issue)
|
def issue_heading(issue)
|
||||||
@@ -88,7 +88,7 @@ module IssuesHelper
|
|||||||
content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
|
content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
|
||||||
:class => "issue issue-#{child.id} hascontextmenu #{level > 0 ? "idnt idnt-#{level}" : nil}")
|
:class => "issue issue-#{child.id} hascontextmenu #{level > 0 ? "idnt idnt-#{level}" : nil}")
|
||||||
end
|
end
|
||||||
s << '</form></table>'
|
s << '</table></form>'
|
||||||
s.html_safe
|
s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -131,14 +131,11 @@ module IssuesHelper
|
|||||||
|
|
||||||
def sidebar_queries
|
def sidebar_queries
|
||||||
unless @sidebar_queries
|
unless @sidebar_queries
|
||||||
# User can see public queries and his own queries
|
@sidebar_queries = Query.visible.all(
|
||||||
visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
|
:order => "#{Query.table_name}.name ASC",
|
||||||
# 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])
|
:conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
|
||||||
@sidebar_queries = Query.find(:all,
|
)
|
||||||
:select => 'id, name, is_public',
|
|
||||||
:order => "name ASC",
|
|
||||||
:conditions => visible.conditions)
|
|
||||||
end
|
end
|
||||||
@sidebar_queries
|
@sidebar_queries
|
||||||
end
|
end
|
||||||
@@ -149,12 +146,14 @@ module IssuesHelper
|
|||||||
|
|
||||||
content_tag('h3', h(title)) +
|
content_tag('h3', h(title)) +
|
||||||
queries.collect {|query|
|
queries.collect {|query|
|
||||||
link_to(h(query.name), url_params.merge(:query_id => query))
|
css = 'query'
|
||||||
}.join('<br />')
|
css << ' selected' if query == @query
|
||||||
|
link_to(h(query.name), url_params.merge(:query_id => query), :class => css)
|
||||||
|
}.join('<br />').html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_sidebar_queries
|
def render_sidebar_queries
|
||||||
out = ''
|
out = ''.html_safe
|
||||||
queries = sidebar_queries.select {|q| !q.is_public?}
|
queries = sidebar_queries.select {|q| !q.is_public?}
|
||||||
out << query_links(l(:label_my_queries), queries) if queries.any?
|
out << query_links(l(:label_my_queries), queries) if queries.any?
|
||||||
queries = sidebar_queries.select {|q| q.is_public?}
|
queries = sidebar_queries.select {|q| q.is_public?}
|
||||||
@@ -162,36 +161,76 @@ module IssuesHelper
|
|||||||
out
|
out
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_detail(detail, no_html=false)
|
# Returns the textual representation of a journal details
|
||||||
|
# as an array of strings
|
||||||
|
def details_to_strings(details, no_html=false, options={})
|
||||||
|
options[:only_path] = (options[:only_path] == false ? false : true)
|
||||||
|
strings = []
|
||||||
|
values_by_field = {}
|
||||||
|
details.each do |detail|
|
||||||
|
if detail.property == 'cf'
|
||||||
|
field_id = detail.prop_key
|
||||||
|
field = CustomField.find_by_id(field_id)
|
||||||
|
if field && field.multiple?
|
||||||
|
values_by_field[field_id] ||= {:added => [], :deleted => []}
|
||||||
|
if detail.old_value
|
||||||
|
values_by_field[field_id][:deleted] << detail.old_value
|
||||||
|
end
|
||||||
|
if detail.value
|
||||||
|
values_by_field[field_id][:added] << detail.value
|
||||||
|
end
|
||||||
|
next
|
||||||
|
end
|
||||||
|
end
|
||||||
|
strings << show_detail(detail, no_html, options)
|
||||||
|
end
|
||||||
|
values_by_field.each do |field_id, changes|
|
||||||
|
detail = JournalDetail.new(:property => 'cf', :prop_key => field_id)
|
||||||
|
if changes[:added].any?
|
||||||
|
detail.value = changes[:added]
|
||||||
|
strings << show_detail(detail, no_html, options)
|
||||||
|
elsif changes[:deleted].any?
|
||||||
|
detail.old_value = changes[:deleted]
|
||||||
|
strings << show_detail(detail, no_html, options)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
strings
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns the textual representation of a single journal detail
|
||||||
|
def show_detail(detail, no_html=false, options={})
|
||||||
|
multiple = false
|
||||||
case detail.property
|
case detail.property
|
||||||
when 'attr'
|
when 'attr'
|
||||||
field = detail.prop_key.to_s.gsub(/\_id$/, "")
|
field = detail.prop_key.to_s.gsub(/\_id$/, "")
|
||||||
label = l(("field_" + field).to_sym)
|
label = l(("field_" + field).to_sym)
|
||||||
case
|
case detail.prop_key
|
||||||
when ['due_date', 'start_date'].include?(detail.prop_key)
|
when 'due_date', 'start_date'
|
||||||
value = format_date(detail.value.to_date) if detail.value
|
value = format_date(detail.value.to_date) if detail.value
|
||||||
old_value = format_date(detail.old_value.to_date) if detail.old_value
|
old_value = format_date(detail.old_value.to_date) if detail.old_value
|
||||||
|
|
||||||
when ['project_id', 'status_id', 'tracker_id', 'assigned_to_id', 'priority_id', 'category_id', 'fixed_version_id'].include?(detail.prop_key)
|
when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
|
||||||
|
'priority_id', 'category_id', 'fixed_version_id'
|
||||||
value = find_name_by_reflection(field, detail.value)
|
value = find_name_by_reflection(field, detail.value)
|
||||||
old_value = find_name_by_reflection(field, detail.old_value)
|
old_value = find_name_by_reflection(field, detail.old_value)
|
||||||
|
|
||||||
when detail.prop_key == 'estimated_hours'
|
when 'estimated_hours'
|
||||||
value = "%0.02f" % detail.value.to_f unless detail.value.blank?
|
value = "%0.02f" % detail.value.to_f unless detail.value.blank?
|
||||||
old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
|
old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
|
||||||
|
|
||||||
when detail.prop_key == 'parent_id'
|
when 'parent_id'
|
||||||
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'
|
when 'is_private'
|
||||||
value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
|
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?
|
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)
|
||||||
if custom_field
|
if custom_field
|
||||||
|
multiple = custom_field.multiple?
|
||||||
label = custom_field.name
|
label = custom_field.name
|
||||||
value = format_value(detail.value, custom_field.field_format) if detail.value
|
value = format_value(detail.value, custom_field.field_format) if detail.value
|
||||||
old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
|
old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
|
||||||
@@ -199,7 +238,8 @@ module IssuesHelper
|
|||||||
when 'attachment'
|
when 'attachment'
|
||||||
label = l(:label_attachment)
|
label = l(:label_attachment)
|
||||||
end
|
end
|
||||||
call_hook(:helper_issues_show_detail_after_setting, {:detail => detail, :label => label, :value => value, :old_value => old_value })
|
call_hook(:helper_issues_show_detail_after_setting,
|
||||||
|
{:detail => detail, :label => label, :value => value, :old_value => old_value })
|
||||||
|
|
||||||
label ||= detail.prop_key
|
label ||= detail.prop_key
|
||||||
value ||= detail.value
|
value ||= detail.value
|
||||||
@@ -209,9 +249,16 @@ module IssuesHelper
|
|||||||
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
|
||||||
old_value = content_tag("strike", old_value) if detail.old_value and detail.value.blank?
|
old_value = content_tag("strike", old_value) if detail.old_value and detail.value.blank?
|
||||||
if detail.property == 'attachment' && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
|
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
|
||||||
# Link to the attachment if it has not been removed
|
# Link to the attachment if it has not been removed
|
||||||
value = link_to_attachment(a)
|
value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
|
||||||
|
if options[:only_path] != false && atta.is_text?
|
||||||
|
value += link_to(
|
||||||
|
image_tag('magnifier.png'),
|
||||||
|
:controller => 'attachments', :action => 'show',
|
||||||
|
:id => atta, :filename => atta.filename
|
||||||
|
)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
value = content_tag("i", h(value)) if value
|
value = content_tag("i", h(value)) if value
|
||||||
end
|
end
|
||||||
@@ -221,24 +268,27 @@ module IssuesHelper
|
|||||||
s = l(:text_journal_changed_no_detail, :label => label)
|
s = l(:text_journal_changed_no_detail, :label => label)
|
||||||
unless no_html
|
unless no_html
|
||||||
diff_link = link_to 'diff',
|
diff_link = link_to 'diff',
|
||||||
{:controller => 'journals', :action => 'diff', :id => detail.journal_id, :detail_id => detail.id},
|
{:controller => 'journals', :action => 'diff', :id => detail.journal_id,
|
||||||
|
:detail_id => detail.id, :only_path => options[:only_path]},
|
||||||
:title => l(:label_view_diff)
|
:title => l(:label_view_diff)
|
||||||
s << " (#{ diff_link })"
|
s << " (#{ diff_link })"
|
||||||
end
|
end
|
||||||
s
|
s.html_safe
|
||||||
elsif !detail.value.blank?
|
elsif detail.value.present?
|
||||||
case detail.property
|
case detail.property
|
||||||
when 'attr', 'cf'
|
when 'attr', 'cf'
|
||||||
if !detail.old_value.blank?
|
if detail.old_value.present?
|
||||||
l(:text_journal_changed, :label => label, :old => old_value, :new => value)
|
l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
|
||||||
|
elsif multiple
|
||||||
|
l(:text_journal_added, :label => label, :value => value).html_safe
|
||||||
else
|
else
|
||||||
l(:text_journal_set_to, :label => label, :value => value)
|
l(:text_journal_set_to, :label => label, :value => value).html_safe
|
||||||
end
|
end
|
||||||
when 'attachment'
|
when 'attachment'
|
||||||
l(:text_journal_added, :label => label, :value => value)
|
l(:text_journal_added, :label => label, :value => value).html_safe
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
l(:text_journal_deleted, :label => label, :old => old_value)
|
l(:text_journal_deleted, :label => label, :old => old_value).html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -279,16 +329,16 @@ module IssuesHelper
|
|||||||
issues.each do |issue|
|
issues.each do |issue|
|
||||||
col_values = columns.collect do |column|
|
col_values = columns.collect do |column|
|
||||||
s = if column.is_a?(QueryCustomFieldColumn)
|
s = if column.is_a?(QueryCustomFieldColumn)
|
||||||
cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
|
cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
|
||||||
show_value(cv)
|
show_value(cv)
|
||||||
else
|
else
|
||||||
value = issue.send(column.name)
|
value = column.value(issue)
|
||||||
if value.is_a?(Date)
|
if value.is_a?(Date)
|
||||||
format_date(value)
|
format_date(value)
|
||||||
elsif value.is_a?(Time)
|
elsif value.is_a?(Time)
|
||||||
format_time(value)
|
format_time(value)
|
||||||
elsif value.is_a?(Float)
|
elsif value.is_a?(Float)
|
||||||
value.to_s.gsub('.', decimal_separator)
|
("%.2f" % value).gsub('.', decimal_separator)
|
||||||
else
|
else
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ module JournalsHelper
|
|||||||
{ :controller => 'journals', :action => 'edit', :id => journal },
|
{ :controller => 'journals', :action => 'edit', :id => journal },
|
||||||
:title => l(:button_edit)) if editable
|
:title => l(:button_edit)) if editable
|
||||||
end
|
end
|
||||||
content << content_tag('div', links.join(' '), :class => 'contextual') unless links.empty?
|
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
|
||||||
content << textilizable(journal, :notes)
|
content << textilizable(journal, :notes)
|
||||||
css_classes = "wiki"
|
css_classes = "wiki"
|
||||||
css_classes << " editable" if editable
|
css_classes << " editable" if editable
|
||||||
content_tag('div', content, :id => "journal-#{journal.id}-notes", :class => css_classes)
|
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_in_place_notes_editor(text, field_id, url, options={})
|
def link_to_in_place_notes_editor(text, field_id, url, options={})
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ module ProjectsHelper
|
|||||||
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
|
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
|
||||||
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
|
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
|
||||||
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
|
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
|
||||||
{:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository},
|
{:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
|
||||||
{: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}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -31,7 +31,14 @@ module QueriesHelper
|
|||||||
|
|
||||||
def column_content(column, issue)
|
def column_content(column, issue)
|
||||||
value = column.value(issue)
|
value = column.value(issue)
|
||||||
|
if value.is_a?(Array)
|
||||||
|
value.collect {|v| column_value(column, issue, v)}.compact.sort.join(', ').html_safe
|
||||||
|
else
|
||||||
|
column_value(column, issue, value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def column_value(column, issue, value)
|
||||||
case value.class.name
|
case value.class.name
|
||||||
when 'String'
|
when 'String'
|
||||||
if column.name == :subject
|
if column.name == :subject
|
||||||
@@ -46,6 +53,8 @@ module QueriesHelper
|
|||||||
when 'Fixnum', 'Float'
|
when 'Fixnum', 'Float'
|
||||||
if column.name == :done_ratio
|
if column.name == :done_ratio
|
||||||
progress_bar(value, :width => '80px')
|
progress_bar(value, :width => '80px')
|
||||||
|
elsif column.name == :spent_hours
|
||||||
|
sprintf "%.2f", value
|
||||||
else
|
else
|
||||||
h(value.to_s)
|
h(value.to_s)
|
||||||
end
|
end
|
||||||
@@ -90,6 +99,23 @@ module QueriesHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def retrieve_query_from_session
|
||||||
|
if session[:query]
|
||||||
|
if session[:query][:id]
|
||||||
|
@query = Query.find_by_id(session[:query][:id])
|
||||||
|
return unless @query
|
||||||
|
else
|
||||||
|
@query = Query.new(:name => "_", :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
|
||||||
|
end
|
||||||
|
if session[:query].has_key?(:project_id)
|
||||||
|
@query.project_id = session[:query][:project_id]
|
||||||
|
else
|
||||||
|
@query.project = @project
|
||||||
|
end
|
||||||
|
@query
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def build_query_from_params
|
def build_query_from_params
|
||||||
if params[:fields] || params[:f]
|
if params[:fields] || params[:f]
|
||||||
@query.filters = {}
|
@query.filters = {}
|
||||||
|
|||||||
@@ -92,22 +92,26 @@ module RepositoriesHelper
|
|||||||
text = link_to(h(text), :controller => 'repositories',
|
text = link_to(h(text), :controller => 'repositories',
|
||||||
:action => 'show',
|
:action => 'show',
|
||||||
:id => @project,
|
:id => @project,
|
||||||
|
:repository_id => @repository.identifier_param,
|
||||||
:path => path_param,
|
:path => path_param,
|
||||||
:rev => @changeset.identifier)
|
:rev => @changeset.identifier)
|
||||||
output << "<li class='#{style}'>#{text}</li>"
|
output << "<li class='#{style}'>#{text}"
|
||||||
output << render_changes_tree(s)
|
output << render_changes_tree(s)
|
||||||
|
output << "</li>"
|
||||||
elsif c = tree[file][:c]
|
elsif c = tree[file][:c]
|
||||||
style << " change-#{c.action}"
|
style << " change-#{c.action}"
|
||||||
path_param = to_path_param(@repository.relative_path(c.path))
|
path_param = to_path_param(@repository.relative_path(c.path))
|
||||||
text = link_to(h(text), :controller => 'repositories',
|
text = link_to(h(text), :controller => 'repositories',
|
||||||
:action => 'entry',
|
:action => 'entry',
|
||||||
:id => @project,
|
:id => @project,
|
||||||
|
:repository_id => @repository.identifier_param,
|
||||||
:path => path_param,
|
:path => path_param,
|
||||||
:rev => @changeset.identifier) unless c.action == 'D'
|
:rev => @changeset.identifier) unless c.action == 'D'
|
||||||
text << " - #{h(c.revision)}" unless c.revision.blank?
|
text << " - #{h(c.revision)}" unless c.revision.blank?
|
||||||
text << ' ('.html_safe + link_to(l(:label_diff), :controller => 'repositories',
|
text << ' ('.html_safe + link_to(l(:label_diff), :controller => 'repositories',
|
||||||
:action => 'diff',
|
:action => 'diff',
|
||||||
:id => @project,
|
:id => @project,
|
||||||
|
:repository_id => @repository.identifier_param,
|
||||||
:path => path_param,
|
:path => path_param,
|
||||||
:rev => @changeset.identifier) + ') '.html_safe if c.action == 'M'
|
:rev => @changeset.identifier) + ') '.html_safe if c.action == 'M'
|
||||||
text << ' '.html_safe + content_tag('span', h(c.from_path), :class => 'copied-from') unless c.from_path.blank?
|
text << ' '.html_safe + content_tag('span', h(c.from_path), :class => 'copied-from') unless c.from_path.blank?
|
||||||
@@ -138,13 +142,10 @@ module RepositoriesHelper
|
|||||||
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(
|
:onchange => remote_function(
|
||||||
:url => {
|
:url => new_project_repository_path(@project),
|
||||||
:controller => 'repositories',
|
:method => :get,
|
||||||
:action => 'edit',
|
:update => 'content',
|
||||||
:id => @project
|
:with => "Form.serialize(this.form)")
|
||||||
},
|
|
||||||
:method => :get,
|
|
||||||
:with => "Form.serialize(this.form)")
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -255,59 +256,63 @@ module RepositoriesHelper
|
|||||||
'<br />'.html_safe + l(:text_scm_path_encoding_note))
|
'<br />'.html_safe + l(:text_scm_path_encoding_note))
|
||||||
end
|
end
|
||||||
|
|
||||||
def index_commits(commits, heads, href_proc = nil)
|
def index_commits(commits, heads)
|
||||||
return nil if commits.nil? or commits.first.parents.nil?
|
return nil if commits.nil? or commits.first.parents.nil?
|
||||||
map = {}
|
|
||||||
commit_hashes = []
|
|
||||||
refs_map = {}
|
refs_map = {}
|
||||||
href_proc ||= Proc.new {|x|x}
|
heads.each do |head|
|
||||||
heads.each{|r| refs_map[r.scmid] ||= []; refs_map[r.scmid] << r}
|
refs_map[head.scmid] ||= []
|
||||||
commits.reverse.each_with_index do |c, i|
|
refs_map[head.scmid] << head
|
||||||
h = {}
|
|
||||||
h[:parents] = c.parents.collect do |p|
|
|
||||||
[p.scmid, 0, 0]
|
|
||||||
end
|
|
||||||
h[:rdmid] = i
|
|
||||||
h[:space] = 0
|
|
||||||
h[:refs] = refs_map[c.scmid].join(" ") if refs_map.include? c.scmid
|
|
||||||
h[:scmid] = c.scmid
|
|
||||||
h[:href] = href_proc.call(c.scmid)
|
|
||||||
commit_hashes << h
|
|
||||||
map[c.scmid] = h
|
|
||||||
end
|
end
|
||||||
heads.sort! do |a,b|
|
|
||||||
a.to_s <=> b.to_s
|
commits_by_scmid = {}
|
||||||
|
commits.reverse.each_with_index do |commit, commit_index|
|
||||||
|
|
||||||
|
commits_by_scmid[commit.scmid] = {
|
||||||
|
:parent_scmids => commit.parents.collect { |parent| parent.scmid },
|
||||||
|
:rdmid => commit_index,
|
||||||
|
:refs => refs_map.include?(commit.scmid) ? refs_map[commit.scmid].join(" ") : nil,
|
||||||
|
:scmid => commit.scmid,
|
||||||
|
:href => block_given? ? yield(commit.scmid) : commit.scmid
|
||||||
|
}
|
||||||
end
|
end
|
||||||
j = 0
|
|
||||||
heads.each do |h|
|
heads.sort! { |head1, head2| head1.to_s <=> head2.to_s }
|
||||||
if map.include? h.scmid then
|
|
||||||
j = mark_chain(j += 1, map[h.scmid], map)
|
space = nil
|
||||||
|
heads.each do |head|
|
||||||
|
if commits_by_scmid.include? head.scmid
|
||||||
|
space = index_head((space || -1) + 1, head, commits_by_scmid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# when no head matched anything use first commit
|
# when no head matched anything use first commit
|
||||||
if j == 0 then
|
space ||= index_head(0, commits.first, commits_by_scmid)
|
||||||
mark_chain(j += 1, map.values.first, map)
|
|
||||||
end
|
return commits_by_scmid, space
|
||||||
map
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_chain(mark, commit, map)
|
def index_head(space, commit, commits_by_scmid)
|
||||||
stack = [[mark, commit]]
|
|
||||||
markmax = mark
|
stack = [[space, commits_by_scmid[commit.scmid]]]
|
||||||
|
max_space = space
|
||||||
|
|
||||||
until stack.empty?
|
until stack.empty?
|
||||||
current = stack.pop
|
space, commit = stack.pop
|
||||||
m, commit = current
|
commit[:space] = space if commit[:space].nil?
|
||||||
commit[:space] = m if commit[:space] == 0
|
|
||||||
m1 = m - 1
|
space -= 1
|
||||||
commit[:parents].each_with_index do |p, i|
|
commit[:parent_scmids].each_with_index do |parent_scmid, parent_index|
|
||||||
psha = p[0]
|
|
||||||
if map.include? psha and map[psha][:space] == 0 then
|
parent_commit = commits_by_scmid[parent_scmid]
|
||||||
stack << [m1 += 1, map[psha]] if i == 0
|
|
||||||
stack = [[m1 += 1, map[psha]]] + stack if i > 0
|
if parent_commit and parent_commit[:space].nil?
|
||||||
|
|
||||||
|
stack.unshift [space += 1, parent_commit]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
markmax = m1 if markmax < m1
|
max_space = space if max_space < space
|
||||||
end
|
end
|
||||||
markmax
|
max_space
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ module SearchHelper
|
|||||||
result << content_tag('span', h(words), :class => "highlight token-#{t}")
|
result << content_tag('span', h(words), :class => "highlight token-#{t}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
result
|
result.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def type_label(t)
|
def type_label(t)
|
||||||
@@ -63,6 +63,8 @@ module SearchHelper
|
|||||||
links << link_to(h(text), :q => params[:q], :titles_only => params[:titles_only],
|
links << link_to(h(text), :q => params[:q], :titles_only => params[:titles_only],
|
||||||
:all_words => params[:all_words], :scope => params[:scope], t => 1)
|
: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>'.html_safe +
|
||||||
|
links.map {|link| content_tag('li', link)}.join(' ').html_safe +
|
||||||
|
'</ul>'.html_safe) unless links.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -160,7 +160,8 @@ module SortHelper
|
|||||||
# sort_clause.
|
# sort_clause.
|
||||||
# - criteria can be either an array or a hash of allowed keys
|
# - criteria can be either an array or a hash of allowed keys
|
||||||
#
|
#
|
||||||
def sort_update(criteria)
|
def sort_update(criteria, sort_name=nil)
|
||||||
|
sort_name ||= self.sort_name
|
||||||
@sort_criteria = SortCriteria.new
|
@sort_criteria = SortCriteria.new
|
||||||
@sort_criteria.available_criteria = criteria
|
@sort_criteria.available_criteria = criteria
|
||||||
@sort_criteria.from_param(params[:sort] || session[sort_name])
|
@sort_criteria.from_param(params[:sort] || session[sort_name])
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ module TimelogHelper
|
|||||||
entry.hours.to_s.gsub('.', decimal_separator),
|
entry.hours.to_s.gsub('.', decimal_separator),
|
||||||
entry.comments
|
entry.comments
|
||||||
]
|
]
|
||||||
fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
|
fields += custom_fields.collect {|f| show_value(entry.custom_field_values.detect {|v| v.custom_field_id == f.id}) }
|
||||||
|
|
||||||
csv << fields.collect {|c| Redmine::CodesetUtil.from_utf8(
|
csv << fields.collect {|c| Redmine::CodesetUtil.from_utf8(
|
||||||
c.to_s,
|
c.to_s,
|
||||||
@@ -128,10 +128,10 @@ module TimelogHelper
|
|||||||
export
|
export
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_criteria_value(criteria, value)
|
def format_criteria_value(criteria_options, value)
|
||||||
if value.blank?
|
if value.blank?
|
||||||
l(:label_none)
|
"[#{l(:label_none)}]"
|
||||||
elsif k = @available_criterias[criteria][:klass]
|
elsif k = criteria_options[:klass]
|
||||||
obj = k.find_by_id(value.to_i)
|
obj = k.find_by_id(value.to_i)
|
||||||
if obj.is_a?(Issue)
|
if obj.is_a?(Issue)
|
||||||
obj.visible? ? "#{obj.tracker} ##{obj.id}: #{obj.subject}" : "##{obj.id}"
|
obj.visible? ? "#{obj.tracker} ##{obj.id}: #{obj.subject}" : "##{obj.id}"
|
||||||
@@ -139,28 +139,28 @@ module TimelogHelper
|
|||||||
obj
|
obj
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
format_value(value, @available_criterias[criteria][:format])
|
format_value(value, criteria_options[:format])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def report_to_csv(criterias, periods, hours)
|
def report_to_csv(report)
|
||||||
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|
|
||||||
# Column headers
|
# Column headers
|
||||||
headers = criterias.collect {|criteria| l(@available_criterias[criteria][:label]) }
|
headers = report.criteria.collect {|criteria| l(report.available_criteria[criteria][:label]) }
|
||||||
headers += periods
|
headers += report.periods
|
||||||
headers << l(:label_total)
|
headers << l(:label_total)
|
||||||
csv << headers.collect {|c| Redmine::CodesetUtil.from_utf8(
|
csv << headers.collect {|c| Redmine::CodesetUtil.from_utf8(
|
||||||
c.to_s,
|
c.to_s,
|
||||||
l(:general_csv_encoding) ) }
|
l(:general_csv_encoding) ) }
|
||||||
# Content
|
# Content
|
||||||
report_criteria_to_csv(csv, criterias, periods, hours)
|
report_criteria_to_csv(csv, report.available_criteria, report.columns, report.criteria, report.periods, report.hours)
|
||||||
# Total row
|
# Total row
|
||||||
str_total = Redmine::CodesetUtil.from_utf8(l(:label_total), l(:general_csv_encoding))
|
str_total = Redmine::CodesetUtil.from_utf8(l(:label_total), l(:general_csv_encoding))
|
||||||
row = [ str_total ] + [''] * (criterias.size - 1)
|
row = [ str_total ] + [''] * (report.criteria.size - 1)
|
||||||
total = 0
|
total = 0
|
||||||
periods.each do |period|
|
report.periods.each do |period|
|
||||||
sum = sum_hours(select_hours(hours, @columns, period.to_s))
|
sum = sum_hours(select_hours(report.hours, report.columns, period.to_s))
|
||||||
total += sum
|
total += sum
|
||||||
row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '')
|
row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '')
|
||||||
end
|
end
|
||||||
@@ -170,26 +170,26 @@ module TimelogHelper
|
|||||||
export
|
export
|
||||||
end
|
end
|
||||||
|
|
||||||
def report_criteria_to_csv(csv, criterias, periods, hours, level=0)
|
def report_criteria_to_csv(csv, available_criteria, columns, criteria, periods, hours, level=0)
|
||||||
decimal_separator = l(:general_csv_decimal_separator)
|
decimal_separator = l(:general_csv_decimal_separator)
|
||||||
hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value|
|
hours.collect {|h| h[criteria[level]].to_s}.uniq.each do |value|
|
||||||
hours_for_value = select_hours(hours, criterias[level], value)
|
hours_for_value = select_hours(hours, criteria[level], value)
|
||||||
next if hours_for_value.empty?
|
next if hours_for_value.empty?
|
||||||
row = [''] * level
|
row = [''] * level
|
||||||
row << Redmine::CodesetUtil.from_utf8(
|
row << Redmine::CodesetUtil.from_utf8(
|
||||||
format_criteria_value(criterias[level], value).to_s,
|
format_criteria_value(available_criteria[criteria[level]], value).to_s,
|
||||||
l(:general_csv_encoding) )
|
l(:general_csv_encoding) )
|
||||||
row += [''] * (criterias.length - level - 1)
|
row += [''] * (criteria.length - level - 1)
|
||||||
total = 0
|
total = 0
|
||||||
periods.each do |period|
|
periods.each do |period|
|
||||||
sum = sum_hours(select_hours(hours_for_value, @columns, period.to_s))
|
sum = sum_hours(select_hours(hours_for_value, columns, period.to_s))
|
||||||
total += sum
|
total += sum
|
||||||
row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '')
|
row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '')
|
||||||
end
|
end
|
||||||
row << ("%.2f" % total).gsub('.',decimal_separator)
|
row << ("%.2f" % total).gsub('.',decimal_separator)
|
||||||
csv << row
|
csv << row
|
||||||
if criterias.length > level + 1
|
if criteria.length > level + 1
|
||||||
report_criteria_to_csv(csv, criterias, periods, hours_for_value, level + 1)
|
report_criteria_to_csv(csv, available_criteria, columns, criteria, periods, hours_for_value, level + 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ module UsersHelper
|
|||||||
def users_status_options_for_select(selected)
|
def users_status_options_for_select(selected)
|
||||||
user_count_by_status = User.count(:group => 'status').to_hash
|
user_count_by_status = User.count(:group => 'status').to_hash
|
||||||
options_for_select([[l(:label_all), ''],
|
options_for_select([[l(:label_all), ''],
|
||||||
["#{l(:status_active)} (#{user_count_by_status[1].to_i})", 1],
|
["#{l(:status_active)} (#{user_count_by_status[1].to_i})", '1'],
|
||||||
["#{l(:status_registered)} (#{user_count_by_status[2].to_i})", 2],
|
["#{l(:status_registered)} (#{user_count_by_status[2].to_i})", '2'],
|
||||||
["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", 3]], selected)
|
["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Options for the new membership projects combo-box
|
# Options for the new membership projects combo-box
|
||||||
|
|||||||
@@ -59,8 +59,16 @@ module WatchersHelper
|
|||||||
:style => "vertical-align: middle",
|
:style => "vertical-align: middle",
|
||||||
:class => "delete")
|
:class => "delete")
|
||||||
end
|
end
|
||||||
"<li>#{ s }</li>"
|
content_tag :li, s.html_safe
|
||||||
end
|
end
|
||||||
lis.empty? ? "" : "<ul>#{ lis.join("\n") }</ul>"
|
(lis.empty? ? "" : "<ul>#{ lis.join("\n") }</ul>").html_safe
|
||||||
|
end
|
||||||
|
|
||||||
|
def watchers_checkboxes(object, users, checked=nil)
|
||||||
|
users.map do |user|
|
||||||
|
c = checked.nil? ? object.watched_by?(user) : checked
|
||||||
|
tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil
|
||||||
|
content_tag 'label', "#{tag} #{h(user)}", :id => "issue_watcher_user_ids_#{user.id}", :class => "floating"
|
||||||
|
end.join
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+88
-40
@@ -1,5 +1,5 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
# Copyright (C) 2006-2012 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
|
||||||
@@ -21,7 +21,7 @@ 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 :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
|
||||||
validate :validate_max_file_size
|
validate :validate_max_file_size
|
||||||
@@ -49,9 +49,26 @@ class Attachment < ActiveRecord::Base
|
|||||||
before_save :files_to_final_location
|
before_save :files_to_final_location
|
||||||
after_destroy :delete_from_disk
|
after_destroy :delete_from_disk
|
||||||
|
|
||||||
|
def container_with_blank_type_check
|
||||||
|
if container_type.blank?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
container_without_blank_type_check
|
||||||
|
end
|
||||||
|
end
|
||||||
|
alias_method_chain :container, :blank_type_check unless method_defined?(:container_without_blank_type_check)
|
||||||
|
|
||||||
|
# Returns an unsaved copy of the attachment
|
||||||
|
def copy(attributes=nil)
|
||||||
|
copy = self.class.new
|
||||||
|
copy.attributes = self.attributes.dup.except("id", "downloads")
|
||||||
|
copy.attributes = attributes if attributes
|
||||||
|
copy
|
||||||
|
end
|
||||||
|
|
||||||
def validate_max_file_size
|
def validate_max_file_size
|
||||||
if self.filesize > Setting.attachment_max_size.to_i.kilobytes
|
if @temp_file && 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, l(:error_attachment_too_big, :max_size => Setting.attachment_max_size.to_i.kilobytes))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -59,21 +76,33 @@ class Attachment < ActiveRecord::Base
|
|||||||
unless incoming_file.nil?
|
unless incoming_file.nil?
|
||||||
@temp_file = incoming_file
|
@temp_file = incoming_file
|
||||||
if @temp_file.size > 0
|
if @temp_file.size > 0
|
||||||
self.filename = sanitize_filename(@temp_file.original_filename)
|
if @temp_file.respond_to?(:original_filename)
|
||||||
self.disk_filename = Attachment.disk_filename(filename)
|
self.filename = @temp_file.original_filename
|
||||||
self.content_type = @temp_file.content_type.to_s.chomp
|
self.filename.force_encoding("UTF-8") if filename.respond_to?(:force_encoding)
|
||||||
if content_type.blank?
|
end
|
||||||
|
if @temp_file.respond_to?(:content_type)
|
||||||
|
self.content_type = @temp_file.content_type.to_s.chomp
|
||||||
|
end
|
||||||
|
if content_type.blank? && filename.present?
|
||||||
self.content_type = Redmine::MimeType.of(filename)
|
self.content_type = Redmine::MimeType.of(filename)
|
||||||
end
|
end
|
||||||
self.filesize = @temp_file.size
|
self.filesize = @temp_file.size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def file
|
def file
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filename=(arg)
|
||||||
|
write_attribute :filename, sanitize_filename(arg.to_s)
|
||||||
|
if new_record? && disk_filename.blank?
|
||||||
|
self.disk_filename = Attachment.disk_filename(filename)
|
||||||
|
end
|
||||||
|
filename
|
||||||
|
end
|
||||||
|
|
||||||
# Copies the temporary file to its final location
|
# Copies the temporary file to its final location
|
||||||
# and computes its MD5 hash
|
# and computes its MD5 hash
|
||||||
def files_to_final_location
|
def files_to_final_location
|
||||||
@@ -81,10 +110,15 @@ class Attachment < ActiveRecord::Base
|
|||||||
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")
|
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")
|
||||||
md5 = Digest::MD5.new
|
md5 = Digest::MD5.new
|
||||||
File.open(diskfile, "wb") do |f|
|
File.open(diskfile, "wb") do |f|
|
||||||
buffer = ""
|
if @temp_file.respond_to?(:read)
|
||||||
while (buffer = @temp_file.read(8192))
|
buffer = ""
|
||||||
f.write(buffer)
|
while (buffer = @temp_file.read(8192))
|
||||||
md5.update(buffer)
|
f.write(buffer)
|
||||||
|
md5.update(buffer)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
f.write(@temp_file)
|
||||||
|
md5.update(@temp_file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.digest = md5.hexdigest
|
self.digest = md5.hexdigest
|
||||||
@@ -96,9 +130,11 @@ class Attachment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deletes file on the disk
|
# Deletes the file from the file system if it's not referenced by other attachments
|
||||||
def delete_from_disk
|
def delete_from_disk
|
||||||
File.delete(diskfile) if !filename.blank? && File.exist?(diskfile)
|
if Attachment.first(:conditions => ["disk_filename = ? AND id <> ?", disk_filename, id]).nil?
|
||||||
|
delete_from_disk!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns file's location on disk
|
# Returns file's location on disk
|
||||||
@@ -111,15 +147,15 @@ class Attachment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def project
|
def project
|
||||||
container.project
|
container.try(:project)
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
container.attachments_visible?(user)
|
container && container.attachments_visible?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def deletable?(user=User.current)
|
def deletable?(user=User.current)
|
||||||
container.attachments_deletable?(user)
|
container && container.attachments_deletable?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def image?
|
def image?
|
||||||
@@ -139,41 +175,53 @@ class Attachment < ActiveRecord::Base
|
|||||||
File.readable?(diskfile)
|
File.readable?(diskfile)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the attachment token
|
||||||
|
def token
|
||||||
|
"#{id}.#{digest}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Finds an attachment that matches the given token and that has no container
|
||||||
|
def self.find_by_token(token)
|
||||||
|
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/
|
||||||
|
attachment_id, attachment_digest = $1, $2
|
||||||
|
attachment = Attachment.first(:conditions => {:id => attachment_id, :digest => attachment_digest})
|
||||||
|
if attachment && attachment.container.nil?
|
||||||
|
attachment
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Bulk attaches a set of files to an object
|
# Bulk attaches a set of files to an object
|
||||||
#
|
#
|
||||||
# Returns a Hash of the results:
|
# Returns a Hash of the results:
|
||||||
# :files => array of the attached files
|
# :files => array of the attached files
|
||||||
# :unsaved => array of the files that could not be attached
|
# :unsaved => array of the files that could not be attached
|
||||||
def self.attach_files(obj, attachments)
|
def self.attach_files(obj, attachments)
|
||||||
attached = []
|
result = obj.save_attachments(attachments, User.current)
|
||||||
if attachments && attachments.is_a?(Hash)
|
obj.attach_saved_attachments
|
||||||
attachments.each_value do |attachment|
|
result
|
||||||
file = attachment['file']
|
|
||||||
next unless file && file.size > 0
|
|
||||||
a = Attachment.create(:container => obj,
|
|
||||||
:file => file,
|
|
||||||
:description => attachment['description'].to_s.strip,
|
|
||||||
:author => User.current)
|
|
||||||
obj.attachments << a
|
|
||||||
|
|
||||||
if a.new_record?
|
|
||||||
obj.unsaved_attachments ||= []
|
|
||||||
obj.unsaved_attachments << a
|
|
||||||
else
|
|
||||||
attached << a
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
{:files => attached, :unsaved => obj.unsaved_attachments}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.latest_attach(attachments, filename)
|
def self.latest_attach(attachments, filename)
|
||||||
attachments.sort_by(&:created_on).reverse.detect {
|
attachments.sort_by(&:created_on).reverse.detect {
|
||||||
|att| att.filename.downcase == filename.downcase
|
|att| att.filename.downcase == filename.downcase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def self.prune(age=1.day)
|
||||||
|
attachments = Attachment.all(:conditions => ["created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age])
|
||||||
|
attachments.each(&:destroy)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Physically deletes the file from the file system
|
||||||
|
def delete_from_disk!
|
||||||
|
if disk_filename.present? && File.exist?(diskfile)
|
||||||
|
File.delete(diskfile)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
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(/^.*(\\|\/)/, '')
|
||||||
|
|||||||
@@ -15,7 +15,12 @@
|
|||||||
# 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.
|
||||||
|
|
||||||
|
# Generic exception for when the AuthSource can not be reached
|
||||||
|
# (eg. can not connect to the LDAP)
|
||||||
|
class AuthSourceException < Exception; end
|
||||||
|
|
||||||
class AuthSource < ActiveRecord::Base
|
class AuthSource < ActiveRecord::Base
|
||||||
|
include Redmine::SubclassFactory
|
||||||
include Redmine::Ciphering
|
include Redmine::Ciphering
|
||||||
|
|
||||||
has_many :users
|
has_many :users
|
||||||
|
|||||||
@@ -15,40 +15,51 @@
|
|||||||
# 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 'net/ldap'
|
|
||||||
require 'iconv'
|
require 'iconv'
|
||||||
|
require 'net/ldap'
|
||||||
|
require 'net/ldap/dn'
|
||||||
|
|
||||||
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, :maximum => 60, :allow_nil => true
|
validates_length_of :name, :host, :maximum => 60, :allow_nil => true
|
||||||
validates_length_of :account, :account_password, :base_dn, :maximum => 255, :allow_nil => true
|
validates_length_of :account, :account_password, :base_dn, :filter, :maximum => 255, :allow_blank => 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
|
||||||
|
validate :validate_filter
|
||||||
|
|
||||||
before_validation :strip_ldap_attributes
|
before_validation :strip_ldap_attributes
|
||||||
|
|
||||||
def after_initialize
|
def self.human_attribute_name(attribute_key_name, *args)
|
||||||
|
attr_name = attribute_key_name.to_s
|
||||||
|
if attr_name == "filter"
|
||||||
|
attr_name = "ldap_filter"
|
||||||
|
end
|
||||||
|
super(attr_name, *args)
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(attributes=nil, *args)
|
||||||
|
super
|
||||||
self.port = 389 if self.port == 0
|
self.port = 389 if self.port == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate(login, password)
|
def authenticate(login, password)
|
||||||
return nil if login.blank? || password.blank?
|
return nil if login.blank? || password.blank?
|
||||||
attrs = get_user_dn(login)
|
attrs = get_user_dn(login, password)
|
||||||
|
|
||||||
if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password)
|
if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password)
|
||||||
logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
|
logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
|
||||||
return attrs.except(:dn)
|
return attrs.except(:dn)
|
||||||
end
|
end
|
||||||
rescue Net::LDAP::LdapError => text
|
rescue Net::LDAP::LdapError => e
|
||||||
raise "LdapError: " + text
|
raise AuthSourceException.new(e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
# test the connection to the LDAP
|
# test the connection to the LDAP
|
||||||
def test_connection
|
def test_connection
|
||||||
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
||||||
ldap_con.open { }
|
ldap_con.open { }
|
||||||
rescue Net::LDAP::LdapError => text
|
rescue Net::LDAP::LdapError => e
|
||||||
raise "LdapError: " + text
|
raise "LdapError: " + e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def auth_method_name
|
def auth_method_name
|
||||||
@@ -57,6 +68,20 @@ class AuthSourceLdap < AuthSource
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def ldap_filter
|
||||||
|
if filter.present?
|
||||||
|
Net::LDAP::Filter.construct(filter)
|
||||||
|
end
|
||||||
|
rescue Net::LDAP::LdapError
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_filter
|
||||||
|
if filter.present? && ldap_filter.nil?
|
||||||
|
errors.add(:filter, :invalid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def strip_ldap_attributes
|
def strip_ldap_attributes
|
||||||
[:attr_login, :attr_firstname, :attr_lastname, :attr_mail].each do |attr|
|
[:attr_login, :attr_firstname, :attr_lastname, :attr_mail].each do |attr|
|
||||||
write_attribute(attr, read_attribute(attr).strip) unless read_attribute(attr).nil?
|
write_attribute(attr, read_attribute(attr).strip) unless read_attribute(attr).nil?
|
||||||
@@ -100,14 +125,24 @@ class AuthSourceLdap < AuthSource
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Get the user's dn and any attributes for them, given their login
|
# Get the user's dn and any attributes for them, given their login
|
||||||
def get_user_dn(login)
|
def get_user_dn(login, password)
|
||||||
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
ldap_con = nil
|
||||||
|
if self.account && self.account.include?("$login")
|
||||||
|
ldap_con = initialize_ldap_con(self.account.sub("$login", Net::LDAP::DN.escape(login)), password)
|
||||||
|
else
|
||||||
|
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
||||||
|
end
|
||||||
login_filter = Net::LDAP::Filter.eq( self.attr_login, login )
|
login_filter = Net::LDAP::Filter.eq( self.attr_login, login )
|
||||||
object_filter = Net::LDAP::Filter.eq( "objectClass", "*" )
|
object_filter = Net::LDAP::Filter.eq( "objectClass", "*" )
|
||||||
attrs = {}
|
attrs = {}
|
||||||
|
|
||||||
|
search_filter = object_filter & login_filter
|
||||||
|
if f = ldap_filter
|
||||||
|
search_filter = search_filter & f
|
||||||
|
end
|
||||||
|
|
||||||
ldap_con.search( :base => self.base_dn,
|
ldap_con.search( :base => self.base_dn,
|
||||||
:filter => object_filter & login_filter,
|
:filter => search_filter,
|
||||||
:attributes=> search_attributes) do |entry|
|
:attributes=> search_attributes) do |entry|
|
||||||
|
|
||||||
if onthefly_register?
|
if onthefly_register?
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# 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 Board < ActiveRecord::Base
|
class Board < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
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 => :destroy, :order => "#{Message.table_name}.created_on DESC"
|
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
|
||||||
@@ -30,6 +31,8 @@ class Board < ActiveRecord::Base
|
|||||||
named_scope :visible, lambda {|*args| { :include => :project,
|
named_scope :visible, lambda {|*args| { :include => :project,
|
||||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
|
||||||
|
|
||||||
|
safe_attributes 'name', 'description', 'move_to'
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
+26
-10
@@ -31,10 +31,10 @@ class Changeset < ActiveRecord::Base
|
|||||||
:join_table => "#{table_name_prefix}changeset_parents#{table_name_suffix}",
|
:join_table => "#{table_name_prefix}changeset_parents#{table_name_suffix}",
|
||||||
:association_foreign_key => 'changeset_id', :foreign_key => 'parent_id'
|
:association_foreign_key => 'changeset_id', :foreign_key => 'parent_id'
|
||||||
|
|
||||||
acts_as_event :title => Proc.new {|o| "#{l(:label_revision)} #{o.format_identifier}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))},
|
acts_as_event :title => Proc.new {|o| o.title},
|
||||||
: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.identifier}}
|
:url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project, :repository_id => o.repository.identifier_param, :rev => o.identifier}}
|
||||||
|
|
||||||
acts_as_searchable :columns => 'comments',
|
acts_as_searchable :columns => 'comments',
|
||||||
:include => {:repository => :project},
|
:include => {:repository => :project},
|
||||||
@@ -151,12 +151,26 @@ class Changeset < ActiveRecord::Base
|
|||||||
@long_comments || split_comments.last
|
@long_comments || split_comments.last
|
||||||
end
|
end
|
||||||
|
|
||||||
def text_tag
|
def text_tag(ref_project=nil)
|
||||||
if scmid?
|
tag = if scmid?
|
||||||
"commit:#{scmid}"
|
"commit:#{scmid}"
|
||||||
else
|
else
|
||||||
"r#{revision}"
|
"r#{revision}"
|
||||||
end
|
end
|
||||||
|
if repository && repository.identifier.present?
|
||||||
|
tag = "#{repository.identifier}|#{tag}"
|
||||||
|
end
|
||||||
|
if ref_project && project && ref_project != project
|
||||||
|
tag = "#{project.identifier}:#{tag}"
|
||||||
|
end
|
||||||
|
tag
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns the title used for the changeset in the activity/search results
|
||||||
|
def title
|
||||||
|
repo = (repository && repository.identifier.present?) ? " (#{repository.identifier})" : ''
|
||||||
|
comm = short_comments.blank? ? '' : (': ' + short_comments)
|
||||||
|
"#{l(:label_revision)} #{format_identifier}#{repo}#{comm}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the previous changeset
|
# Returns the previous changeset
|
||||||
@@ -184,14 +198,14 @@ class Changeset < ActiveRecord::Base
|
|||||||
:from_revision => change[:from_revision])
|
:from_revision => change[:from_revision])
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# Finds an issue that can be referenced by the commit message
|
# Finds an issue that can be referenced by the commit message
|
||||||
# i.e. an issue that belong to the repository project, a subproject or a parent project
|
|
||||||
def find_referenced_issue_by_id(id)
|
def find_referenced_issue_by_id(id)
|
||||||
return nil if id.blank?
|
return nil if id.blank?
|
||||||
issue = Issue.find_by_id(id.to_i, :include => :project)
|
issue = Issue.find_by_id(id.to_i, :include => :project)
|
||||||
if issue
|
if Setting.commit_cross_project_ref?
|
||||||
|
# all issues can be referenced/fixed
|
||||||
|
elsif issue
|
||||||
|
# issue that belong to the repository project, a subproject or a parent project only
|
||||||
unless issue.project &&
|
unless issue.project &&
|
||||||
(project == issue.project || project.is_ancestor_of?(issue.project) ||
|
(project == issue.project || project.is_ancestor_of?(issue.project) ||
|
||||||
project.is_descendant_of?(issue.project))
|
project.is_descendant_of?(issue.project))
|
||||||
@@ -201,6 +215,8 @@ class Changeset < ActiveRecord::Base
|
|||||||
issue
|
issue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def fix_issue(issue)
|
def fix_issue(issue)
|
||||||
status = IssueStatus.find_by_id(Setting.commit_fix_status_id.to_i)
|
status = IssueStatus.find_by_id(Setting.commit_fix_status_id.to_i)
|
||||||
if status.nil?
|
if status.nil?
|
||||||
@@ -213,7 +229,7 @@ class Changeset < ActiveRecord::Base
|
|||||||
# don't change the status is the issue is closed
|
# don't change the status is the issue is closed
|
||||||
return if issue.status && issue.status.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))
|
journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag(issue.project)))
|
||||||
issue.status = status
|
issue.status = status
|
||||||
unless Setting.commit_fix_done_ratio.blank?
|
unless Setting.commit_fix_done_ratio.blank?
|
||||||
issue.done_ratio = Setting.commit_fix_done_ratio.to_i
|
issue.done_ratio = Setting.commit_fix_done_ratio.to_i
|
||||||
@@ -232,7 +248,7 @@ class Changeset < ActiveRecord::Base
|
|||||||
:hours => hours,
|
:hours => hours,
|
||||||
:issue => issue,
|
:issue => issue,
|
||||||
:spent_on => commit_date,
|
:spent_on => commit_date,
|
||||||
:comments => l(:text_time_logged_by_changeset, :value => text_tag,
|
:comments => l(:text_time_logged_by_changeset, :value => text_tag(issue.project),
|
||||||
:locale => Setting.default_language)
|
:locale => Setting.default_language)
|
||||||
)
|
)
|
||||||
time_entry.activity = log_time_activity unless log_time_activity.nil?
|
time_entry.activity = log_time_activity unless log_time_activity.nil?
|
||||||
|
|||||||
@@ -16,8 +16,11 @@
|
|||||||
# 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 Comment < ActiveRecord::Base
|
class Comment < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
belongs_to :commented, :polymorphic => true, :counter_cache => true
|
belongs_to :commented, :polymorphic => true, :counter_cache => true
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
|
|
||||||
validates_presence_of :commented, :author, :comments
|
validates_presence_of :commented, :author, :comments
|
||||||
|
|
||||||
|
safe_attributes 'comments'
|
||||||
end
|
end
|
||||||
|
|||||||
+82
-12
@@ -1,5 +1,5 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
# Copyright (C) 2006-2012 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,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 CustomField < ActiveRecord::Base
|
class CustomField < ActiveRecord::Base
|
||||||
|
include Redmine::SubclassFactory
|
||||||
|
|
||||||
has_many :custom_values, :dependent => :delete_all
|
has_many :custom_values, :dependent => :delete_all
|
||||||
acts_as_list :scope => 'type = \'#{self.class}\''
|
acts_as_list :scope => 'type = \'#{self.class}\''
|
||||||
serialize :possible_values
|
serialize :possible_values
|
||||||
@@ -25,20 +27,23 @@ class CustomField < ActiveRecord::Base
|
|||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
|
validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
|
||||||
|
|
||||||
validate :validate_values
|
validate :validate_custom_field
|
||||||
|
before_validation :set_searchable
|
||||||
|
|
||||||
def initialize(attributes = nil)
|
def initialize(attributes=nil, *args)
|
||||||
super
|
super
|
||||||
self.possible_values ||= []
|
self.possible_values ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_validation
|
def set_searchable
|
||||||
# make sure these fields are not searchable
|
# make sure these fields are not searchable
|
||||||
self.searchable = false if %w(int float date bool).include?(field_format)
|
self.searchable = false if %w(int float date bool).include?(field_format)
|
||||||
|
# make sure only these fields can have multiple values
|
||||||
|
self.multiple = false unless %w(list user version).include?(field_format)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_values
|
def validate_custom_field
|
||||||
if self.field_format == "list"
|
if self.field_format == "list"
|
||||||
errors.add(:possible_values, :blank) if self.possible_values.nil? || self.possible_values.empty?
|
errors.add(:possible_values, :blank) if self.possible_values.nil? || self.possible_values.empty?
|
||||||
errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
|
errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
|
||||||
@@ -52,10 +57,9 @@ class CustomField < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# validate default value
|
if default_value.present? && !valid_field_value?(default_value)
|
||||||
v = CustomValue.new(:custom_field => self.clone, :value => default_value, :customized => nil)
|
errors.add(:default_value, :invalid)
|
||||||
v.custom_field.is_required = false
|
end
|
||||||
errors.add(:default_value, :invalid) unless v.valid?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def possible_values_options(obj=nil)
|
def possible_values_options(obj=nil)
|
||||||
@@ -69,12 +73,14 @@ class CustomField < ActiveRecord::Base
|
|||||||
obj.project.shared_versions.sort.collect {|u| [u.to_s, u.id.to_s]}
|
obj.project.shared_versions.sort.collect {|u| [u.to_s, u.id.to_s]}
|
||||||
end
|
end
|
||||||
elsif obj.is_a?(Array)
|
elsif obj.is_a?(Array)
|
||||||
obj.collect {|o| possible_values_options(o)}.inject {|memo, v| memo & v}
|
obj.collect {|o| possible_values_options(o)}.reduce(:&)
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
when 'bool'
|
||||||
|
[[l(:general_text_Yes), '1'], [l(:general_text_No), '0']]
|
||||||
else
|
else
|
||||||
read_attribute :possible_values
|
read_possible_values_utf8_encoded || []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -82,8 +88,10 @@ class CustomField < ActiveRecord::Base
|
|||||||
case field_format
|
case field_format
|
||||||
when 'user', 'version'
|
when 'user', 'version'
|
||||||
possible_values_options(obj).collect(&:last)
|
possible_values_options(obj).collect(&:last)
|
||||||
|
when 'bool'
|
||||||
|
['1', '0']
|
||||||
else
|
else
|
||||||
read_attribute :possible_values
|
read_possible_values_utf8_encoded
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -121,6 +129,7 @@ class CustomField < ActiveRecord::Base
|
|||||||
# objects by their value of the custom field.
|
# objects by their value of the custom field.
|
||||||
# Returns false, if the custom field can not be used for sorting.
|
# Returns false, if the custom field can not be used for sorting.
|
||||||
def order_statement
|
def order_statement
|
||||||
|
return nil if multiple?
|
||||||
case field_format
|
case field_format
|
||||||
when 'string', 'text', 'list', 'date', 'bool'
|
when 'string', 'text', 'list', 'date', 'bool'
|
||||||
# COALESCE is here to make sure that blank and NULL values are sorted equally
|
# COALESCE is here to make sure that blank and NULL values are sorted equally
|
||||||
@@ -158,4 +167,65 @@ class CustomField < ActiveRecord::Base
|
|||||||
def type_name
|
def type_name
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the error messages for the given value
|
||||||
|
# or an empty array if value is a valid value for the custom field
|
||||||
|
def validate_field_value(value)
|
||||||
|
errs = []
|
||||||
|
if value.is_a?(Array)
|
||||||
|
if !multiple?
|
||||||
|
errs << ::I18n.t('activerecord.errors.messages.invalid')
|
||||||
|
end
|
||||||
|
if is_required? && value.detect(&:present?).nil?
|
||||||
|
errs << ::I18n.t('activerecord.errors.messages.blank')
|
||||||
|
end
|
||||||
|
value.each {|v| errs += validate_field_value_format(v)}
|
||||||
|
else
|
||||||
|
if is_required? && value.blank?
|
||||||
|
errs << ::I18n.t('activerecord.errors.messages.blank')
|
||||||
|
end
|
||||||
|
errs += validate_field_value_format(value)
|
||||||
|
end
|
||||||
|
errs
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns true if value is a valid value for the custom field
|
||||||
|
def valid_field_value?(value)
|
||||||
|
validate_field_value(value).empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
# Returns the error message for the given value regarding its format
|
||||||
|
def validate_field_value_format(value)
|
||||||
|
errs = []
|
||||||
|
if value.present?
|
||||||
|
errs << ::I18n.t('activerecord.errors.messages.invalid') unless regexp.blank? or value =~ Regexp.new(regexp)
|
||||||
|
errs << ::I18n.t('activerecord.errors.messages.too_short', :count => min_length) if min_length > 0 and value.length < min_length
|
||||||
|
errs << ::I18n.t('activerecord.errors.messages.too_long', :count => max_length) if max_length > 0 and value.length > max_length
|
||||||
|
|
||||||
|
# Format specific validations
|
||||||
|
case field_format
|
||||||
|
when 'int'
|
||||||
|
errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value =~ /^[+-]?\d+$/
|
||||||
|
when 'float'
|
||||||
|
begin; Kernel.Float(value); rescue; errs << ::I18n.t('activerecord.errors.messages.invalid') end
|
||||||
|
when 'date'
|
||||||
|
errs << ::I18n.t('activerecord.errors.messages.not_a_date') unless value =~ /^\d{4}-\d{2}-\d{2}$/ && begin; value.to_date; rescue; false end
|
||||||
|
when 'list'
|
||||||
|
errs << ::I18n.t('activerecord.errors.messages.inclusion') unless possible_values.include?(value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
errs
|
||||||
|
end
|
||||||
|
|
||||||
|
def read_possible_values_utf8_encoded
|
||||||
|
values = read_attribute(:possible_values)
|
||||||
|
if values.is_a?(Array)
|
||||||
|
values.each do |value|
|
||||||
|
value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
values
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2012 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 CustomFieldValue
|
||||||
|
attr_accessor :custom_field, :customized, :value
|
||||||
|
|
||||||
|
def custom_field_id
|
||||||
|
custom_field.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def true?
|
||||||
|
self.value == '1'
|
||||||
|
end
|
||||||
|
|
||||||
|
def editable?
|
||||||
|
custom_field.editable?
|
||||||
|
end
|
||||||
|
|
||||||
|
def visible?
|
||||||
|
custom_field.visible?
|
||||||
|
end
|
||||||
|
|
||||||
|
def required?
|
||||||
|
custom_field.is_required?
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
value.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_value
|
||||||
|
custom_field.validate_field_value(value).each do |message|
|
||||||
|
customized.errors.add(:base, custom_field.name + ' ' + message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
# Copyright (C) 2006-2012 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,9 +19,8 @@ class CustomValue < ActiveRecord::Base
|
|||||||
belongs_to :custom_field
|
belongs_to :custom_field
|
||||||
belongs_to :customized, :polymorphic => true
|
belongs_to :customized, :polymorphic => true
|
||||||
|
|
||||||
validate :validate_custom_value
|
def initialize(attributes=nil, *args)
|
||||||
|
super
|
||||||
def after_initialize
|
|
||||||
if new_record? && custom_field && (customized_type.blank? || (customized && customized.new_record?))
|
if new_record? && custom_field && (customized_type.blank? || (customized && customized.new_record?))
|
||||||
self.value ||= custom_field.default_value
|
self.value ||= custom_field.default_value
|
||||||
end
|
end
|
||||||
@@ -47,27 +46,4 @@ class CustomValue < ActiveRecord::Base
|
|||||||
def to_s
|
def to_s
|
||||||
value.to_s
|
value.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
|
||||||
def validate_custom_value
|
|
||||||
if value.blank?
|
|
||||||
errors.add(:value, :blank) if custom_field.is_required? and value.blank?
|
|
||||||
else
|
|
||||||
errors.add(:value, :invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
|
|
||||||
errors.add(:value, :too_short, :count => custom_field.min_length) if custom_field.min_length > 0 and value.length < custom_field.min_length
|
|
||||||
errors.add(:value, :too_long, :count => custom_field.max_length) if custom_field.max_length > 0 and value.length > custom_field.max_length
|
|
||||||
|
|
||||||
# Format specific validations
|
|
||||||
case custom_field.field_format
|
|
||||||
when 'int'
|
|
||||||
errors.add(:value, :not_a_number) unless value =~ /^[+-]?\d+$/
|
|
||||||
when 'float'
|
|
||||||
begin; Kernel.Float(value); rescue; errors.add(:value, :invalid) end
|
|
||||||
when 'date'
|
|
||||||
errors.add(:value, :not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ && begin; value.to_date; rescue; false end
|
|
||||||
when 'list'
|
|
||||||
errors.add(:value, :inclusion) unless custom_field.possible_values.include?(value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# 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 Document < ActiveRecord::Base
|
class Document < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
||||||
acts_as_attachable :delete_permission => :manage_documents
|
acts_as_attachable :delete_permission => :manage_documents
|
||||||
@@ -32,11 +33,14 @@ class Document < ActiveRecord::Base
|
|||||||
named_scope :visible, lambda {|*args| { :include => :project,
|
named_scope :visible, lambda {|*args| { :include => :project,
|
||||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_documents, *args) } }
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_documents, *args) } }
|
||||||
|
|
||||||
|
safe_attributes 'category_id', 'title', 'description'
|
||||||
|
|
||||||
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 initialize(attributes=nil, *args)
|
||||||
|
super
|
||||||
if new_record?
|
if new_record?
|
||||||
self.category ||= DocumentCategory.default
|
self.category ||= DocumentCategory.default
|
||||||
end
|
end
|
||||||
@@ -44,7 +48,7 @@ class Document < ActiveRecord::Base
|
|||||||
|
|
||||||
def updated_on
|
def updated_on
|
||||||
unless @updated_on
|
unless @updated_on
|
||||||
a = attachments.find(:first, :order => 'created_on DESC')
|
a = attachments.last
|
||||||
@updated_on = (a && a.created_on) || created_on
|
@updated_on = (a && a.created_on) || created_on
|
||||||
end
|
end
|
||||||
@updated_on
|
@updated_on
|
||||||
|
|||||||
@@ -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 Enumeration < ActiveRecord::Base
|
class Enumeration < ActiveRecord::Base
|
||||||
|
include Redmine::SubclassFactory
|
||||||
|
|
||||||
default_scope :order => "#{Enumeration.table_name}.position ASC"
|
default_scope :order => "#{Enumeration.table_name}.position ASC"
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
@@ -27,6 +29,8 @@ class Enumeration < ActiveRecord::Base
|
|||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
before_save :check_default
|
before_save :check_default
|
||||||
|
|
||||||
|
attr_protected :type
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name, :scope => [:type, :project_id]
|
validates_uniqueness_of :name, :scope => [:type, :project_id]
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
@@ -94,7 +98,7 @@ class Enumeration < ActiveRecord::Base
|
|||||||
#
|
#
|
||||||
# Note: subclasses is protected in ActiveRecord
|
# Note: subclasses is protected in ActiveRecord
|
||||||
def self.get_subclasses
|
def self.get_subclasses
|
||||||
@@subclasses[Enumeration]
|
subclasses
|
||||||
end
|
end
|
||||||
|
|
||||||
# Does the +new+ Hash override the previous Enumeration?
|
# Does the +new+ Hash override the previous Enumeration?
|
||||||
|
|||||||
+3
-3
@@ -51,12 +51,12 @@ class Group < Principal
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.human_attribute_name(attribute_key_name)
|
def self.human_attribute_name(attribute_key_name, *args)
|
||||||
attr_name = attribute_key_name
|
attr_name = attribute_key_name.to_s
|
||||||
if attr_name == 'lastname'
|
if attr_name == 'lastname'
|
||||||
attr_name = "name"
|
attr_name = "name"
|
||||||
end
|
end
|
||||||
super(attr_name)
|
super(attr_name, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
+317
-177
@@ -63,27 +63,19 @@ class Issue < ActiveRecord::Base
|
|||||||
named_scope :visible, lambda {|*args| { :include => :project,
|
named_scope :visible, lambda {|*args| { :include => :project,
|
||||||
:conditions => Issue.visible_condition(args.shift || User.current, *args) } }
|
:conditions => Issue.visible_condition(args.shift || User.current, *args) } }
|
||||||
|
|
||||||
named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status
|
named_scope :open, lambda {|*args|
|
||||||
|
is_closed = args.size > 0 ? !args.first : false
|
||||||
|
{:conditions => ["#{IssueStatus.table_name}.is_closed = ?", is_closed], :include => :status}
|
||||||
|
}
|
||||||
|
|
||||||
named_scope :recently_updated, :order => "#{Issue.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 :close_duplicates, :update_done_ratio_from_issue_status
|
before_save :close_duplicates, :update_done_ratio_from_issue_status
|
||||||
|
after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
|
||||||
after_save :reschedule_following_issues, :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 :update_parent_attributes
|
after_destroy :update_parent_attributes
|
||||||
|
|
||||||
@@ -121,97 +113,96 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_initialize
|
def initialize(attributes=nil, *args)
|
||||||
|
super
|
||||||
if new_record?
|
if new_record?
|
||||||
# set default values for new records only
|
# set default values for new records only
|
||||||
self.status ||= IssueStatus.default
|
self.status ||= IssueStatus.default
|
||||||
self.priority ||= IssuePriority.default
|
self.priority ||= IssuePriority.default
|
||||||
|
self.watcher_user_ids = []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# AR#Base#destroy would raise and StaleObjectError exception
|
||||||
|
# if the issue was already deleted or updated (non matching lock_version).
|
||||||
|
# This is a problem when bulk deleting issues or deleting a project
|
||||||
|
# (because an issue may already be deleted if its parent was deleted
|
||||||
|
# first).
|
||||||
|
# The issue is reloaded by the nested_set before being deleted so
|
||||||
|
# the lock_version condition should not be an issue but we handle it.
|
||||||
|
def destroy
|
||||||
|
super
|
||||||
|
rescue ActiveRecord::StaleObjectError
|
||||||
|
# Stale or already deleted
|
||||||
|
begin
|
||||||
|
reload
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
# The issue was actually already deleted
|
||||||
|
@destroyed = true
|
||||||
|
return freeze
|
||||||
|
end
|
||||||
|
# The issue was stale, retry to destroy
|
||||||
|
super
|
||||||
|
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 & tracker.custom_fields.all) : []
|
(project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_from(arg)
|
# Copies attributes from another issue, arg can be an id or an Issue
|
||||||
|
def copy_from(arg, options={})
|
||||||
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")
|
||||||
self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
|
self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
|
||||||
self.status = issue.status
|
self.status = issue.status
|
||||||
|
self.author = User.current
|
||||||
|
unless options[:attachments] == false
|
||||||
|
self.attachments = issue.attachments.map do |attachement|
|
||||||
|
attachement.copy(:container => self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@copied_from = issue
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns an unsaved copy of the issue
|
||||||
|
def copy(attributes=nil, copy_options={})
|
||||||
|
copy = self.class.new.copy_from(self, copy_options)
|
||||||
|
copy.attributes = attributes if attributes
|
||||||
|
copy
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns true if the issue is a copy
|
||||||
|
def copy?
|
||||||
|
@copied_from.present?
|
||||||
|
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(new_project, new_tracker=nil, options={})
|
||||||
ret = Issue.transaction do
|
ActiveSupport::Deprecation.warn "Issue#move_to_project is deprecated, use #project= instead."
|
||||||
move_to_project_without_transaction(*args) || raise(ActiveRecord::Rollback)
|
|
||||||
end || false
|
|
||||||
end
|
|
||||||
|
|
||||||
def move_to_project_without_transaction(new_project, new_tracker = nil, options = {})
|
if options[:copy]
|
||||||
options ||= {}
|
issue = self.copy
|
||||||
issue = options[:copy] ? self.class.new.copy_from(self) : self
|
else
|
||||||
|
issue = self
|
||||||
if new_project && issue.project_id != new_project.id
|
|
||||||
# delete issue relations
|
|
||||||
unless Setting.cross_project_issue_relations?
|
|
||||||
issue.relations_from.clear
|
|
||||||
issue.relations_to.clear
|
|
||||||
end
|
|
||||||
# issue is moved to another project
|
|
||||||
# reassign to the category with same name if any
|
|
||||||
new_category = issue.category.nil? ? nil : new_project.issue_categories.find_by_name(issue.category.name)
|
|
||||||
issue.category = new_category
|
|
||||||
# Keep the fixed_version if it's still valid in the new_project
|
|
||||||
unless new_project.shared_versions.include?(issue.fixed_version)
|
|
||||||
issue.fixed_version = nil
|
|
||||||
end
|
|
||||||
issue.project = new_project
|
|
||||||
if issue.parent && issue.parent.project_id != issue.project_id
|
|
||||||
issue.parent_issue_id = nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
issue.init_journal(User.current, options[:notes])
|
||||||
|
|
||||||
|
# Preserve previous behaviour
|
||||||
|
# #move_to_project doesn't change tracker automatically
|
||||||
|
issue.send :project=, new_project, true
|
||||||
if new_tracker
|
if new_tracker
|
||||||
issue.tracker = new_tracker
|
issue.tracker = new_tracker
|
||||||
issue.reset_custom_values!
|
|
||||||
end
|
|
||||||
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.status = if options[:attributes] && options[:attributes][:status_id]
|
|
||||||
IssueStatus.find_by_id(options[:attributes][:status_id])
|
|
||||||
else
|
|
||||||
self.status
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Allow bulk setting of attributes on the issue
|
# Allow bulk setting of attributes on the issue
|
||||||
if options[:attributes]
|
if options[:attributes]
|
||||||
issue.attributes = options[:attributes]
|
issue.attributes = options[:attributes]
|
||||||
end
|
end
|
||||||
if issue.save
|
|
||||||
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
|
|
||||||
TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
|
|
||||||
|
|
||||||
issue.children.each do |child|
|
issue.save ? issue : false
|
||||||
unless child.move_to_project_without_transaction(new_project)
|
|
||||||
# Move failed and transaction was rollback'd
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
issue
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def status_id=(sid)
|
def status_id=(sid)
|
||||||
@@ -224,6 +215,16 @@ class Issue < ActiveRecord::Base
|
|||||||
write_attribute(:priority_id, pid)
|
write_attribute(:priority_id, pid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def category_id=(cid)
|
||||||
|
self.category = nil
|
||||||
|
write_attribute(:category_id, cid)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fixed_version_id=(vid)
|
||||||
|
self.fixed_version = nil
|
||||||
|
write_attribute(:fixed_version_id, vid)
|
||||||
|
end
|
||||||
|
|
||||||
def tracker_id=(tid)
|
def tracker_id=(tid)
|
||||||
self.tracker = nil
|
self.tracker = nil
|
||||||
result = write_attribute(:tracker_id, tid)
|
result = write_attribute(:tracker_id, tid)
|
||||||
@@ -231,6 +232,35 @@ class Issue < ActiveRecord::Base
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def project_id=(project_id)
|
||||||
|
if project_id.to_s != self.project_id.to_s
|
||||||
|
self.project = (project_id.present? ? Project.find_by_id(project_id) : nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def project=(project, keep_tracker=false)
|
||||||
|
project_was = self.project
|
||||||
|
write_attribute(:project_id, project ? project.id : nil)
|
||||||
|
association_instance_set('project', project)
|
||||||
|
if project_was && project && project_was != project
|
||||||
|
unless keep_tracker || project.trackers.include?(tracker)
|
||||||
|
self.tracker = project.trackers.first
|
||||||
|
end
|
||||||
|
# Reassign to the category with same name if any
|
||||||
|
if category
|
||||||
|
self.category = project.issue_categories.find_by_name(category.name)
|
||||||
|
end
|
||||||
|
# Keep the fixed_version if it's still valid in the new_project
|
||||||
|
if fixed_version && fixed_version.project != project && !project.shared_versions.include?(fixed_version)
|
||||||
|
self.fixed_version = nil
|
||||||
|
end
|
||||||
|
if parent && parent.project_id != project_id
|
||||||
|
self.parent_issue_id = nil
|
||||||
|
end
|
||||||
|
@custom_field_values = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def description=(arg)
|
def description=(arg)
|
||||||
if arg.is_a?(String)
|
if arg.is_a?(String)
|
||||||
arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
|
arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
|
||||||
@@ -238,25 +268,38 @@ class Issue < ActiveRecord::Base
|
|||||||
write_attribute(:description, arg)
|
write_attribute(:description, arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overrides attributes= so that tracker_id gets assigned first
|
# Overrides attributes= so that project and tracker get assigned first
|
||||||
def attributes_with_tracker_first=(new_attributes, *args)
|
def attributes_with_project_and_tracker_first=(new_attributes, *args)
|
||||||
return if new_attributes.nil?
|
return if new_attributes.nil?
|
||||||
new_tracker_id = new_attributes['tracker_id'] || new_attributes[:tracker_id]
|
attrs = new_attributes.dup
|
||||||
if new_tracker_id
|
attrs.stringify_keys!
|
||||||
self.tracker_id = new_tracker_id
|
|
||||||
|
%w(project project_id tracker tracker_id).each do |attr|
|
||||||
|
if attrs.has_key?(attr)
|
||||||
|
send "#{attr}=", attrs.delete(attr)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
send :attributes_without_tracker_first=, new_attributes, *args
|
send :attributes_without_project_and_tracker_first=, attrs, *args
|
||||||
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=, :project_and_tracker_first) unless method_defined?(:attributes_without_project_and_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 'project_id',
|
||||||
|
:if => lambda {|issue, user|
|
||||||
|
if issue.new_record?
|
||||||
|
issue.copy?
|
||||||
|
elsif user.allowed_to?(:move_issues, issue.project)
|
||||||
|
projects = Issue.allowed_target_projects_on_move(user)
|
||||||
|
projects.include?(issue.project) && projects.size > 1
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
safe_attributes 'tracker_id',
|
safe_attributes 'tracker_id',
|
||||||
'status_id',
|
'status_id',
|
||||||
'parent_issue_id',
|
|
||||||
'category_id',
|
'category_id',
|
||||||
'assigned_to_id',
|
'assigned_to_id',
|
||||||
'priority_id',
|
'priority_id',
|
||||||
@@ -276,19 +319,26 @@ class Issue < ActiveRecord::Base
|
|||||||
'assigned_to_id',
|
'assigned_to_id',
|
||||||
'fixed_version_id',
|
'fixed_version_id',
|
||||||
'done_ratio',
|
'done_ratio',
|
||||||
|
'lock_version',
|
||||||
:if => lambda {|issue, user| issue.new_statuses_allowed_to(user).any? }
|
:if => lambda {|issue, user| issue.new_statuses_allowed_to(user).any? }
|
||||||
|
|
||||||
|
safe_attributes 'watcher_user_ids',
|
||||||
|
:if => lambda {|issue, user| issue.new_record? && user.allowed_to?(:add_issue_watchers, issue.project)}
|
||||||
|
|
||||||
safe_attributes 'is_private',
|
safe_attributes 'is_private',
|
||||||
:if => lambda {|issue, user|
|
:if => lambda {|issue, user|
|
||||||
user.allowed_to?(:set_issues_private, issue.project) ||
|
user.allowed_to?(:set_issues_private, issue.project) ||
|
||||||
(issue.author == user && user.allowed_to?(:set_own_issues_private, issue.project))
|
(issue.author == user && user.allowed_to?(:set_own_issues_private, issue.project))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
safe_attributes 'parent_issue_id',
|
||||||
|
:if => lambda {|issue, user| (issue.new_record? || user.allowed_to?(:edit_issues, issue.project)) &&
|
||||||
|
user.allowed_to?(:manage_subtasks, 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
|
|
||||||
def safe_attributes=(attrs, user=User.current)
|
def safe_attributes=(attrs, user=User.current)
|
||||||
return unless attrs.is_a?(Hash)
|
return unless attrs.is_a?(Hash)
|
||||||
|
|
||||||
@@ -296,7 +346,13 @@ class Issue < ActiveRecord::Base
|
|||||||
attrs = delete_unsafe_attributes(attrs, user)
|
attrs = delete_unsafe_attributes(attrs, user)
|
||||||
return if attrs.empty?
|
return if attrs.empty?
|
||||||
|
|
||||||
# Tracker must be set before since new_statuses_allowed_to depends on it.
|
# Project and Tracker must be set before since new_statuses_allowed_to depends on it.
|
||||||
|
if p = attrs.delete('project_id')
|
||||||
|
if allowed_target_projects(user).collect(&:id).include?(p.to_i)
|
||||||
|
self.project_id = p
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if t = attrs.delete('tracker_id')
|
if t = attrs.delete('tracker_id')
|
||||||
self.tracker_id = t
|
self.tracker_id = t
|
||||||
end
|
end
|
||||||
@@ -311,15 +367,12 @@ class Issue < ActiveRecord::Base
|
|||||||
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['parent_issue_id'].present?
|
||||||
if !user.allowed_to?(:manage_subtasks, project)
|
attrs.delete('parent_issue_id') unless Issue.visible(user).exists?(attrs['parent_issue_id'].to_i)
|
||||||
attrs.delete('parent_issue_id')
|
|
||||||
elsif !attrs['parent_issue_id'].blank?
|
|
||||||
attrs.delete('parent_issue_id') unless Issue.visible(user).exists?(attrs['parent_issue_id'].to_i)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.attributes = attrs
|
# mass-assignment security bypass
|
||||||
|
self.send :attributes=, attrs, false
|
||||||
end
|
end
|
||||||
|
|
||||||
def done_ratio
|
def done_ratio
|
||||||
@@ -393,15 +446,27 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
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
|
if new_record?
|
||||||
@issue_before_change.status = self.status
|
@current_journal.notify = false
|
||||||
@custom_values_before_change = {}
|
else
|
||||||
self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
|
@attributes_before_change = attributes.dup
|
||||||
|
@custom_values_before_change = {}
|
||||||
|
self.custom_field_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
|
||||||
|
end
|
||||||
# Make sure updated_on is updated when adding a note.
|
# Make sure updated_on is updated when adding a note.
|
||||||
updated_on_will_change!
|
updated_on_will_change!
|
||||||
@current_journal
|
@current_journal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the id of the last journal or nil
|
||||||
|
def last_journal_id
|
||||||
|
if new_record?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
journals.first(:order => "#{Journal.table_name}.id DESC").try(:id)
|
||||||
|
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?
|
||||||
@@ -466,46 +531,72 @@ class Issue < ActiveRecord::Base
|
|||||||
!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 statuses that user is able to apply
|
||||||
def new_statuses_allowed_to(user, include_default=false)
|
def new_statuses_allowed_to(user=User.current, include_default=false)
|
||||||
statuses = status.find_new_statuses_allowed_to(
|
if new_record? && @copied_from
|
||||||
user.roles_for_project(project),
|
[IssueStatus.default, @copied_from.status].compact.uniq.sort
|
||||||
tracker,
|
else
|
||||||
author == user,
|
initial_status = nil
|
||||||
assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id
|
if new_record?
|
||||||
)
|
initial_status = IssueStatus.default
|
||||||
statuses << status unless statuses.empty?
|
elsif status_id_was
|
||||||
statuses << IssueStatus.default if include_default
|
initial_status = IssueStatus.find_by_id(status_id_was)
|
||||||
statuses = statuses.uniq.sort
|
end
|
||||||
blocked? ? statuses.reject {|s| s.is_closed?} : statuses
|
initial_status ||= status
|
||||||
|
|
||||||
|
statuses = initial_status.find_new_statuses_allowed_to(
|
||||||
|
user.admin ? Role.all : user.roles_for_project(project),
|
||||||
|
tracker,
|
||||||
|
author == user,
|
||||||
|
assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id
|
||||||
|
)
|
||||||
|
statuses << initial_status unless statuses.empty?
|
||||||
|
statuses << IssueStatus.default if include_default
|
||||||
|
statuses = statuses.compact.uniq.sort
|
||||||
|
blocked? ? statuses.reject {|s| s.is_closed?} : statuses
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def assigned_to_was
|
||||||
|
if assigned_to_id_changed? && assigned_to_id_was.present?
|
||||||
|
@assigned_to_was ||= User.find_by_id(assigned_to_id_was)
|
||||||
|
end
|
||||||
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 = []
|
||||||
# Author and assignee are always notified unless they have been
|
# Author and assignee are always notified unless they have been
|
||||||
# locked or don't want to be notified
|
# locked or don't want to be notified
|
||||||
notified << author if author && author.active? && author.notify_about?(self)
|
notified << author if author
|
||||||
if assigned_to
|
if assigned_to
|
||||||
if assigned_to.is_a?(Group)
|
notified += (assigned_to.is_a?(Group) ? assigned_to.users : [assigned_to])
|
||||||
notified += assigned_to.users.select {|u| u.active? && u.notify_about?(self)}
|
|
||||||
else
|
|
||||||
notified << assigned_to if assigned_to.active? && assigned_to.notify_about?(self)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
if assigned_to_was
|
||||||
|
notified += (assigned_to_was.is_a?(Group) ? assigned_to_was.users : [assigned_to_was])
|
||||||
|
end
|
||||||
|
notified = notified.select {|u| u.active? && u.notify_about?(self)}
|
||||||
|
|
||||||
|
notified += project.notified_users
|
||||||
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 number of hours spent on this issue
|
||||||
|
def spent_hours
|
||||||
|
@spent_hours ||= time_entries.sum(:hours) || 0
|
||||||
|
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:
|
||||||
# spent_hours => 0.0
|
# spent_hours => 0.0
|
||||||
# spent_hours => 50.2
|
# spent_hours => 50.2
|
||||||
def spent_hours
|
def total_spent_hours
|
||||||
@spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours", :include => :time_entries).to_f || 0.0
|
@total_spent_hours ||= self_and_descendants.sum("#{TimeEntry.table_name}.hours",
|
||||||
|
:joins => "LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id").to_f || 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
def relations
|
def relations
|
||||||
@@ -522,6 +613,16 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Preloads visible spent time for a collection of issues
|
||||||
|
def self.load_visible_spent_hours(issues, user=User.current)
|
||||||
|
if issues.any?
|
||||||
|
hours_by_issue_id = TimeEntry.visible(user).sum(:hours, :group => :issue_id)
|
||||||
|
issues.each do |issue|
|
||||||
|
issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Finds an issue relation given its id.
|
# Finds an issue relation given its id.
|
||||||
def find_relation(relation_id)
|
def find_relation(relation_id)
|
||||||
IssueRelation.find(relation_id, :conditions => ["issue_to_id = ? OR issue_from_id = ?", id, id])
|
IssueRelation.find(relation_id, :conditions => ["issue_to_id = ? OR issue_from_id = ?", id, id])
|
||||||
@@ -571,7 +672,13 @@ class Issue < ActiveRecord::Base
|
|||||||
if leaf?
|
if leaf?
|
||||||
if start_date.nil? || start_date < date
|
if start_date.nil? || start_date < date
|
||||||
self.start_date, self.due_date = date, date + duration
|
self.start_date, self.due_date = date, date + duration
|
||||||
save
|
begin
|
||||||
|
save
|
||||||
|
rescue ActiveRecord::StaleObjectError
|
||||||
|
reload
|
||||||
|
self.start_date, self.due_date = date, date + duration
|
||||||
|
save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
leaves.each do |leaf|
|
leaves.each do |leaf|
|
||||||
@@ -607,8 +714,7 @@ class Issue < ActiveRecord::Base
|
|||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Saves an issue, time_entry, attachments, and a journal from the parameters
|
# Saves an issue and a time_entry from the parameters
|
||||||
# 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? || params[:time_entry][:comments].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)
|
||||||
@@ -621,22 +727,13 @@ class Issue < ActiveRecord::Base
|
|||||||
self.time_entries << @time_entry
|
self.time_entries << @time_entry
|
||||||
end
|
end
|
||||||
|
|
||||||
if valid?
|
# TODO: Rename hook
|
||||||
attachments = Attachment.attach_files(self, params[:attachments])
|
Redmine::Hook.call_hook(:controller_issues_edit_before_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
|
||||||
|
if save
|
||||||
# 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_after_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
|
||||||
begin
|
else
|
||||||
if save
|
raise ActiveRecord::Rollback
|
||||||
# TODO: Rename hook
|
|
||||||
Redmine::Hook.call_hook(:controller_issues_edit_after_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
|
|
||||||
else
|
|
||||||
raise ActiveRecord::Rollback
|
|
||||||
end
|
|
||||||
rescue ActiveRecord::StaleObjectError
|
|
||||||
attachments[:files].each(&:destroy)
|
|
||||||
errors.add :base, l(:notice_locking_conflict)
|
|
||||||
raise ActiveRecord::Rollback
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -726,24 +823,42 @@ class Issue < ActiveRecord::Base
|
|||||||
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 user can assign the issue to
|
||||||
def self.allowed_target_projects_on_move
|
def allowed_target_projects(user=User.current)
|
||||||
projects = []
|
if new_record?
|
||||||
if User.current.admin?
|
Project.all(:conditions => Project.allowed_to_condition(user, :add_issues))
|
||||||
# admin is allowed to move issues to any active (visible) project
|
else
|
||||||
projects = Project.visible.all
|
self.class.allowed_target_projects_on_move(user)
|
||||||
elsif User.current.logged?
|
|
||||||
if Role.non_member.allowed_to?(:move_issues)
|
|
||||||
projects = Project.visible.all
|
|
||||||
else
|
|
||||||
User.current.memberships.each {|m| projects << m.project if m.roles.detect {|r| r.allowed_to?(:move_issues)}}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
projects
|
end
|
||||||
|
|
||||||
|
# Returns an array of projects that user can move issues to
|
||||||
|
def self.allowed_target_projects_on_move(user=User.current)
|
||||||
|
Project.all(:conditions => Project.allowed_to_condition(user, :move_issues))
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def after_project_change
|
||||||
|
# Update project_id on related time entries
|
||||||
|
TimeEntry.update_all(["project_id = ?", project_id], {:issue_id => id})
|
||||||
|
|
||||||
|
# Delete issue relations
|
||||||
|
unless Setting.cross_project_issue_relations?
|
||||||
|
relations_from.clear
|
||||||
|
relations_to.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
# Move subtasks
|
||||||
|
children.each do |child|
|
||||||
|
# Change project and keep project
|
||||||
|
child.send :project=, project, true
|
||||||
|
unless child.save
|
||||||
|
raise ActiveRecord::Rollback
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
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
|
||||||
@@ -798,7 +913,7 @@ class Issue < ActiveRecord::Base
|
|||||||
def recalculate_attributes_for(issue_id)
|
def recalculate_attributes_for(issue_id)
|
||||||
if issue_id && p = Issue.find_by_id(issue_id)
|
if issue_id && p = Issue.find_by_id(issue_id)
|
||||||
# priority = highest priority of children
|
# priority = highest priority of children
|
||||||
if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :include => :priority)
|
if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :joins => :priority)
|
||||||
p.priority = IssuePriority.find_by_position(priority_position)
|
p.priority = IssuePriority.find_by_position(priority_position)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -817,7 +932,7 @@ class Issue < ActiveRecord::Base
|
|||||||
if average == 0
|
if average == 0
|
||||||
average = 1
|
average = 1
|
||||||
end
|
end
|
||||||
done = p.leaves.sum("COALESCE(estimated_hours, #{average}) * (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)", :include => :status).to_f
|
done = p.leaves.sum("COALESCE(estimated_hours, #{average}) * (CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END)", :joins => :status).to_f
|
||||||
progress = done / (average * leaves_count)
|
progress = done / (average * leaves_count)
|
||||||
p.done_ratio = progress.round
|
p.done_ratio = progress.round
|
||||||
end
|
end
|
||||||
@@ -837,12 +952,12 @@ class Issue < ActiveRecord::Base
|
|||||||
def self.update_versions(conditions=nil)
|
def self.update_versions(conditions=nil)
|
||||||
# Only need to update issues with a fixed_version from
|
# Only need to update issues with a fixed_version from
|
||||||
# a different project and that is not systemwide shared
|
# a different project and that is not systemwide shared
|
||||||
Issue.all(:conditions => merge_conditions("#{Issue.table_name}.fixed_version_id IS NOT NULL" +
|
Issue.scoped(:conditions => conditions).all(
|
||||||
" AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
|
:conditions => "#{Issue.table_name}.fixed_version_id IS NOT NULL" +
|
||||||
" AND #{Version.table_name}.sharing <> 'system'",
|
" AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
|
||||||
conditions),
|
" AND #{Version.table_name}.sharing <> 'system'",
|
||||||
:include => [:project, :fixed_version]
|
:include => [:project, :fixed_version]
|
||||||
).each do |issue|
|
).each do |issue|
|
||||||
next if issue.project.nil? || issue.fixed_version.nil?
|
next if issue.project.nil? || issue.fixed_version.nil?
|
||||||
unless issue.project.shared_versions.include?(issue.fixed_version)
|
unless issue.project.shared_versions.include?(issue.fixed_version)
|
||||||
issue.init_journal(User.current)
|
issue.init_journal(User.current)
|
||||||
@@ -861,11 +976,10 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
# Callback on attachment deletion
|
# Callback on attachment deletion
|
||||||
def attachment_removed(obj)
|
def attachment_removed(obj)
|
||||||
journal = init_journal(User.current)
|
if @current_journal && !obj.new_record?
|
||||||
journal.details << JournalDetail.new(:property => 'attachment',
|
@current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :old_value => obj.filename)
|
||||||
:prop_key => obj.id,
|
@current_journal.save
|
||||||
:old_value => obj.filename)
|
end
|
||||||
journal.save
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Default assignment based on category
|
# Default assignment based on category
|
||||||
@@ -906,24 +1020,50 @@ class Issue < ActiveRecord::Base
|
|||||||
def create_journal
|
def create_journal
|
||||||
if @current_journal
|
if @current_journal
|
||||||
# attributes changes
|
# attributes changes
|
||||||
(Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
|
if @attributes_before_change
|
||||||
before = @issue_before_change.send(c)
|
(Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
|
||||||
after = send(c)
|
before = @attributes_before_change[c]
|
||||||
next if before == after || (before.blank? && after.blank?)
|
after = send(c)
|
||||||
@current_journal.details << JournalDetail.new(:property => 'attr',
|
next if before == after || (before.blank? && after.blank?)
|
||||||
:prop_key => c,
|
@current_journal.details << JournalDetail.new(:property => 'attr',
|
||||||
:old_value => @issue_before_change.send(c),
|
:prop_key => c,
|
||||||
:value => send(c))
|
:old_value => before,
|
||||||
}
|
:value => after)
|
||||||
# custom fields changes
|
}
|
||||||
custom_values.each {|c|
|
end
|
||||||
next if (@custom_values_before_change[c.custom_field_id]==c.value ||
|
if @custom_values_before_change
|
||||||
(@custom_values_before_change[c.custom_field_id].blank? && c.value.blank?))
|
# custom fields changes
|
||||||
@current_journal.details << JournalDetail.new(:property => 'cf',
|
custom_field_values.each {|c|
|
||||||
:prop_key => c.custom_field_id,
|
before = @custom_values_before_change[c.custom_field_id]
|
||||||
:old_value => @custom_values_before_change[c.custom_field_id],
|
after = c.value
|
||||||
:value => c.value)
|
next if before == after || (before.blank? && after.blank?)
|
||||||
}
|
|
||||||
|
if before.is_a?(Array) || after.is_a?(Array)
|
||||||
|
before = [before] unless before.is_a?(Array)
|
||||||
|
after = [after] unless after.is_a?(Array)
|
||||||
|
|
||||||
|
# values removed
|
||||||
|
(before - after).reject(&:blank?).each do |value|
|
||||||
|
@current_journal.details << JournalDetail.new(:property => 'cf',
|
||||||
|
:prop_key => c.custom_field_id,
|
||||||
|
:old_value => value,
|
||||||
|
:value => nil)
|
||||||
|
end
|
||||||
|
# values added
|
||||||
|
(after - before).reject(&:blank?).each do |value|
|
||||||
|
@current_journal.details << JournalDetail.new(:property => 'cf',
|
||||||
|
:prop_key => c.custom_field_id,
|
||||||
|
:old_value => nil,
|
||||||
|
:value => value)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@current_journal.details << JournalDetail.new(:property => 'cf',
|
||||||
|
:prop_key => c.custom_field_id,
|
||||||
|
:old_value => before,
|
||||||
|
:value => after)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
@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
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# 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 IssueCategory < ActiveRecord::Base
|
class IssueCategory < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id'
|
belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id'
|
||||||
has_many :issues, :foreign_key => 'category_id', :dependent => :nullify
|
has_many :issues, :foreign_key => 'category_id', :dependent => :nullify
|
||||||
@@ -24,7 +25,7 @@ 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
|
||||||
|
|
||||||
attr_protected :project_id
|
safe_attributes 'name', 'assigned_to_id'
|
||||||
|
|
||||||
named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ class IssueRelation < ActiveRecord::Base
|
|||||||
(issue_to.nil? || user.allowed_to?(:manage_issue_relations, issue_to.project)))
|
(issue_to.nil? || user.allowed_to?(:manage_issue_relations, issue_to.project)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_initialize
|
def initialize(attributes=nil, *args)
|
||||||
|
super
|
||||||
if new_record?
|
if new_record?
|
||||||
if relation_type.blank?
|
if relation_type.blank?
|
||||||
self.relation_type = IssueRelation::TYPE_RELATES
|
self.relation_type = IssueRelation::TYPE_RELATES
|
||||||
|
|||||||
+72
-27
@@ -29,7 +29,9 @@ class MailHandler < ActionMailer::Base
|
|||||||
|
|
||||||
@@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)
|
if @@handler_options[:allow_override].is_a?(String)
|
||||||
|
@@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip)
|
||||||
|
end
|
||||||
@@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)
|
||||||
@@ -40,6 +42,12 @@ class MailHandler < ActionMailer::Base
|
|||||||
super email
|
super email
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cattr_accessor :ignored_emails_headers
|
||||||
|
@@ignored_emails_headers = {
|
||||||
|
'X-Auto-Response-Suppress' => 'OOF',
|
||||||
|
'Auto-Submitted' => 'auto-replied'
|
||||||
|
}
|
||||||
|
|
||||||
# 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)
|
||||||
@@ -47,12 +55,26 @@ class MailHandler < ActionMailer::Base
|
|||||||
sender_email = email.from.to_a.first.to_s.strip
|
sender_email = email.from.to_a.first.to_s.strip
|
||||||
# Ignore emails received from the application emission address to avoid hell cycles
|
# Ignore emails received from the application emission address to avoid hell cycles
|
||||||
if sender_email.downcase == Setting.mail_from.to_s.strip.downcase
|
if sender_email.downcase == Setting.mail_from.to_s.strip.downcase
|
||||||
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]" if logger && logger.info
|
if logger && logger.info
|
||||||
|
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]"
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
# Ignore auto generated emails
|
||||||
|
self.class.ignored_emails_headers.each do |key, ignored_value|
|
||||||
|
value = email.header_string(key)
|
||||||
|
if value && value.to_s.downcase == ignored_value.downcase
|
||||||
|
if logger && logger.info
|
||||||
|
logger.info "MailHandler: ignoring email with #{key}:#{value} header"
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
@user = User.find_by_mail(sender_email) if sender_email.present?
|
@user = User.find_by_mail(sender_email) if sender_email.present?
|
||||||
if @user && !@user.active?
|
if @user && !@user.active?
|
||||||
logger.info "MailHandler: ignoring email from non-active user [#{@user.login}]" if logger && logger.info
|
if logger && logger.info
|
||||||
|
logger.info "MailHandler: ignoring email from non-active user [#{@user.login}]"
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if @user.nil?
|
if @user.nil?
|
||||||
@@ -61,17 +83,23 @@ class MailHandler < ActionMailer::Base
|
|||||||
when 'accept'
|
when 'accept'
|
||||||
@user = User.anonymous
|
@user = User.anonymous
|
||||||
when 'create'
|
when 'create'
|
||||||
@user = create_user_from_email(email)
|
@user = create_user_from_email
|
||||||
if @user
|
if @user
|
||||||
logger.info "MailHandler: [#{@user.login}] account created" if logger && logger.info
|
if logger && logger.info
|
||||||
|
logger.info "MailHandler: [#{@user.login}] account created"
|
||||||
|
end
|
||||||
Mailer.deliver_account_information(@user, @user.password)
|
Mailer.deliver_account_information(@user, @user.password)
|
||||||
else
|
else
|
||||||
logger.error "MailHandler: could not create account for [#{sender_email}]" if logger && logger.error
|
if logger && logger.error
|
||||||
|
logger.error "MailHandler: could not create account for [#{sender_email}]"
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# Default behaviour, emails from unknown users are ignored
|
# Default behaviour, emails from unknown users are ignored
|
||||||
logger.info "MailHandler: ignoring email from unknown user [#{sender_email}]" if logger && logger.info
|
if logger && logger.info
|
||||||
|
logger.info "MailHandler: ignoring email from unknown user [#{sender_email}]"
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -149,7 +177,10 @@ class MailHandler < ActionMailer::Base
|
|||||||
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)
|
unless user.allowed_to?(:add_issue_notes, issue.project) ||
|
||||||
|
user.allowed_to?(:edit_issues, issue.project)
|
||||||
|
raise UnauthorizedAction
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# ignore CLI-supplied defaults for new issues
|
# ignore CLI-supplied defaults for new issues
|
||||||
@@ -161,7 +192,9 @@ class MailHandler < ActionMailer::Base
|
|||||||
journal.notes = cleaned_up_text_body
|
journal.notes = cleaned_up_text_body
|
||||||
add_attachments(issue)
|
add_attachments(issue)
|
||||||
issue.save!
|
issue.save!
|
||||||
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
|
if logger && logger.info
|
||||||
|
logger.info "MailHandler: issue ##{issue.id} updated by #{user}"
|
||||||
|
end
|
||||||
journal
|
journal
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -192,7 +225,9 @@ class MailHandler < ActionMailer::Base
|
|||||||
add_attachments(reply)
|
add_attachments(reply)
|
||||||
reply
|
reply
|
||||||
else
|
else
|
||||||
logger.info "MailHandler: ignoring reply from [#{sender_email}] to a locked topic" if logger && logger.info
|
if logger && logger.info
|
||||||
|
logger.info "MailHandler: ignoring reply from [#{sender_email}] to a locked topic"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -226,7 +261,8 @@ class MailHandler < ActionMailer::Base
|
|||||||
@keywords[attr]
|
@keywords[attr]
|
||||||
else
|
else
|
||||||
@keywords[attr] = begin
|
@keywords[attr] = begin
|
||||||
if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && (v = extract_keyword!(plain_text_body, attr, options[:format]))
|
if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) &&
|
||||||
|
(v = extract_keyword!(plain_text_body, attr, options[:format]))
|
||||||
v
|
v
|
||||||
elsif !@@handler_options[:issue][attr].blank?
|
elsif !@@handler_options[:issue][attr].blank?
|
||||||
@@handler_options[:issue][attr]
|
@@handler_options[:issue][attr]
|
||||||
@@ -240,8 +276,12 @@ class MailHandler < ActionMailer::Base
|
|||||||
def extract_keyword!(text, attr, format=nil)
|
def extract_keyword!(text, attr, format=nil)
|
||||||
keys = [attr.to_s.humanize]
|
keys = [attr.to_s.humanize]
|
||||||
if attr.is_a?(Symbol)
|
if attr.is_a?(Symbol)
|
||||||
keys << l("field_#{attr}", :default => '', :locale => user.language) if user && user.language.present?
|
if user && user.language.present?
|
||||||
keys << l("field_#{attr}", :default => '', :locale => Setting.default_language) if Setting.default_language.present?
|
keys << l("field_#{attr}", :default => '', :locale => user.language)
|
||||||
|
end
|
||||||
|
if Setting.default_language.present?
|
||||||
|
keys << l("field_#{attr}", :default => '', :locale => Setting.default_language)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
keys.reject! {|k| k.blank?}
|
keys.reject! {|k| k.blank?}
|
||||||
keys.collect! {|k| Regexp.escape(k)}
|
keys.collect! {|k| Regexp.escape(k)}
|
||||||
@@ -269,7 +309,8 @@ class MailHandler < ActionMailer::Base
|
|||||||
'priority_id' => (k = get_keyword(:priority)) && IssuePriority.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),
|
'category_id' => (k = get_keyword(:category)) && issue.project.issue_categories.named(k).first.try(:id),
|
||||||
'assigned_to_id' => assigned_to.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),
|
'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}'),
|
'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}'),
|
'due_date' => get_keyword(:due_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
|
||||||
'estimated_hours' => get_keyword(:estimated_hours, :override => true),
|
'estimated_hours' => get_keyword(:estimated_hours, :override => true),
|
||||||
@@ -322,8 +363,8 @@ class MailHandler < ActionMailer::Base
|
|||||||
@full_sanitizer ||= HTML::FullSanitizer.new
|
@full_sanitizer ||= HTML::FullSanitizer.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.assign_string_attribute_with_limit(object, attribute, value)
|
def self.assign_string_attribute_with_limit(object, attribute, value, limit=nil)
|
||||||
limit = object.class.columns_hash[attribute.to_s].limit || 255
|
limit ||= object.class.columns_hash[attribute.to_s].limit || 255
|
||||||
value = value.to_s.slice(0, limit)
|
value = value.to_s.slice(0, limit)
|
||||||
object.send("#{attribute}=", value)
|
object.send("#{attribute}=", value)
|
||||||
end
|
end
|
||||||
@@ -334,7 +375,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
|
|
||||||
# Truncating the email address would result in an invalid format
|
# Truncating the email address would result in an invalid format
|
||||||
user.mail = email_address
|
user.mail = email_address
|
||||||
assign_string_attribute_with_limit(user, 'login', email_address)
|
assign_string_attribute_with_limit(user, 'login', email_address, User::LOGIN_LENGTH_LIMIT)
|
||||||
|
|
||||||
names = fullname.blank? ? email_address.gsub(/@.*$/, '').split('.') : fullname.split
|
names = fullname.blank? ? email_address.gsub(/@.*$/, '').split('.') : fullname.split
|
||||||
assign_string_attribute_with_limit(user, 'firstname', names.shift)
|
assign_string_attribute_with_limit(user, 'firstname', names.shift)
|
||||||
@@ -342,13 +383,13 @@ class MailHandler < ActionMailer::Base
|
|||||||
user.lastname = '-' if user.lastname.blank?
|
user.lastname = '-' if user.lastname.blank?
|
||||||
|
|
||||||
password_length = [Setting.password_min_length.to_i, 10].max
|
password_length = [Setting.password_min_length.to_i, 10].max
|
||||||
user.password = ActiveSupport::SecureRandom.hex(password_length / 2 + 1)
|
user.password = Redmine::Utils.random_hex(password_length / 2 + 1)
|
||||||
user.language = Setting.default_language
|
user.language = Setting.default_language
|
||||||
|
|
||||||
unless user.valid?
|
unless user.valid?
|
||||||
user.login = "user#{ActiveSupport::SecureRandom.hex(6)}" if user.errors.on(:login)
|
user.login = "user#{Redmine::Utils.random_hex(6)}" unless user.errors[:login].blank?
|
||||||
user.firstname = "-" if user.errors.on(:firstname)
|
user.firstname = "-" unless user.errors[:firstname].blank?
|
||||||
user.lastname = "-" if user.errors.on(:lastname)
|
user.lastname = "-" unless user.errors[:lastname].blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
user
|
user
|
||||||
@@ -356,10 +397,10 @@ class MailHandler < ActionMailer::Base
|
|||||||
|
|
||||||
# Creates a User for the +email+ sender
|
# Creates a User for the +email+ sender
|
||||||
# Returns the user or nil if it could not be created
|
# Returns the user or nil if it could not be created
|
||||||
def create_user_from_email(email)
|
def create_user_from_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 = self.class.new_user_from_attributes(addr.spec, addr.name)
|
user = self.class.new_user_from_attributes(addr.spec, TMail::Unquoter.unquote_and_convert_to(addr.name, 'utf-8'))
|
||||||
if user.save
|
if user.save
|
||||||
user
|
user
|
||||||
else
|
else
|
||||||
@@ -372,8 +413,6 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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)}
|
||||||
@@ -388,10 +427,16 @@ class MailHandler < ActionMailer::Base
|
|||||||
keyword = keyword.to_s.downcase
|
keyword = keyword.to_s.downcase
|
||||||
assignable = issue.assignable_users
|
assignable = issue.assignable_users
|
||||||
assignee = nil
|
assignee = nil
|
||||||
assignee ||= assignable.detect {|a| a.mail.to_s.downcase == keyword || a.login.to_s.downcase == keyword}
|
assignee ||= assignable.detect {|a|
|
||||||
|
a.mail.to_s.downcase == keyword ||
|
||||||
|
a.login.to_s.downcase == keyword
|
||||||
|
}
|
||||||
if assignee.nil? && keyword.match(/ /)
|
if assignee.nil? && keyword.match(/ /)
|
||||||
firstname, lastname = *(keyword.split) # "First Last Throwaway"
|
firstname, lastname = *(keyword.split) # "First Last Throwaway"
|
||||||
assignee ||= assignable.detect {|a| a.is_a?(User) && a.firstname.to_s.downcase == firstname && a.lastname.to_s.downcase == lastname}
|
assignee ||= assignable.detect {|a|
|
||||||
|
a.is_a?(User) && a.firstname.to_s.downcase == firstname &&
|
||||||
|
a.lastname.to_s.downcase == lastname
|
||||||
|
}
|
||||||
end
|
end
|
||||||
if assignee.nil?
|
if assignee.nil?
|
||||||
assignee ||= assignable.detect {|a| a.is_a?(Group) && a.name.downcase == keyword}
|
assignee ||= assignable.detect {|a| a.is_a?(Group) && a.name.downcase == keyword}
|
||||||
|
|||||||
+45
-21
@@ -15,8 +15,6 @@
|
|||||||
# 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
|
||||||
@@ -43,6 +41,7 @@ class Mailer < ActionMailer::Base
|
|||||||
'Issue-Author' => issue.author.login
|
'Issue-Author' => issue.author.login
|
||||||
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
||||||
message_id issue
|
message_id issue
|
||||||
|
@author = issue.author
|
||||||
recipients issue.recipients
|
recipients issue.recipients
|
||||||
cc(issue.watcher_recipients - @recipients)
|
cc(issue.watcher_recipients - @recipients)
|
||||||
subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
|
subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
|
||||||
@@ -99,6 +98,7 @@ class Mailer < ActionMailer::Base
|
|||||||
def document_added(document)
|
def document_added(document)
|
||||||
redmine_headers 'Project' => document.project.identifier
|
redmine_headers 'Project' => document.project.identifier
|
||||||
recipients document.recipients
|
recipients document.recipients
|
||||||
|
@author = User.current
|
||||||
subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
|
subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
|
||||||
body :document => document,
|
body :document => document,
|
||||||
:document_url => url_for(:controller => 'documents', :action => 'show', :id => document)
|
:document_url => url_for(:controller => 'documents', :action => 'show', :id => document)
|
||||||
@@ -114,6 +114,7 @@ class Mailer < ActionMailer::Base
|
|||||||
container = attachments.first.container
|
container = attachments.first.container
|
||||||
added_to = ''
|
added_to = ''
|
||||||
added_to_url = ''
|
added_to_url = ''
|
||||||
|
@author = attachments.first.author
|
||||||
case container.class.name
|
case container.class.name
|
||||||
when 'Project'
|
when 'Project'
|
||||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
|
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
|
||||||
@@ -143,6 +144,7 @@ class Mailer < ActionMailer::Base
|
|||||||
# Mailer.deliver_news_added(news) => sends an email to the news' project recipients
|
# Mailer.deliver_news_added(news) => sends an email to the news' project recipients
|
||||||
def news_added(news)
|
def news_added(news)
|
||||||
redmine_headers 'Project' => news.project.identifier
|
redmine_headers 'Project' => news.project.identifier
|
||||||
|
@author = news.author
|
||||||
message_id news
|
message_id news
|
||||||
recipients news.recipients
|
recipients news.recipients
|
||||||
subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
||||||
@@ -159,6 +161,7 @@ class Mailer < ActionMailer::Base
|
|||||||
def news_comment_added(comment)
|
def news_comment_added(comment)
|
||||||
news = comment.commented
|
news = comment.commented
|
||||||
redmine_headers 'Project' => news.project.identifier
|
redmine_headers 'Project' => news.project.identifier
|
||||||
|
@author = comment.author
|
||||||
message_id comment
|
message_id comment
|
||||||
recipients news.recipients
|
recipients news.recipients
|
||||||
cc news.watcher_recipients
|
cc news.watcher_recipients
|
||||||
@@ -177,6 +180,7 @@ class Mailer < ActionMailer::Base
|
|||||||
def message_posted(message)
|
def message_posted(message)
|
||||||
redmine_headers 'Project' => message.project.identifier,
|
redmine_headers 'Project' => message.project.identifier,
|
||||||
'Topic-Id' => (message.parent_id || message.id)
|
'Topic-Id' => (message.parent_id || message.id)
|
||||||
|
@author = message.author
|
||||||
message_id message
|
message_id message
|
||||||
references message.parent unless message.parent.nil?
|
references message.parent unless message.parent.nil?
|
||||||
recipients(message.recipients)
|
recipients(message.recipients)
|
||||||
@@ -195,6 +199,7 @@ class Mailer < ActionMailer::Base
|
|||||||
def wiki_content_added(wiki_content)
|
def wiki_content_added(wiki_content)
|
||||||
redmine_headers 'Project' => wiki_content.project.identifier,
|
redmine_headers 'Project' => wiki_content.project.identifier,
|
||||||
'Wiki-Page-Id' => wiki_content.page.id
|
'Wiki-Page-Id' => wiki_content.page.id
|
||||||
|
@author = wiki_content.author
|
||||||
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)
|
||||||
@@ -214,6 +219,7 @@ class Mailer < ActionMailer::Base
|
|||||||
def wiki_content_updated(wiki_content)
|
def wiki_content_updated(wiki_content)
|
||||||
redmine_headers 'Project' => wiki_content.project.identifier,
|
redmine_headers 'Project' => wiki_content.project.identifier,
|
||||||
'Wiki-Page-Id' => wiki_content.page.id
|
'Wiki-Page-Id' => wiki_content.page.id
|
||||||
|
@author = wiki_content.author
|
||||||
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)
|
||||||
@@ -291,12 +297,12 @@ class Mailer < ActionMailer::Base
|
|||||||
render_multipart('register', body)
|
render_multipart('register', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test(user)
|
def test_email(user)
|
||||||
set_language_if_valid(user.language)
|
set_language_if_valid(user.language)
|
||||||
recipients user.mail
|
recipients user.mail
|
||||||
subject 'Redmine test'
|
subject 'Redmine test'
|
||||||
body :url => url_for(:controller => 'welcome')
|
body :url => url_for(:controller => 'welcome')
|
||||||
render_multipart('test', body)
|
render_multipart('test_email', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overrides default deliver! method to prevent from sending an email
|
# Overrides default deliver! method to prevent from sending an email
|
||||||
@@ -343,18 +349,17 @@ class Mailer < ActionMailer::Base
|
|||||||
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
|
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
|
||||||
user_ids = options[:users]
|
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]
|
scope = Issue.open.scoped(:conditions => ["#{Issue.table_name}.assigned_to_id IS NOT NULL" +
|
||||||
s << "#{Issue.table_name}.assigned_to_id IS NOT NULL"
|
" AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
|
||||||
s << ["#{Issue.table_name}.assigned_to_id IN (?)", user_ids] if user_ids.present?
|
" AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date]
|
||||||
s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}"
|
)
|
||||||
s << "#{Issue.table_name}.project_id = #{project.id}" if project
|
scope = scope.scoped(:conditions => {:assigned_to_id => user_ids}) if user_ids.present?
|
||||||
s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker
|
scope = scope.scoped(:conditions => {:project_id => project.id}) if project
|
||||||
|
scope = scope.scoped(:conditions => {:tracker_id => tracker.id}) if tracker
|
||||||
|
|
||||||
issues_by_assignee = Issue.find(:all, :include => [:status, :assigned_to, :project, :tracker],
|
issues_by_assignee = scope.all(:include => [:status, :assigned_to, :project, :tracker]).group_by(&:assigned_to)
|
||||||
:conditions => s.conditions
|
|
||||||
).group_by(&:assigned_to)
|
|
||||||
issues_by_assignee.each do |assignee, issues|
|
issues_by_assignee.each do |assignee, issues|
|
||||||
deliver_reminder(assignee, issues, days) if assignee && assignee.active?
|
deliver_reminder(assignee, issues, days) if assignee.is_a?(User) && assignee.active?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -367,6 +372,17 @@ class Mailer < ActionMailer::Base
|
|||||||
ActionMailer::Base.perform_deliveries = was_enabled
|
ActionMailer::Base.perform_deliveries = was_enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Sends emails synchronously in the given block
|
||||||
|
def self.with_synched_deliveries(&block)
|
||||||
|
saved_method = ActionMailer::Base.delivery_method
|
||||||
|
if m = saved_method.to_s.match(%r{^async_(.+)$})
|
||||||
|
ActionMailer::Base.delivery_method = m[1].to_sym
|
||||||
|
end
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
ActionMailer::Base.delivery_method = saved_method
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def initialize_defaults(method_name)
|
def initialize_defaults(method_name)
|
||||||
super
|
super
|
||||||
@@ -379,22 +395,30 @@ class Mailer < ActionMailer::Base
|
|||||||
'X-Redmine-Host' => Setting.host_name,
|
'X-Redmine-Host' => Setting.host_name,
|
||||||
'X-Redmine-Site' => Setting.app_title,
|
'X-Redmine-Site' => Setting.app_title,
|
||||||
'X-Auto-Response-Suppress' => 'OOF',
|
'X-Auto-Response-Suppress' => 'OOF',
|
||||||
'Auto-Submitted' => 'auto-generated'
|
'Auto-Submitted' => 'auto-generated',
|
||||||
|
'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Appends a Redmine header field (name is prepended with 'X-Redmine-')
|
# Appends a Redmine header field (name is prepended with 'X-Redmine-')
|
||||||
def redmine_headers(h)
|
def redmine_headers(h)
|
||||||
h.each { |k,v| headers["X-Redmine-#{k}"] = v }
|
h.each { |k,v| headers["X-Redmine-#{k}"] = v.to_s }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overrides the create_mail method
|
# Overrides the create_mail method
|
||||||
def create_mail
|
def create_mail
|
||||||
# Removes the current user from the recipients and cc
|
# Removes the author from the recipients and cc
|
||||||
# if he doesn't want to receive notifications about what he does
|
# if he doesn't want to receive notifications about what he does
|
||||||
@author ||= User.current
|
if @author && @author.logged? && @author.pref[:no_self_notified]
|
||||||
if @author.pref[:no_self_notified]
|
if recipients
|
||||||
recipients.delete(@author.mail) if recipients
|
recipients((recipients.is_a?(Array) ? recipients : [recipients]) - [@author.mail])
|
||||||
cc.delete(@author.mail) if cc
|
end
|
||||||
|
if cc
|
||||||
|
cc((cc.is_a?(Array) ? cc : [cc]) - [@author.mail])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if @author && @author.logged?
|
||||||
|
redmine_headers 'Sender' => @author.login
|
||||||
end
|
end
|
||||||
|
|
||||||
notified_users = [recipients, cc].flatten.compact.uniq
|
notified_users = [recipients, cc].flatten.compact.uniq
|
||||||
|
|||||||
+21
-3
@@ -24,9 +24,17 @@ class Member < ActiveRecord::Base
|
|||||||
|
|
||||||
validates_presence_of :principal, :project
|
validates_presence_of :principal, :project
|
||||||
validates_uniqueness_of :user_id, :scope => :project_id
|
validates_uniqueness_of :user_id, :scope => :project_id
|
||||||
|
validate :validate_role
|
||||||
|
|
||||||
|
before_destroy :set_issue_category_nil
|
||||||
after_destroy :unwatch_from_permission_change
|
after_destroy :unwatch_from_permission_change
|
||||||
|
|
||||||
|
def role
|
||||||
|
end
|
||||||
|
|
||||||
|
def role=
|
||||||
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
self.user.name
|
self.user.name
|
||||||
end
|
end
|
||||||
@@ -50,7 +58,17 @@ class Member < ActiveRecord::Base
|
|||||||
|
|
||||||
def <=>(member)
|
def <=>(member)
|
||||||
a, b = roles.sort.first, member.roles.sort.first
|
a, b = roles.sort.first, member.roles.sort.first
|
||||||
a == b ? (principal <=> member.principal) : (a <=> b)
|
if a == b
|
||||||
|
if principal
|
||||||
|
principal <=> member.principal
|
||||||
|
else
|
||||||
|
1
|
||||||
|
end
|
||||||
|
elsif a
|
||||||
|
a <=> b
|
||||||
|
else
|
||||||
|
1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def deletable?
|
def deletable?
|
||||||
@@ -65,7 +83,7 @@ class Member < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_destroy
|
def set_issue_category_nil
|
||||||
if user
|
if user
|
||||||
# remove category based auto assignments for this member
|
# remove category based auto assignments for this member
|
||||||
IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
|
IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
|
||||||
@@ -81,7 +99,7 @@ class Member < ActiveRecord::Base
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def validate
|
def validate_role
|
||||||
errors.add_on_empty :role if member_roles.empty? && roles.empty?
|
errors.add_on_empty :role if member_roles.empty? && roles.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ class MemberRole < ActiveRecord::Base
|
|||||||
after_destroy :remove_role_from_group_users
|
after_destroy :remove_role_from_group_users
|
||||||
|
|
||||||
validates_presence_of :role
|
validates_presence_of :role
|
||||||
|
validate :validate_role_member
|
||||||
|
|
||||||
def validate
|
def validate_role_member
|
||||||
errors.add :role_id, :invalid if role && !role.member?
|
errors.add :role_id, :invalid if role && !role.member?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# 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 Message < ActiveRecord::Base
|
class Message < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
belongs_to :board
|
belongs_to :board
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
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"
|
||||||
@@ -36,7 +37,6 @@ class Message < ActiveRecord::Base
|
|||||||
:author_key => :author_id
|
:author_key => :author_id
|
||||||
acts_as_watchable
|
acts_as_watchable
|
||||||
|
|
||||||
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
|
||||||
validate :cannot_reply_to_locked_topic, :on => :create
|
validate :cannot_reply_to_locked_topic, :on => :create
|
||||||
@@ -48,6 +48,12 @@ class Message < ActiveRecord::Base
|
|||||||
named_scope :visible, lambda {|*args| { :include => {:board => :project},
|
named_scope :visible, lambda {|*args| { :include => {:board => :project},
|
||||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
|
||||||
|
|
||||||
|
safe_attributes 'subject', 'content'
|
||||||
|
safe_attributes 'locked', 'sticky', 'board_id',
|
||||||
|
:if => lambda {|message, user|
|
||||||
|
user.allowed_to?(:edit_messages, message.project)
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
+13
-1
@@ -16,6 +16,7 @@
|
|||||||
# 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 News < ActiveRecord::Base
|
class News < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
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"
|
||||||
@@ -24,6 +25,7 @@ class News < ActiveRecord::Base
|
|||||||
validates_length_of :title, :maximum => 60
|
validates_length_of :title, :maximum => 60
|
||||||
validates_length_of :summary, :maximum => 255
|
validates_length_of :summary, :maximum => 255
|
||||||
|
|
||||||
|
acts_as_attachable :delete_permission => :manage_news
|
||||||
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project
|
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project
|
||||||
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]},
|
||||||
@@ -37,13 +39,23 @@ class News < ActiveRecord::Base
|
|||||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_news, *args)
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_news, *args)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
safe_attributes 'title', 'summary', 'description'
|
||||||
|
|
||||||
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 true if the news can be commented by user
|
||||||
|
def commentable?(user=User.current)
|
||||||
|
user.allowed_to?(:comment_news, project)
|
||||||
|
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
|
private
|
||||||
|
|||||||
+39
-6
@@ -24,13 +24,44 @@ class Principal < ActiveRecord::Base
|
|||||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||||
|
|
||||||
# Groups and active users
|
# Groups and active users
|
||||||
named_scope :active, :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status = 1)"
|
named_scope :active, :conditions => "#{Principal.table_name}.status = 1"
|
||||||
|
|
||||||
named_scope :like, lambda {|q|
|
named_scope :like, lambda {|q|
|
||||||
s = "%#{q.to_s.strip.downcase}%"
|
if q.blank?
|
||||||
{:conditions => ["LOWER(login) LIKE :s OR LOWER(firstname) LIKE :s OR LOWER(lastname) LIKE :s OR LOWER(mail) LIKE :s", {:s => s}],
|
{}
|
||||||
:order => 'type, login, lastname, firstname, mail'
|
else
|
||||||
}
|
q = q.to_s.downcase
|
||||||
|
pattern = "%#{q}%"
|
||||||
|
sql = "LOWER(login) LIKE :p OR LOWER(firstname) LIKE :p OR LOWER(lastname) LIKE :p OR LOWER(mail) LIKE :p"
|
||||||
|
params = {:p => pattern}
|
||||||
|
if q =~ /^(.+)\s+(.+)$/
|
||||||
|
a, b = "#{$1}%", "#{$2}%"
|
||||||
|
sql << " OR (LOWER(firstname) LIKE :a AND LOWER(lastname) LIKE :b) OR (LOWER(firstname) LIKE :b AND LOWER(lastname) LIKE :a)"
|
||||||
|
params.merge!(:a => a, :b => b)
|
||||||
|
end
|
||||||
|
{:conditions => [sql, params]}
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
# Principals that are members of a collection of projects
|
||||||
|
named_scope :member_of, lambda {|projects|
|
||||||
|
projects = [projects] unless projects.is_a?(Array)
|
||||||
|
if projects.empty?
|
||||||
|
{:conditions => "1=0"}
|
||||||
|
else
|
||||||
|
ids = projects.map(&:id)
|
||||||
|
{:conditions => ["#{Principal.table_name}.status = 1 AND #{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids]}
|
||||||
|
end
|
||||||
|
}
|
||||||
|
# Principals that are not members of projects
|
||||||
|
named_scope :not_member_of, lambda {|projects|
|
||||||
|
projects = [projects] unless projects.is_a?(Array)
|
||||||
|
if projects.empty?
|
||||||
|
{:conditions => "1=0"}
|
||||||
|
else
|
||||||
|
ids = projects.map(&:id)
|
||||||
|
{:conditions => ["#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids]}
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
before_create :set_default_empty_values
|
before_create :set_default_empty_values
|
||||||
@@ -40,7 +71,9 @@ class Principal < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def <=>(principal)
|
def <=>(principal)
|
||||||
if self.class.name == principal.class.name
|
if principal.nil?
|
||||||
|
-1
|
||||||
|
elsif self.class.name == principal.class.name
|
||||||
self.to_s.downcase <=> principal.to_s.downcase
|
self.to_s.downcase <=> principal.to_s.downcase
|
||||||
else
|
else
|
||||||
# groups after users
|
# groups after users
|
||||||
|
|||||||
+49
-10
@@ -37,7 +37,7 @@ class Project < ActiveRecord::Base
|
|||||||
|
|
||||||
has_many :enabled_modules, :dependent => :delete_all
|
has_many :enabled_modules, :dependent => :delete_all
|
||||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||||
has_many :issues, :dependent => :destroy, :order => "#{Issue.table_name}.created_on DESC", :include => [:status, :tracker]
|
has_many :issues, :dependent => :destroy, :include => [:status, :tracker]
|
||||||
has_many :issue_changes, :through => :issues, :source => :journals
|
has_many :issue_changes, :through => :issues, :source => :journals
|
||||||
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
|
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
|
||||||
has_many :time_entries, :dependent => :delete_all
|
has_many :time_entries, :dependent => :delete_all
|
||||||
@@ -46,7 +46,8 @@ class Project < ActiveRecord::Base
|
|||||||
has_many :news, :dependent => :destroy, :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, :conditions => ["is_default = ?", true]
|
||||||
|
has_many :repositories, :dependent => :destroy
|
||||||
has_many :changesets, :through => :repository
|
has_many :changesets, :through => :repository
|
||||||
has_one :wiki, :dependent => :destroy
|
has_one :wiki, :dependent => :destroy
|
||||||
# Custom field for the project issues
|
# Custom field for the project issues
|
||||||
@@ -75,7 +76,7 @@ class Project < ActiveRecord::Base
|
|||||||
validates_length_of :homepage, :maximum => 255
|
validates_length_of :homepage, :maximum => 255
|
||||||
validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH
|
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 )
|
||||||
|
|
||||||
@@ -83,10 +84,30 @@ class Project < ActiveRecord::Base
|
|||||||
|
|
||||||
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 :status, lambda {|arg| arg.blank? ? {} : {:conditions => {:status => arg.to_i}} }
|
||||||
named_scope :all_public, { :conditions => { :is_public => true } }
|
named_scope :all_public, { :conditions => { :is_public => true } }
|
||||||
named_scope :visible, lambda {|*args| {:conditions => Project.visible_condition(args.shift || User.current, *args) }}
|
named_scope :visible, lambda {|*args| {:conditions => Project.visible_condition(args.shift || User.current, *args) }}
|
||||||
|
named_scope :allowed_to, lambda {|*args|
|
||||||
|
user = User.current
|
||||||
|
permission = nil
|
||||||
|
if args.first.is_a?(Symbol)
|
||||||
|
permission = args.shift
|
||||||
|
else
|
||||||
|
user = args.shift
|
||||||
|
permission = args.shift
|
||||||
|
end
|
||||||
|
{ :conditions => Project.allowed_to_condition(user, permission, *args) }
|
||||||
|
}
|
||||||
|
named_scope :like, lambda {|arg|
|
||||||
|
if arg.blank?
|
||||||
|
{}
|
||||||
|
else
|
||||||
|
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||||
|
{:conditions => ["LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p", {:p => pattern}]}
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
def initialize(attributes = nil)
|
def initialize(attributes=nil, *args)
|
||||||
super
|
super
|
||||||
|
|
||||||
initialized = (attributes || {}).stringify_keys
|
initialized = (attributes || {}).stringify_keys
|
||||||
@@ -251,9 +272,22 @@ class Project < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reload(*args)
|
||||||
|
@shared_versions = nil
|
||||||
|
@rolled_up_versions = nil
|
||||||
|
@rolled_up_trackers = nil
|
||||||
|
@all_issue_custom_fields = nil
|
||||||
|
@all_time_entry_custom_fields = nil
|
||||||
|
@to_param = nil
|
||||||
|
@allowed_parents = nil
|
||||||
|
@allowed_permissions = nil
|
||||||
|
@actions_allowed = nil
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
# id is used for projects with a numeric identifier (compatibility)
|
# id is used for projects with a numeric identifier (compatibility)
|
||||||
@to_param ||= (identifier.to_s =~ %r{^\d*$} ? id : identifier)
|
@to_param ||= (identifier.to_s =~ %r{^\d*$} ? id.to_s : identifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
def active?
|
def active?
|
||||||
@@ -390,16 +424,21 @@ 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 ||= begin
|
if new_record?
|
||||||
r = root? ? self : root
|
|
||||||
Version.scoped(:include => :project,
|
Version.scoped(:include => :project,
|
||||||
:conditions => "#{Project.table_name}.id = #{id}" +
|
:conditions => "#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND #{Version.table_name}.sharing = 'system'")
|
||||||
" OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" +
|
else
|
||||||
|
@shared_versions ||= begin
|
||||||
|
r = root? ? self : root
|
||||||
|
Version.scoped(:include => :project,
|
||||||
|
:conditions => "#{Project.table_name}.id = #{id}" +
|
||||||
|
" OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" +
|
||||||
" #{Version.table_name}.sharing = 'system'" +
|
" #{Version.table_name}.sharing = 'system'" +
|
||||||
" 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 >= #{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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -801,7 +840,7 @@ class Project < ActiveRecord::Base
|
|||||||
# Copies queries from +project+
|
# Copies queries from +project+
|
||||||
def copy_queries(project)
|
def copy_queries(project)
|
||||||
project.queries.each do |query|
|
project.queries.each do |query|
|
||||||
new_query = Query.new
|
new_query = ::Query.new
|
||||||
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
|
||||||
|
|||||||
+109
-37
@@ -57,7 +57,7 @@ class QueryCustomFieldColumn < QueryColumn
|
|||||||
def initialize(custom_field)
|
def initialize(custom_field)
|
||||||
self.name = "cf_#{custom_field.id}".to_sym
|
self.name = "cf_#{custom_field.id}".to_sym
|
||||||
self.sortable = custom_field.order_statement || false
|
self.sortable = custom_field.order_statement || false
|
||||||
if %w(list date bool int).include?(custom_field.field_format)
|
if %w(list date bool int).include?(custom_field.field_format) && !custom_field.multiple?
|
||||||
self.groupable = custom_field.order_statement
|
self.groupable = custom_field.order_statement
|
||||||
end
|
end
|
||||||
self.groupable ||= false
|
self.groupable ||= false
|
||||||
@@ -73,8 +73,8 @@ class QueryCustomFieldColumn < QueryColumn
|
|||||||
end
|
end
|
||||||
|
|
||||||
def value(issue)
|
def value(issue)
|
||||||
cv = issue.custom_values.detect {|v| v.custom_field_id == @cf.id}
|
cv = issue.custom_values.select {|v| v.custom_field_id == @cf.id}.collect {|v| @cf.cast_value(v.value)}
|
||||||
cv && @cf.cast_value(cv.value)
|
cv.size > 1 ? cv : cv.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def css_classes
|
def css_classes
|
||||||
@@ -94,7 +94,7 @@ class Query < ActiveRecord::Base
|
|||||||
|
|
||||||
attr_protected :project_id, :user_id
|
attr_protected :project_id, :user_id
|
||||||
|
|
||||||
validates_presence_of :name, :on => :save
|
validates_presence_of :name
|
||||||
validates_length_of :name, :maximum => 255
|
validates_length_of :name, :maximum => 255
|
||||||
validate :validate_query_filters
|
validate :validate_query_filters
|
||||||
|
|
||||||
@@ -126,8 +126,8 @@ class Query < ActiveRecord::Base
|
|||||||
:list_subprojects => [ "*", "!*", "=" ],
|
:list_subprojects => [ "*", "!*", "=" ],
|
||||||
:date => [ "=", ">=", "<=", "><", "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-", "!*", "*" ],
|
:date => [ "=", ">=", "<=", "><", "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-", "!*", "*" ],
|
||||||
:date_past => [ "=", ">=", "<=", "><", ">t-", "<t-", "t-", "t", "w", "!*", "*" ],
|
:date_past => [ "=", ">=", "<=", "><", ">t-", "<t-", "t-", "t", "w", "!*", "*" ],
|
||||||
:string => [ "=", "~", "!", "!~" ],
|
:string => [ "=", "~", "!", "!~", "!*", "*" ],
|
||||||
:text => [ "~", "!~" ],
|
:text => [ "~", "!~", "!*", "*" ],
|
||||||
:integer => [ "=", ">=", "<=", "><", "!*", "*" ],
|
:integer => [ "=", ">=", "<=", "><", "!*", "*" ],
|
||||||
:float => [ "=", ">=", "<=", "><", "!*", "*" ] }
|
:float => [ "=", ">=", "<=", "><", "!*", "*" ] }
|
||||||
|
|
||||||
@@ -163,13 +163,9 @@ class Query < ActiveRecord::Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def initialize(attributes = nil)
|
def initialize(attributes=nil, *args)
|
||||||
super attributes
|
super attributes
|
||||||
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
|
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
|
||||||
end
|
|
||||||
|
|
||||||
def after_initialize
|
|
||||||
# Store the fact that project is nil (used in #editable_by?)
|
|
||||||
@is_for_all = project.nil?
|
@is_for_all = project.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -178,20 +174,20 @@ class Query < ActiveRecord::Base
|
|||||||
if values_for(field)
|
if values_for(field)
|
||||||
case type_for(field)
|
case type_for(field)
|
||||||
when :integer
|
when :integer
|
||||||
errors.add(label_for(field), :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }
|
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }
|
||||||
when :float
|
when :float
|
||||||
errors.add(label_for(field), :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+(\.\d*)?$/) }
|
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+(\.\d*)?$/) }
|
||||||
when :date, :date_past
|
when :date, :date_past
|
||||||
case operator_for(field)
|
case operator_for(field)
|
||||||
when "=", ">=", "<=", "><"
|
when "=", ">=", "<=", "><"
|
||||||
errors.add(label_for(field), :invalid) if values_for(field).detect {|v| v.present? && (!v.match(/^\d{4}-\d{2}-\d{2}$/) || (Date.parse(v) rescue nil).nil?) }
|
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && (!v.match(/^\d{4}-\d{2}-\d{2}$/) || (Date.parse(v) rescue nil).nil?) }
|
||||||
when ">t-", "<t-", "t-"
|
when ">t-", "<t-", "t-"
|
||||||
errors.add(label_for(field), :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }
|
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
errors.add label_for(field), :blank unless
|
add_filter_error(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
|
||||||
@@ -199,6 +195,11 @@ class Query < ActiveRecord::Base
|
|||||||
end if filters
|
end if filters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_filter_error(field, message)
|
||||||
|
m = label_for(field) + " " + l(message, :scope => 'activerecord.errors.messages')
|
||||||
|
errors.add(:base, m)
|
||||||
|
end
|
||||||
|
|
||||||
# Returns true if the query is visible to +user+ or the current user.
|
# Returns true if the query is visible to +user+ or the current user.
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
(project.nil? || user.allowed_to?(:view_issues, project)) && (self.is_public? || self.user_id == user.id)
|
(project.nil? || user.allowed_to?(:view_issues, project)) && (self.is_public? || self.user_id == user.id)
|
||||||
@@ -231,14 +232,24 @@ class Query < ActiveRecord::Base
|
|||||||
principals = []
|
principals = []
|
||||||
if project
|
if project
|
||||||
principals += project.principals.sort
|
principals += project.principals.sort
|
||||||
|
unless project.leaf?
|
||||||
|
subprojects = project.descendants.visible.all
|
||||||
|
if subprojects.any?
|
||||||
|
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => subprojects.collect{|s| [s.name, s.id.to_s] } }
|
||||||
|
principals += Principal.member_of(subprojects)
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
all_projects = Project.visible.all
|
all_projects = Project.visible.all
|
||||||
if all_projects.any?
|
if all_projects.any?
|
||||||
# members of visible projects
|
# members of visible projects
|
||||||
principals += Principal.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", all_projects.collect(&:id)]).sort
|
principals += Principal.member_of(all_projects)
|
||||||
|
|
||||||
# project filter
|
# project filter
|
||||||
project_values = []
|
project_values = []
|
||||||
|
if User.current.logged? && User.current.memberships.any?
|
||||||
|
project_values << ["<< #{l(:label_my_projects).downcase} >>", "mine"]
|
||||||
|
end
|
||||||
Project.project_tree(all_projects) do |p, level|
|
Project.project_tree(all_projects) do |p, level|
|
||||||
prefix = (level > 0 ? ('--' * level + ' ') : '')
|
prefix = (level > 0 ? ('--' * level + ' ') : '')
|
||||||
project_values << ["#{prefix}#{p.name}", p.id.to_s]
|
project_values << ["#{prefix}#{p.name}", p.id.to_s]
|
||||||
@@ -246,6 +257,8 @@ class Query < ActiveRecord::Base
|
|||||||
@available_filters["project_id"] = { :type => :list, :order => 1, :values => project_values} unless project_values.empty?
|
@available_filters["project_id"] = { :type => :list, :order => 1, :values => project_values} unless project_values.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
principals.uniq!
|
||||||
|
principals.sort!
|
||||||
users = principals.select {|p| p.is_a?(User)}
|
users = principals.select {|p| p.is_a?(User)}
|
||||||
|
|
||||||
assigned_to_values = []
|
assigned_to_values = []
|
||||||
@@ -278,12 +291,6 @@ class Query < ActiveRecord::Base
|
|||||||
unless versions.empty?
|
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] } }
|
@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.leaf?
|
|
||||||
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
|
|
||||||
add_custom_fields_filters(project.all_issue_custom_fields)
|
add_custom_fields_filters(project.all_issue_custom_fields)
|
||||||
else
|
else
|
||||||
# global filters for cross project issue list
|
# global filters for cross project issue list
|
||||||
@@ -351,16 +358,29 @@ class Query < ActiveRecord::Base
|
|||||||
|
|
||||||
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 ||= l("field_#{field.to_s.gsub(/_id$/, '')}", :default => field)
|
||||||
end
|
end
|
||||||
|
|
||||||
def available_columns
|
def available_columns
|
||||||
return @available_columns if @available_columns
|
return @available_columns if @available_columns
|
||||||
@available_columns = ::Query.available_columns
|
@available_columns = ::Query.available_columns.dup
|
||||||
@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) }
|
||||||
|
|
||||||
|
if User.current.allowed_to?(:view_time_entries, project, :global => true)
|
||||||
|
index = nil
|
||||||
|
@available_columns.each_with_index {|column, i| index = i if column.name == :estimated_hours}
|
||||||
|
index = (index ? index + 1 : -1)
|
||||||
|
# insert the column after estimated_hours or at the end
|
||||||
|
@available_columns.insert index, QueryColumn.new(:spent_hours,
|
||||||
|
:sortable => "(SELECT COALESCE(SUM(hours), 0) FROM #{TimeEntry.table_name} WHERE #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id)",
|
||||||
|
:default_order => 'desc',
|
||||||
|
:caption => :label_spent_time
|
||||||
|
)
|
||||||
|
end
|
||||||
|
@available_columns
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.available_columns=(v)
|
def self.available_columns=(v)
|
||||||
@@ -412,7 +432,7 @@ class Query < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def has_column?(column)
|
def has_column?(column)
|
||||||
column_names && column_names.include?(column.name)
|
column_names && column_names.include?(column.is_a?(QueryColumn) ? column.name : column)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_default_columns?
|
def has_default_columns?
|
||||||
@@ -508,6 +528,12 @@ class Query < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if field == 'project_id'
|
||||||
|
if v.delete('mine')
|
||||||
|
v += User.current.memberships.map(&:project_id).map(&:to_s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if field =~ /^cf_(\d+)$/
|
if field =~ /^cf_(\d+)$/
|
||||||
# custom field
|
# custom field
|
||||||
filters_clauses << sql_for_custom_field(field, operator, v, $1)
|
filters_clauses << sql_for_custom_field(field, operator, v, $1)
|
||||||
@@ -561,12 +587,34 @@ class Query < ActiveRecord::Base
|
|||||||
|
|
||||||
joins = (order_option && order_option.include?('authors')) ? "LEFT OUTER JOIN users authors ON authors.id = #{Issue.table_name}.author_id" : nil
|
joins = (order_option && order_option.include?('authors')) ? "LEFT OUTER JOIN users authors ON authors.id = #{Issue.table_name}.author_id" : nil
|
||||||
|
|
||||||
Issue.visible.scoped(:conditions => options[:conditions]).find :all, :include => ([:status, :project] + (options[:include] || [])).uniq,
|
issues = Issue.visible.scoped(:conditions => options[:conditions]).find :all, :include => ([:status, :project] + (options[:include] || [])).uniq,
|
||||||
:conditions => statement,
|
:conditions => statement,
|
||||||
:order => order_option,
|
:order => order_option,
|
||||||
:joins => joins,
|
:joins => joins,
|
||||||
:limit => options[:limit],
|
:limit => options[:limit],
|
||||||
:offset => options[:offset]
|
:offset => options[:offset]
|
||||||
|
|
||||||
|
if has_column?(:spent_hours)
|
||||||
|
Issue.load_visible_spent_hours(issues)
|
||||||
|
end
|
||||||
|
issues
|
||||||
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
|
raise StatementInvalid.new(e.message)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns the issues ids
|
||||||
|
def issue_ids(options={})
|
||||||
|
order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
|
||||||
|
order_option = nil if order_option.blank?
|
||||||
|
|
||||||
|
joins = (order_option && order_option.include?('authors')) ? "LEFT OUTER JOIN users authors ON authors.id = #{Issue.table_name}.author_id" : nil
|
||||||
|
|
||||||
|
Issue.visible.scoped(:conditions => options[:conditions]).scoped(:include => ([:status, :project] + (options[:include] || [])).uniq,
|
||||||
|
:conditions => statement,
|
||||||
|
:order => order_option,
|
||||||
|
:joins => joins,
|
||||||
|
:limit => options[:limit],
|
||||||
|
:offset => options[:offset]).find_ids
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
@@ -643,7 +691,19 @@ class Query < ActiveRecord::Base
|
|||||||
def sql_for_custom_field(field, operator, value, custom_field_id)
|
def sql_for_custom_field(field, operator, value, custom_field_id)
|
||||||
db_table = CustomValue.table_name
|
db_table = CustomValue.table_name
|
||||||
db_field = 'value'
|
db_field = 'value'
|
||||||
"#{Issue.table_name}.id IN (SELECT #{Issue.table_name}.id FROM #{Issue.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{custom_field_id} WHERE " +
|
filter = @available_filters[field]
|
||||||
|
if filter && filter[:format] == 'user'
|
||||||
|
if value.delete('me')
|
||||||
|
value.push User.current.id.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
not_in = nil
|
||||||
|
if operator == '!'
|
||||||
|
# Makes ! operator work for custom fields with multiple values
|
||||||
|
operator = '='
|
||||||
|
not_in = 'NOT'
|
||||||
|
end
|
||||||
|
"#{Issue.table_name}.id #{not_in} IN (SELECT #{Issue.table_name}.id FROM #{Issue.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{custom_field_id} WHERE " +
|
||||||
sql_for_field(field, operator, value, db_table, db_field, true) + ')'
|
sql_for_field(field, operator, value, db_table, db_field, true) + ')'
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -657,9 +717,17 @@ class Query < ActiveRecord::Base
|
|||||||
when :date, :date_past
|
when :date, :date_past
|
||||||
sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))
|
sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))
|
||||||
when :integer
|
when :integer
|
||||||
sql = "#{db_table}.#{db_field} = #{value.first.to_i}"
|
if is_custom_filter
|
||||||
|
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) = #{value.first.to_i})"
|
||||||
|
else
|
||||||
|
sql = "#{db_table}.#{db_field} = #{value.first.to_i}"
|
||||||
|
end
|
||||||
when :float
|
when :float
|
||||||
sql = "#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}"
|
if is_custom_filter
|
||||||
|
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})"
|
||||||
|
else
|
||||||
|
sql = "#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}"
|
||||||
|
end
|
||||||
else
|
else
|
||||||
sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
|
sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
|
||||||
end
|
end
|
||||||
@@ -685,7 +753,7 @@ class Query < ActiveRecord::Base
|
|||||||
sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)
|
sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)
|
||||||
else
|
else
|
||||||
if is_custom_filter
|
if is_custom_filter
|
||||||
sql = "CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_f}"
|
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_f})"
|
||||||
else
|
else
|
||||||
sql = "#{db_table}.#{db_field} >= #{value.first.to_f}"
|
sql = "#{db_table}.#{db_field} >= #{value.first.to_f}"
|
||||||
end
|
end
|
||||||
@@ -695,7 +763,7 @@ class Query < ActiveRecord::Base
|
|||||||
sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))
|
sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))
|
||||||
else
|
else
|
||||||
if is_custom_filter
|
if is_custom_filter
|
||||||
sql = "CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_f}"
|
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_f})"
|
||||||
else
|
else
|
||||||
sql = "#{db_table}.#{db_field} <= #{value.first.to_f}"
|
sql = "#{db_table}.#{db_field} <= #{value.first.to_f}"
|
||||||
end
|
end
|
||||||
@@ -705,15 +773,15 @@ class Query < ActiveRecord::Base
|
|||||||
sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))
|
sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))
|
||||||
else
|
else
|
||||||
if is_custom_filter
|
if is_custom_filter
|
||||||
sql = "CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f}"
|
sql = "(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})"
|
||||||
else
|
else
|
||||||
sql = "#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}"
|
sql = "#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
when "o"
|
when "o"
|
||||||
sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id"
|
sql = "#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})" if field == "status_id"
|
||||||
when "c"
|
when "c"
|
||||||
sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id"
|
sql = "#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})" if field == "status_id"
|
||||||
when ">t-"
|
when ">t-"
|
||||||
sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)
|
sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)
|
||||||
when "<t-"
|
when "<t-"
|
||||||
@@ -763,11 +831,15 @@ class Query < ActiveRecord::Base
|
|||||||
options = { :type => :float, :order => 20 }
|
options = { :type => :float, :order => 20 }
|
||||||
when "user", "version"
|
when "user", "version"
|
||||||
next unless project
|
next unless project
|
||||||
options = { :type => :list_optional, :values => field.possible_values_options(project), :order => 20}
|
values = field.possible_values_options(project)
|
||||||
|
if User.current.logged? && field.field_format == 'user'
|
||||||
|
values.unshift ["<< #{l(:label_me)} >>", "me"]
|
||||||
|
end
|
||||||
|
options = { :type => :list_optional, :values => values, :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, :format => field.field_format })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+105
-11
@@ -26,11 +26,19 @@ class Repository < ActiveRecord::Base
|
|||||||
|
|
||||||
serialize :extra_info
|
serialize :extra_info
|
||||||
|
|
||||||
|
before_save :check_default
|
||||||
|
|
||||||
# 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
|
validates_length_of :password, :maximum => 255, :allow_nil => true
|
||||||
|
validates_length_of :identifier, :maximum => 255, :allow_blank => true
|
||||||
|
validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
|
||||||
|
validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
|
||||||
|
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
|
||||||
|
# donwcase letters, digits, dashes but not digits only
|
||||||
|
validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-]*$/, :allow_blank => true
|
||||||
# Checks if the SCM is enabled when creating a repository
|
# Checks if the SCM is enabled when creating a repository
|
||||||
validate :repo_create_validation, :on => :create
|
validate :repo_create_validation, :on => :create
|
||||||
|
|
||||||
@@ -40,12 +48,34 @@ class Repository < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.human_attribute_name(attribute_key_name)
|
def self.human_attribute_name(attribute_key_name, *args)
|
||||||
attr_name = attribute_key_name
|
attr_name = attribute_key_name.to_s
|
||||||
if attr_name == "log_encoding"
|
if attr_name == "log_encoding"
|
||||||
attr_name = "commit_logs_encoding"
|
attr_name = "commit_logs_encoding"
|
||||||
end
|
end
|
||||||
super(attr_name)
|
super(attr_name, *args)
|
||||||
|
end
|
||||||
|
|
||||||
|
alias :attributes_without_extra_info= :attributes=
|
||||||
|
def attributes=(new_attributes, guard_protected_attributes = true)
|
||||||
|
return if new_attributes.nil?
|
||||||
|
attributes = new_attributes.dup
|
||||||
|
attributes.stringify_keys!
|
||||||
|
|
||||||
|
p = {}
|
||||||
|
p_extra = {}
|
||||||
|
attributes.each do |k, v|
|
||||||
|
if k =~ /^extra_/
|
||||||
|
p_extra[k] = v
|
||||||
|
else
|
||||||
|
p[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
send :attributes_without_extra_info=, p, guard_protected_attributes
|
||||||
|
if p_extra.keys.any?
|
||||||
|
merge_extra_info(p_extra)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Removes leading and trailing whitespace
|
# Removes leading and trailing whitespace
|
||||||
@@ -71,9 +101,13 @@ class Repository < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def scm
|
def scm
|
||||||
@scm ||= self.scm_adapter.new(url, root_url,
|
unless @scm
|
||||||
|
@scm = self.scm_adapter.new(url, root_url,
|
||||||
login, password, path_encoding)
|
login, password, path_encoding)
|
||||||
update_attribute(:root_url, @scm.root_url) if root_url.blank?
|
if root_url.blank? && @scm.root_url.present?
|
||||||
|
update_attribute(:root_url, @scm.root_url)
|
||||||
|
end
|
||||||
|
end
|
||||||
@scm
|
@scm
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -81,6 +115,44 @@ class Repository < ActiveRecord::Base
|
|||||||
self.class.scm_name
|
self.class.scm_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def name
|
||||||
|
if identifier.present?
|
||||||
|
identifier
|
||||||
|
elsif is_default?
|
||||||
|
l(:field_repository_is_default)
|
||||||
|
else
|
||||||
|
scm_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def identifier_param
|
||||||
|
if is_default?
|
||||||
|
nil
|
||||||
|
elsif identifier.present?
|
||||||
|
identifier
|
||||||
|
else
|
||||||
|
id.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def <=>(repository)
|
||||||
|
if is_default?
|
||||||
|
-1
|
||||||
|
elsif repository.is_default?
|
||||||
|
1
|
||||||
|
else
|
||||||
|
identifier.to_s <=> repository.identifier.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.find_by_identifier_param(param)
|
||||||
|
if param.to_s =~ /^\d+$/
|
||||||
|
find_by_id(param)
|
||||||
|
else
|
||||||
|
find_by_identifier(param)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def merge_extra_info(arg)
|
def merge_extra_info(arg)
|
||||||
h = extra_info || {}
|
h = extra_info || {}
|
||||||
return h if arg.nil?
|
return h if arg.nil?
|
||||||
@@ -159,8 +231,9 @@ class Repository < ActiveRecord::Base
|
|||||||
# 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)
|
||||||
return nil if name.blank?
|
return nil if name.blank?
|
||||||
changesets.find(:first, :conditions => (name.match(/^\d*$/) ?
|
s = name.to_s
|
||||||
["revision = ?", name.to_s] : ["revision LIKE ?", name + '%']))
|
changesets.find(:first, :conditions => (s.match(/^\d*$/) ?
|
||||||
|
["revision = ?", s] : ["revision LIKE ?", s + '%']))
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest_changeset
|
def latest_changeset
|
||||||
@@ -249,10 +322,10 @@ class Repository < ActiveRecord::Base
|
|||||||
# 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).all.each do |project|
|
||||||
if project.repository
|
project.repositories.each do |repository|
|
||||||
begin
|
begin
|
||||||
project.repository.fetch_changesets
|
repository.fetch_changesets
|
||||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||||
logger.error "scm: error during fetching changesets: #{e.message}"
|
logger.error "scm: error during fetching changesets: #{e.message}"
|
||||||
end
|
end
|
||||||
@@ -314,12 +387,33 @@ class Repository < ActiveRecord::Base
|
|||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_as_default?
|
||||||
|
new_record? && project && !Repository.first(:conditions => {:project_id => project.id})
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def check_default
|
||||||
|
if !is_default? && set_as_default?
|
||||||
|
self.is_default = true
|
||||||
|
end
|
||||||
|
if is_default? && is_default_changed?
|
||||||
|
Repository.update_all(["is_default = ?", false], ["project_id = ?", project_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# Deletes repository data
|
||||||
def clear_changesets
|
def clear_changesets
|
||||||
cs, ch, ci = Changeset.table_name, Change.table_name, "#{table_name_prefix}changesets_issues#{table_name_suffix}"
|
cs = Changeset.table_name
|
||||||
|
ch = Change.table_name
|
||||||
|
ci = "#{table_name_prefix}changesets_issues#{table_name_suffix}"
|
||||||
|
cp = "#{table_name_prefix}changeset_parents#{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})")
|
||||||
connection.delete("DELETE FROM #{ci} WHERE #{ci}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
connection.delete("DELETE FROM #{ci} WHERE #{ci}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
||||||
|
connection.delete("DELETE FROM #{cp} WHERE #{cp}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
||||||
connection.delete("DELETE FROM #{cs} WHERE #{cs}.repository_id = #{id}")
|
connection.delete("DELETE FROM #{cs} WHERE #{cs}.repository_id = #{id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ class Repository::Bazaar < Repository
|
|||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url, :log_encoding
|
validates_presence_of :url, :log_encoding
|
||||||
|
|
||||||
def self.human_attribute_name(attribute_key_name)
|
def self.human_attribute_name(attribute_key_name, *args)
|
||||||
attr_name = attribute_key_name
|
attr_name = attribute_key_name.to_s
|
||||||
if attr_name == "url"
|
if attr_name == "url"
|
||||||
attr_name = "path_to_repository"
|
attr_name = "path_to_repository"
|
||||||
end
|
end
|
||||||
super(attr_name)
|
super(attr_name, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_adapter_class
|
def self.scm_adapter_class
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ require 'digest/sha1'
|
|||||||
class Repository::Cvs < Repository
|
class Repository::Cvs < Repository
|
||||||
validates_presence_of :url, :root_url, :log_encoding
|
validates_presence_of :url, :root_url, :log_encoding
|
||||||
|
|
||||||
def self.human_attribute_name(attribute_key_name)
|
def self.human_attribute_name(attribute_key_name, *args)
|
||||||
attr_name = attribute_key_name
|
attr_name = attribute_key_name.to_s
|
||||||
if attr_name == "root_url"
|
if attr_name == "root_url"
|
||||||
attr_name = "cvsroot"
|
attr_name = "cvsroot"
|
||||||
elsif attr_name == "url"
|
elsif attr_name == "url"
|
||||||
attr_name = "cvs_module"
|
attr_name = "cvs_module"
|
||||||
end
|
end
|
||||||
super(attr_name)
|
super(attr_name, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_adapter_class
|
def self.scm_adapter_class
|
||||||
@@ -181,10 +181,9 @@ class Repository::Cvs < Repository
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Renumber new changesets in chronological order
|
# Renumber new changesets in chronological order
|
||||||
changesets.find(
|
Changeset.all(
|
||||||
:all,
|
|
||||||
:order => 'committed_on ASC, id ASC',
|
:order => 'committed_on ASC, id ASC',
|
||||||
:conditions => "revision LIKE 'tmp%'"
|
:conditions => ["repository_id = ? AND revision LIKE 'tmp%'", id]
|
||||||
).each do |changeset|
|
).each do |changeset|
|
||||||
changeset.update_attribute :revision, next_revision_number
|
changeset.update_attribute :revision, next_revision_number
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ require 'redmine/scm/adapters/darcs_adapter'
|
|||||||
class Repository::Darcs < Repository
|
class Repository::Darcs < Repository
|
||||||
validates_presence_of :url, :log_encoding
|
validates_presence_of :url, :log_encoding
|
||||||
|
|
||||||
def self.human_attribute_name(attribute_key_name)
|
def self.human_attribute_name(attribute_key_name, *args)
|
||||||
attr_name = attribute_key_name
|
attr_name = attribute_key_name.to_s
|
||||||
if attr_name == "url"
|
if attr_name == "url"
|
||||||
attr_name = "path_to_repository"
|
attr_name = "path_to_repository"
|
||||||
end
|
end
|
||||||
super(attr_name)
|
super(attr_name, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_adapter_class
|
def self.scm_adapter_class
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ class Repository::Filesystem < Repository
|
|||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
|
|
||||||
def self.human_attribute_name(attribute_key_name)
|
def self.human_attribute_name(attribute_key_name, *args)
|
||||||
attr_name = attribute_key_name
|
attr_name = attribute_key_name.to_s
|
||||||
if attr_name == "url"
|
if attr_name == "url"
|
||||||
attr_name = "root_directory"
|
attr_name = "root_directory"
|
||||||
end
|
end
|
||||||
super(attr_name)
|
super(attr_name, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_adapter_class
|
def self.scm_adapter_class
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
# Copyright (C) 2006-2012 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
|
||||||
@@ -22,12 +22,12 @@ class Repository::Git < Repository
|
|||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
|
|
||||||
def self.human_attribute_name(attribute_key_name)
|
def self.human_attribute_name(attribute_key_name, *args)
|
||||||
attr_name = attribute_key_name
|
attr_name = attribute_key_name.to_s
|
||||||
if attr_name == "url"
|
if attr_name == "url"
|
||||||
attr_name = "path_to_repository"
|
attr_name = "path_to_repository"
|
||||||
end
|
end
|
||||||
super(attr_name)
|
super(attr_name, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_adapter_class
|
def self.scm_adapter_class
|
||||||
@@ -103,12 +103,11 @@ class Repository::Git < Repository
|
|||||||
# such as Subversion and Mercurial,
|
# such as Subversion and Mercurial,
|
||||||
# Redmine is able to be clever and only fetch changesets
|
# Redmine is able to be clever and only fetch changesets
|
||||||
# going forward from the most recent one it knows about.
|
# going forward from the most recent one it knows about.
|
||||||
#
|
#
|
||||||
# However, Git does not have a sequential commit numbering.
|
# However, Git does not have a sequential commit numbering.
|
||||||
#
|
#
|
||||||
# In order to fetch only new adding revisions,
|
# In order to fetch only new adding revisions,
|
||||||
# Redmine needs to parse revisions per branch.
|
# Redmine needs to save "heads".
|
||||||
# Branch "last_scmid" is for this requirement.
|
|
||||||
#
|
#
|
||||||
# In Git and Mercurial, revisions are not in date order.
|
# In Git and Mercurial, revisions are not in date order.
|
||||||
# Redmine Mercurial fixed issues.
|
# Redmine Mercurial fixed issues.
|
||||||
@@ -131,9 +130,17 @@ class Repository::Git < Repository
|
|||||||
def fetch_changesets
|
def fetch_changesets
|
||||||
scm_brs = branches
|
scm_brs = branches
|
||||||
return if scm_brs.nil? || scm_brs.empty?
|
return if scm_brs.nil? || scm_brs.empty?
|
||||||
|
|
||||||
h1 = extra_info || {}
|
h1 = extra_info || {}
|
||||||
h = h1.dup
|
h = h1.dup
|
||||||
h["branches"] ||= {}
|
repo_heads = scm_brs.map{ |br| br.scmid }
|
||||||
|
h["heads"] ||= []
|
||||||
|
prev_db_heads = h["heads"].dup
|
||||||
|
if prev_db_heads.empty?
|
||||||
|
prev_db_heads += heads_from_branches_hash
|
||||||
|
end
|
||||||
|
return if prev_db_heads.sort == repo_heads.sort
|
||||||
|
|
||||||
h["db_consistent"] ||= {}
|
h["db_consistent"] ||= {}
|
||||||
if changesets.count == 0
|
if changesets.count == 0
|
||||||
h["db_consistent"]["ordering"] = 1
|
h["db_consistent"]["ordering"] = 1
|
||||||
@@ -144,51 +151,97 @@ class Repository::Git < Repository
|
|||||||
merge_extra_info(h)
|
merge_extra_info(h)
|
||||||
self.save
|
self.save
|
||||||
end
|
end
|
||||||
scm_brs.each do |br1|
|
save_revisions(prev_db_heads, repo_heads)
|
||||||
br = br1.to_s
|
|
||||||
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?
|
|
||||||
db_saved_rev = save_revision(rev)
|
|
||||||
parents = {}
|
|
||||||
parents[db_saved_rev] = rev.parents unless rev.parents.nil?
|
|
||||||
parents.each do |ch, chparents|
|
|
||||||
ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
|
|
||||||
end
|
|
||||||
end
|
|
||||||
h["branches"][br]["last_scmid"] = rev.scmid
|
|
||||||
merge_extra_info(h)
|
|
||||||
self.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def save_revisions(prev_db_heads, repo_heads)
|
||||||
|
h = {}
|
||||||
|
opts = {}
|
||||||
|
opts[:reverse] = true
|
||||||
|
opts[:excludes] = prev_db_heads
|
||||||
|
opts[:includes] = repo_heads
|
||||||
|
|
||||||
|
revisions = scm.revisions('', nil, nil, opts)
|
||||||
|
return if revisions.blank?
|
||||||
|
|
||||||
|
# Make the search for existing revisions in the database in a more sufficient manner
|
||||||
|
#
|
||||||
|
# Git branch is the reference to the specific revision.
|
||||||
|
# Git can *delete* remote branch and *re-push* branch.
|
||||||
|
#
|
||||||
|
# $ git push remote :branch
|
||||||
|
# $ git push remote branch
|
||||||
|
#
|
||||||
|
# After deleting branch, revisions remain in repository until "git gc".
|
||||||
|
# On git 1.7.2.3, default pruning date is 2 weeks.
|
||||||
|
# So, "git log --not deleted_branch_head_revision" return code is 0.
|
||||||
|
#
|
||||||
|
# After re-pushing branch, "git log" returns revisions which are saved in database.
|
||||||
|
# So, Redmine needs to scan revisions and database every time.
|
||||||
|
#
|
||||||
|
# This is replacing the one-after-one queries.
|
||||||
|
# Find all revisions, that are in the database, and then remove them from the revision array.
|
||||||
|
# Then later we won't need any conditions for db existence.
|
||||||
|
# Query for several revisions at once, and remove them from the revisions array, if they are there.
|
||||||
|
# Do this in chunks, to avoid eventual memory problems (in case of tens of thousands of commits).
|
||||||
|
# If there are no revisions (because the original code's algorithm filtered them),
|
||||||
|
# then this part will be stepped over.
|
||||||
|
# We make queries, just if there is any revision.
|
||||||
|
limit = 100
|
||||||
|
offset = 0
|
||||||
|
revisions_copy = revisions.clone # revisions will change
|
||||||
|
while offset < revisions_copy.size
|
||||||
|
recent_changesets_slice = changesets.find(
|
||||||
|
:all,
|
||||||
|
:conditions => [
|
||||||
|
'scmid IN (?)',
|
||||||
|
revisions_copy.slice(offset, limit).map{|x| x.scmid}
|
||||||
|
]
|
||||||
|
)
|
||||||
|
# Subtract revisions that redmine already knows about
|
||||||
|
recent_revisions = recent_changesets_slice.map{|c| c.scmid}
|
||||||
|
revisions.reject!{|r| recent_revisions.include?(r.scmid)}
|
||||||
|
offset += limit
|
||||||
|
end
|
||||||
|
|
||||||
|
revisions.each do |rev|
|
||||||
|
transaction do
|
||||||
|
# There is no search in the db for this revision, because above we ensured,
|
||||||
|
# that it's not in the db.
|
||||||
|
save_revision(rev)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
h["heads"] = repo_heads.dup
|
||||||
|
merge_extra_info(h)
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
private :save_revisions
|
||||||
|
|
||||||
def save_revision(rev)
|
def save_revision(rev)
|
||||||
changeset = Changeset.new(
|
parents = (rev.parents || []).collect{|rp| find_changeset_by_name(rp)}.compact
|
||||||
|
changeset = Changeset.create(
|
||||||
:repository => self,
|
:repository => self,
|
||||||
:revision => rev.identifier,
|
:revision => rev.identifier,
|
||||||
:scmid => rev.scmid,
|
:scmid => rev.scmid,
|
||||||
:committer => rev.author,
|
:committer => rev.author,
|
||||||
:committed_on => rev.time,
|
:committed_on => rev.time,
|
||||||
:comments => rev.message
|
:comments => rev.message,
|
||||||
|
:parents => parents
|
||||||
)
|
)
|
||||||
if changeset.save
|
unless changeset.new_record?
|
||||||
rev.paths.each do |file|
|
rev.paths.each { |change| changeset.create_change(change) }
|
||||||
Change.create(
|
|
||||||
:changeset => changeset,
|
|
||||||
:action => file[:action],
|
|
||||||
:path => file[:path])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
changeset
|
changeset
|
||||||
end
|
end
|
||||||
private :save_revision
|
private :save_revision
|
||||||
|
|
||||||
|
def heads_from_branches_hash
|
||||||
|
h1 = extra_info || {}
|
||||||
|
h = h1.dup
|
||||||
|
h["branches"] ||= {}
|
||||||
|
h['branches'].map{|br, hs| hs['last_scmid']}
|
||||||
|
end
|
||||||
|
|
||||||
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?
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ class Repository::Mercurial < Repository
|
|||||||
# number of changesets to fetch at once
|
# number of changesets to fetch at once
|
||||||
FETCH_AT_ONCE = 100
|
FETCH_AT_ONCE = 100
|
||||||
|
|
||||||
def self.human_attribute_name(attribute_key_name)
|
def self.human_attribute_name(attribute_key_name, *args)
|
||||||
attr_name = attribute_key_name
|
attr_name = attribute_key_name.to_s
|
||||||
if attr_name == "url"
|
if attr_name == "url"
|
||||||
attr_name = "path_to_repository"
|
attr_name = "path_to_repository"
|
||||||
end
|
end
|
||||||
super(attr_name)
|
super(attr_name, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.scm_adapter_class
|
def self.scm_adapter_class
|
||||||
@@ -73,14 +73,15 @@ class Repository::Mercurial < Repository
|
|||||||
|
|
||||||
# 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)
|
||||||
return nil if name.nil? || name.empty?
|
return nil if name.blank?
|
||||||
if /[^\d]/ =~ name or name.to_s.size > 8
|
s = name.to_s
|
||||||
e = changesets.find(:first, :conditions => ['scmid = ?', name.to_s])
|
if /[^\d]/ =~ s or s.size > 8
|
||||||
|
e = changesets.find(:first, :conditions => ['scmid = ?', s])
|
||||||
else
|
else
|
||||||
e = changesets.find(:first, :conditions => ['revision = ?', name.to_s])
|
e = changesets.find(:first, :conditions => ['revision = ?', s])
|
||||||
end
|
end
|
||||||
return e if e
|
return e if e
|
||||||
changesets.find(:first, :conditions => ['scmid LIKE ?', "#{name}%"]) # last ditch
|
changesets.find(:first, :conditions => ['scmid LIKE ?', "#{s}%"]) # last ditch
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the latest changesets for +path+; sorted by revision number
|
# Returns the latest changesets for +path+; sorted by revision number
|
||||||
@@ -137,19 +138,18 @@ class Repository::Mercurial < Repository
|
|||||||
|
|
||||||
logger.debug "Fetching changesets for repository #{url}" if logger
|
logger.debug "Fetching changesets for repository #{url}" if logger
|
||||||
(db_rev + 1).step(scm_rev, FETCH_AT_ONCE) do |i|
|
(db_rev + 1).step(scm_rev, FETCH_AT_ONCE) do |i|
|
||||||
transaction do
|
scm.each_revision('', i, [i + FETCH_AT_ONCE - 1, scm_rev].min) do |re|
|
||||||
scm.each_revision('', i, [i + FETCH_AT_ONCE - 1, scm_rev].min) do |re|
|
transaction do
|
||||||
|
parents = (re.parents || []).collect{|rp| find_changeset_by_name(rp)}.compact
|
||||||
cs = Changeset.create(:repository => self,
|
cs = Changeset.create(:repository => self,
|
||||||
:revision => re.revision,
|
:revision => re.revision,
|
||||||
:scmid => re.scmid,
|
:scmid => re.scmid,
|
||||||
:committer => re.author,
|
:committer => re.author,
|
||||||
:committed_on => re.time,
|
:committed_on => re.time,
|
||||||
:comments => re.message)
|
:comments => re.message,
|
||||||
re.paths.each { |e| cs.create_change(e) }
|
:parents => parents)
|
||||||
parents = {}
|
unless cs.new_record?
|
||||||
parents[cs] = re.parents unless re.parents.nil?
|
re.paths.each { |e| cs.create_change(e) }
|
||||||
parents.each do |ch, chparents|
|
|
||||||
ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Role < ActiveRecord::Base
|
|||||||
['own', :label_issues_visibility_own]
|
['own', :label_issues_visibility_own]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
named_scope :sorted, {:order => 'builtin, position'}
|
||||||
named_scope :givable, { :conditions => "builtin = 0", :order => 'position' }
|
named_scope :givable, { :conditions => "builtin = 0", :order => 'position' }
|
||||||
named_scope :builtin, lambda { |*args|
|
named_scope :builtin, lambda { |*args|
|
||||||
compare = 'not' if args.first == true
|
compare = 'not' if args.first == true
|
||||||
|
|||||||
@@ -169,6 +169,10 @@ private
|
|||||||
name = name.to_s
|
name = name.to_s
|
||||||
raise "There's no setting named #{name}" unless @@available_settings.has_key?(name)
|
raise "There's no setting named #{name}" unless @@available_settings.has_key?(name)
|
||||||
setting = find_by_name(name)
|
setting = find_by_name(name)
|
||||||
setting ||= new(:name => name, :value => @@available_settings[name]['default']) if @@available_settings.has_key? name
|
unless setting
|
||||||
|
setting = new(:name => name)
|
||||||
|
setting.value = @@available_settings[name]['default']
|
||||||
|
end
|
||||||
|
setting
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+33
-17
@@ -16,6 +16,7 @@
|
|||||||
# 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 TimeEntry < ActiveRecord::Base
|
class TimeEntry < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
# could have used polymorphic association
|
# could have used polymorphic association
|
||||||
# project association here allows easy loading of time entries at project level with one database trip
|
# project association here allows easy loading of time entries at project level with one database trip
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
@@ -45,8 +46,30 @@ class TimeEntry < ActiveRecord::Base
|
|||||||
:include => :project,
|
:include => :project,
|
||||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args)
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args)
|
||||||
}}
|
}}
|
||||||
|
named_scope :on_issue, lambda {|issue| {
|
||||||
|
:include => :issue,
|
||||||
|
:conditions => "#{Issue.table_name}.root_id = #{issue.root_id} AND #{Issue.table_name}.lft >= #{issue.lft} AND #{Issue.table_name}.rgt <= #{issue.rgt}"
|
||||||
|
}}
|
||||||
|
named_scope :on_project, lambda {|project, include_subprojects| {
|
||||||
|
:include => :project,
|
||||||
|
:conditions => project.project_condition(include_subprojects)
|
||||||
|
}}
|
||||||
|
named_scope :spent_between, lambda {|from, to|
|
||||||
|
if from && to
|
||||||
|
{:conditions => ["#{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", from, to]}
|
||||||
|
elsif from
|
||||||
|
{:conditions => ["#{TimeEntry.table_name}.spent_on >= ?", from]}
|
||||||
|
elsif to
|
||||||
|
{:conditions => ["#{TimeEntry.table_name}.spent_on <= ?", to]}
|
||||||
|
else
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
def after_initialize
|
safe_attributes 'hours', 'comments', 'issue_id', 'activity_id', 'spent_on', 'custom_field_values', 'custom_fields'
|
||||||
|
|
||||||
|
def initialize(attributes=nil, *args)
|
||||||
|
super
|
||||||
if new_record? && self.activity.nil?
|
if new_record? && self.activity.nil?
|
||||||
if default_activity = TimeEntryActivity.default
|
if default_activity = TimeEntryActivity.default
|
||||||
self.activity_id = default_activity.id
|
self.activity_id = default_activity.id
|
||||||
@@ -69,6 +92,15 @@ class TimeEntry < ActiveRecord::Base
|
|||||||
write_attribute :hours, (h.is_a?(String) ? (h.to_hours || h) : h)
|
write_attribute :hours, (h.is_a?(String) ? (h.to_hours || h) : h)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hours
|
||||||
|
h = read_attribute(:hours)
|
||||||
|
if h.is_a?(Float)
|
||||||
|
h.round(2)
|
||||||
|
else
|
||||||
|
h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# tyear, tmonth, tweek assigned where setting spent_on attributes
|
# tyear, tmonth, tweek assigned where setting spent_on attributes
|
||||||
# these attributes make time aggregations easier
|
# these attributes make time aggregations easier
|
||||||
def spent_on=(date)
|
def spent_on=(date)
|
||||||
@@ -85,20 +117,4 @@ class TimeEntry < ActiveRecord::Base
|
|||||||
def editable_by?(usr)
|
def editable_by?(usr)
|
||||||
(usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)
|
(usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.earilest_date_for_project(project=nil)
|
|
||||||
finder_conditions = ARCondition.new(Project.allowed_to_condition(User.current, :view_time_entries))
|
|
||||||
if project
|
|
||||||
finder_conditions << ["project_id IN (?)", project.hierarchy.collect(&:id)]
|
|
||||||
end
|
|
||||||
TimeEntry.minimum(:spent_on, :include => :project, :conditions => finder_conditions.conditions)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.latest_date_for_project(project=nil)
|
|
||||||
finder_conditions = ARCondition.new(Project.allowed_to_condition(User.current, :view_time_entries))
|
|
||||||
if project
|
|
||||||
finder_conditions << ["project_id IN (?)", project.hierarchy.collect(&:id)]
|
|
||||||
end
|
|
||||||
TimeEntry.maximum(:spent_on, :include => :project, :conditions => finder_conditions.conditions)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
+2
-2
@@ -34,12 +34,12 @@ class Token < ActiveRecord::Base
|
|||||||
|
|
||||||
# Delete all expired tokens
|
# Delete all expired tokens
|
||||||
def self.destroy_expired
|
def self.destroy_expired
|
||||||
Token.delete_all ["action <> 'feeds' AND created_on < ?", Time.now - @@validity_time]
|
Token.delete_all ["action NOT IN (?) AND created_on < ?", ['feeds', 'api'], Time.now - @@validity_time]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def self.generate_token_value
|
def self.generate_token_value
|
||||||
ActiveSupport::SecureRandom.hex(20)
|
Redmine::Utils.random_hex(20)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Removes obsolete tokens (same user and action)
|
# Removes obsolete tokens (same user and action)
|
||||||
|
|||||||
+50
-26
@@ -54,6 +54,8 @@ class User < Principal
|
|||||||
|
|
||||||
# Active non-anonymous users scope
|
# Active non-anonymous users scope
|
||||||
named_scope :active, :conditions => "#{User.table_name}.status = #{STATUS_ACTIVE}"
|
named_scope :active, :conditions => "#{User.table_name}.status = #{STATUS_ACTIVE}"
|
||||||
|
named_scope :logged, :conditions => "#{User.table_name}.status <> #{STATUS_ANONYMOUS}"
|
||||||
|
named_scope :status, lambda {|arg| arg.blank? ? {} : {:conditions => {:status => arg.to_i}} }
|
||||||
|
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
|
|
||||||
@@ -61,16 +63,19 @@ class User < Principal
|
|||||||
attr_accessor :last_before_login_on
|
attr_accessor :last_before_login_on
|
||||||
# Prevents unauthorized assignments
|
# Prevents unauthorized assignments
|
||||||
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
||||||
|
|
||||||
|
LOGIN_LENGTH_LIMIT = 60
|
||||||
|
MAIL_LENGTH_LIMIT = 60
|
||||||
|
|
||||||
validates_presence_of :login, :firstname, :lastname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
|
validates_presence_of :login, :firstname, :lastname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
|
||||||
validates_uniqueness_of :login, :if => Proc.new { |user| !user.login.blank? }, :case_sensitive => false
|
validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, :case_sensitive => false
|
||||||
validates_uniqueness_of :mail, :if => Proc.new { |user| !user.mail.blank? }, :case_sensitive => false
|
validates_uniqueness_of :mail, :if => Proc.new { |user| !user.mail.blank? }, :case_sensitive => false
|
||||||
# Login must contain lettres, numbers, underscores only
|
# Login must contain lettres, numbers, underscores only
|
||||||
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
|
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
|
||||||
validates_length_of :login, :maximum => 30
|
validates_length_of :login, :maximum => LOGIN_LENGTH_LIMIT
|
||||||
validates_length_of :firstname, :lastname, :maximum => 30
|
validates_length_of :firstname, :lastname, :maximum => 30
|
||||||
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_blank => true
|
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_blank => true
|
||||||
validates_length_of :mail, :maximum => 60, :allow_nil => true
|
validates_length_of :mail, :maximum => MAIL_LENGTH_LIMIT, :allow_nil => true
|
||||||
validates_confirmation_of :password, :allow_nil => true
|
validates_confirmation_of :password, :allow_nil => true
|
||||||
validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
|
validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
|
||||||
validate :validate_password_length
|
validate :validate_password_length
|
||||||
@@ -125,8 +130,11 @@ class User < Principal
|
|||||||
|
|
||||||
# Returns the user that matches provided login and password, or nil
|
# Returns the user that matches provided login and password, or nil
|
||||||
def self.try_to_login(login, password)
|
def self.try_to_login(login, password)
|
||||||
|
login = login.to_s
|
||||||
|
password = password.to_s
|
||||||
|
|
||||||
# Make sure no one can sign in with an empty password
|
# Make sure no one can sign in with an empty password
|
||||||
return nil if password.to_s.empty?
|
return nil if password.empty?
|
||||||
user = find_by_login(login)
|
user = find_by_login(login)
|
||||||
if user
|
if user
|
||||||
# user is already in local database
|
# user is already in local database
|
||||||
@@ -159,7 +167,7 @@ class User < Principal
|
|||||||
|
|
||||||
# Returns the user who matches the given autologin +key+ or nil
|
# Returns the user who matches the given autologin +key+ or nil
|
||||||
def self.try_to_autologin(key)
|
def self.try_to_autologin(key)
|
||||||
tokens = Token.find_all_by_action_and_value('autologin', key)
|
tokens = Token.find_all_by_action_and_value('autologin', key.to_s)
|
||||||
# Make sure there's only 1 token that matches the key
|
# Make sure there's only 1 token that matches the key
|
||||||
if tokens.size == 1
|
if tokens.size == 1
|
||||||
token = tokens.first
|
token = tokens.first
|
||||||
@@ -249,7 +257,7 @@ class User < Principal
|
|||||||
|
|
||||||
# Does the backend storage allow this user to change their password?
|
# Does the backend storage allow this user to change their password?
|
||||||
def change_password_allowed?
|
def change_password_allowed?
|
||||||
return true if auth_source_id.blank?
|
return true if auth_source.nil?
|
||||||
return auth_source.allow_password_changes?
|
return auth_source.allow_password_changes?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -279,14 +287,18 @@ class User < Principal
|
|||||||
|
|
||||||
# Return user's RSS key (a 40 chars long string), used to access feeds
|
# Return user's RSS key (a 40 chars long string), used to access feeds
|
||||||
def rss_key
|
def rss_key
|
||||||
token = self.rss_token || Token.create(:user => self, :action => 'feeds')
|
if rss_token.nil?
|
||||||
token.value
|
create_rss_token(:action => 'feeds')
|
||||||
|
end
|
||||||
|
rss_token.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return user's API key (a 40 chars long string), used to access the API
|
# Return user's API key (a 40 chars long string), used to access the API
|
||||||
def api_key
|
def api_key
|
||||||
token = self.api_token || self.create_api_token(:action => 'api')
|
if api_token.nil?
|
||||||
token.value
|
create_api_token(:action => 'api')
|
||||||
|
end
|
||||||
|
api_token.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return an array of project ids for which the user has explicitly turned mail notifications on
|
# Return an array of project ids for which the user has explicitly turned mail notifications on
|
||||||
@@ -319,22 +331,22 @@ class User < Principal
|
|||||||
# Find a user account by matching the exact login and then a case-insensitive
|
# Find a user account by matching the exact login and then a case-insensitive
|
||||||
# version. Exact matches will be given priority.
|
# version. Exact matches will be given priority.
|
||||||
def self.find_by_login(login)
|
def self.find_by_login(login)
|
||||||
# force string comparison to be case sensitive on MySQL
|
|
||||||
type_cast = (ActiveRecord::Base.connection.adapter_name == 'MySQL') ? 'BINARY' : ''
|
|
||||||
|
|
||||||
# First look for an exact match
|
# First look for an exact match
|
||||||
user = first(:conditions => ["#{type_cast} login = ?", login])
|
user = all(:conditions => {:login => login}).detect {|u| u.login == login}
|
||||||
# Fail over to case-insensitive if none was found
|
unless user
|
||||||
user ||= first(:conditions => ["#{type_cast} LOWER(login) = ?", login.to_s.downcase])
|
# Fail over to case-insensitive if none was found
|
||||||
|
user = first(:conditions => ["LOWER(login) = ?", login.to_s.downcase])
|
||||||
|
end
|
||||||
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_by_rss_key(key)
|
def self.find_by_rss_key(key)
|
||||||
token = Token.find_by_value(key)
|
token = Token.find_by_action_and_value('feeds', key.to_s)
|
||||||
token && token.user.active? ? token.user : nil
|
token && token.user.active? ? token.user : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_by_api_key(key)
|
def self.find_by_api_key(key)
|
||||||
token = Token.find_by_action_and_value('api', key)
|
token = Token.find_by_action_and_value('api', key.to_s)
|
||||||
token && token.user.active? ? token.user : nil
|
token && token.user.active? ? token.user : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -343,6 +355,11 @@ class User < Principal
|
|||||||
find(:first, :conditions => ["LOWER(mail) = ?", mail.to_s.downcase])
|
find(:first, :conditions => ["LOWER(mail) = ?", mail.to_s.downcase])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns true if the default admin account can no longer be used
|
||||||
|
def self.default_admin_account_changed?
|
||||||
|
!User.active.find_by_login("admin").try(:check_password?, "admin")
|
||||||
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
@@ -472,6 +489,12 @@ class User < Principal
|
|||||||
allowed_to?(action, nil, options.reverse_merge(:global => true), &block)
|
allowed_to?(action, nil, options.reverse_merge(:global => true), &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns true if the user is allowed to delete his own account
|
||||||
|
def own_account_deletable?
|
||||||
|
Setting.unsubscribe? &&
|
||||||
|
(!admin? || User.active.first(:conditions => ["admin = ? AND id <> ?", true, id]).present?)
|
||||||
|
end
|
||||||
|
|
||||||
safe_attributes 'login',
|
safe_attributes 'login',
|
||||||
'firstname',
|
'firstname',
|
||||||
'lastname',
|
'lastname',
|
||||||
@@ -499,7 +522,7 @@ class User < Principal
|
|||||||
true
|
true
|
||||||
when 'selected'
|
when 'selected'
|
||||||
# user receives notifications for created/assigned issues on unselected projects
|
# user receives notifications for created/assigned issues on unselected projects
|
||||||
if object.is_a?(Issue) && (object.author == self || is_or_belongs_to?(object.assigned_to))
|
if object.is_a?(Issue) && (object.author == self || is_or_belongs_to?(object.assigned_to) || is_or_belongs_to?(object.assigned_to_was))
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
@@ -507,13 +530,13 @@ class User < Principal
|
|||||||
when 'none'
|
when 'none'
|
||||||
false
|
false
|
||||||
when 'only_my_events'
|
when 'only_my_events'
|
||||||
if object.is_a?(Issue) && (object.author == self || is_or_belongs_to?(object.assigned_to))
|
if object.is_a?(Issue) && (object.author == self || is_or_belongs_to?(object.assigned_to) || is_or_belongs_to?(object.assigned_to_was))
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
when 'only_assigned'
|
when 'only_assigned'
|
||||||
if object.is_a?(Issue) && is_or_belongs_to?(object.assigned_to)
|
if object.is_a?(Issue) && (is_or_belongs_to?(object.assigned_to) || is_or_belongs_to?(object.assigned_to_was))
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
@@ -589,8 +612,8 @@ class User < Principal
|
|||||||
Message.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
|
Message.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
|
||||||
News.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
|
News.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
|
||||||
# Remove private queries and keep public ones
|
# Remove private queries and keep public ones
|
||||||
Query.delete_all ['user_id = ? AND is_public = ?', id, false]
|
::Query.delete_all ['user_id = ? AND is_public = ?', id, false]
|
||||||
Query.update_all ['user_id = ?', substitute.id], ['user_id = ?', id]
|
::Query.update_all ['user_id = ?', substitute.id], ['user_id = ?', id]
|
||||||
TimeEntry.update_all ['user_id = ?', substitute.id], ['user_id = ?', id]
|
TimeEntry.update_all ['user_id = ?', substitute.id], ['user_id = ?', id]
|
||||||
Token.delete_all ['user_id = ?', id]
|
Token.delete_all ['user_id = ?', id]
|
||||||
Watcher.delete_all ['user_id = ?', id]
|
Watcher.delete_all ['user_id = ?', id]
|
||||||
@@ -605,14 +628,15 @@ class User < Principal
|
|||||||
|
|
||||||
# Returns a 128bits random salt as a hex string (32 chars long)
|
# Returns a 128bits random salt as a hex string (32 chars long)
|
||||||
def self.generate_salt
|
def self.generate_salt
|
||||||
ActiveSupport::SecureRandom.hex(16)
|
Redmine::Utils.random_hex(16)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class AnonymousUser < User
|
class AnonymousUser < User
|
||||||
|
validate :validate_anonymous_uniqueness, :on => :create
|
||||||
|
|
||||||
def validate_on_create
|
def validate_anonymous_uniqueness
|
||||||
# There should be only one AnonymousUser in the database
|
# There should be only one AnonymousUser in the database
|
||||||
errors.add :base, 'An anonymous user already exists.' if AnonymousUser.find(:first)
|
errors.add :base, 'An anonymous user already exists.' if AnonymousUser.find(:first)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,14 +19,16 @@ class UserPreference < ActiveRecord::Base
|
|||||||
belongs_to :user
|
belongs_to :user
|
||||||
serialize :others
|
serialize :others
|
||||||
|
|
||||||
attr_protected :others
|
attr_protected :others, :user_id
|
||||||
|
|
||||||
def initialize(attributes = nil)
|
before_save :set_others_hash
|
||||||
|
|
||||||
|
def initialize(attributes=nil, *args)
|
||||||
super
|
super
|
||||||
self.others ||= {}
|
self.others ||= {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_save
|
def set_others_hash
|
||||||
self.others ||= {}
|
self.others ||= {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+34
-6
@@ -16,6 +16,7 @@
|
|||||||
# 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 Version < ActiveRecord::Base
|
class Version < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
after_update :update_issues_from_sharing_change
|
after_update :update_issues_from_sharing_change
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify
|
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify
|
||||||
@@ -38,6 +39,15 @@ class Version < ActiveRecord::Base
|
|||||||
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 => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
|
||||||
|
|
||||||
|
safe_attributes 'name',
|
||||||
|
'description',
|
||||||
|
'effective_date',
|
||||||
|
'due_date',
|
||||||
|
'wiki_page_title',
|
||||||
|
'status',
|
||||||
|
'sharing',
|
||||||
|
'custom_field_values'
|
||||||
|
|
||||||
# Returns true if +user+ or current user is allowed to view the version
|
# Returns true if +user+ or current user is allowed to view the version
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
user.allowed_to?(:view_issues, self.project)
|
user.allowed_to?(:view_issues, self.project)
|
||||||
@@ -68,7 +78,7 @@ class Version < ActiveRecord::Base
|
|||||||
|
|
||||||
# Returns the total reported time for this version
|
# Returns the total reported time for this version
|
||||||
def spent_hours
|
def spent_hours
|
||||||
@spent_hours ||= TimeEntry.sum(:hours, :include => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f
|
@spent_hours ||= TimeEntry.sum(:hours, :joins => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f
|
||||||
end
|
end
|
||||||
|
|
||||||
def closed?
|
def closed?
|
||||||
@@ -123,17 +133,20 @@ class Version < ActiveRecord::Base
|
|||||||
|
|
||||||
# Returns assigned issues count
|
# Returns assigned issues count
|
||||||
def issues_count
|
def issues_count
|
||||||
@issue_count ||= fixed_issues.count
|
load_issue_counts
|
||||||
|
@issue_count
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the total amount of open issues for this version.
|
# Returns the total amount of open issues for this version.
|
||||||
def open_issues_count
|
def open_issues_count
|
||||||
@open_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, false], :include => :status)
|
load_issue_counts
|
||||||
|
@open_issues_count
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the total amount of closed issues for this version.
|
# Returns the total amount of closed issues for this version.
|
||||||
def closed_issues_count
|
def closed_issues_count
|
||||||
@closed_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, true], :include => :status)
|
load_issue_counts
|
||||||
|
@closed_issues_count
|
||||||
end
|
end
|
||||||
|
|
||||||
def wiki_page
|
def wiki_page
|
||||||
@@ -194,6 +207,21 @@ class Version < ActiveRecord::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def load_issue_counts
|
||||||
|
unless @issue_count
|
||||||
|
@open_issues_count = 0
|
||||||
|
@closed_issues_count = 0
|
||||||
|
fixed_issues.count(:all, :group => :status).each do |status, count|
|
||||||
|
if status.is_closed?
|
||||||
|
@closed_issues_count += count
|
||||||
|
else
|
||||||
|
@open_issues_count += count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@issue_count = @open_issues_count + @closed_issues_count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Update the issue's fixed versions. Used if a version's sharing changes.
|
# Update the issue's fixed versions. Used if a version's sharing changes.
|
||||||
def update_issues_from_sharing_change
|
def update_issues_from_sharing_change
|
||||||
if sharing_changed?
|
if sharing_changed?
|
||||||
@@ -233,8 +261,8 @@ class Version < ActiveRecord::Base
|
|||||||
ratio = open ? 'done_ratio' : 100
|
ratio = open ? 'done_ratio' : 100
|
||||||
|
|
||||||
done = fixed_issues.sum("COALESCE(estimated_hours, #{estimated_average}) * #{ratio}",
|
done = fixed_issues.sum("COALESCE(estimated_hours, #{estimated_average}) * #{ratio}",
|
||||||
:include => :status,
|
:joins => :status,
|
||||||
:conditions => ["is_closed = ?", !open]).to_f
|
:conditions => ["#{IssueStatus.table_name}.is_closed = ?", !open]).to_f
|
||||||
progress = done / (estimated_average * issues_count)
|
progress = done / (estimated_average * issues_count)
|
||||||
end
|
end
|
||||||
progress
|
progress
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class Watcher < ActiveRecord::Base
|
|||||||
|
|
||||||
validates_presence_of :user
|
validates_presence_of :user
|
||||||
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
|
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
|
||||||
|
validate :validate_user
|
||||||
|
|
||||||
# Unwatch things that users are no longer allowed to view
|
# Unwatch things that users are no longer allowed to view
|
||||||
def self.prune(options={})
|
def self.prune(options={})
|
||||||
@@ -37,7 +38,7 @@ class Watcher < ActiveRecord::Base
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def validate
|
def validate_user
|
||||||
errors.add :user_id, :invalid unless user.nil? || user.active?
|
errors.add :user_id, :invalid unless user.nil? || user.active?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# 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 Wiki < ActiveRecord::Base
|
class Wiki < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
has_many :pages, :class_name => 'WikiPage', :dependent => :destroy, :order => 'title'
|
has_many :pages, :class_name => 'WikiPage', :dependent => :destroy, :order => 'title'
|
||||||
has_many :redirects, :class_name => 'WikiRedirect', :dependent => :delete_all
|
has_many :redirects, :class_name => 'WikiRedirect', :dependent => :delete_all
|
||||||
@@ -25,6 +26,8 @@ class Wiki < ActiveRecord::Base
|
|||||||
validates_presence_of :start_page
|
validates_presence_of :start_page
|
||||||
validates_format_of :start_page, :with => /^[^,\.\/\?\;\|\:]*$/
|
validates_format_of :start_page, :with => /^[^,\.\/\?\;\|\:]*$/
|
||||||
|
|
||||||
|
safe_attributes 'start_page'
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
!user.nil? && user.allowed_to?(:view_wiki_pages, project)
|
!user.nil? && user.allowed_to?(:view_wiki_pages, project)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# RedMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
# Copyright (C) 2006-2012 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
|
||||||
@@ -91,14 +91,16 @@ class WikiContent < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def text
|
def text
|
||||||
@text ||= case compression
|
@text ||= begin
|
||||||
when 'gzip'
|
str = case compression
|
||||||
str = Zlib::Inflate.inflate(data)
|
when 'gzip'
|
||||||
|
Zlib::Inflate.inflate(data)
|
||||||
|
else
|
||||||
|
# uncompressed data
|
||||||
|
data
|
||||||
|
end
|
||||||
str.force_encoding("UTF-8") if str.respond_to?(:force_encoding)
|
str.force_encoding("UTF-8") if str.respond_to?(:force_encoding)
|
||||||
str
|
str
|
||||||
else
|
|
||||||
# uncompressed data
|
|
||||||
data
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+11
-2
@@ -19,6 +19,8 @@ require 'diff'
|
|||||||
require 'enumerator'
|
require 'enumerator'
|
||||||
|
|
||||||
class WikiPage < ActiveRecord::Base
|
class WikiPage < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
belongs_to :wiki
|
belongs_to :wiki
|
||||||
has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy
|
has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy
|
||||||
acts_as_attachable :delete_permission => :delete_wiki_pages_attachments
|
acts_as_attachable :delete_permission => :delete_wiki_pages_attachments
|
||||||
@@ -55,7 +57,11 @@ class WikiPage < ActiveRecord::Base
|
|||||||
# Wiki pages that are protected by default
|
# Wiki pages that are protected by default
|
||||||
DEFAULT_PROTECTED_PAGES = %w(sidebar)
|
DEFAULT_PROTECTED_PAGES = %w(sidebar)
|
||||||
|
|
||||||
def after_initialize
|
safe_attributes 'parent_id',
|
||||||
|
:if => lambda {|page, user| page.new_record? || user.allowed_to?(:rename_wiki_pages, page.project)}
|
||||||
|
|
||||||
|
def initialize(attributes=nil, *args)
|
||||||
|
super
|
||||||
if new_record? && DEFAULT_PROTECTED_PAGES.include?(title.to_s.downcase)
|
if new_record? && DEFAULT_PROTECTED_PAGES.include?(title.to_s.downcase)
|
||||||
self.protected = true
|
self.protected = true
|
||||||
end
|
end
|
||||||
@@ -136,7 +142,10 @@ class WikiPage < ActiveRecord::Base
|
|||||||
unless @updated_on
|
unless @updated_on
|
||||||
if time = read_attribute(:updated_on)
|
if time = read_attribute(:updated_on)
|
||||||
# content updated_on was eager loaded with the page
|
# content updated_on was eager loaded with the page
|
||||||
@updated_on = Time.parse(time) rescue nil
|
begin
|
||||||
|
@updated_on = Time.zone ? Time.zone.parse(time.to_s) : Time.parse(time.to_s)
|
||||||
|
rescue
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@updated_on = content && content.updated_on
|
@updated_on = content && content.updated_on
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,17 +41,6 @@ class Workflow < ActiveRecord::Base
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find potential statuses the user could be allowed to switch issues to
|
|
||||||
def self.available_statuses(project, user=User.current)
|
|
||||||
Workflow.find(:all,
|
|
||||||
:include => :new_status,
|
|
||||||
:conditions => {:role_id => user.roles_for_project(project).collect(&:id)}).
|
|
||||||
collect(&:new_status).
|
|
||||||
compact.
|
|
||||||
uniq.
|
|
||||||
sort
|
|
||||||
end
|
|
||||||
|
|
||||||
# Copies workflows from source to targets
|
# Copies workflows from source to targets
|
||||||
def self.copy(source_tracker, source_role, target_trackers, target_roles)
|
def self.copy(source_tracker, source_role, target_trackers, target_roles)
|
||||||
unless source_tracker.is_a?(Tracker) || source_role.is_a?(Role)
|
unless source_tracker.is_a?(Tracker) || source_role.is_a?(Role)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
<% form_tag({:token => @token.value}) do %>
|
<% form_tag({:token => @token.value}) do %>
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
|
<p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
|
||||||
<%= password_field_tag 'new_password', nil, :size => 25 %><br />
|
<%= password_field_tag 'new_password', nil, :size => 25 %>
|
||||||
<em><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
|
<em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
|
||||||
|
|
||||||
<p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
|
<p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
|
||||||
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
|
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
|
||||||
|
|||||||
@@ -1,43 +1,30 @@
|
|||||||
<h2><%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h2>
|
<h2><%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h2>
|
||||||
|
|
||||||
<% form_tag({:action => 'register'}, :class => "tabular") do %>
|
<% labelled_form_for @user, :url => {:action => 'register'} do |f| %>
|
||||||
<%= error_messages_for 'user' %>
|
<%= error_messages_for 'user' %>
|
||||||
|
|
||||||
<div class="box">
|
<div class="box tabular">
|
||||||
<!--[form:user]-->
|
|
||||||
<% if @user.auth_source_id.nil? %>
|
<% if @user.auth_source_id.nil? %>
|
||||||
<p><label for="user_login"><%=l(:field_login)%> <span class="required">*</span></label>
|
<p><%= f.text_field :login, :size => 25, :required => true %></p>
|
||||||
<%= text_field 'user', 'login', :size => 25 %></p>
|
|
||||||
|
|
||||||
<p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
|
<p><%= f.password_field :password, :size => 25, :required => true %>
|
||||||
<%= password_field_tag 'password', nil, :size => 25 %><br />
|
<em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
|
||||||
<em><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
|
|
||||||
|
|
||||||
<p><label for="password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
|
<p><%= f.password_field :password_confirmation, :size => 25, :required => true %></p>
|
||||||
<%= password_field_tag 'password_confirmation', nil, :size => 25 %></p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<p><label for="user_firstname"><%=l(:field_firstname)%> <span class="required">*</span></label>
|
<p><%= f.text_field :firstname, :required => true %></p>
|
||||||
<%= text_field 'user', 'firstname' %></p>
|
<p><%= f.text_field :lastname, :required => true %></p>
|
||||||
|
<p><%= f.text_field :mail, :required => true %></p>
|
||||||
<p><label for="user_lastname"><%=l(:field_lastname)%> <span class="required">*</span></label>
|
<p><%= f.select :language, lang_options_for_select %></p>
|
||||||
<%= text_field 'user', 'lastname' %></p>
|
|
||||||
|
|
||||||
<p><label for="user_mail"><%=l(:field_mail)%> <span class="required">*</span></label>
|
|
||||||
<%= text_field 'user', 'mail' %></p>
|
|
||||||
|
|
||||||
<p><label for="user_language"><%=l(:field_language)%></label>
|
|
||||||
<%= select("user", "language", lang_options_for_select) %></p>
|
|
||||||
|
|
||||||
<% if Setting.openid? %>
|
<% if Setting.openid? %>
|
||||||
<p><label for="user_identity_url"><%=l(:field_identity_url)%></label>
|
<p><%= f.text_field :identity_url %></p>
|
||||||
<%= text_field 'user', 'identity_url' %></p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% @user.custom_field_values.select {|v| v.editable? || v.required?}.each do |value| %>
|
<% @user.custom_field_values.select {|v| v.editable? || v.required?}.each do |value| %>
|
||||||
<p><%= custom_field_tag_with_label :user, value %></p>
|
<p><%= custom_field_tag_with_label :user, value %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!--[eoform:user]-->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= submit_tag l(:button_submit) %>
|
<%= submit_tag l(:button_submit) %>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user