Compare commits
727 Commits
master
...
competitio
Author | SHA1 | Date |
---|---|---|
|
304effa8e4 | |
|
a2f14bc0b2 | |
|
e0cdcc0211 | |
|
5cb1683332 | |
|
801025d967 | |
|
54ed41e483 | |
|
a47b1eee47 | |
|
dec77da33c | |
|
c8e895ec74 | |
|
24a0f3e774 | |
|
c743f58104 | |
|
8fc9e65e66 | |
|
acfd8837bb | |
|
59fadeacf6 | |
|
bfb29ea14c | |
|
d8e04ae974 | |
|
e3a7d365ea | |
|
b50dac6a36 | |
|
dcde828e64 | |
|
3919d0fd48 | |
|
fbb19480f5 | |
|
2f1b6386f6 | |
|
c614734768 | |
|
e8cde5f1cd | |
|
4711e638eb | |
|
56a0ec336a | |
|
594d3364ac | |
|
bcb9e8688c | |
|
51b21000a7 | |
|
82b23da54b | |
|
bdeb2e5947 | |
|
19be668221 | |
|
c7caa08c70 | |
|
5afcb73624 | |
|
f0db3e1b4a | |
|
a77b07a99b | |
|
d256b2d336 | |
|
8e6ed35497 | |
|
060759774b | |
|
42285ce44d | |
|
97f8aedd13 | |
|
e1672fd0e0 | |
|
62aa1d0ed5 | |
|
c6b189a846 | |
|
79e83b9a85 | |
|
30cbbb5a2a | |
|
cb8b0e0f41 | |
|
eb5d1c9efe | |
|
e63be10680 | |
|
74ba4384b1 | |
|
ddc8da99e4 | |
|
d16b54a1ea | |
![]() |
9f3392eba8 | |
|
87f8e90f25 | |
|
51f1841d78 | |
|
0e84982203 | |
![]() |
4d583b08c7 | |
|
b1048074ef | |
|
5b85aa0961 | |
|
2be1ac0dbd | |
|
889af8be5f | |
|
afc5a05ed8 | |
|
38c5c86a39 | |
![]() |
9bcd06b315 | |
![]() |
37920d36c9 | |
|
7ec103e135 | |
|
c1da351ea0 | |
|
9f54df232b | |
![]() |
fa90219a52 | |
|
4998420410 | |
|
bbb38d381d | |
|
2a7b9025b6 | |
|
25affe30b0 | |
|
00b38dc792 | |
|
c046ad011c | |
|
fe14c1e427 | |
|
167a819a84 | |
|
08a6e9af1a | |
|
c6a19209f4 | |
|
d608d092da | |
|
969b8a2d3e | |
|
d1d2dd0e4b | |
|
9e419876a9 | |
|
f3807461d9 | |
|
e1e8942dc7 | |
|
b96a08a200 | |
|
27e15e6a9a | |
|
f41d3f8b6a | |
![]() |
e900e6d6fd | |
|
08cde8a142 | |
|
880f2057ac | |
|
9da85bb5a3 | |
|
273c932acf | |
|
74d98e9bac | |
|
0d93783764 | |
![]() |
6253f281bc | |
|
3279fda3e5 | |
|
b635a6b3c5 | |
|
589c6d37db | |
|
554d744929 | |
|
d2bd1cc261 | |
|
1498f5c20b | |
|
c4fff8a8ac | |
|
123353fd8f | |
![]() |
0635932187 | |
|
337ca5fb93 | |
|
9d23e6a8be | |
![]() |
aa4b8c2da9 | |
![]() |
b30bfd073c | |
|
85a95262fe | |
|
234a781342 | |
|
4e49da836e | |
|
644cfe6c21 | |
|
9ae553bace | |
|
5482ba3207 | |
|
38188804a1 | |
|
a690fd79cf | |
|
50e1f41345 | |
|
cbd3610bf4 | |
|
e303a3789a | |
|
e112bb2803 | |
|
16d86a1fbd | |
|
3343e1c413 | |
|
532cb23141 | |
|
3a2754eb27 | |
|
8932633b23 | |
|
142d413544 | |
|
a328a934c8 | |
![]() |
075b43f836 | |
![]() |
66dfa1ce4f | |
![]() |
cc08cdc140 | |
|
136c991060 | |
|
c13eeee56d | |
|
8f83c63c79 | |
|
9bd22b1b99 | |
|
86e377a228 | |
|
73537a30cb | |
![]() |
507235cd69 | |
![]() |
4c57136a1d | |
|
f396a45e1f | |
|
fae3c45920 | |
|
337f0ec270 | |
|
4905511060 | |
|
80bd535b4f | |
|
1e234a9adf | |
![]() |
a0a8868c24 | |
![]() |
5e600380c7 | |
![]() |
97707ea44a | |
|
7b00008721 | |
|
c042add122 | |
|
bfe0299d40 | |
![]() |
4252e52d1d | |
|
9039755fc5 | |
|
ed3e9e3a03 | |
|
5fb1b220e5 | |
|
e181f0ed4d | |
|
4ed9b13f0b | |
![]() |
3239ab12e9 | |
|
a7e066add8 | |
|
90e65825db | |
|
012791e44d | |
|
13becbefb2 | |
|
5a7aabd7cf | |
|
1cd00f55fb | |
|
13717dc3a3 | |
|
fac973db20 | |
|
7e00890667 | |
![]() |
ecae8d1f35 | |
![]() |
4f0817a146 | |
|
378c06379e | |
|
3d6ee127cb | |
|
f4fd1b1133 | |
![]() |
6b66a205b3 | |
|
c77a1fc2ef | |
|
a3fb08817c | |
|
2b12654796 | |
|
0d398fdc17 | |
|
9688a73aa1 | |
|
6f5df31d14 | |
|
12434e22c5 | |
|
4cea972e56 | |
|
8d03068ce2 | |
![]() |
fcaeb86687 | |
|
dfae970d1c | |
|
746022506d | |
|
ace256bea1 | |
|
bd56286b4e | |
|
a420a41b78 | |
|
e44ece80f6 | |
|
ae61ccaca9 | |
|
2b6a376d31 | |
|
19c5ebf450 | |
|
05ed41615e | |
|
33b5f821c4 | |
|
af869deb8e | |
|
7b14be7310 | |
|
e923fd1e5b | |
|
b92f385202 | |
|
5f559fcb67 | |
|
4a0f11dfce | |
|
20f183799f | |
|
4d870ca9e5 | |
|
9ac53e5a0b | |
|
46ba7f6a7b | |
|
fb50defbec | |
|
1b4b21fc19 | |
|
0215c96ec9 | |
|
2a831136ae | |
|
daeab7ef64 | |
|
36004913c6 | |
|
43cfcce44e | |
|
14a436a310 | |
|
445d29d036 | |
|
08115c9de4 | |
|
e18129c935 | |
|
d21bda87a7 | |
|
4acf5f3f06 | |
|
79c6722aad | |
|
f99543ab4b | |
|
87ada7c0d5 | |
|
86cb7d13d5 | |
|
3b87f86267 | |
|
027bd1ace6 | |
|
a4441bca37 | |
|
9d0f759a71 | |
|
22bbf45269 | |
|
df0c1e5917 | |
|
bd97356090 | |
|
e12a540061 | |
|
b8acd13f25 | |
|
361e48fea8 | |
|
8c59abc070 | |
|
440395f26f | |
|
e65487d527 | |
|
bc6ad5d416 | |
|
ce7d91d164 | |
|
a7e22a7379 | |
|
f2f06a9d28 | |
|
c833c4ac62 | |
|
14026d0e0b | |
|
88aa66b15b | |
|
4934c8c801 | |
|
a54676c583 | |
|
0e35967433 | |
|
582ccd2ecf | |
|
56aa2fb8dc | |
|
caed78327a | |
|
ef6f239182 | |
|
ecccbf1cf7 | |
|
0064018a37 | |
|
339a06007c | |
|
835ef97510 | |
|
7b3468718f | |
|
64f6175f22 | |
|
f6f1bddaff | |
|
50e172a25a | |
|
d7bfdc8de4 | |
|
b9ee7fe00d | |
|
0c597d23a2 | |
|
33855f721d | |
|
f7635370d7 | |
|
8724b79296 | |
|
8c6160f496 | |
|
e3ab21e409 | |
![]() |
044bba4d0d | |
![]() |
0028c11426 | |
|
ea0b7ef3f1 | |
|
6ab17a2bf7 | |
|
db826a71ff | |
|
6037421c7d | |
|
dd64f13e49 | |
|
006d1eac8f | |
|
87f6f81279 | |
|
f8c6b66119 | |
|
683cd9f918 | |
|
b5e8b12806 | |
![]() |
3d76b26e26 | |
![]() |
70a1839e74 | |
|
dbe8456fd5 | |
|
eac85b338f | |
![]() |
192bc8d89c | |
![]() |
cb4869fd20 | |
|
019a1d4cba | |
|
d9a9867f96 | |
|
f2f7dfaf12 | |
|
d087c52314 | |
![]() |
af683f917d | |
![]() |
5e8eda6a40 | |
![]() |
387d482059 | |
|
4c71af51f4 | |
|
f3fe5d918e | |
|
7179943f8b | |
|
78343effaf | |
|
08821b9391 | |
![]() |
b545c5034d | |
|
96fa28f70d | |
|
b0b3f257a4 | |
|
dac4042ee9 | |
|
722a568466 | |
|
56a06c4a04 | |
|
45cc3ddb9b | |
|
68a86c5e5d | |
|
eacc0fdf53 | |
|
34af8053cc | |
![]() |
0c00754057 | |
|
17e6f0ee4f | |
|
c6271e2aa9 | |
![]() |
f173db4c9d | |
|
a4199e4c54 | |
|
22335b23a6 | |
|
0eca547ec5 | |
![]() |
23c9d5381e | |
|
05186c8590 | |
|
1ca6447478 | |
![]() |
d8964d81a8 | |
|
b4be18ab9d | |
|
7907edf168 | |
|
c155ebdfd7 | |
|
fbe3e535b4 | |
![]() |
3862f857f7 | |
|
8b217735c3 | |
|
2c77d1b4cf | |
![]() |
65174ad8ef | |
![]() |
f8d7aeebac | |
|
226d19b912 | |
|
37e5bdee22 | |
|
8c8127c8d9 | |
|
426ea23d6e | |
|
5f3ab0322b | |
|
94f6e871b1 | |
|
8b3b1bdcfa | |
|
9cb026ed39 | |
|
80b2a2dc45 | |
|
653c505471 | |
|
209c1aeaab | |
|
69f7f97bf8 | |
![]() |
01ab676622 | |
![]() |
5a5ac28833 | |
|
25cfb7aa71 | |
|
ab2d92315e | |
|
ff02c4f9f2 | |
|
c5a7497910 | |
|
63cfa9b35a | |
|
c78047ae98 | |
|
acb41158e7 | |
|
204ced9490 | |
|
5a2d0ce649 | |
|
54a246b6e6 | |
|
0d46c63c54 | |
|
087105ad9e | |
|
aa0caff077 | |
|
9e5f7e6fc6 | |
|
2505cb30c4 | |
|
2ad51d7afe | |
![]() |
c1519984de | |
|
b8f27b51c0 | |
|
d66dc65cca | |
|
d5ac443f90 | |
|
8b80d99a70 | |
|
2c689b6399 | |
|
7b32debb92 | |
|
5564ca063b | |
|
a9fad79c8d | |
|
bb6be3ed8a | |
|
27feeee03f | |
|
8a9e2b47ad | |
|
a3cbcdad51 | |
|
f0cee20f11 | |
|
41d983e904 | |
|
321712bd94 | |
|
290d9b1973 | |
|
cb6c95c632 | |
|
31e8ad98ae | |
|
4dc2a23f9d | |
|
03b212e363 | |
|
1f4943483e | |
|
01ea6238a4 | |
|
281c48c0b3 | |
|
847bb35906 | |
|
583bdd7a54 | |
|
5800cf5fff | |
|
952fcce0de | |
|
c60188038e | |
|
28606f030d | |
|
c4aa9aadbe | |
|
b05e112a3f | |
|
3119d9a9aa | |
|
81b77bc870 | |
|
c1bbd8a535 | |
|
233f041cc5 | |
|
e7503237f1 | |
|
d8fcf8eb9b | |
|
225e3c396a | |
|
52dcc6d1a1 | |
|
d6876fabc1 | |
|
1156387161 | |
|
e344f16f5c | |
|
2141fcc3ca | |
|
9da116c0e3 | |
|
cb4efd914e | |
|
f18e828632 | |
|
bf9a992399 | |
|
0d0fb7052e | |
|
a39672dd14 | |
|
90a35fa24a | |
|
18ddb8604b | |
|
2c79a51e48 | |
|
9bf8abd03b | |
|
a4ecccc048 | |
|
1b589bf562 | |
|
74de064cca | |
|
a8ed4272cc | |
|
f8328727cd | |
|
dfdc58719a | |
|
1daec14ab5 | |
|
8871652e01 | |
|
cc215e6c7b | |
|
ef62fc1fac | |
|
f36ccad76a | |
|
9c9778d433 | |
|
979d6dd067 | |
|
983cdebbb6 | |
|
00cf448bda | |
|
4fae105b96 | |
|
f052d0d461 | |
|
1922593fee | |
|
a1e06991d5 | |
|
f8a59220e3 | |
|
97531960da | |
|
43efd63dda | |
|
758541250f | |
|
560ee0a2fc | |
|
b5b246f098 | |
|
c0ac9924e7 | |
|
2a4daf04f9 | |
|
ea322d6177 | |
|
1257e67380 | |
|
6531bf5195 | |
|
735d7f2c1f | |
|
2c08f39001 | |
|
d6a425849a | |
|
34626e03a4 | |
|
5a0d76c1e0 | |
|
673ffb1819 | |
|
2bfc7aa93f | |
|
70003c8374 | |
|
6d5f72326f | |
|
42f0c49093 | |
|
7eb1a76734 | |
|
138d90a887 | |
|
ca52de614d | |
|
3b54def1c7 | |
|
6ad3a1128e | |
|
f83336aed0 | |
|
4542b9e21a | |
|
6a14676248 | |
|
1755d7a790 | |
|
ec41054008 | |
|
37802e81de | |
|
0d7bedeb0d | |
|
8b0b31f749 | |
|
1b503f3b6d | |
|
0fc2e3be21 | |
|
d59ab02db8 | |
|
990dc3cbff | |
|
dd589c4811 | |
|
6b441760c4 | |
|
80b5871756 | |
|
f1a2effbd2 | |
|
9c3ff51633 | |
|
da05ce5d61 | |
|
9be52f6cf7 | |
|
fb6cd2e9d8 | |
|
0b6168c7fd | |
|
a7debdae98 | |
|
0a06e2033f | |
|
5d22bc5510 | |
|
ee95d9b115 | |
|
18d096f0d8 | |
|
cccbd941ce | |
|
f22a39fbfa | |
|
a5d829b95e | |
|
41ea3a1baf | |
|
dee09aad75 | |
|
8f74241eda | |
|
095cb7fc32 | |
|
c2ff861fba | |
|
47ae398748 | |
|
de17a84061 | |
|
42c2f6c2ee | |
|
7e0210dd9d | |
|
e5547b953e | |
|
3ba8ba010d | |
|
09f13409de | |
|
840a7b337b | |
|
d9b9b2152f | |
|
68be9c25b8 | |
|
58c3e98a21 | |
|
ab55043880 | |
|
87671e9d73 | |
|
5954ba1788 | |
|
cf11cac0ad | |
|
8496d6e0d2 | |
|
edee2b2327 | |
|
67dfd72845 | |
|
518edeac68 | |
|
513fd32ec5 | |
|
221aef4a7f | |
|
3e79dd6e32 | |
|
b49344107c | |
|
aebae800dd | |
|
79eac39dc2 | |
|
6e954d314f | |
|
bfda30ee80 | |
|
feaea8375e | |
|
774eed0dbf | |
|
b1251db30c | |
|
5e462f1ae7 | |
|
51e4d00691 | |
|
c8aaa2776c | |
|
fb138d1593 | |
|
222959d1da | |
|
27fda1f938 | |
|
04ec6ff27a | |
|
472b61fefe | |
|
aea41ba997 | |
|
890bc7459d | |
|
5adac1a32a | |
|
35ab3a2c7d | |
|
d8d8473811 | |
|
3a249e7196 | |
|
ec71e8eeeb | |
|
c7f80effb7 | |
|
5e4571d6af | |
|
2a8929b90f | |
|
f273b60f32 | |
|
162a4cfa84 | |
|
0322258386 | |
|
376ba1d793 | |
|
8db6b50a65 | |
|
e24323147d | |
|
5c0e3e96cc | |
|
ba66cde840 | |
|
bda9921fb0 | |
|
49aa3a994e | |
|
0922715301 | |
|
6186ff343e | |
|
4259d9c282 | |
|
fdfba199f3 | |
|
93d8fd31a0 | |
|
64f025fe70 | |
|
71ffdb9164 | |
|
206aeeccfb | |
|
79c76d26c8 | |
|
f20f0aaa45 | |
|
60fa473608 | |
|
6bced5106e | |
|
9fe4c9f8a2 | |
|
599a277af3 | |
|
74ff5d505d | |
|
e1edb46ba2 | |
|
908254b911 | |
|
f5efaac93a | |
|
6af11fea68 | |
|
40d8ec6c6e | |
|
4bd083b059 | |
|
6a42ce143b | |
|
b44b488807 | |
|
6780167674 | |
|
0e0da39113 | |
|
9f02003bb9 | |
|
955cf619b8 | |
|
0e9a15aad5 | |
|
41983833d7 | |
|
bd43ef5d61 | |
|
e0f5708038 | |
|
3f6a298eb4 | |
|
999a252f7b | |
|
5087f90a26 | |
|
3b9245d143 | |
|
0f3c2ff558 | |
|
0443f2085e | |
|
bc50d5f469 | |
|
46c7a4bb9f | |
|
4a04d47c3c | |
|
b655f0c7b0 | |
|
29618d6a72 | |
|
c443de5873 | |
|
5272a90227 | |
|
7898bc1dd7 | |
|
046142f437 | |
|
df848ca756 | |
|
5838b3e47d | |
|
057447f810 | |
|
a4d06fbb12 | |
|
6f858795ef | |
|
bcaaa02bed | |
|
b7c4f87a8f | |
|
6968039c87 | |
|
036f8a3870 | |
|
28543e3288 | |
|
8eac756ac7 | |
|
164ec645ee | |
|
5b7fc4048a | |
|
6379dd704a | |
|
b81b5fc42c | |
|
0f4933240b | |
|
7c3a81735c | |
|
355d452472 | |
|
ed00adb3ba | |
|
3b1b057f0a | |
|
634ef8df5f | |
|
baf181f1d7 | |
|
f4d6696d2e | |
|
2554e9fc5b | |
|
02b4029e8c | |
|
615b3ac2ac | |
|
6a65b2a84b | |
|
0dc2466539 | |
|
b60a0ddf59 | |
|
12fb6bf5ca | |
|
63e855725f | |
|
a58a747cfa | |
|
4eee70a845 | |
|
b34a8d6166 | |
|
3d8571b59e | |
|
1f5d792783 | |
|
6dcc50e60b | |
|
8d181c4e93 | |
|
2cab9f7895 | |
|
ab05bf6f36 | |
|
494d3af9a4 | |
|
36ab954cf9 | |
|
297fe9a3f4 | |
|
386aa1adc3 | |
|
d9e04bab0a | |
|
cc4bf3b328 | |
|
62af03debd | |
|
ca7ad03a05 | |
|
4825c5287e | |
|
fbc4cd1cf1 | |
|
3254c4a237 | |
|
3cda9294fd | |
|
13a3725b06 | |
|
f8d3d60b27 | |
|
62e24eda1c | |
|
e303009917 | |
|
53ff6ea335 | |
|
6a45a0287d | |
|
121ffa0342 | |
|
b142953a4b | |
|
37d0560b70 | |
|
bff1319c5e | |
|
61ba2c47ee | |
|
ba3d1755d4 | |
|
e6b80de3b5 | |
|
ec2384f110 | |
|
8f8fb79a63 | |
|
cf339edb6c | |
|
14f1ad63d2 | |
|
90e28518f2 | |
|
1da147684a | |
|
2a1a051362 | |
|
ef95835bc6 | |
|
31245f6fb2 | |
|
b704a44dfb | |
|
7a9b5156c9 | |
|
0950ac2329 | |
|
0031f90c64 | |
|
3aab1b172c | |
|
87b623bc51 | |
|
fd5747f4dc | |
|
98ddd6940d | |
|
f44c715cfb | |
|
6b6fd2906f | |
|
59a5541e45 | |
|
9da70f9a20 | |
|
9472a7eb5c | |
|
e1c7aaa220 | |
|
fcdfeae326 | |
|
3dfcc90574 | |
|
1d4dad22ad | |
|
48e2d8ecee | |
|
6d698cb5d8 | |
|
2be5041d0d | |
|
4f2298fd22 | |
|
bdaf59513b | |
|
9b3ffc90ba | |
|
6688ba61dd | |
|
bed662c2e5 | |
|
b4dd8409eb | |
|
86adfaecce | |
|
51ef3fa5a1 | |
|
7bcb1cbe2e | |
|
47ad20421e | |
|
056f86caad | |
|
39434766e3 | |
|
803e9cbdb5 | |
|
e573438e43 | |
|
249ea19c0c | |
|
a5518363c3 | |
|
65c137e617 | |
|
720c75478a | |
|
2ff24841fd | |
|
2b57e170ef | |
|
76db0e61c3 | |
|
aec6d33db7 | |
|
41823fbddf | |
|
91eb7751da | |
|
6082eca117 | |
|
4d75fbfcb8 | |
|
9634046d11 | |
|
0998438e67 | |
|
4259f63fbf | |
|
fd71435b30 | |
|
38b3e86e62 | |
|
4c942bd55f | |
|
b87abf1f68 | |
|
449b87e38d | |
|
4c6fb2a266 | |
![]() |
25ee1d8672 | |
|
0fa552c8d3 | |
|
b4bf320c2e | |
|
5e3a763776 | |
|
4dbe149b42 | |
|
ab03962e9a | |
|
aca63146e9 |
|
@ -14,3 +14,4 @@
|
|||
/db/schema.rb
|
||||
/Gemfile.lock
|
||||
/lib/plugins/acts_as_versioned/test/debug.log
|
||||
/config/configuration.yml
|
||||
|
|
46
Gemfile
46
Gemfile
|
@ -1,4 +1,4 @@
|
|||
source 'https://rubygems.org'
|
||||
source 'http://ruby.taobao.org'
|
||||
|
||||
unless RUBY_PLATFORM =~ /w32/
|
||||
# unix-like only
|
||||
|
@ -19,19 +19,34 @@ gem 'acts-as-taggable-on', '2.4.1'
|
|||
group :development do
|
||||
gem 'better_errors', path: 'lib/better_errors'
|
||||
gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler'
|
||||
if ENV['PRY']
|
||||
gem 'pry'
|
||||
gem 'pry-nav'
|
||||
end
|
||||
end
|
||||
|
||||
group :test do
|
||||
# shoulda的版本做了改动
|
||||
#gem "shoulda", "~> 3.3.2"
|
||||
gem "shoulda", "> 3.3.2"
|
||||
gem "mocha", "~> 0.13.3"
|
||||
gem 'capybara', '~> 2.0.0'
|
||||
gem 'nokogiri', '< 1.6.0'
|
||||
gem "shoulda", "~> 3.5.0"
|
||||
gem "mocha", "~> 1.1.0"
|
||||
gem 'capybara', '~> 2.4.1'
|
||||
gem 'nokogiri', '~> 1.6.3'
|
||||
gem 'factory_girl', '~> 4.4.0'
|
||||
gem 'selenium-webdriver', '~> 2.42.0'
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
gem "guard-rails", '~> 0.5.3'
|
||||
gem 'spork-testunit', '~> 0.0.8'
|
||||
gem 'guard-spork', '~> 1.5.1'
|
||||
gem 'guard-test', '~> 1.0.0'
|
||||
gem 'ruby-prof', '~> 0.15.1' unless RUBY_PLATFORM =~ /w32/
|
||||
gem 'pry'
|
||||
gem 'pry-nav'
|
||||
end
|
||||
|
||||
|
||||
|
@ -53,15 +68,6 @@ group :ldap do
|
|||
end
|
||||
|
||||
|
||||
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
|
||||
|
||||
# Optional gem for OpenID authentication
|
||||
group :openid do
|
||||
gem "ruby-openid", "~> 2.1.4", :require => "openid"
|
||||
|
|
148
Gemfile.lock
148
Gemfile.lock
|
@ -19,6 +19,7 @@ PATH
|
|||
rails
|
||||
|
||||
GEM
|
||||
remote: http://ruby.taobao.org/
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (3.2.13)
|
||||
|
@ -50,55 +51,113 @@ GEM
|
|||
multi_json (~> 1.0)
|
||||
acts-as-taggable-on (2.4.1)
|
||||
rails (>= 3, < 5)
|
||||
arel (3.0.2)
|
||||
arel (3.0.3)
|
||||
builder (3.0.0)
|
||||
capybara (2.0.3)
|
||||
capybara (2.4.1)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (~> 2.0)
|
||||
xpath (~> 1.0.0)
|
||||
xpath (~> 2.0)
|
||||
celluloid (0.15.2)
|
||||
timers (~> 1.1.0)
|
||||
childprocess (0.5.3)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
climate_control (0.0.3)
|
||||
activesupport (>= 3.0)
|
||||
cocaine (0.5.4)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
coderay (1.0.9)
|
||||
coffee-rails (3.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (~> 3.2.0)
|
||||
coffee-script (2.2.0)
|
||||
coffee-script (2.3.0)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.7.0)
|
||||
coffee-script-source (1.7.1)
|
||||
erubis (2.7.0)
|
||||
execjs (2.0.2)
|
||||
fastercsv (1.5.0)
|
||||
execjs (2.2.1)
|
||||
factory_girl (4.4.0)
|
||||
activesupport (>= 3.0.0)
|
||||
fastercsv (1.5.5)
|
||||
ffi (1.9.3)
|
||||
ffi (1.9.3-x86-mingw32)
|
||||
formatador (0.2.5)
|
||||
guard (2.6.1)
|
||||
formatador (>= 0.2.4)
|
||||
listen (~> 2.7)
|
||||
lumberjack (~> 1.0)
|
||||
pry (>= 0.9.12)
|
||||
thor (>= 0.18.1)
|
||||
guard-rails (0.5.3)
|
||||
guard (~> 2.0)
|
||||
guard-spork (1.5.1)
|
||||
childprocess (>= 0.2.3)
|
||||
guard (>= 1.1)
|
||||
spork (>= 0.8.4)
|
||||
guard-test (1.0.0)
|
||||
guard (>= 1.8)
|
||||
test-unit (~> 2.2)
|
||||
hike (1.2.3)
|
||||
htmlentities (4.3.2)
|
||||
i18n (0.6.1)
|
||||
journey (1.0.4)
|
||||
jquery-rails (2.0.3)
|
||||
railties (>= 3.1.0, < 5.0)
|
||||
thor (~> 0.14)
|
||||
json (1.8.0)
|
||||
json (1.8.1)
|
||||
kaminari (0.16.1)
|
||||
actionpack (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
libv8 (3.16.14.3)
|
||||
listen (2.7.9)
|
||||
celluloid (>= 0.15.2)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
lumberjack (1.0.9)
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
metaclass (0.0.4)
|
||||
mime-types (1.23)
|
||||
mocha (0.13.3)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mini_portile (0.6.0)
|
||||
mocha (1.1.0)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.7.6)
|
||||
multi_json (1.10.1)
|
||||
mysql2 (0.3.11)
|
||||
mysql2 (0.3.11-x86-mingw32)
|
||||
net-ldap (0.3.1)
|
||||
nokogiri (1.5.11-x86-mingw32)
|
||||
polyglot (0.3.3)
|
||||
nokogiri (1.6.3)
|
||||
mini_portile (= 0.6.0)
|
||||
nokogiri (1.6.3-x86-mingw32)
|
||||
mini_portile (= 0.6.0)
|
||||
paperclip (3.5.4)
|
||||
activemodel (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
cocaine (~> 0.5.3)
|
||||
mime-types
|
||||
polyglot (0.3.5)
|
||||
pry (0.9.12.6)
|
||||
coderay (~> 1.0)
|
||||
method_source (~> 0.8)
|
||||
slop (~> 3.4)
|
||||
pry (0.9.12.6-x86-mingw32)
|
||||
coderay (~> 1.0)
|
||||
method_source (~> 0.8)
|
||||
slop (~> 3.4)
|
||||
win32console (~> 1.3)
|
||||
pry-nav (0.2.3)
|
||||
pry (~> 0.9.10)
|
||||
rack (1.4.5)
|
||||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
rack-openid (1.3.1)
|
||||
rack-openid (1.4.2)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-ssl (1.3.3)
|
||||
rack-raw-upload (1.1.1)
|
||||
multi_json
|
||||
rack-ssl (1.3.4)
|
||||
rack
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
|
@ -118,12 +177,24 @@ GEM
|
|||
rdoc (~> 3.4)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
rake (10.3.2)
|
||||
rb-fsevent (0.9.4)
|
||||
rb-inotify (0.9.5)
|
||||
ffi (>= 0.5.0)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
ref (1.0.5)
|
||||
rich (1.4.6)
|
||||
jquery-rails
|
||||
kaminari
|
||||
mime-types
|
||||
paperclip
|
||||
rack-raw-upload
|
||||
rails (>= 3.2.0)
|
||||
sass-rails
|
||||
rmagick (2.13.2)
|
||||
ruby-openid (2.1.8)
|
||||
rubyzip (1.1.4)
|
||||
sass (3.2.14)
|
||||
rubyzip (1.1.6)
|
||||
sass (3.3.10)
|
||||
sass-rails (3.2.6)
|
||||
railties (~> 3.2.0)
|
||||
sass (>= 3.1.10)
|
||||
|
@ -139,25 +210,36 @@ GEM
|
|||
shoulda-context (1.2.1)
|
||||
shoulda-matchers (2.6.1)
|
||||
activesupport (>= 3.0.0)
|
||||
slop (3.5.0)
|
||||
spork (0.9.2)
|
||||
spork-testunit (0.0.8)
|
||||
spork (>= 0.6.0)
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
thor (0.18.1)
|
||||
test-unit (2.5.5)
|
||||
therubyracer (0.12.1)
|
||||
libv8 (~> 3.16.14.0)
|
||||
ref
|
||||
thor (0.19.1)
|
||||
tilt (1.4.1)
|
||||
treetop (1.4.14)
|
||||
timers (1.1.0)
|
||||
treetop (1.4.15)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.37)
|
||||
uglifier (2.4.0)
|
||||
tzinfo (0.3.40)
|
||||
uglifier (2.5.1)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
websocket (1.0.7)
|
||||
xpath (1.0.0)
|
||||
win32console (1.3.2-x86-mingw32)
|
||||
xpath (2.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86-mingw32
|
||||
|
||||
DEPENDENCIES
|
||||
|
@ -166,23 +248,35 @@ DEPENDENCIES
|
|||
acts-as-taggable-on (= 2.4.1)
|
||||
better_errors!
|
||||
builder (= 3.0.0)
|
||||
capybara (~> 2.0.0)
|
||||
capybara (~> 2.4.1)
|
||||
coderay (~> 1.0.6)
|
||||
coffee-rails (~> 3.2.1)
|
||||
factory_girl (~> 4.4.0)
|
||||
fastercsv (~> 1.5.0)
|
||||
guard-rails (~> 0.5.3)
|
||||
guard-spork (~> 1.5.1)
|
||||
guard-test (~> 1.0.0)
|
||||
htmlentities
|
||||
i18n (~> 0.6.0)
|
||||
jquery-rails (~> 2.0.2)
|
||||
mocha (~> 0.13.3)
|
||||
kaminari
|
||||
mocha (~> 1.1.0)
|
||||
mysql2 (= 0.3.11)
|
||||
net-ldap (~> 0.3.1)
|
||||
nokogiri (< 1.6.0)
|
||||
nokogiri (~> 1.6.3)
|
||||
paperclip (~> 3.5.4)
|
||||
pry
|
||||
pry-nav
|
||||
rack-mini-profiler!
|
||||
rack-openid
|
||||
rails (= 3.2.13)
|
||||
rich (= 1.4.6)
|
||||
rmagick (>= 2.0.0)
|
||||
ruby-openid (~> 2.1.4)
|
||||
sass-rails (~> 3.2.3)
|
||||
seems_rateable!
|
||||
shoulda (> 3.3.2)
|
||||
selenium-webdriver (~> 2.42.0)
|
||||
shoulda (~> 3.5.0)
|
||||
spork-testunit (~> 0.0.8)
|
||||
therubyracer
|
||||
uglifier (>= 1.0.3)
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
# More info at https://github.com/guard/guard#readme
|
||||
|
||||
# guard 'rails' do
|
||||
# watch('Gemfile.lock')
|
||||
# watch(%r{^(config|lib)/.*})
|
||||
# end
|
||||
#
|
||||
guard 'spork', :test_unit => true, :test_unit_env => {'RAILS_ENV' => 'test'}, :wait => 60 do
|
||||
watch(%r{app/models/.+\.rb})
|
||||
watch('config/application.rb')
|
||||
watch('config/environment.rb')
|
||||
watch('config/environments/test.rb')
|
||||
watch(%r{^config/initializers/.+\.rb$})
|
||||
watch('Gemfile.lock')
|
||||
watch('spec/spec_helper.rb') { :rspec }
|
||||
watch('test/test_helper.rb') { :test_unit }
|
||||
watch(%r{features/support/}) { :cucumber }
|
||||
end
|
||||
|
||||
guard :test, :drb => true, :all_after_pass => false, :all_on_start => false do
|
||||
watch(%r{^test/.+_test\.rb$})
|
||||
watch('test/test_helper.rb') { 'test' }
|
||||
|
||||
# Non-rails
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
||||
|
||||
# Rails 4
|
||||
# watch(%r{^app/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
|
||||
# watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' }
|
||||
# watch(%r{^app/controllers/(.+)_controller\.rb}) { |m| "test/integration/#{m[1]}_test.rb" }
|
||||
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
||||
# watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" }
|
||||
|
||||
# Rails < 4
|
||||
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
||||
watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
||||
watch(%r{^app/views/(.+)/.+\.erb$}) { |m| "test/functional/#{m[1]}_controller_test.rb" }
|
||||
watch(%r{^app/views/.+$}) { 'test/integration' }
|
||||
watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] }
|
||||
end
|
143
ReadMe.txt
143
ReadMe.txt
|
@ -1,53 +1,90 @@
|
|||
patch:
|
||||
用户姓名的部分,根据issues#655。
|
||||
为了修改方便
|
||||
alias:
|
||||
方法 之前显示 调整之后
|
||||
name firstname+lastname login
|
||||
nickname xxx login
|
||||
realname xxx firstname+lastname
|
||||
|
||||
User model经过修改,已经完全集成了user_extensions的功能
|
||||
例如
|
||||
user.gender=1
|
||||
user.save
|
||||
user_extensions字段会自动保存
|
||||
不必要每次user.user_extensions.xxx以及判断是否为空
|
||||
================================================================================
|
||||
app/models/setting.rb :165
|
||||
# fixed domain url in development. tantantan's bug
|
||||
if Rails.env.development?
|
||||
methods.map do |m|
|
||||
define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/
|
||||
end
|
||||
end
|
||||
程序部分链接中制定了subdomain参数,使链接在二级域名中来回跳转。
|
||||
为了开发方便,使之功能在development模式下失效。
|
||||
# => nyan
|
||||
================================================================================
|
||||
app/controller/projects_controller.rb ===> projects#fake
|
||||
fake filter: 修改了传到页面中的Count后缀的数量
|
||||
改为正确的数量,删掉fake过滤器即可
|
||||
================================================================================
|
||||
#导航栏匹配域名显示和改变
|
||||
app\helper\application_helper.rb
|
||||
# rewrite navigation
|
||||
|
||||
app\views\layouts\_base_header.html.erb
|
||||
# reset navigation by domain name and url through regular match
|
||||
================================================================================
|
||||
#首页根据域名匹配进入不同的页面
|
||||
app\controller\welcome_controller.rb
|
||||
def entry_select_user
|
||||
if request.original_url.match(/user\.trustie\.net/)
|
||||
redirect_to(:controller => "users", :action => "index")
|
||||
return 0
|
||||
end
|
||||
end
|
||||
================================================================================
|
||||
|
||||
================================================================================
|
||||
0606:新坑
|
||||
user_scores表结构有问题,需要运行
|
||||
bundle exec rake db:migrate:down VERSION=20140410021724
|
||||
bundle exec rake db:migrate:up VERSION=20140410021724
|
||||
===================================[2014-04-09]=================================
|
||||
kw: 域名, 二级域名, subdomain, forge, course, contest
|
||||
域名跳转(forge/course/contest)这几个设置在settings.yml中
|
||||
但是跳转在development模式下会导致无法开发
|
||||
|
||||
app/models/setting.rb :165
|
||||
# fixed domain url in development. tantantan's bug
|
||||
if Rails.env.development?
|
||||
methods.map do |m|
|
||||
define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/
|
||||
end
|
||||
end
|
||||
程序部分链接中制定了subdomain参数,使链接在二级域名中来回跳转。
|
||||
为了开发方便,使之功能在development模式下失效。
|
||||
|
||||
|
||||
===================================[2014-04-09]=================================
|
||||
kw: 菜单, 导航栏, layout
|
||||
网页上方的导航条没有用Redmine::MenuManager
|
||||
MenuManager的样式无法定制,菜单显示条件if中的proc执行行为没有了解
|
||||
|
||||
#导航栏匹配域名显示和改变
|
||||
app\helper\application_helper.rb
|
||||
render_dynamic_nav 方法中,利用变量,可以设置在layout中具体显示哪些条目
|
||||
|
||||
app\views\layouts\_base_header.html.erb
|
||||
需要显示的条目,由具体的实例变量设置(在各个layout中)
|
||||
|
||||
|
||||
===================================[2014-04-09]=================================
|
||||
kw: home_path, 首页, 跳转, 二级域名, welcome
|
||||
#首页根据域名匹配进入不同的页面
|
||||
app\controller\welcome_controller.rb
|
||||
#entry_select 放射设置二级域名所显示的首页
|
||||
|
||||
|
||||
|
||||
===================================[2014-06-06]=================================
|
||||
kw: user_scores
|
||||
user_scores表结构有问题,需要运行
|
||||
bundle exec rake db:migrate:down VERSION=20140410021724
|
||||
bundle exec rake db:migrate:up VERSION=20140410021724
|
||||
|
||||
|
||||
|
||||
===================================[2014-07-08]=================================
|
||||
kw: CKEditor, 富文本, 编辑器
|
||||
CKEditor插件加载方法
|
||||
1.把插件文件夹拷入plugins文件夹,确保文件夹名为redmine_ckeditor
|
||||
2.运行 bundle install --without development test
|
||||
3.运行 rake redmine:plugins:migrate RAILS_ENV=production
|
||||
4.启动服务器
|
||||
5.配置CKEditor插件(Administration > Plugins > Configure)
|
||||
6.把文本格式 (Administration > Settings > General > Text formatting)改为CKEditor
|
||||
注意:一定要先配置CKEditor插件再见文本格式更改,不然,数据库不会生成对应记录,会报错。。
|
||||
|
||||
|
||||
|
||||
===================================[2014-07-19]=================================
|
||||
kw: 首页, 定制, forge, course, contest, 排序
|
||||
若遇到首页定制报错问题请尝试如下操作
|
||||
如果运行迁移文件有报错与‘sort_type’相关
|
||||
先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202
|
||||
在按如下步骤执行,未报与之相关的则直接按如下步骤执行
|
||||
1.运行 bundle exec rake db:migrate:down version=20140719080032
|
||||
2.运行 bundle exec rake db:migrate:up version=20140719080032
|
||||
===================================[2014-07-30]=================================
|
||||
kw: 首页, 定制, forge, course, contest, 排序,image_width
|
||||
|
||||
undefined image_width 问题
|
||||
bundle exec rake db:migrate:down version=20140725062302
|
||||
bundle exec rake db:migrate:up version=20140725062302
|
||||
|
||||
=================================[2014-07-19]=====================================
|
||||
kw: Mysql2::Error,存储过程,CALL sp_project_status_cursor();
|
||||
bundle exec rake db:migrate:down version=20130828004955
|
||||
bundle exec rake db:migrate:up version=20130828004955
|
||||
|
||||
=================================[2014-08-13]====================================
|
||||
kw:配置支持的图片格式
|
||||
默认支持如下格式:"bmp,jpeg,jpg,png,gif"
|
||||
可在configuration.yml中修改,格式:pic_types: "bmp,jpeg,jpg,png,gif"(注意:pic_types若前面有#号需去掉)
|
||||
配置完成后重启服务
|
||||
|
||||
=================================[2014-08-16]====================================
|
||||
kw:数据迁移,project_scores表已存在
|
||||
bundle exec rake db:migrate:down VERSION=20140811022947
|
||||
bundle exec rake db:migrate:up VERSION=20140811022947
|
||||
bundle exec rake db:migrate
|
||||
bundle exec rake project_score:calculate
|
||||
|
|
Binary file not shown.
|
@ -102,7 +102,14 @@ class AccountController < ApplicationController
|
|||
# User self-registration
|
||||
def register
|
||||
# @root_path="/home/pdl/redmine-2.3.2-0/apache2/"
|
||||
#
|
||||
#
|
||||
@cache_identityy = params[:identity]||"" #身份
|
||||
@cache_no = params[:no]||"" #学号
|
||||
@cache_technical_title = params[:technical_title]||"" #教师职称
|
||||
@cache_province = params[:province]||"" #省份
|
||||
@cache_city = params[:city]||"" #城市
|
||||
@cache_enterprise_name = params[:enterprise_name]||"" #企业
|
||||
|
||||
(redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
|
||||
if request.get?
|
||||
session[:auth_source_registration] = nil
|
||||
|
@ -133,6 +140,15 @@ class AccountController < ApplicationController
|
|||
@user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
|
||||
end
|
||||
|
||||
if(@cache_identityy == "")
|
||||
flash.now[:error]= l(:label_identity)+l(:'activerecord.errors.messages.empty')
|
||||
return
|
||||
end
|
||||
if(@cache_city == "")
|
||||
flash.now[:error]= l(:label_location)+l(:'activerecord.errors.messages.empty')
|
||||
return
|
||||
end
|
||||
|
||||
case Setting.self_registration
|
||||
when '1'
|
||||
register_by_email_activation(@user)
|
||||
|
|
|
@ -20,7 +20,7 @@ class ActivitiesController < ApplicationController
|
|||
before_filter :find_optional_project, :index
|
||||
accept_rss_auth :index
|
||||
helper :Watchers
|
||||
|
||||
helper :project_score
|
||||
def index
|
||||
@days = Setting.activity_days_default.to_i
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class AdminController < ApplicationController
|
|||
before_filter :require_admin
|
||||
helper :sort
|
||||
helper :Users
|
||||
helper :Settings
|
||||
include SortHelper
|
||||
|
||||
def index
|
||||
|
@ -35,15 +36,12 @@ class AdminController < ApplicationController
|
|||
|
||||
scope = Project.status(@status).order('lft')
|
||||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
@projects = scope.all
|
||||
@projects = scope.where(project_type: Project::ProjectType_project).all
|
||||
|
||||
render :action => "projects", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def users
|
||||
@project_type = params[:project_type]
|
||||
role = params[:role]
|
||||
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
||||
|
@ -55,95 +53,14 @@ class AdminController < ApplicationController
|
|||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
has = {
|
||||
"show_changesets" => true
|
||||
}
|
||||
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
|
||||
|
||||
scope = UserStatus.visible
|
||||
case role
|
||||
when 'teacher'
|
||||
scope = UserStatus.teacher
|
||||
when 'student'
|
||||
scope = UserStatus.student
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
scope = User.logged.status(@status)
|
||||
scope = User.like(params[:name]) if params[:name].present?
|
||||
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||
# scope.each do |user|
|
||||
# UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id)
|
||||
# end
|
||||
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
#@offset ||= @user_pages.offset
|
||||
#@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
if params[:user_sort_type].present?
|
||||
case params[:user_sort_type]
|
||||
when '0'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 0
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
when '1'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
#sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}
|
||||
#@users = @users[@offset, @limit]
|
||||
when '2'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 2
|
||||
#@users = @users[@offset, @limit]
|
||||
end
|
||||
|
||||
else
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
end
|
||||
|
||||
@users = []
|
||||
@users_statuses.each do |obj|
|
||||
@users << User.find_by_id("#{obj.user_id}")
|
||||
end
|
||||
@offset ||= @user_pages.offset
|
||||
@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -208,24 +125,13 @@ class AdminController < ApplicationController
|
|||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
has = {
|
||||
"show_changesets" => true
|
||||
}
|
||||
scope = User.logged.status(@status)
|
||||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users = scope.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users = scope.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
|
||||
@users = scope.offset(@user_pages.offset).limit(@user_pages.per_page)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -234,4 +140,116 @@ class AdminController < ApplicationController
|
|||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
#首页定制
|
||||
def first_page_made
|
||||
if request.get?
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
elsif request.post?
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
@first_page.web_title = params[:web_title]
|
||||
@first_page.description = params[:first_page][:description]
|
||||
#@first_page.title = params[:title]
|
||||
@first_page.image_width = params[:image_width]
|
||||
@first_page.image_height = params[:image_height]
|
||||
@first_page.sort_type = params[:sort_type]
|
||||
@first_page.show_course = params[:show_course]
|
||||
@first_page.show_contest = params[:show_contest]
|
||||
if @first_page.save
|
||||
respond_to do |format|
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
format.html {
|
||||
redirect_to admin_first_page_made_path
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
#format.json { render json: @first_page, status: :created, location: @first_page }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}"
|
||||
format.html {
|
||||
render :action => 'first_page_made'
|
||||
}
|
||||
format.api { render_validation_errors(@first_page) }
|
||||
#format.json { render json: @first_page.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def course_page_made
|
||||
if request.get?
|
||||
@course_page = FirstPage.where("page_type = 'course'").first
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
elsif request.post?
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
@course_page = FirstPage.where("page_type = 'course'").first
|
||||
@first_page.web_title = params[:web_title]
|
||||
@course_page.web_title = params[:web_title]
|
||||
@course_page.title = params[:course_title]
|
||||
@course_page.image_width = params[:image_width]
|
||||
@course_page.image_height = params[:image_height]
|
||||
@course_page.description = params[:course_description]
|
||||
if @first_page.save && @course_page.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to admin_course_page_made_path
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@course_page.errors.full_messages[0]}"
|
||||
#flash.now[:error] = "#{l :label_first_page_create_fail}: #{@course_page.errors.full_messages[0]}"
|
||||
format.html {
|
||||
|
||||
render :action => 'course_page_made'
|
||||
}
|
||||
format.api { render_validation_errors(@first_page) }
|
||||
format.api { render_validation_errors(@course_page) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def contest_page_made
|
||||
if request.get?
|
||||
@contest_page = FirstPage.where("page_type = 'contest'").first
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
@notification = ContestNotification.all.first;
|
||||
elsif request.post?
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
@contest_page = FirstPage.where("page_type = 'contest'").first
|
||||
@notification = ContestNotification.all.first;
|
||||
@first_page.web_title = params[:web_title]
|
||||
@contest_page.web_title = params[:web_title]
|
||||
@contest_page.title = params[:contest_title]
|
||||
@contest_page.image_width = params[:image_width]
|
||||
@contest_page.image_height = params[:image_height]
|
||||
@contest_page.description = params[:contest_description]
|
||||
@notification.title = params[:contest_notification_title]
|
||||
@notification.content = params[:contest_notification][:content]
|
||||
|
||||
if @first_page.save && @contest_page.save && @notification.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to admin_contest_page_made_path
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@contest_page.errors.full_messages[0]}\n\t#{@notification.errors.full_messages[0]}"
|
||||
format.html {
|
||||
render :action => 'contest_page_made'
|
||||
}
|
||||
format.api { render_validation_errors(@first_page) }
|
||||
format.api { render_validation_errors(@contest_page) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -41,6 +41,7 @@ class ApplicationController < ActionController::Base
|
|||
cookies.delete(autologin_cookie_name)
|
||||
end
|
||||
|
||||
before_filter :find_first_page
|
||||
before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
|
||||
before_filter :user_agent
|
||||
|
||||
|
@ -278,7 +279,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
# Find project of id params[:id]
|
||||
def find_project
|
||||
@project = Project.find(params[:id])
|
||||
@project = Project.find_by_id(params[:id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
@ -482,14 +483,19 @@ class ApplicationController < ActionController::Base
|
|||
# Renders an error response
|
||||
def render_error(arg)
|
||||
arg = {:message => arg} unless arg.is_a?(Hash)
|
||||
|
||||
@message = arg[:message]
|
||||
@lay = arg[:layout]
|
||||
@message = l(@message) if @message.is_a?(Symbol)
|
||||
@status = arg[:status] || 500
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :template => 'common/error', :layout => use_layout, :status => @status
|
||||
if @lay
|
||||
render :template => 'common/error', :layout => @lay,:status => @status
|
||||
else
|
||||
render :template => 'common/error', :layout => use_layout, :status => @status
|
||||
end
|
||||
|
||||
}
|
||||
format.any { head @status }
|
||||
end
|
||||
|
@ -519,7 +525,7 @@ class ApplicationController < ActionController::Base
|
|||
#
|
||||
# @return [boolean, string] name of the layout to use or false for no layout
|
||||
def use_layout
|
||||
request.xhr? ? false : 'base'
|
||||
request.xhr? ? false : 'users_base'
|
||||
end
|
||||
|
||||
def invalid_authenticity_token
|
||||
|
@ -715,4 +721,17 @@ class ApplicationController < ActionController::Base
|
|||
raise RuntimeError, 'unknow type, Please input you type into this helper.'
|
||||
end
|
||||
end
|
||||
|
||||
#查找首页相关信息
|
||||
def find_first_page
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.nil?
|
||||
@first_page = FirstPage.new
|
||||
@first_page.page_type = 'project'
|
||||
@first_page.description = ""
|
||||
@first_page.save()
|
||||
end
|
||||
@show_course = @first_page.show_course
|
||||
@show_contest = @first_page.show_contest
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,8 @@ class AppliedProjectController < ApplicationController
|
|||
@project = Project.find(params[:project_id])
|
||||
@applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
|
||||
if @applieds.count == 0
|
||||
AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
|
||||
appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
|
||||
Mailer.applied_project(appliedproject).deliver
|
||||
end
|
||||
|
||||
#redirect_to project_path(params[:project_id])
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class AttachmentsController < ApplicationController
|
||||
layout "users_base"
|
||||
before_filter :find_project, :only => [:show, :download, :thumbnail, :destroy, :delete_homework]#, :except => [:upload, :autocomplete]
|
||||
before_filter :file_readable, :read_authorize, :only => [:show, :thumbnail]#Modified by young
|
||||
before_filter :delete_authorize, :only => :destroy
|
||||
|
@ -23,6 +24,8 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
before_filter :login_without_softapplication, only: [:download]
|
||||
accept_api_auth :show, :download, :upload
|
||||
require 'iconv'
|
||||
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
|
@ -39,6 +42,13 @@ class AttachmentsController < ApplicationController
|
|||
render :action => 'diff'
|
||||
elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte
|
||||
@content = File.new(@attachment.diskfile, "rb").read
|
||||
# 编码为非 UTF-8先进行间接转码
|
||||
# 部分unicode编码不直接支持转为 UTF-8
|
||||
# modify by nwb
|
||||
if @content.encoding.name != 'UTF-8'
|
||||
@content = @content.force_encoding('GBK')
|
||||
@content = @content.encode('UTF-8')
|
||||
end
|
||||
render :action => 'file'
|
||||
else
|
||||
download
|
||||
|
@ -49,16 +59,40 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
|
||||
def download
|
||||
if true || @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
|
||||
# modify by nwb
|
||||
# 下载添加权限设置
|
||||
candown = false
|
||||
if (@attachment.container.has_attribute?(:project) || @attachment.container.has_attribute?(:project_id)) && @attachment.container.project
|
||||
project = @attachment.container.project
|
||||
candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
|
||||
elsif @attachment.container.is_a?(Project)
|
||||
project = @attachment.container
|
||||
candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
|
||||
elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course
|
||||
course = @attachment.container.course
|
||||
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
|
||||
elsif @attachment.container.is_a?(Course)
|
||||
course = @attachment.container
|
||||
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
|
||||
elsif @attachment.container.class.to_s=="HomeworkAttach" && @attachment.container.bid.reward_type == 3
|
||||
candown = true
|
||||
else
|
||||
candown = @attachment.is_public == 1
|
||||
end
|
||||
if candown || User.current.admin? || User.current.id == @attachment.author_id
|
||||
@attachment.increment_download
|
||||
|
||||
if stale?(:etag => @attachment.digest)
|
||||
# images are sent inline
|
||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => detect_content_type(@attachment),
|
||||
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
||||
end
|
||||
|
||||
else
|
||||
render_403 :message => :notice_not_authorized
|
||||
end
|
||||
|
||||
if stale?(:etag => @attachment.digest)
|
||||
# images are sent inline
|
||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => detect_content_type(@attachment),
|
||||
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
||||
end
|
||||
rescue => e
|
||||
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
|
||||
end
|
||||
|
@ -75,6 +109,25 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 更新文件密级
|
||||
def updateFileDense
|
||||
@attachment = Attachment.find(params[:attachmentid])
|
||||
if @attachment != nil
|
||||
filedense = params[:newtype].to_s
|
||||
# d = Iconv.conv("unicodebig","utf-8",filedense)
|
||||
if filedense == "%E5%85%AC%E5%BC%80" #l(:field_is_public)
|
||||
@attachment.is_public = 1
|
||||
else
|
||||
@attachment.is_public = 0
|
||||
end
|
||||
@attachment.save
|
||||
@newfiledense = filedense
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def thumbnail
|
||||
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
|
||||
if stale?(:etag => thumbnail)
|
||||
|
@ -89,6 +142,7 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
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
|
||||
|
@ -127,8 +181,13 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
# modify by nwb
|
||||
if @attachment.container_type == 'Course'
|
||||
if @course.nil?
|
||||
if !@attachment.container.nil? &&
|
||||
(@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board && @attachment.container.board.course ) )
|
||||
if @attachment.container.is_a?(News)
|
||||
format.html { redirect_to_referer_or news_path(@attachment.container) }
|
||||
elsif @attachment.container.is_a?(Message)
|
||||
format.html { redirect_to_referer_or new_board_message_path(@attachment.container) }
|
||||
elsif @course.nil?
|
||||
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
||||
else
|
||||
format.html { redirect_to_referer_or course_path(@course) }
|
||||
|
@ -160,6 +219,17 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#删除竞赛作品的附件
|
||||
def delete_softapplications
|
||||
@attachment = Attachment.find params[:id]
|
||||
@softapplication = @attachment.container if @attachment!=nil
|
||||
@attachment.container.attachments.delete(@attachment) if @attachment!=nil
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_referer_or edit_softapplication_path(@softapplication) }
|
||||
#format.js
|
||||
end
|
||||
end
|
||||
|
||||
def autocomplete
|
||||
# modify by nwb
|
||||
if params[:project_id]
|
||||
|
@ -187,6 +257,9 @@ class AttachmentsController < ApplicationController
|
|||
attach_copied_obj.container = obj
|
||||
attach_copied_obj.created_on = Time.now
|
||||
attach_copied_obj.author_id = User.current.id
|
||||
if attach_copied_obj.attachtype == nil
|
||||
attach_copied_obj.attachtype = 1
|
||||
end
|
||||
@obj = obj
|
||||
@save_flag = attach_copied_obj.save
|
||||
@save_message = attach_copied_obj.errors.full_messages
|
||||
|
@ -216,6 +289,9 @@ class AttachmentsController < ApplicationController
|
|||
attach_copied_obj.container = obj
|
||||
attach_copied_obj.created_on = Time.now
|
||||
attach_copied_obj.author_id = User.current.id
|
||||
if attach_copied_obj.attachtype == nil
|
||||
attach_copied_obj.attachtype = 4
|
||||
end
|
||||
@obj = obj
|
||||
@save_flag = attach_copied_obj.save
|
||||
@save_message = attach_copied_obj.errors.full_messages
|
||||
|
@ -240,6 +316,8 @@ private
|
|||
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
|
||||
if @attachment.container_type == 'Course'
|
||||
@course = @attachment.course
|
||||
elsif !@attachment.container.nil? && (@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course)) && @attachment.container.course
|
||||
@course = @attachment.container.course
|
||||
else
|
||||
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication'
|
||||
@project = @attachment.project
|
||||
|
|
|
@ -2,7 +2,7 @@ class AvatarController < ApplicationController
|
|||
|
||||
|
||||
#before_filter :set_cache_buster
|
||||
include AvatarHelper
|
||||
include AvatarHelper
|
||||
|
||||
def upload
|
||||
# Make sure that API users get used to set this content type
|
||||
|
@ -28,6 +28,13 @@ class AvatarController < ApplicationController
|
|||
if @temp_file && (@temp_file.size > 0)
|
||||
diskfile=disk_filename(@source_type,@source_id)
|
||||
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
|
||||
|
||||
# 用户头像上传时进行特别处理
|
||||
if @source_type == 'User'
|
||||
diskfile += "temp"
|
||||
@urlfile += "temp"
|
||||
end
|
||||
|
||||
logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)")
|
||||
path = File.dirname(diskfile)
|
||||
unless File.directory?(path)
|
||||
|
@ -55,17 +62,20 @@ class AvatarController < ApplicationController
|
|||
# saved = @avatar.save
|
||||
begin
|
||||
f = Magick::ImageList.new(diskfile)
|
||||
width = 300.0
|
||||
proportion = (width/f[0].columns)
|
||||
height = (f[0].rows*proportion)
|
||||
f.resize_to_fill!(width,height)
|
||||
# f.scale!(width,height)
|
||||
f.write(diskfile)
|
||||
# gif格式不再做大小处理
|
||||
if f.format != 'GIF'
|
||||
width = 300.0
|
||||
proportion = (width/f[0].columns)
|
||||
height = (f[0].rows*proportion)
|
||||
f.resize_to_fill!(width,height)
|
||||
f.write(diskfile)
|
||||
end
|
||||
|
||||
rescue Exception => e
|
||||
logger.error "[Error] avatar : avatar_controller#upload ===> #{e}"
|
||||
end
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.api {
|
||||
|
@ -77,6 +87,49 @@ class AvatarController < ApplicationController
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
#add by zjc
|
||||
#删除图片
|
||||
def delete_image
|
||||
@source_type = params[:source_type]
|
||||
@source_id = params[:source_id]
|
||||
@source = nil #eval(@source_type).find(@source_id)
|
||||
c = Object.const_get(@source_type)
|
||||
if c.respond_to?(:find)
|
||||
@source = c.find(@source_id)
|
||||
end
|
||||
|
||||
diskfile=disk_filename(@source_type,@source_id)
|
||||
unless diskfile.nil? || diskfile == ""
|
||||
path = File.dirname(diskfile)
|
||||
if File.directory?(path) && File.exist?(diskfile)
|
||||
# 用户头像进行特别处理
|
||||
if @source_type == 'User'
|
||||
diskfile1 = diskfile + 'temp'
|
||||
File.open(diskfile1, "wb") do |f|
|
||||
buffer = "DELETE"
|
||||
f.write(buffer)
|
||||
end
|
||||
else
|
||||
File.delete(diskfile)
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue e do
|
||||
logger.info e.message
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.api {
|
||||
if saved
|
||||
render :action => 'upload', :status => :created
|
||||
else
|
||||
render_validation_errors(@avatar)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ class BidsController < ApplicationController
|
|||
menu_item :project, :only => [:show_project,:show_results, :new_submit_homework]
|
||||
menu_item :homework_respond, :only => :homework_respond
|
||||
menu_item :homework_statistics, :only => :homework_statistics
|
||||
|
||||
before_filter :can_show_course,only: []
|
||||
before_filter :can_show_contest,only: []
|
||||
#Ended by young
|
||||
before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork,
|
||||
:show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
|
||||
|
@ -15,7 +18,7 @@ class BidsController < ApplicationController
|
|||
# end
|
||||
before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ]
|
||||
|
||||
before_filter :memberAccess, only: :show_project
|
||||
#before_filter :memberAccess, only: :show_project
|
||||
|
||||
helper :watchers
|
||||
helper :attachments
|
||||
|
@ -26,6 +29,7 @@ class BidsController < ApplicationController
|
|||
helper :projects
|
||||
helper :words
|
||||
helper :welcome
|
||||
helper :project_score
|
||||
|
||||
def find_project_by_bid_id
|
||||
@bid = Bid.find(params[:id])
|
||||
|
@ -375,11 +379,9 @@ class BidsController < ApplicationController
|
|||
@option = []
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
@option << membership.project
|
||||
end
|
||||
}
|
||||
if membership.user.allowed_to?(:quote_project,membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -451,17 +453,9 @@ class BidsController < ApplicationController
|
|||
# 显示作业课程
|
||||
# add by nwb
|
||||
def show_courseEx
|
||||
if (User.current.logged? && User.current.member_of_course?(@bid.courses.first))
|
||||
if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?))
|
||||
# flash[:notice] = ""
|
||||
@membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
@option = []
|
||||
@membership.each do |membership|
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
@option << membership.course
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
@user = @bid.author
|
||||
@bidding_project = @bid.biding_projects.all
|
||||
|
@ -492,8 +486,13 @@ class BidsController < ApplicationController
|
|||
#ended
|
||||
end
|
||||
|
||||
if @bid.homework_type == 1
|
||||
if @bid.homework_type
|
||||
@homework = HomeworkAttach.new
|
||||
if @bid.proportion
|
||||
teacher_proportion = @bid.proportion * 1.0 / 100
|
||||
else
|
||||
teacher_proportion = 1.0
|
||||
end
|
||||
#@homework_list = @bid.homeworks
|
||||
#增加作业按评分排序,
|
||||
#@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
|
||||
|
@ -501,7 +500,7 @@ class BidsController < ApplicationController
|
|||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.author_id}) AS t_score,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> #{@bid.author_id}) AS s_score
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY
|
||||
(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{@bid.proportion * 1.0 / 100} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - @bid.proportion * 1.0 / 100} END) DESC,created_at ASC")
|
||||
(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC")
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
@homework_list.each do |pro|
|
||||
|
@ -990,7 +989,23 @@ class BidsController < ApplicationController
|
|||
return true if current_user.admin?
|
||||
#return 0 if @bid.courses.first.project_type == Project::ProjectType_project
|
||||
currentUser = User.current
|
||||
render_403 unless currentUser.member_of_cousrse?(@bid.courses.first)
|
||||
render_403 unless currentUser.member_of_course?(@bid.courses.first)
|
||||
end
|
||||
|
||||
#验证是否显示课程
|
||||
def can_show_course
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_course == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
#验证是否显示竞赛
|
||||
def can_show_contest
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_contest == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -26,6 +26,7 @@ class BoardsController < ApplicationController
|
|||
helper :sort
|
||||
include SortHelper
|
||||
helper :watchers
|
||||
helper :project_score
|
||||
|
||||
def index
|
||||
#modify by nwb
|
||||
|
@ -70,7 +71,7 @@ class BoardsController < ApplicationController
|
|||
@message = Message.new(:board => @board)
|
||||
#modify by nwb
|
||||
if @project
|
||||
render :action => 'show', :layout => !request.xhr?
|
||||
render :action => 'show', :layout => 'base_projects'
|
||||
elsif @course
|
||||
render :action => 'show', :layout => 'base_courses'
|
||||
end
|
||||
|
@ -140,7 +141,11 @@ private
|
|||
end
|
||||
|
||||
def find_board_if_available
|
||||
@board = @project.boards.find(params[:id]) if params[:id]
|
||||
if @project
|
||||
@board = @project.boards.find(params[:id]) if params[:id]
|
||||
elsif @course
|
||||
@board = @course.boards.find(params[:id]) if params[:id]
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
|
|
@ -27,6 +27,7 @@ class CalendarsController < ApplicationController
|
|||
include QueriesHelper
|
||||
helper :sort
|
||||
include SortHelper
|
||||
helper :project_score
|
||||
|
||||
def show
|
||||
if params[:year] and params[:year].to_i > 1900
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class ContestNotificationController
|
||||
def show
|
||||
|
||||
end
|
||||
end
|
|
@ -1,11 +1,14 @@
|
|||
# fq
|
||||
# class BidsController < ApplicationController
|
||||
class ContestsController < ApplicationController
|
||||
layout "contest_base"
|
||||
menu_item :respond
|
||||
menu_item :project, :only => :show_project
|
||||
menu_item :application, :only => :show_softapplication
|
||||
menu_item :attendingcontests, :only => :show_attendingcontest
|
||||
menu_item :contestnotifications, :only => :index
|
||||
|
||||
before_filter :can_show_contest,except: []
|
||||
before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :index, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward,
|
||||
:show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
|
||||
|
||||
|
@ -26,8 +29,9 @@ class ContestsController < ApplicationController
|
|||
# @contests = Contest.visible
|
||||
# @contests ||= []
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@contests = Contest.visible
|
||||
@contests = @contests.like(params[:name]) if params[:name].present?
|
||||
#@contests = Contest.visible
|
||||
#@contests = @contests.like(params[:name]) if params[:name].present?
|
||||
@contests = Contest.visible.where("name like '%#{params[:name]}%'")
|
||||
if params[:contests_search]
|
||||
(redirect_to contests_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||
end
|
||||
|
@ -77,6 +81,10 @@ class ContestsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def search
|
||||
redirect_to action: 'index',name:params[:name]
|
||||
end
|
||||
|
||||
def homework
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@bids = @course.homeworks.order('deadline DESC')
|
||||
|
@ -232,12 +240,7 @@ class ContestsController < ApplicationController
|
|||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
#membership.member_roles.each{|role|
|
||||
# if(role.role_id == 3)
|
||||
# @option << membership.project
|
||||
# end
|
||||
#}
|
||||
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
if User.current.allowed_to?(:quote_project, membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
|
@ -326,13 +329,8 @@ class ContestsController < ApplicationController
|
|||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
#membership.member_roles.each{|role|
|
||||
#if(role.role_id == 3)
|
||||
#@option << membership.project
|
||||
#end
|
||||
#}
|
||||
#拥有编辑项目权限的可将该项目参赛
|
||||
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
if User.current.allowed_to?(:quote_project, membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
|
@ -650,5 +648,13 @@ end
|
|||
render_404
|
||||
end
|
||||
|
||||
#验证是否显示竞赛
|
||||
def can_show_contest
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_contest == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ class CoursesController < ApplicationController
|
|||
menu_item l(:label_sort_by_active), :only => :index
|
||||
menu_item l(:label_sort_by_influence), :only => :index
|
||||
|
||||
before_filter :can_show_course, :except => []
|
||||
before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches]
|
||||
before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
||||
before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create]
|
||||
|
@ -62,6 +63,8 @@ class CoursesController < ApplicationController
|
|||
#更新课程信息
|
||||
def update
|
||||
@course.safe_attributes = params[:course]
|
||||
@course.time = params[:time]
|
||||
@course.term = params[:term]
|
||||
@course.class_period = params[:class_period]
|
||||
if @course.save
|
||||
if params[:course][:is_public] == '0'
|
||||
|
@ -155,7 +158,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base'
|
||||
render :layout => 'course_base'
|
||||
scope = Course
|
||||
unless params[:closed]
|
||||
scope = scope.active
|
||||
|
@ -172,7 +175,7 @@ class CoursesController < ApplicationController
|
|||
## 有角色参数的才是课程,没有的就是项目
|
||||
@render_file = 'member_list'
|
||||
@teachers= searchTeacherAndAssistant(@course)
|
||||
@canShowCode = isCourseTeacher(User.current.id)
|
||||
@canShowCode = isCourseTeacher(User.current.id,@course)
|
||||
case params[:role]
|
||||
when '1'
|
||||
@subPage_title = l :label_teacher_list
|
||||
|
@ -217,7 +220,7 @@ class CoursesController < ApplicationController
|
|||
@issue_category ||= IssueCategory.new
|
||||
@member ||= @course.members.new
|
||||
@trackers = Tracker.sorted.all
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
if User.current.user_extensions.identity
|
||||
|
@ -239,18 +242,18 @@ class CoursesController < ApplicationController
|
|||
@trackers = Tracker.sorted.all
|
||||
|
||||
if User.current.user_extensions.identity == 0
|
||||
if @course.save
|
||||
if @course.save
|
||||
#unless User.current.admin?
|
||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||
m = Member.new(:user => User.current, :roles => [r])
|
||||
m.project_id = -1
|
||||
course = CourseInfos.new(:user_id => User.current.id, :course_id => @course.id)
|
||||
#user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
||||
if params[:course][:is_public] == '1'
|
||||
course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)
|
||||
end
|
||||
@course.members << m
|
||||
@course.course_infos << course
|
||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||
m = Member.new(:user => User.current, :roles => [r])
|
||||
m.project_id = -1
|
||||
course = CourseInfos.new(:user_id => User.current.id, :course_id => @course.id)
|
||||
#user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
||||
if params[:course][:is_public] == '1'
|
||||
course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)
|
||||
end
|
||||
@course.members << m
|
||||
@course.course_infos << course
|
||||
#end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -272,7 +275,7 @@ class CoursesController < ApplicationController
|
|||
format.api { render_validation_errors(@course) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -494,50 +497,12 @@ class CoursesController < ApplicationController
|
|||
if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] ))
|
||||
render :layout => 'base_courses'
|
||||
else
|
||||
render_404
|
||||
render_403
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def get_course_activity courses, activities
|
||||
@course_ids=activities.keys()
|
||||
|
||||
days = Setting.activity_days_default.to_i
|
||||
date_to ||= Date.today + 1
|
||||
date_from = date_to - days-1.years
|
||||
|
||||
#file_count
|
||||
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
|
||||
activities[attachment.container_id]+=1
|
||||
end
|
||||
|
||||
#message_count
|
||||
Board.where(course_id: @course_ids).each do |board|
|
||||
# activities[board.course_id]+=1
|
||||
activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count
|
||||
end
|
||||
|
||||
#news
|
||||
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
|
||||
activities[news.course_id]+=1
|
||||
end
|
||||
|
||||
#feedbackc_count
|
||||
JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess|
|
||||
activities[jourformess.jour_id]+=1
|
||||
end
|
||||
|
||||
#activities!=0
|
||||
i=0;
|
||||
courses.each do |course|
|
||||
id=course.id
|
||||
if activities[id]==0
|
||||
activities[id]=1
|
||||
end
|
||||
end
|
||||
|
||||
return activities
|
||||
end
|
||||
|
||||
def toggleCourse
|
||||
@course_prefs = Course.find_by_extra(@course.extra)
|
||||
|
@ -623,14 +588,31 @@ class CoursesController < ApplicationController
|
|||
"show_course_journals_for_messages" => true
|
||||
}
|
||||
@date_to ||= Date.today + 1
|
||||
@date_from = @date_to - @days-1.years
|
||||
#
|
||||
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
|
||||
#@date_from = @date_to - @days-1.years
|
||||
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
||||
# 决定显示所用用户或单个用户活动
|
||||
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
||||
:with_subprojects => false,
|
||||
:author => @author)
|
||||
@activity.scope_select {|t| has["show_#{t}"]}
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
# modify by nwb
|
||||
# 添加私密性判断
|
||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
else
|
||||
events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||
end
|
||||
|
||||
# 无新动态时,显示老动态
|
||||
if events.count == 0
|
||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||
events = @activity.events
|
||||
else
|
||||
events = @activity.events(:is_public => 1)
|
||||
end
|
||||
end
|
||||
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@events_count = events.count
|
||||
|
@ -643,7 +625,7 @@ class CoursesController < ApplicationController
|
|||
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
||||
#
|
||||
@teachers= searchTeacherAndAssistant(@course)
|
||||
@canShowRealName = isCourseTeacher(User.current.id)
|
||||
@canShowRealName = isCourseTeacher(User.current.id,@course)
|
||||
|
||||
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
||||
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||
|
@ -656,9 +638,10 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
|
||||
#判断指定用户是否为课程教师
|
||||
def isCourseTeacher(id)
|
||||
def isCourseTeacher(id,course)
|
||||
result = false
|
||||
if @teachers && @teachers.find_by_user_id(id) != nil
|
||||
user = User.find(id)
|
||||
if user.nil? && user.allowed_to?(:as_teacher,course)#@teachers && @teachers.count != 0 && @teachers.find_by_user_id(id) != nil
|
||||
result = true
|
||||
end
|
||||
result
|
||||
|
@ -704,8 +687,14 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#验证是否显示课程
|
||||
def can_show_course
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_course == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,19 +23,28 @@ class DocumentsController < ApplicationController
|
|||
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||
before_filter :find_project_from_association, :except => [:index, :new, :create]
|
||||
before_filter :authorize , :except => [:index]#Added by young
|
||||
before_filter :authorize_document
|
||||
|
||||
helper :attachments
|
||||
helper :project_score
|
||||
|
||||
def index
|
||||
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
||||
documents = @project.documents.includes(:attachments, :category).all
|
||||
temp = @project.documents.includes(:attachments, :category).all
|
||||
documents = []
|
||||
temp.each do |doc|
|
||||
if doc.has_right?(@project)
|
||||
documents << doc
|
||||
end
|
||||
end
|
||||
case @sort_by
|
||||
when 'date'
|
||||
@grouped = documents.group_by {|d| d.updated_on.to_date }
|
||||
when 'title'
|
||||
@grouped = documents.group_by {|d| d.title.first.upcase}
|
||||
when 'author'
|
||||
@grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
|
||||
# @grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
|
||||
@grouped = documents.group_by {|d| d.user.name }
|
||||
else
|
||||
@grouped = documents.group_by(&:category)
|
||||
end
|
||||
|
@ -100,4 +109,12 @@ class DocumentsController < ApplicationController
|
|||
end
|
||||
redirect_to document_path(@document)
|
||||
end
|
||||
|
||||
# 权限判断
|
||||
# add by nwb
|
||||
def authorize_document
|
||||
if !(User.current.admin? || User.current.member_of?(@project) || @document == nil || (@document != nil && @document.is_public==1))
|
||||
render_403 :message => :notice_not_authorized
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,19 @@ class FilesController < ApplicationController
|
|||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
helper :project_score
|
||||
|
||||
def show_attachments obj
|
||||
all_attachments = []
|
||||
obj.each do |container|
|
||||
all_attachments += container.attachments
|
||||
end
|
||||
@limit = 10
|
||||
@feedback_count = all_attachments.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
@curse_attachments = all_attachments[@offset, @limit]
|
||||
end
|
||||
|
||||
def index
|
||||
#sort_init 'filename', 'asc'
|
||||
|
@ -32,17 +45,90 @@ class FilesController < ApplicationController
|
|||
'filename' => "#{Attachment.table_name}.filename",
|
||||
'size' => "#{Attachment.table_name}.filesize",
|
||||
'downloads' => "#{Attachment.table_name}.downloads"
|
||||
sort = ""
|
||||
|
||||
if params[:project_id]
|
||||
@isproject = true
|
||||
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
|
||||
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||
|
||||
if params[:sort]
|
||||
params[:sort].split(",").each do |sort_type|
|
||||
order_by = sort_type.split(":")
|
||||
|
||||
case order_by[0]
|
||||
when "filename"
|
||||
attribute = "filename"
|
||||
when "size"
|
||||
attribute = "filesize"
|
||||
when "attach_type"
|
||||
attribute = "attachtype"
|
||||
when "content_type"
|
||||
attribute = "created_on"
|
||||
when "field_file_dense"
|
||||
attribute = "is_public"
|
||||
when "downloads"
|
||||
attribute = "downloads"
|
||||
when "created_on"
|
||||
attribute = "created_on"
|
||||
end
|
||||
|
||||
if order_by.count == 1
|
||||
sort += "#{Attachment.table_name}.#{attribute} desc "
|
||||
elsif order_by.count == 2
|
||||
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
|
||||
end
|
||||
if sort_type != params[:sort].split(",").last
|
||||
sort += ","
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
|
||||
@containers += @project.versions.includes(:attachments).reorder(sort).all.sort
|
||||
|
||||
show_attachments @containers
|
||||
|
||||
render :layout => !request.xhr?
|
||||
elsif params[:course_id]
|
||||
@isproject = false
|
||||
@containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
||||
|
||||
if params[:sort]
|
||||
params[:sort].split(",").each do |sort_type|
|
||||
order_by = sort_type.split(":")
|
||||
|
||||
case order_by[0]
|
||||
when "filename"
|
||||
attribute = "filename"
|
||||
when "size"
|
||||
attribute = "filesize"
|
||||
when "attach_type"
|
||||
attribute = "attachtype"
|
||||
when "content_type"
|
||||
attribute = "created_on"
|
||||
when "field_file_dense"
|
||||
attribute = "is_public"
|
||||
when "downloads"
|
||||
attribute = "downloads"
|
||||
when "created_on"
|
||||
attribute = "created_on"
|
||||
end
|
||||
|
||||
if order_by.count == 1
|
||||
sort += "#{Attachment.table_name}.#{attribute} desc "
|
||||
elsif order_by.count == 2
|
||||
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
|
||||
end
|
||||
if sort_type != params[:sort].split(",").last
|
||||
sort += ","
|
||||
end
|
||||
end
|
||||
end
|
||||
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
|
||||
|
||||
show_attachments @containers
|
||||
|
||||
render :layout => 'base_courses'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
|
@ -84,6 +170,8 @@ class FilesController < ApplicationController
|
|||
@containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
|
||||
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||
|
||||
show_attachments @containers
|
||||
|
||||
@attachtype = 0
|
||||
@contenttype = 0
|
||||
|
||||
|
@ -110,6 +198,8 @@ class FilesController < ApplicationController
|
|||
|
||||
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
||||
|
||||
show_attachments @containers
|
||||
|
||||
@attachtype = 0
|
||||
@contenttype = 0
|
||||
|
||||
|
@ -163,7 +253,7 @@ class FilesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 返回制定资源类型的资源列表
|
||||
# 返回指定资源类型的资源列表
|
||||
# added by nwb
|
||||
def getattachtype
|
||||
sort_init 'created_on', 'desc'
|
||||
|
@ -178,6 +268,7 @@ class FilesController < ApplicationController
|
|||
elsif @course
|
||||
@containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
||||
end
|
||||
show_attachments @containers
|
||||
|
||||
@attachtype = params[:type].to_i
|
||||
@contenttype = params[:contentType].to_s
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# added by fq
|
||||
class ForumsController < ApplicationController
|
||||
layout "users_base"
|
||||
|
||||
# GET /forums
|
||||
# GET /forums.json
|
||||
before_filter :find_forum_if_available
|
||||
|
@ -50,14 +52,14 @@ class ForumsController < ApplicationController
|
|||
|
||||
def index
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@forums_all = Forum.all
|
||||
@forums_all = Forum.where('1=1')
|
||||
@forums_count = @forums_all.count
|
||||
@forums_pages = Paginator.new @forums_count, @limit, params['page']
|
||||
|
||||
|
||||
@offset ||= @forums_pages.offset
|
||||
# @forums = @forums_all.offset(@offset).limit(@limit).all
|
||||
@forums = Forum.all
|
||||
@forums = @forums_all.offset(@offset).limit(@limit).all
|
||||
#@forums = Forum.all
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @forums }
|
||||
|
@ -143,9 +145,10 @@ class ForumsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
if @forum.update_attributes(params[:forum])
|
||||
format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }
|
||||
format.html { redirect_to @forum, notice: l(:label_forum_update_succ) }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
flash.now[:error] = "#{l :label_forum_update_fail}: #{@forum.errors.full_messages[0]}"
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @forum.errors, status: :unprocessable_entity }
|
||||
end
|
||||
|
@ -166,10 +169,10 @@ class ForumsController < ApplicationController
|
|||
|
||||
def search_forum
|
||||
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
|
||||
name = params[:name]
|
||||
(redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||
q = "%#{params[:name].strip}%"
|
||||
(redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@forums_all = Forum.where("name LIKE '%#{params[:name]}%'")
|
||||
@forums_all = Forum.where("name LIKE ?", q)
|
||||
@forums_count = @forums_all.count
|
||||
@forums_pages = Paginator.new @forums_count, @limit, params['page']
|
||||
|
||||
|
@ -185,11 +188,13 @@ class ForumsController < ApplicationController
|
|||
end
|
||||
|
||||
def search_memo
|
||||
q = "%#{params[:name].strip}%"
|
||||
|
||||
limit = PageLimit
|
||||
@memo = Memo.new
|
||||
@offset, @limit = api_offset_and_limit({:limit => limit})
|
||||
@forum = Forum.find(params[:id])
|
||||
@memos_all = @forum.topics.where("subject LIKE '%#{params[:name]}%'")
|
||||
@memos_all = @forum.topics.where("subject LIKE ?", q)
|
||||
@topic_count = @memos_all.count
|
||||
@topic_pages = Paginator.new @topic_count, @limit, params['page']
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ class GanttsController < ApplicationController
|
|||
helper :sort
|
||||
include SortHelper
|
||||
include Redmine::Export::PDF
|
||||
helper :project_score
|
||||
|
||||
def show
|
||||
@gantt = Redmine::Helpers::Gantt.new(params)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#added by baiyu
|
||||
class GitUsageController < ApplicationController
|
||||
layout "project_base"
|
||||
def ch_usage
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
class HomeworkAttachController < ApplicationController
|
||||
layout "course_base"
|
||||
include CoursesHelper
|
||||
###############################
|
||||
before_filter :can_show_course,except: []
|
||||
#判断当前角色权限时需先找到当前操作的project
|
||||
before_filter :find_course_by_bid_id, :only => [:new]
|
||||
before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users]
|
||||
|
@ -169,7 +171,15 @@ class HomeworkAttachController < ApplicationController
|
|||
#users:该作业所有成员
|
||||
#q:模糊匹配的用户的昵称
|
||||
def members_for_homework homework,users,q
|
||||
homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'")
|
||||
#homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'")
|
||||
unpartin_users = homework.bid.courses.first.members.where("user_id not in (:users)", {:users => users}).joins(:user).where("users.login like '%#{q}%'")
|
||||
canpartin_users = []
|
||||
unpartin_users.each do |m|
|
||||
if m.user.allowed_to?(:paret_in_homework,homework.bid.courses.first)
|
||||
canpartin_users << m
|
||||
end
|
||||
end
|
||||
canpartin_users
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -343,5 +353,13 @@ class HomeworkAttachController < ApplicationController
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
#验证是否显示课程
|
||||
def can_show_course
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_course == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class IssueCategoriesController < ApplicationController
|
||||
layout "project_base"
|
||||
menu_item :settings
|
||||
model_object IssueCategory
|
||||
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||
|
@ -25,6 +26,8 @@ class IssueCategoriesController < ApplicationController
|
|||
before_filter :authorize
|
||||
accept_api_auth :index, :show, :create, :update, :destroy
|
||||
|
||||
helper :project_score
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_settings_in_projects }
|
||||
|
|
|
@ -52,6 +52,7 @@ class IssuesController < ApplicationController
|
|||
include IssuesHelper
|
||||
helper :timelog
|
||||
include Redmine::Export::PDF
|
||||
helper :project_score
|
||||
|
||||
def index
|
||||
retrieve_query
|
||||
|
@ -82,6 +83,10 @@ class IssuesController < ApplicationController
|
|||
:limit => @limit)
|
||||
@issue_count_by_group = @query.issue_count_by_group
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :template => 'issues/index', :layout => @project_base_tag }#by young
|
||||
format.api {
|
||||
|
@ -119,6 +124,7 @@ class IssuesController < ApplicationController
|
|||
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
||||
|
||||
@project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young
|
||||
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -194,6 +200,30 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
if saved
|
||||
|
||||
#修改界面增加跟踪者
|
||||
watcherlist = @issue.watcher_users
|
||||
select_users = []
|
||||
if params[:issue]
|
||||
if params[:issue][:watcher_user_ids]
|
||||
params[:issue][:watcher_user_ids].each do |user_id|
|
||||
select_users << User.find(user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
select_users.each do |user|
|
||||
if watcherlist.include? user
|
||||
else
|
||||
@issue.add_watcher user
|
||||
end
|
||||
end
|
||||
watcherlist.each do |user|
|
||||
if select_users.include? user
|
||||
else
|
||||
@issue.remove_watcher user
|
||||
end
|
||||
end
|
||||
|
||||
render_attachment_warning_if_needed(@issue)
|
||||
reply_id = params[:reference_user_id].to_i
|
||||
if reply_id > 0
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# -*coding:utf-8 -*-
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
|
@ -14,6 +15,7 @@
|
|||
# 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 MembersController < ApplicationController
|
||||
model_object Member
|
||||
before_filter :find_model_object, :except => [:index, :create, :autocomplete]
|
||||
|
@ -76,8 +78,10 @@ class MembersController < ApplicationController
|
|||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||
user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id)
|
||||
## added by nie
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id)
|
||||
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id) if role.allowed_to?(:is_manager)
|
||||
# ProjectInfo.create(:name => "test", :user_id => 123)
|
||||
end
|
||||
## end
|
||||
|
@ -86,8 +90,9 @@ class MembersController < ApplicationController
|
|||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
||||
user_grades << UserGrade.new(:user_id => params[:membership][:user_id], :project_id => @project.id)
|
||||
## added by nie
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
project_info << ProjectInfo.new(:project_id => @project.id, :user_id => params[:membership][:user_id])
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
project_info << ProjectInfo.new(:project_id => @project.id, :user_id => params[:membership][:user_id]) if role.allowed_to?(:is_manager)
|
||||
end
|
||||
## end
|
||||
end
|
||||
|
@ -121,16 +126,24 @@ class MembersController < ApplicationController
|
|||
attrs = params[:membership].dup
|
||||
user_ids = attrs.delete(:user_ids)
|
||||
user_ids.each do |user_id|
|
||||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||
member = Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||
role = Role.find_by_id(params[:membership][:role_ids])
|
||||
# 这里的判断只能通过角色名,可以弄成常量
|
||||
if role.name == "学生"
|
||||
StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id)
|
||||
end
|
||||
members << member
|
||||
#user_grades << UserGrade.new(:user_id => user_id, :course_id => @course.id)
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
course_info << CourseInfo.new(:user_id => user_id, :course_id => @course.id)
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
course_info << CourseInfo.new(:user_id => user_id, :course_id => @course.id) if role.allowed_to?(:is_manager)
|
||||
end
|
||||
end
|
||||
else
|
||||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
course_info << CourseInfo.new(:course_id => @course.id, :user_id => params[:membership][:user_id])
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
course_info << CourseInfo.new(:course_id => @course.id, :user_id => params[:membership][:user_id]) if role.allowed_to?(:is_manager)
|
||||
end
|
||||
end
|
||||
@course.members << members
|
||||
|
@ -162,14 +175,17 @@ class MembersController < ApplicationController
|
|||
@member.role_ids = params[:membership][:role_ids]
|
||||
|
||||
#added by nie
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
|
||||
@projectInfo.save
|
||||
else
|
||||
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||
if user_admin.size > 0
|
||||
user_admin.each do |user|
|
||||
user.destroy
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
if role.allowed_to?(:is_manager)
|
||||
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
|
||||
@projectInfo.save
|
||||
else
|
||||
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||
if user_admin.size > 0
|
||||
user_admin.each do |user|
|
||||
user.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -191,14 +207,26 @@ class MembersController < ApplicationController
|
|||
if params[:membership]
|
||||
@member.role_ids = params[:membership][:role_ids]
|
||||
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
@courseInfo = CourseInfos.new(:user_id => @member.user_id, :course_id => @course.id)
|
||||
@courseInfo.save
|
||||
else
|
||||
user_admin = CourseInfos.where("user_id = ? and course_id = ?", @member.user_id, @course.id)
|
||||
if user_admin.size > 0
|
||||
user_admin.each do |user|
|
||||
user.destroy
|
||||
if (params[:membership][:role_ids])
|
||||
role = Role.find(params[:membership][:role_ids][0])
|
||||
# 这里的判断只能通过角色名,可以弄成常量
|
||||
if role.name == "学生"
|
||||
StudentsForCourse.create(:student_id => @member.user_id, :course_id =>@course.id)
|
||||
else
|
||||
joined = StudentsForCourse.where('student_id = ? and course_id = ?', @member.user_id,@course.id)
|
||||
joined.each do |join|
|
||||
join.delete
|
||||
end
|
||||
end
|
||||
if role.allowed_to?(:is_manager)
|
||||
@courseInfo = CourseInfos.new(:user_id => @member.user_id, :course_id => @course.id)
|
||||
@courseInfo.save
|
||||
else
|
||||
user_admin = CourseInfos.where("user_id = ? and course_id = ?", @member.user_id, @course.id)
|
||||
if user_admin.size > 0
|
||||
user_admin.each do |user|
|
||||
user.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -260,6 +288,11 @@ class MembersController < ApplicationController
|
|||
user.destroy
|
||||
end
|
||||
end
|
||||
joined = StudentsForCourse.where('student_id = ? and course_id = ?', @member.user_id,@course.id)
|
||||
joined.each do |join|
|
||||
join.delete
|
||||
end
|
||||
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_settings_in_courses }
|
||||
|
|
|
@ -9,6 +9,7 @@ class MemosController < ApplicationController
|
|||
|
||||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
include ApplicationHelper
|
||||
|
||||
layout 'base_memos'
|
||||
|
||||
|
@ -19,6 +20,11 @@ class MemosController < ApplicationController
|
|||
@content = "#{ll(Setting.default_language, :text_user_wrote, @memo.author)} <br/> "
|
||||
@content << @memo.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n") + "</blockquote>\n\n<br/>"
|
||||
@content = "<blockquote>" << @content
|
||||
#@content = "> #{ll(Setting.default_language, :text_user_wrote, @memo.author)}\n> "
|
||||
#@content << @memo.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
#@content_html = textilizable(@content)
|
||||
@temp = Memo.new
|
||||
@temp.content = @content
|
||||
end
|
||||
|
||||
def new
|
||||
|
@ -34,12 +40,23 @@ class MemosController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
|
||||
if params[:quote].nil?
|
||||
@quote = ""
|
||||
else
|
||||
@quote = params[:quote]
|
||||
end
|
||||
|
||||
#unless params[:quote].nil?
|
||||
# @quote = params[:quote][:quote]
|
||||
#end
|
||||
|
||||
@memo = Memo.new(params[:memo])
|
||||
@memo.forum_id = params[:forum_id]
|
||||
@memo.author_id = User.current.id
|
||||
|
||||
@memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads]))
|
||||
|
||||
@memo.content = @quote + @memo.content
|
||||
respond_to do |format|
|
||||
if @memo.save
|
||||
format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
|
||||
|
@ -67,7 +84,7 @@ class MemosController < ApplicationController
|
|||
@reply_pages = Paginator.new @reply_count, pre_count, page
|
||||
@replies = @memo.children.
|
||||
includes(:author, :attachments).
|
||||
reorder("#{Memo.table_name}.created_at ASC").
|
||||
reorder("#{Memo.table_name}.created_at DESC").
|
||||
limit(@reply_pages.per_page).
|
||||
offset(@reply_pages.offset).
|
||||
all
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class MessagesController < ApplicationController
|
||||
include ApplicationHelper
|
||||
menu_item :boards
|
||||
default_search_scope :messages
|
||||
before_filter :find_board, :only => [:new, :preview]
|
||||
before_filter :find_board, :only => [:new, :preview,:edit]
|
||||
before_filter :find_attachments, :only => [:preview]
|
||||
before_filter :find_message, :except => [:new, :preview]
|
||||
before_filter :authorize, :except => [:preview, :edit, :destroy, :new]
|
||||
|
@ -27,11 +28,13 @@ class MessagesController < ApplicationController
|
|||
helper :watchers
|
||||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
helper :project_score
|
||||
|
||||
REPLIES_PER_PAGE = 25 unless const_defined?(:REPLIES_PER_PAGE)
|
||||
|
||||
# Show a topic and its replies
|
||||
def show
|
||||
@isReply = true
|
||||
page = params[:page]
|
||||
# Find the page of the requested reply
|
||||
if params[:r] && page.nil?
|
||||
|
@ -77,12 +80,17 @@ class MessagesController < ApplicationController
|
|||
|
||||
# Reply to a topic
|
||||
def reply
|
||||
if params[:reply][:content] == ""
|
||||
(redirect_to board_message_path(@board, @topic, :r => @reply), :notice => l(:label_reply_empty);return)
|
||||
end
|
||||
@quote = params[:quote][:quote]
|
||||
@reply = Message.new
|
||||
@reply.author = User.current
|
||||
@reply.board = @board
|
||||
@reply.safe_attributes = params[:reply]
|
||||
@reply.content = @quote + @reply.content
|
||||
@topic.children << @reply
|
||||
@topic.update_attribute(:updated_on, Time.now)
|
||||
#@topic.update_attribute(:updated_on, Time.now)
|
||||
if !@reply.new_record?
|
||||
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
|
||||
attachments = Attachment.attach_files(@reply, params[:attachments])
|
||||
|
@ -96,7 +104,12 @@ class MessagesController < ApplicationController
|
|||
|
||||
# Edit a message
|
||||
def edit
|
||||
(render_403; return false) unless @message.editable_by?(User.current)
|
||||
@isReply = false
|
||||
if @project
|
||||
(render_403; return false) unless @message.editable_by?(User.current)
|
||||
else
|
||||
(render_403; return false) unless @message.course_editable_by?(User.current)
|
||||
end
|
||||
@message.safe_attributes = params[:message]
|
||||
if request.post? && @message.save
|
||||
attachments = Attachment.attach_files(@message, params[:attachments])
|
||||
|
@ -104,18 +117,38 @@ class MessagesController < ApplicationController
|
|||
flash[:notice] = l(:notice_successful_update)
|
||||
@message.reload
|
||||
redirect_to board_message_path(@message.board, @message.root, :r => (@message.parent_id && @message.id))
|
||||
elsif request.get?
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :layout => layout_file
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Delete a messages
|
||||
def destroy
|
||||
(render_403; return false) unless @message.destroyable_by?(User.current)
|
||||
if @project
|
||||
(render_403; return false) unless @message.destroyable_by?(User.current)
|
||||
else
|
||||
(render_403; return false) unless @message.course_destroyable_by?(User.current)
|
||||
end
|
||||
r = @message.to_param
|
||||
@message.destroy
|
||||
if @message.parent
|
||||
redirect_to board_message_path(@board, @message.parent, :r => r)
|
||||
else
|
||||
redirect_to project_board_path(@project, @board)
|
||||
# modify by nwb
|
||||
if @project
|
||||
if @message.parent
|
||||
redirect_to board_message_path(@board, @message.parent, :r => r)
|
||||
else
|
||||
redirect_to project_board_path(@project, @board)
|
||||
end
|
||||
elsif @course
|
||||
if @message.parent
|
||||
redirect_to board_message_path(@board, @message.parent, :r => r)
|
||||
else
|
||||
redirect_to course_board_path(@course, @board)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -123,8 +156,18 @@ class MessagesController < ApplicationController
|
|||
@subject = @message.subject
|
||||
@subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
|
||||
|
||||
@content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
|
||||
@content << @message.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
#@content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
|
||||
#@temp = Message.new
|
||||
##@temp.content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}> "
|
||||
#@content << @message.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
#@content_html = textilizable(@content)
|
||||
#@temp.content = @content_html
|
||||
@content = "#{ll(Setting.default_language, :text_user_wrote, @message.author)} <br/> "
|
||||
@content << @message.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n") + "</blockquote>\n\n<br/>"
|
||||
@content = "<blockquote>" << @content
|
||||
@temp = Message.new
|
||||
@temp.content = @content
|
||||
|
||||
end
|
||||
|
||||
def preview
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class MyController < ApplicationController
|
||||
layout "users_base"
|
||||
before_filter :require_login
|
||||
|
||||
helper :issues
|
||||
|
@ -36,20 +37,47 @@ class MyController < ApplicationController
|
|||
}.freeze
|
||||
|
||||
def index
|
||||
|
||||
page
|
||||
render :action => 'page'
|
||||
end
|
||||
end
|
||||
|
||||
# Show user's page
|
||||
def page
|
||||
@user = User.current
|
||||
@Issues= Issue.visible.open.
|
||||
where(:assigned_to_id => ([User.current.id] + User.current.group_ids))
|
||||
@limit = 10
|
||||
@feedback_count = @Issues.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
@curse_attachments = @Issues[@offset, @limit]
|
||||
|
||||
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT
|
||||
end
|
||||
|
||||
def page2
|
||||
@limit = 10
|
||||
@user = User.current
|
||||
@Issues= Issue.visible.open.
|
||||
where(:assigned_to_id => ([User.current.id] + User.current.group_ids))
|
||||
@feedback_count = @Issues.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
@curse_attachments = @Issues[@offset, @limit]
|
||||
@state = false
|
||||
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# Edit user's account
|
||||
def account
|
||||
@user = User.current
|
||||
@pref = @user.pref
|
||||
diskfile = disk_filename('User', @user.id)
|
||||
diskfile1 = diskfile + 'temp'
|
||||
if request.post?
|
||||
@user.safe_attributes = params[:user]
|
||||
@user.pref.attributes = params[:pref]
|
||||
|
@ -71,6 +99,33 @@ class MyController < ApplicationController
|
|||
@se.student_id = params[:no] if params[:no]
|
||||
|
||||
if @user.save && @se.save
|
||||
# 头像保存
|
||||
if File.exist?(diskfile1)
|
||||
if File.exist?(diskfile)
|
||||
File.delete(diskfile)
|
||||
end
|
||||
File.open(diskfile1, "rb") do |f|
|
||||
buffer = f.read(10)
|
||||
if buffer != "DELETE"
|
||||
File.open(diskfile1, "rb") do |f1|
|
||||
File.open(diskfile, "wb") do |f|
|
||||
buffer = ""
|
||||
while (buffer = f1.read(8192))
|
||||
f.write(buffer)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# File.rename(diskfile + 'temp',diskfile);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 确保文件被删除
|
||||
if File.exist?(diskfile1)
|
||||
File.delete(diskfile1)
|
||||
end
|
||||
|
||||
@user.pref.save
|
||||
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||
set_language_if_valid @user.language
|
||||
|
@ -78,8 +133,17 @@ class MyController < ApplicationController
|
|||
redirect_to user_path(@user)
|
||||
return
|
||||
else
|
||||
# 确保文件被删除
|
||||
if File.exist?(diskfile1)
|
||||
File.delete(diskfile1)
|
||||
end
|
||||
@user
|
||||
end
|
||||
else
|
||||
# 确保文件被删除
|
||||
if File.exist?(diskfile1)
|
||||
File.delete(diskfile1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -114,11 +178,11 @@ class MyController < ApplicationController
|
|||
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
||||
|
||||
if @user.save
|
||||
flash[:notice] = l(:notice_account_password_updated)
|
||||
flash.now[:notice] = l(:notice_account_password_updated)
|
||||
redirect_to my_account_path
|
||||
end
|
||||
else
|
||||
flash[:error] = l(:notice_account_wrong_password)
|
||||
flash.now[:error] = l(:notice_account_wrong_password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,6 +29,7 @@ class NewsController < ApplicationController
|
|||
|
||||
helper :watchers
|
||||
helper :attachments
|
||||
helper :project_score
|
||||
|
||||
def index
|
||||
case params[:format]
|
||||
|
@ -98,10 +99,12 @@ class NewsController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@news = News.new(:project => @project, :author => User.current)
|
||||
@course_tag = @project.project_type
|
||||
if @course_tag
|
||||
render :layout => 'base_courses'
|
||||
#modify by nwb
|
||||
if @project
|
||||
@news = News.new(:project => @project, :author => User.current)
|
||||
elsif @course
|
||||
@news = News.new(:course => @course, :author => User.current)
|
||||
render :layout => 'base_courses'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -145,7 +148,8 @@ class NewsController < ApplicationController
|
|||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to news_path(@news)
|
||||
else
|
||||
render :action => 'edit'
|
||||
#flash[:error] = l(:notice_successful_update)
|
||||
redirect_to news_path(@news)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class NotificationcommentsController < ApplicationController
|
||||
def show
|
||||
|
||||
end
|
||||
# default_search_scope :contestnotifications
|
||||
# model_object Contestnotifications
|
||||
# before_filter :authorize
|
||||
|
@ -20,8 +23,14 @@ class NotificationcommentsController < ApplicationController
|
|||
end
|
||||
|
||||
def destroy
|
||||
@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
|
||||
redirect_to contest_contestnotification_path(@contestnotifications)
|
||||
@contest = Contest.find(params[:contest_id])
|
||||
@contestnotification = Contestnotification.find(params[:contestnotification_id])
|
||||
notificaioncomments = Notificationcomment.find(params[:id])
|
||||
notificaioncomments.destroy if notificaioncomments
|
||||
#@contestnotifications = notificaioncomments.Contestnotification
|
||||
#@contest = @contestnotifications.contest
|
||||
#@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
|
||||
redirect_to contest_contestnotification_path(@contest,@contestnotification)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -16,11 +16,10 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class PreviewsController < ApplicationController
|
||||
before_filter :find_project, :find_attachments, :find_contest, except: [:contestnotification]
|
||||
before_filter :find_project, :find_attachments, except: :contestnotification
|
||||
|
||||
def issue
|
||||
@issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
|
||||
@issue = @contest.issues.find_by_id(params[:id]) unless params[:id].blank?
|
||||
if @issue
|
||||
@description = params[:issue] && params[:issue][:description]
|
||||
if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
|
||||
|
@ -65,12 +64,4 @@ class PreviewsController < ApplicationController
|
|||
render :partial => 'common/preview'
|
||||
end
|
||||
|
||||
private
|
||||
def find_contest
|
||||
contest_id = (params[:issue] && params[:issue][:contest_id]) || params[:contest_id]
|
||||
@contest = Contest.find(contest_id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -42,7 +42,7 @@ class ProjectsController < ApplicationController
|
|||
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
|
||||
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
|
||||
before_filter :file, :statistics, :watcherlist
|
||||
before_filter :find_project_repository, :only => [:show]
|
||||
#before_filter :find_project_repository, :only => [:show]
|
||||
# 除非项目内人员,不可查看成员, TODO: 完了写报表里去
|
||||
before_filter :memberAccess, only: :member
|
||||
|
||||
|
@ -75,6 +75,8 @@ class ProjectsController < ApplicationController
|
|||
helper :watchers
|
||||
# helper :watcherlist
|
||||
helper :words
|
||||
helper :project_score
|
||||
helper :user_score
|
||||
### added by william
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
|
||||
|
@ -103,12 +105,14 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def index
|
||||
#调用存储过程更新提交次数
|
||||
#ActiveRecord::Base.connection.execute("CALL sp_project_status_cursor();")
|
||||
#Modified by nie
|
||||
@project_type = params[:project_type].to_i
|
||||
per_page_option = 10
|
||||
|
||||
@projects_all = Project.active.visible.
|
||||
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
|
||||
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").joins("LEFT JOIN #{ProjectScore.table_name} ON #{Project.table_name}.id = #{ProjectScore.table_name}.project_id").
|
||||
where("#{Project.table_name}.project_type = ? ", Project::ProjectType_project)
|
||||
|
||||
@project_count = @projects_all.count
|
||||
|
@ -131,7 +135,7 @@ class ProjectsController < ApplicationController
|
|||
@projects = @projects_all.order("created_on desc")
|
||||
@s_type = 0
|
||||
when '1'
|
||||
@projects = @projects_all.order("grade desc")
|
||||
@projects = @projects_all.order("score desc")
|
||||
@s_type = 1
|
||||
when '2'
|
||||
@projects = @projects_all.order("watchers_count desc")
|
||||
|
@ -145,11 +149,12 @@ class ProjectsController < ApplicationController
|
|||
@projects = @projects[@project_pages.offset, @project_pages.per_page]
|
||||
|
||||
else
|
||||
@projects = @projects = @projects_all.order("grade desc")
|
||||
@projects = @projects = @projects_all.order("score desc")
|
||||
@s_type = 1
|
||||
end
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base'
|
||||
|
@ -398,21 +403,35 @@ class ProjectsController < ApplicationController
|
|||
#Ended by young
|
||||
|
||||
def feedback
|
||||
page = params[:page]
|
||||
@page = params[:page]
|
||||
@page = @page.to_i
|
||||
# Find the page of the requested reply
|
||||
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@limit = 10
|
||||
if params[:r] && page.nil?
|
||||
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
||||
page = 1 + offset / @limit
|
||||
|
||||
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
||||
page = 1 + offset / @limit
|
||||
if params[:r] && @page.nil?
|
||||
@page = page
|
||||
end
|
||||
|
||||
|
||||
puts @page
|
||||
if @page < 0
|
||||
@page = 1
|
||||
end
|
||||
if @page > page
|
||||
@page = page
|
||||
end
|
||||
|
||||
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, page
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, @page
|
||||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
@state = false
|
||||
@base_courses_tag = @project.project_type
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_courses' if @base_courses_tag==1}
|
||||
format.api
|
||||
|
@ -448,24 +467,10 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@project_type = params[:project_type] ||= params[:course]
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
|
||||
case @project_type
|
||||
when '0' # Project
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
when '1' # Course
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
@course_tag = params[:course]
|
||||
@course = Course.new
|
||||
@course.safe_attributes = params[:course]
|
||||
else # default Project
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
end
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
render :layout => 'base'
|
||||
end
|
||||
|
||||
|
@ -478,127 +483,44 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@course_tag = params[:project][:project_type]
|
||||
if(@course_tag=="1")
|
||||
if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER)
|
||||
@course = Course.new
|
||||
@course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
|
||||
@course.safe_attributes = params[:project][:course]
|
||||
@course.tea_id = User.current.id
|
||||
# added by bai
|
||||
@course.term = params[:term]
|
||||
@course.time = params[:time]
|
||||
#@course.school_id = params[:occupation]
|
||||
@course.school_id = User.current.user_extensions.school_id
|
||||
@course.setup_time = params[:setup_time]
|
||||
@course.endup_time = params[:endup_time]
|
||||
@course.class_period = params[:class_period]
|
||||
end
|
||||
end
|
||||
def create
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
@project = Project.new
|
||||
@project.user_id = User.current.id
|
||||
@project.safe_attributes = params[:project]
|
||||
if @course_tag == '1'
|
||||
@project.identifier = @course.extra
|
||||
end
|
||||
if @course_tag == '1'
|
||||
if User.current.user_extensions.identity == 0
|
||||
if@course.save
|
||||
if validate_parent_id && @project.save
|
||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||
# Add current user as a project member if he is not admin
|
||||
unless User.current.admin?
|
||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||
m = Member.new(:user => User.current, :roles => [r])
|
||||
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
|
||||
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
|
||||
if params[:project][:is_public] == '1'
|
||||
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :project_type => @course_tag)
|
||||
end
|
||||
@project.members << m
|
||||
@project.project_infos << project
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
if params[:continue]
|
||||
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
|
||||
redirect_to new_project_path(attrs, :course => '0')
|
||||
#Added by young
|
||||
|
||||
elsif params[:course_continue]
|
||||
redirect_to new_project_path(:course => '1')
|
||||
#Ended by young
|
||||
else
|
||||
redirect_to settings_project_path(@project,:project_type => 1)
|
||||
end
|
||||
}
|
||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
|
||||
end
|
||||
if validate_parent_id && @project.save
|
||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||
# Add current user as a project member if he is not admin
|
||||
#unless User.current.admin?
|
||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||
m = Member.new(:user => User.current, :roles => [r])
|
||||
project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
|
||||
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
|
||||
Rails.logger.debug "UserGrade created: #{user_grades.to_json}"
|
||||
#if params[:project][:is_public] == '1'
|
||||
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type,:grade => 0)
|
||||
Rails.logger.debug "ProjectStatus created: #{project_status.to_json}"
|
||||
#end
|
||||
@project.members << m
|
||||
@project.project_infos << project_info
|
||||
#end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
if params[:continue]
|
||||
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
|
||||
redirect_to new_project_path(attrs, :course => '0')
|
||||
else
|
||||
@course.destroy
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new', :layout => 'base'}#Added by young
|
||||
format.api { render_validation_errors(@project) }
|
||||
end
|
||||
redirect_to settings_project_path(@project)
|
||||
end
|
||||
else
|
||||
if validate_parent_id && @project.save
|
||||
@project.delete
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new', :layout => 'base'}#Added by young
|
||||
format.api { render_validation_errors(@project) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new', :layout => 'base'}#Added by young
|
||||
format.api { render_validation_errors(@project) }
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
|
||||
end
|
||||
else
|
||||
if validate_parent_id && @project.save
|
||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||
# Add current user as a project member if he is not admin
|
||||
unless User.current.admin?
|
||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||
m = Member.new(:user => User.current, :roles => [r])
|
||||
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
|
||||
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
|
||||
if params[:project][:is_public] == '1' || @course_tag=="1"
|
||||
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type)
|
||||
end
|
||||
@project.members << m
|
||||
@project.project_infos << project
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
if params[:continue]
|
||||
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
|
||||
redirect_to new_project_path(attrs, :course => '0')
|
||||
#Added by young
|
||||
|
||||
elsif params[:course_continue]
|
||||
redirect_to new_project_path(:course => '1')
|
||||
#Ended by young
|
||||
else
|
||||
redirect_to settings_project_path(@project)
|
||||
end
|
||||
}
|
||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new', :layout => 'base'}#Added by young
|
||||
format.api { render_validation_errors(@project) }
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new', :layout => 'base'}#Added by young
|
||||
format.api { render_validation_errors(@project) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -672,6 +594,7 @@ class ProjectsController < ApplicationController
|
|||
"show_news" => true,
|
||||
"show_bids" => true,
|
||||
"show_contests" => true,
|
||||
"show_wiki_edits"=>true,
|
||||
"show_journals_for_messages" => true
|
||||
}
|
||||
@date_to ||= Date.today + 1
|
||||
|
@ -685,8 +608,14 @@ class ProjectsController < ApplicationController
|
|||
@activity.scope_select {|t| !has["show_#{t}"].nil?}
|
||||
# logger.debug "=========================================#{@activity.scope}"
|
||||
# @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
|
||||
#Added by young
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
|
||||
# modify by nwb
|
||||
# 添加私密性判断
|
||||
if User.current.member_of?(@project)|| User.current.admin?
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
else
|
||||
events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||
end
|
||||
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@events_count = events.count
|
||||
|
@ -717,8 +646,8 @@ class ProjectsController < ApplicationController
|
|||
@canShowRealName = isCourseTeacher(User.current.id)
|
||||
end
|
||||
|
||||
#勿删 real_name action为虚拟的该方法并不存在,用来辅助判断真名权限
|
||||
#勿删 @canShowRealName = User.current.allowed_to?({:controller => "projects", :action => "real_name"}, @project || @projects, :global => false)
|
||||
# real_name action为虚拟的该方法并不存在,用来辅助判断真名权限
|
||||
# @canShowRealName = User.current.allowed_to?({:controller => "projects", :action => "real_name"}, @project || @projects, :global => false)
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_courses' if @base_courses_tag==1}
|
||||
format.api
|
||||
|
@ -734,7 +663,7 @@ class ProjectsController < ApplicationController
|
|||
#Added by young
|
||||
# @course_tag = params[:course]
|
||||
# if @course_tag == '1'
|
||||
@course = Course.find_by_extra(@project.identifier)
|
||||
#@course = Course.find_by_extra(@project.identifier)
|
||||
# if @project.project_type == 1
|
||||
# render :layout => 'base_courses'
|
||||
# else
|
||||
|
@ -769,8 +698,8 @@ class ProjectsController < ApplicationController
|
|||
else # @project.project_type == Project::ProjectType_project
|
||||
roles = Role.find_all_givable
|
||||
@subPage_title = l :label_member_list
|
||||
@members = @project.member_principals.includes(:roles, :principal).all
|
||||
@members = sort_project_members(@project, @members)
|
||||
@members = @project.member_principals.includes(:roles, :principal).joins("LEFT JOIN #{OptionNumber.table_name} ON #{OptionNumber.table_name}.user_id = #{Member.table_name}.user_id and #{OptionNumber.table_name}.score_type = 2 AND #{Member.table_name}.project_id = #{OptionNumber.table_name}.project_id").order("#{OptionNumber.table_name}.total_score DESC").all
|
||||
#@members = sort_project_members(@project, @members)
|
||||
@applied_members = appied_project_members(@project, @members)
|
||||
end
|
||||
@members = paginateHelper @members
|
||||
|
@ -826,6 +755,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def update
|
||||
@project.safe_attributes = params[:project]
|
||||
#@project.dts_test = params[:project][:dts_test]
|
||||
if validate_parent_id && @project.save
|
||||
@course = Course.find_by_extra(@project.identifier)
|
||||
unless @course.nil?
|
||||
|
@ -966,6 +896,18 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def exit_project
|
||||
@project = Project.find params[:id]
|
||||
if User.current.login?
|
||||
members = Member.where(:user_id => User.current.id, :project_id=>params[:id]).first
|
||||
if members != nil
|
||||
members.destroy
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
private
|
||||
|
||||
def memberAccess
|
||||
|
@ -1112,4 +1054,5 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
#gcmend
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -39,6 +39,7 @@ class RepositoriesController < ApplicationController
|
|||
before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ]
|
||||
helper :repositories
|
||||
include RepositoriesHelper
|
||||
helper :project_score
|
||||
#@root_path = RepositoriesHelper::ROOT_PATH
|
||||
|
||||
|
||||
|
@ -92,57 +93,74 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
##xianbo
|
||||
@root_path=RepositoriesHelper::ROOT_PATH
|
||||
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
|
||||
@project_path=@root_path+"htdocs/"+@repository_name
|
||||
@repository_tag=params[:repository][:upassword]
|
||||
@repo_name=User.current.login.to_s+"_"+params[:repository][:identifier]
|
||||
logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag
|
||||
logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name
|
||||
attrs = pickup_extra_info
|
||||
if((@repository_tag!="")&¶ms[:repository_scm]=="Git")
|
||||
if params[:repository_scm].to_s == 'Gitlab'
|
||||
# add by nwb
|
||||
# 增加对gitlab版本库的支持
|
||||
attrs = pickup_extra_info
|
||||
@repository = Repository.factory('Git')
|
||||
@repository.safe_attributes = params[:repository]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
@repository.project = @project
|
||||
if request.post? && @repository.save
|
||||
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||
else
|
||||
render :action => 'new'
|
||||
end
|
||||
else # 原逻辑
|
||||
##xianbo
|
||||
@root_path=RepositoriesHelper::ROOT_PATH
|
||||
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
|
||||
@project_path=@root_path+"htdocs/"+@repository_name
|
||||
@repository_tag=params[:repository][:upassword]
|
||||
@repo_name=User.current.login.to_s+"_"+params[:repository][:identifier]
|
||||
logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag
|
||||
logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name
|
||||
attrs = pickup_extra_info
|
||||
if((@repository_tag!="")&¶ms[:repository_scm]=="Git")
|
||||
params[:repository][:url]=@project_path
|
||||
end
|
||||
###xianbo
|
||||
@repository = Repository.factory(params[:repository_scm])
|
||||
@repository.safe_attributes = params[:repository]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
#by xianbo
|
||||
|
||||
@repository.project = @project
|
||||
if request.post? && @repository.save
|
||||
if(params[:repository_scm]=="Git")
|
||||
system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag
|
||||
system "echo -e '"+@repo_name+"-write:"+
|
||||
" "+@repo_name+"' >> "+@root_path+"group.passwd"
|
||||
system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s
|
||||
system "git init --bare "+@project_path
|
||||
system "mv "+@project_path+"/hooks/post-update{.sample,}"
|
||||
system "chmod a+x "+@project_path+"/hooks/post-update"
|
||||
system "echo -e 'Allow from all \n Order Deny,Allow \n "+
|
||||
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
|
||||
"Require group "+@repo_name+"-write \n "+
|
||||
"</Limit> \n ' >> "+
|
||||
@root_path+"htdocs/"+ @repository_name+"/.htaccess"
|
||||
system "cd "+@project_path+" ;git update-server-info"
|
||||
# if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info)
|
||||
# else
|
||||
# logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+
|
||||
# crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+
|
||||
# "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info
|
||||
# end
|
||||
end
|
||||
###xianbo
|
||||
@repository = Repository.factory(params[:repository_scm])
|
||||
@repository.safe_attributes = params[:repository]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
#by xianbo
|
||||
|
||||
@repository.project = @project
|
||||
if request.post? && @repository.save
|
||||
if(params[:repository_scm]=="Git")
|
||||
system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag
|
||||
system "echo -e '"+@repo_name+"-write:"+
|
||||
" "+@repo_name+"' >> "+@root_path+"group.passwd"
|
||||
system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s
|
||||
system "git init --bare "+@project_path
|
||||
system "mv "+@project_path+"/hooks/post-update{.sample,}"
|
||||
system "chmod a+x "+@project_path+"/hooks/post-update"
|
||||
system "echo -e 'Allow from all \n Order Deny,Allow \n "+
|
||||
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
|
||||
"Require group "+@repo_name+"-write \n "+
|
||||
"</Limit> \n ' >> "+
|
||||
@root_path+"htdocs/"+ @repository_name+"/.htaccess"
|
||||
system "cd "+@project_path+" ;git update-server-info"
|
||||
# if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info)
|
||||
# else
|
||||
# logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+
|
||||
# crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+
|
||||
# "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info
|
||||
# end
|
||||
@repository.update_attributes(:login => User.current.login.to_s)
|
||||
end
|
||||
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||
else if(@repository_tag)
|
||||
render :action => 'newrepo', :layout =>'base_projects'
|
||||
else
|
||||
render :action => 'new', :layout =>'base_projects'
|
||||
end
|
||||
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||
else if(@repository_tag)
|
||||
render :action => 'newrepo', :layout =>'base_projects'
|
||||
else
|
||||
render :action => 'new', :layout =>'base_projects'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -188,6 +206,14 @@ class RepositoriesController < ApplicationController
|
|||
@repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h}
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to settings_project_path(@project, :tab => 'repositories')
|
||||
elsif request.get?
|
||||
respond_to do |format|
|
||||
format.html{
|
||||
render :layout => "project_base"
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -240,7 +266,7 @@ class RepositoriesController < ApplicationController
|
|||
@course_tag = params[:course]
|
||||
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
|
||||
ip = RepositoriesHelper::REPO_IP_ADDRESS
|
||||
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip+
|
||||
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+
|
||||
@repository.url.slice(project_path_cut, @repository.url.length).to_s
|
||||
if @course_tag == 1
|
||||
render :action => 'show', :layout => 'base_courses'
|
||||
|
@ -395,7 +421,10 @@ class RepositoriesController < ApplicationController
|
|||
Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}")
|
||||
unless read_fragment(@cache_key)
|
||||
@diff = @repository.diff(@path, @rev, @rev_to)
|
||||
show_error_not_found unless @diff
|
||||
unless @diff
|
||||
show_error_not_found
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@changeset = @repository.find_changeset_by_name(@rev)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class SchoolController < ApplicationController
|
||||
|
||||
layout 'course_base'
|
||||
before_filter :require_admin, :only => :upload_logo
|
||||
|
||||
def upload
|
||||
|
@ -98,16 +98,18 @@ class SchoolController < ApplicationController
|
|||
end
|
||||
|
||||
def search_school
|
||||
if params[:province].nil? or params[:province] == "0"
|
||||
@school = School.where("name LIKE '%"+params[:key_word]+"%'");
|
||||
else
|
||||
@school = School.where("province = ? AND name LIKE '%"+params[:key_word]+"%'", params[:province]);
|
||||
end
|
||||
q = "%#{params[:key_word].strip}%"
|
||||
|
||||
@school = School.where("name LIKE ?", q)
|
||||
@school = @school.where("province = ?", params[:province]) if (params[:province] != '0' )
|
||||
|
||||
options = ""
|
||||
@school.each do |s|
|
||||
options << "<li style = 'width: 33%; float: left'> <a id=#{s.id} onclick='test(this.id)'>#{s.name}</a></li>"
|
||||
end
|
||||
|
||||
render :text => options
|
||||
|
||||
options = "<div class='flash error' id='flash_error'>#{l(:label_school_not_fount)}</div>" if options.blank?
|
||||
|
||||
render :text => options
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class SoftapplicationsController < ApplicationController
|
||||
layout "contest_base"
|
||||
before_filter :find_softapplication, only: [:edit, :update, :destroy]
|
||||
before_filter :editable, only: [:edit, :update]
|
||||
before_filter :destroyable, only: :destroy
|
||||
|
@ -18,20 +19,20 @@ class SoftapplicationsController < ApplicationController
|
|||
|
||||
#new added sort
|
||||
if params[:softapplication_sort_type].present?
|
||||
case params[:softapplication_sort_type]
|
||||
case params[:softapplication_sort_type]
|
||||
when '0'
|
||||
@softapplications = @softapplications[@offset, @limit]
|
||||
@softapplications = @softapplications[@offset, @limit]
|
||||
@s_state = 0
|
||||
when '1'
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
else
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
else
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
#new added end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @softapplications }
|
||||
|
@ -108,14 +109,8 @@ class SoftapplicationsController < ApplicationController
|
|||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
#membership.member_roles.each{|role|
|
||||
# if(role.role_id == 3)
|
||||
# @option << membership.project
|
||||
# end
|
||||
#}
|
||||
|
||||
#拥有编辑项目权限的可操作该项目
|
||||
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
if User.current.allowed_to?(:quote_project,membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
|
@ -145,13 +140,14 @@ class SoftapplicationsController < ApplicationController
|
|||
|
||||
#new changed created function
|
||||
def create
|
||||
#options = params[:softapplication]
|
||||
#options[:app_type_name] = params[:other_input] if options[:app_type_name] == "其他" && params[:other_input]
|
||||
@softapplication = Softapplication.new(params[:softapplication])
|
||||
@softapplication.user = User.current
|
||||
#@softapplication.deposit_project = params[:project]
|
||||
@softapplication.project = Project.find_by_id(params[:project])
|
||||
|
||||
@softapplication.app_type_name = params[:other_input] if params[:other_input] != ""
|
||||
@softapplication.save_attachments(params[:attachments])
|
||||
|
||||
respond_to do |format|
|
||||
if @softapplication.save
|
||||
ContestingSoftapplication.create(:contest_id => params[:contest_id], :softapplication_id => @softapplication.id)
|
||||
|
@ -160,8 +156,8 @@ class SoftapplicationsController < ApplicationController
|
|||
format.html { redirect_to show_attendingcontest_contest_path(:id => params[:contest_id]), notice: l(:notice_attendingcontest_work_successfully_created) }
|
||||
# format.json { render json: @softapplication, status: :created, location: @softapplication }
|
||||
else
|
||||
format.js { render status: 406 }
|
||||
format.html { render action: "new" }
|
||||
#format.js { render status: 406 }
|
||||
format.html { render action: "contests/show_attendingcontest" }
|
||||
# format.json { render json: @softapplication.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
|
@ -176,12 +172,20 @@ class SoftapplicationsController < ApplicationController
|
|||
# PUT /softapplications/1.json
|
||||
def update
|
||||
# @softapplication = Softapplication.find(params[:id])
|
||||
@softapplication.attachments.map{|attach| attach.destroy }
|
||||
@softapplication.save_attachments(params[:attachments])
|
||||
#@softapplication.attachments.map{|attach| attach.destroy }
|
||||
@softapplication.save_attachments(params[:attachments]) if params[:attachments]
|
||||
#@softapplication.deposit_project = params[:project]
|
||||
@softapplication.project = Project.find_by_id(params[:project])
|
||||
|
||||
@softapplication.name = params[:softapplication][:name]
|
||||
@softapplication.android_min_version_available = params[:softapplication][:android_min_version_available]
|
||||
@softapplication.app_type_name = params[:other_input] == "" ? params[:softapplication][:app_type_name] : params[:other_input]
|
||||
@softapplication.description = params[:softapplication][:description]
|
||||
@softapplication.application_developers = params[:softapplication][:application_developers]
|
||||
#@softapplication.app_type_name = params[:other_input] if params[:other_input] != ""
|
||||
respond_to do |format|
|
||||
if @softapplication.update_attributes(params[:softapplication])
|
||||
#if @softapplication.update_attributes(params[:softapplication])
|
||||
if @softapplication.save
|
||||
format.html { redirect_to @softapplication, notice: l(:notice_softapplication_was_successfully_updated) }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
|
@ -212,19 +216,19 @@ class SoftapplicationsController < ApplicationController
|
|||
def new_message
|
||||
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
|
||||
if @jour
|
||||
user = @jour.user
|
||||
text = @jour.notes
|
||||
user = @jour.user
|
||||
text = @jour.notes
|
||||
else
|
||||
user = @softapplication.user
|
||||
text = @softapplication.description
|
||||
user = @softapplication.user
|
||||
text = @softapplication.description
|
||||
end
|
||||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||
@content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> "
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
@id = user.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
#新建评价
|
||||
def create_message
|
||||
|
@ -300,6 +304,36 @@ class SoftapplicationsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def search
|
||||
@softapplications = Softapplication.where("name like '%#{params[:name]}%'")
|
||||
|
||||
#new added fenyefunction
|
||||
@limit = 5
|
||||
@softapplication_count = @softapplications.count
|
||||
@softapplication_pages = Paginator.new @softapplication_count, @limit, params['page']
|
||||
@offset ||= @softapplication_pages.offset
|
||||
|
||||
#new added sort
|
||||
if params[:softapplication_sort_type].present?
|
||||
case params[:softapplication_sort_type]
|
||||
when '0'
|
||||
@softapplications = @softapplications[@offset, @limit]
|
||||
@s_state = 0
|
||||
when '1'
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
else
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
#new added end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_softapplication
|
||||
@softapplication = Softapplication.find_by_id(params[:id])
|
||||
|
|
|
@ -5,12 +5,18 @@ class StoresController < ApplicationController
|
|||
layout 'base_stores'
|
||||
|
||||
def search
|
||||
name = params[:name] ||= ''
|
||||
(redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||
begin
|
||||
q = "%#{params[:name].strip}%"
|
||||
(redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||
|
||||
result = find_public_attache name
|
||||
result = find_public_attache q
|
||||
@searched_attach = paginateHelper result
|
||||
@result_all_count = result.count;
|
||||
rescue Exception => e
|
||||
#render 'stores'
|
||||
redirect_to stores_path
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def find_public_attache keywords
|
||||
|
@ -20,25 +26,27 @@ class StoresController < ApplicationController
|
|||
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%").
|
||||
reorder("created_on DESC")
|
||||
|
||||
result = resultSet.to_a.dup
|
||||
# result = resultSet.to_a.dup
|
||||
|
||||
resultSet.to_a.map { |res|
|
||||
if(res.container.nil? ||
|
||||
(res.container.class.to_s=="Project" && res.container.is_public == false) ||
|
||||
(res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
|
||||
(res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
|
||||
false
|
||||
)
|
||||
result.delete(res)
|
||||
end
|
||||
}
|
||||
result
|
||||
# resultSet.to_a.map { |res|
|
||||
# if(res.container.nil? ||
|
||||
# (res.container.class.to_s=="Project" && res.container.is_public == false) ||
|
||||
# (res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
|
||||
# (res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
|
||||
# false
|
||||
# )
|
||||
# result.delete(res)
|
||||
# end
|
||||
# }
|
||||
# result
|
||||
end
|
||||
|
||||
LIMIT = 12 unless const_defined?(:LIMIT)
|
||||
def index
|
||||
@projects_attach = project_classification(0).take(LIMIT)
|
||||
@courses_attach = project_classification(1).take(LIMIT)
|
||||
@courses_attach = Attachment.includes(:course).where("courses.is_public = 1").
|
||||
where(container_type: 'Course').
|
||||
limit(LIMIT)
|
||||
# @projects_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 0, 1).
|
||||
# reorder("#{Attachment.table_name}.downloads DESC").
|
||||
# limit(LIMIT)
|
||||
|
|
|
@ -71,8 +71,8 @@ class TagsController < ApplicationController
|
|||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results,
|
||||
attachments_results,
|
||||
@forums_results,
|
||||
@attachments_results,
|
||||
@contests_results,
|
||||
@courses_results,
|
||||
@open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags)
|
||||
|
@ -107,8 +107,8 @@ class TagsController < ApplicationController
|
|||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results,
|
||||
attachments_results,
|
||||
@forums_results,
|
||||
@attachments_results,
|
||||
@contests_results,
|
||||
@courses_results,
|
||||
@open_source_projects_results= refresh_results(@obj_id,@show_flag)
|
||||
|
@ -130,8 +130,8 @@ class TagsController < ApplicationController
|
|||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results,
|
||||
attachments_results,
|
||||
@forums_results,
|
||||
@attachments_results,
|
||||
@contests_results,
|
||||
@courses_results,
|
||||
@open_source_projects_results= refresh_results(@obj_id,@show_flag)
|
||||
|
@ -199,7 +199,7 @@ class TagsController < ApplicationController
|
|||
@bids_results = nil
|
||||
@contests_results = nil
|
||||
@forums_results = nil
|
||||
attachments_results = nil
|
||||
@attachments_results = nil
|
||||
@open_source_projects_results = nil
|
||||
@obj_pages = nil
|
||||
@obj = nil
|
||||
|
@ -228,8 +228,9 @@ class TagsController < ApplicationController
|
|||
|
||||
# modifed by Long Jun
|
||||
# this is used to find the attachments that came from the same project and tagged with the same tag.
|
||||
@result = get_attachments_by_project_tag(selected_tags, @obj)
|
||||
@obj_pages, attachments_results, @results_count = for_pagination(@result)
|
||||
#@result = get_attachments_by_project_tag(selected_tags, @obj)
|
||||
@result = get_attachments_by_tag(selected_tags)
|
||||
@obj_pages, @attachments_results, @results_count = for_pagination(@result)
|
||||
when '7'
|
||||
@obj = Contest.find_by_id(obj_id)
|
||||
@obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags))
|
||||
|
@ -249,8 +250,8 @@ class TagsController < ApplicationController
|
|||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results,
|
||||
attachments_results,
|
||||
@forums_results,
|
||||
@attachments_results,
|
||||
@contests_results,
|
||||
@courses_results,
|
||||
@open_source_projects_results]
|
||||
|
|
|
@ -26,7 +26,7 @@ class TestController < ApplicationController
|
|||
end
|
||||
|
||||
def courselist
|
||||
@courses = Project.course_entities
|
||||
@courses = paginateHelper Course.includes(:homeworks).all, 10
|
||||
end
|
||||
|
||||
def ziping files_path
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
|
||||
class TrackersController < ApplicationController
|
||||
layout 'admin'
|
||||
|
||||
helper "project_score"
|
||||
before_filter :require_admin, :except => :index
|
||||
before_filter :require_admin_or_api_request, :only => :index
|
||||
accept_api_auth :index
|
||||
|
||||
include CoursesHelper
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -37,7 +37,13 @@ class TrackersController < ApplicationController
|
|||
def new
|
||||
@tracker ||= Tracker.new(params[:tracker])
|
||||
@trackers = Tracker.sorted.all
|
||||
@projects = Project.all
|
||||
@projects = Project.where("project_type = #{Project::ProjectType_project}").all
|
||||
@courses = Course.all
|
||||
@course_activity_count=Hash.new
|
||||
@courses.each do |course|
|
||||
@course_activity_count[course.id]=0
|
||||
end
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -57,7 +63,8 @@ class TrackersController < ApplicationController
|
|||
|
||||
def edit
|
||||
@tracker ||= Tracker.find(params[:id])
|
||||
@projects = Project.all
|
||||
@projects = Project.where("project_type = #{Project::ProjectType_project}").all
|
||||
@courses = Course.all
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
@ -29,11 +29,11 @@ class UsersController < ApplicationController
|
|||
|
||||
#Ended by young
|
||||
|
||||
|
||||
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
|
||||
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info,
|
||||
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score]
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities]
|
||||
#edit has been deleted by huang, 2013-9-23
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
|
@ -41,10 +41,12 @@ class UsersController < ApplicationController
|
|||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index]
|
||||
before_filter :auth_user_extension, only: :show
|
||||
before_filter :rest_user_score, only: :show
|
||||
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx
|
||||
|
||||
#william
|
||||
before_filter :require_login, :only => [:tag_save,:tag_saveEx]
|
||||
#before_filter :refresh_changests, :only =>[:user_activities,:user_courses,:user_projects,:user_newfeedback]
|
||||
|
||||
|
||||
helper :sort
|
||||
|
@ -53,6 +55,9 @@ class UsersController < ApplicationController
|
|||
include CustomFieldsHelper
|
||||
include AvatarHelper
|
||||
include WordsHelper
|
||||
include GitlabHelper
|
||||
include UserScoreHelper
|
||||
helper :user_score
|
||||
|
||||
# added by liuping 关注
|
||||
|
||||
|
@ -64,6 +69,17 @@ class UsersController < ApplicationController
|
|||
|
||||
# fq
|
||||
helper :words
|
||||
|
||||
def refresh_changests
|
||||
if !(@user.nil?) && !(@user.memberships.nil?)
|
||||
@user.memberships.each do |member|
|
||||
unless member.project.nil?
|
||||
member.project.repository.fetch_changesets if Setting.autofetch_changesets?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#added by young
|
||||
def user_projects
|
||||
|
||||
|
@ -150,6 +166,9 @@ class UsersController < ApplicationController
|
|||
|
||||
# added by fq
|
||||
def user_activities
|
||||
redirect_to user_path(@user, type: params[:type], page: params[:page])
|
||||
return
|
||||
# useless abort.
|
||||
@watcher = User.watched_by_id(@user)
|
||||
events = []
|
||||
for user in @watcher
|
||||
|
@ -255,10 +274,7 @@ class UsersController < ApplicationController
|
|||
|
||||
#end
|
||||
def index
|
||||
|
||||
@project_type = params[:project_type]
|
||||
role = params[:role]
|
||||
|
||||
@status = params[:status] || 1
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
||||
|
@ -266,101 +282,52 @@ class UsersController < ApplicationController
|
|||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 15})
|
||||
else
|
||||
@limit = 15#per_page_option
|
||||
@limit = 15
|
||||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
has = {
|
||||
"show_changesets" => true
|
||||
}
|
||||
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
|
||||
|
||||
scope = UserStatus.visible
|
||||
case role
|
||||
when 'teacher'
|
||||
scope = UserStatus.teacher
|
||||
when 'student'
|
||||
scope = UserStatus.student
|
||||
else
|
||||
|
||||
end
|
||||
# retrieve all users
|
||||
# 先内连一下statuses 保证排序之后数量一致
|
||||
scope = User.visible.
|
||||
joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id")
|
||||
|
||||
# unknow
|
||||
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||
# scope.each do |user|
|
||||
# UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id)
|
||||
# end
|
||||
|
||||
# pagination
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
#@offset ||= @user_pages.offset
|
||||
#@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
if params[:user_sort_type].present?
|
||||
case params[:user_sort_type]
|
||||
when '0'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 0
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
when '1'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
#sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}
|
||||
#@users = @users[@offset, @limit]
|
||||
when '2'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 2
|
||||
#@users = @users[@offset, @limit]
|
||||
end
|
||||
|
||||
# users classify
|
||||
case params[:user_sort_type]
|
||||
when '0'
|
||||
# 创建时间排序
|
||||
@s_type = 0
|
||||
@users = scope.reorder('users.created_on DESC')
|
||||
when '1'
|
||||
# 活跃度排序, 就是所谓的得分情况
|
||||
@s_type = 1
|
||||
@users = scope.
|
||||
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
|
||||
reorder('option_numbers.total_score DESC')
|
||||
when '2'
|
||||
# 粉丝数排序
|
||||
@s_type = 2
|
||||
@users = scope.
|
||||
#joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id").
|
||||
reorder('user_statuses.watchers_count DESC')
|
||||
|
||||
else
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
# 默认活跃度排序
|
||||
@s_type = 1
|
||||
@users = scope.
|
||||
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
|
||||
reorder('option_numbers.total_score DESC')
|
||||
end
|
||||
|
||||
@users = []
|
||||
@users_statuses.each do |obj|
|
||||
@users << User.find_by_id("#{obj.user_id}")
|
||||
end
|
||||
|
||||
|
||||
# limit and offset
|
||||
@users = @users.limit(@user_pages.per_page).offset(@user_pages.offset)
|
||||
|
||||
@user_base_tag = params[:id] ? 'base_users':'users_base'
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@groups = Group.all.sort
|
||||
|
@ -378,7 +345,7 @@ class UsersController < ApplicationController
|
|||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 15})
|
||||
else
|
||||
@limit = 15#per_page_option
|
||||
@limit = 15#per_page_option
|
||||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
|
@ -389,7 +356,7 @@ class UsersController < ApplicationController
|
|||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
@user_base_tag = params[:id] ? 'base_users':'users_base'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users = scope.offset(@offset).limit(@limit).all.reverse
|
||||
|
@ -520,7 +487,7 @@ class UsersController < ApplicationController
|
|||
def new
|
||||
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
||||
@auth_sources = AuthSource.all
|
||||
render :layout => "base"
|
||||
render :layout => "users_base"
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -555,7 +522,7 @@ class UsersController < ApplicationController
|
|||
@user.password = @user.password_confirmation = nil
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new' }
|
||||
format.html { render :action => 'new',:layout => "users_base" }
|
||||
format.api { render_validation_errors(@user) }
|
||||
end
|
||||
end
|
||||
|
@ -631,7 +598,7 @@ class UsersController < ApplicationController
|
|||
def destroy
|
||||
@user.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default(users_path) }
|
||||
format.html { redirect_back_or_default(admin_users_path) }
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
@ -690,9 +657,9 @@ class UsersController < ApplicationController
|
|||
return
|
||||
end
|
||||
if @obj.save
|
||||
## 执行成功的操作。
|
||||
logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}"
|
||||
else
|
||||
#捕获异常
|
||||
logger.error "#{__FILE__}:#{__LINE__} ===> #{@obj.errors.try(:full_messages)}"
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -829,4 +796,27 @@ class UsersController < ApplicationController
|
|||
redirect_to my_account_path
|
||||
end
|
||||
end
|
||||
|
||||
#重置用户得分
|
||||
def rest_user_score
|
||||
memo_num(@user)
|
||||
messges_for_issue_num(@user)
|
||||
issues_status_num(@user)
|
||||
replay_for_memo_num(@user)
|
||||
tread_num(@user)
|
||||
praise_num(@user)
|
||||
changeset_num(@user)
|
||||
document_num(@user)
|
||||
attachment_num(@user)
|
||||
issue_done_ratio_num(@user)
|
||||
post_issue_num(@user)
|
||||
end
|
||||
|
||||
#验证是否显示课程
|
||||
def can_show_course
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_course == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,6 +29,7 @@ class VersionsController < ApplicationController
|
|||
|
||||
helper :custom_fields
|
||||
helper :projects
|
||||
helper :project_score
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
|
|
|
@ -16,11 +16,42 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class WelcomeController < ApplicationController
|
||||
include ApplicationHelper
|
||||
include WelcomeHelper
|
||||
helper :project_score
|
||||
caches_action :robots
|
||||
before_filter :find_first_page, :only => [:index]
|
||||
# before_filter :fake, :only => [:index, :course]
|
||||
before_filter :entry_select, :only => [:index]
|
||||
|
||||
def index
|
||||
#@first_page = FirstPage.where("page_type = 'project'").first
|
||||
#@show_course = @first_page.show_course
|
||||
if @first_page.nil? || @first_page.sort_type.nil?
|
||||
@projects = find_miracle_project(10, 3,"score desc")
|
||||
else
|
||||
case @first_page.sort_type
|
||||
when 0
|
||||
@projects = find_miracle_project(10, 3,"created_on desc")
|
||||
#@projects = @projects_all.order("created_on desc")
|
||||
when 1
|
||||
@projects = find_miracle_project(10, 3,"score desc")
|
||||
#@projects = @projects_all.order("grade desc")
|
||||
when 2
|
||||
@projects = find_miracle_project(10, 3,"watchers_count desc")
|
||||
#@projects = @projects_all.order("watchers_count desc")
|
||||
|
||||
#gcm
|
||||
#when '3'
|
||||
#@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array)
|
||||
# @projects=handle_project @projects_all,@project_activity_count
|
||||
# @s_type = 3
|
||||
# @projects = @projects[@project_pages.offset, @project_pages.per_page]
|
||||
|
||||
else
|
||||
@projects = @projects_all.order("score desc")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -30,6 +61,7 @@ class WelcomeController < ApplicationController
|
|||
end
|
||||
|
||||
def course
|
||||
@course_page = FirstPage.where("page_type = 'course'").first
|
||||
if params[:school_id]
|
||||
@school_id = params[:school_id]
|
||||
elsif User.current.logged? && User.current.user_extensions.school
|
||||
|
@ -41,13 +73,24 @@ class WelcomeController < ApplicationController
|
|||
|
||||
|
||||
def logolink()
|
||||
@course_page = FirstPage.where("page_type = 'course'").first
|
||||
logo = get_avatar?(@course_page)
|
||||
id = params[:school_id]
|
||||
logo_link = ""
|
||||
if id.nil? and User.current.user_extensions.school.nil?
|
||||
logo_link = '/images/transparent.png'
|
||||
if id.nil? && (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?)
|
||||
if logo
|
||||
logo_link = url_to_avatar(@course_page)
|
||||
else
|
||||
logo_link = '/images/transparent.png'
|
||||
end
|
||||
|
||||
else
|
||||
if id == "0"
|
||||
logo_link = '/images/transparent.png'
|
||||
if logo
|
||||
logo_link = url_to_avatar(@course_page)
|
||||
else
|
||||
logo_link = '/images/transparent.png'
|
||||
end
|
||||
else
|
||||
if id.nil?
|
||||
if School.find(User.current.user_extensions.school.id).logo_link.nil?
|
||||
|
@ -66,13 +109,19 @@ class WelcomeController < ApplicationController
|
|||
|
||||
|
||||
def contest
|
||||
|
||||
@contest_page = FirstPage.where("page_type = 'contest'").first
|
||||
@contestNotification = ContestNotification.all.first
|
||||
end
|
||||
|
||||
def search
|
||||
search_condition = params[:q]
|
||||
search_type = params[:search_type].to_sym unless search_condition.blank?
|
||||
|
||||
if search_type.nil? && params[:contests_search] && params[:name] != ""
|
||||
search_type = :contests
|
||||
search_condition = params[:name]
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html{
|
||||
case search_type
|
||||
|
@ -81,6 +130,8 @@ class WelcomeController < ApplicationController
|
|||
:project_type => Project::ProjectType_project)
|
||||
when :courses
|
||||
redirect_to courses_search_path(:name => search_condition)
|
||||
when :contests
|
||||
redirect_to contests_path(:name => search_condition)
|
||||
when :users
|
||||
redirect_to users_search_path(:name => search_condition)
|
||||
when :users_teacher
|
||||
|
@ -96,46 +147,35 @@ class WelcomeController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
||||
def entry_select
|
||||
url = request.original_url
|
||||
if url.include?("course.trustie.net")
|
||||
course
|
||||
render :course
|
||||
#@first_page = FirstPage.where("page_type = 'project'").first
|
||||
url = request.original_url.gsub('/','')
|
||||
if url.include?(Setting.host_course.gsub('/',''))
|
||||
if @first_page.show_course == 1
|
||||
course
|
||||
render :course
|
||||
else
|
||||
render_404
|
||||
end
|
||||
|
||||
return 0
|
||||
elsif url.include?("contest.trustie.net")
|
||||
contest
|
||||
render :contest
|
||||
elsif url.include?(Setting.host_contest.gsub('/',''))
|
||||
if @first_page.show_contest == 1
|
||||
contest
|
||||
render :contest
|
||||
else
|
||||
render_404
|
||||
end
|
||||
|
||||
return 0
|
||||
elsif url.include?("user.trustie.net")
|
||||
elsif url.include?(Setting.host_user.gsub('/',''))
|
||||
redirect_to(:controller => "users", :action => "index")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
||||
def entry_select_course
|
||||
if request.original_url.match(/course\.trustie\.net/)
|
||||
(course() and render :course and return 0)
|
||||
end
|
||||
end
|
||||
|
||||
def entry_select_contest
|
||||
if request.original_url.match(/contest\.trustie\.net/)
|
||||
contest
|
||||
render :contest
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
def entry_select_user
|
||||
if request.original_url.match(/user\.trustie\.net$/)
|
||||
redirect_to(:controller => "users", :action => "index")
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
# def render(*args)
|
||||
# _fake if @fake_filter
|
||||
# super
|
||||
|
|
|
@ -44,6 +44,7 @@ class WikiController < ApplicationController
|
|||
include AttachmentsHelper
|
||||
helper :watchers
|
||||
include Redmine::Export::PDF
|
||||
helper :project_score
|
||||
|
||||
# List of pages, sorted alphabetically and by parent (hierarchy)
|
||||
def index
|
||||
|
|
|
@ -88,7 +88,43 @@ class WordsController < ApplicationController
|
|||
#format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def destroyJournal
|
||||
@journalP=JournalsForMessage.find(params[:object_id])
|
||||
@journalP.destroy
|
||||
|
||||
@page = params[:page]
|
||||
@page = @page.to_i
|
||||
@project = Project.find params[:project_id]
|
||||
# Find the page of the requested reply
|
||||
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@limit = 10
|
||||
|
||||
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
||||
page = 1 + offset / @limit
|
||||
if params[:r] && @page.nil?
|
||||
@page = page
|
||||
end
|
||||
|
||||
if @page < 0
|
||||
@page = 1
|
||||
end
|
||||
if @page > page
|
||||
@page = page
|
||||
end
|
||||
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, @page
|
||||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
@state = false
|
||||
@base_courses_tag = @project.project_type
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
|
||||
if @jour
|
||||
|
@ -216,7 +252,7 @@ class WordsController < ApplicationController
|
|||
elsif ( referer.match(/homework_attach/) || referer.match(/homework_attach/) ) #new added
|
||||
obj = HomeworkAttach.find_by_id(obj_id)
|
||||
else
|
||||
raise 'create reply obj unknow type.'
|
||||
raise "create reply obj unknow type.#{referer}"
|
||||
end
|
||||
obj
|
||||
end
|
||||
|
@ -240,8 +276,8 @@ class WordsController < ApplicationController
|
|||
elsif obj.kind_of? HomeworkAttach
|
||||
obj.add_jour(nil, nil, obj.id, options) #new added
|
||||
else
|
||||
raise 'create reply obj unknow type.'
|
||||
raise "create reply obj unknow type.#{obj.class}"
|
||||
end
|
||||
end
|
||||
#######end of message
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class ZipdownController < ApplicationController
|
||||
|
||||
#查找项目(课程)
|
||||
before_filter :find_project_by_bid_id, :only => [:assort]
|
||||
#检查权限
|
||||
|
@ -37,12 +38,23 @@ class ZipdownController < ApplicationController
|
|||
#下载某一学生的作业的所有文件
|
||||
def download_user_homework
|
||||
homework = HomeworkAttach.find params[:homework]
|
||||
if homework != nil && (User.current.admin? || User.current.member_of_course?(homework.bid.courses.first))
|
||||
zipfile = zip_homework_by_user homework
|
||||
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile
|
||||
if User.current.admin? || User.current.member_of_course?(homework.bid.courses.first)
|
||||
if homework != nil
|
||||
if homework.attachments.count > 0
|
||||
zipfile = zip_homework_by_user homework
|
||||
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if(zipfile)
|
||||
else
|
||||
render_403 :message => :no_file_dowmload ,:layout => "course_base"
|
||||
end
|
||||
else
|
||||
render_403 :message =>:notice_file_not_found ,:layout => "course_base"
|
||||
end
|
||||
else
|
||||
render_403 :message => :notice_not_authorized
|
||||
render_403 :message => :notice_not_authorized ,:layout => "course_base"
|
||||
end
|
||||
|
||||
rescue => e
|
||||
render file: 'public/file_not_found.html' , :layout => 'course_base'
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -67,7 +79,9 @@ class ZipdownController < ApplicationController
|
|||
# 得到每一个人所有文件打包的zip文件
|
||||
# 并将每一个人的zip打包为一个并返回路径
|
||||
user_zip_paths = homeattaches.map do |homeattach|
|
||||
zip_homework_by_user homeattach
|
||||
if homeattach.attachments.count > 0
|
||||
zip_homework_by_user homeattach
|
||||
end
|
||||
end
|
||||
zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER
|
||||
|
||||
|
@ -81,15 +95,17 @@ class ZipdownController < ApplicationController
|
|||
end
|
||||
|
||||
def zip_homework_by_user(homeattach)
|
||||
homeworks_attach_path = []
|
||||
# 需要将所有homework.attachments遍历加入zip
|
||||
# 并且返回zip路径
|
||||
user_attaches_paths = homeattach.attachments.each do |attach|
|
||||
#length = attach.storage_path.length
|
||||
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
||||
end
|
||||
zipping "#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
|
||||
#user_attaches_paths
|
||||
#if homeattach.attachments.count > 0
|
||||
homeworks_attach_path = []
|
||||
# 需要将所有homework.attachments遍历加入zip
|
||||
# 并且返回zip路径
|
||||
user_attaches_paths = homeattach.attachments.each do |attach|
|
||||
#length = attach.storage_path.length
|
||||
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
||||
end
|
||||
zipping("#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true)
|
||||
#user_attaches_paths
|
||||
#end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ module ApplicationHelper
|
|||
|
||||
extend Forwardable
|
||||
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
|
||||
|
||||
|
||||
#Added by young
|
||||
#Define the course menu's link class
|
||||
# 不是数组的转化成数组,然后判断当前menu_item是否在给定的列表
|
||||
|
@ -53,10 +53,10 @@ module ApplicationHelper
|
|||
def authorize_for_course(controller, action)
|
||||
User.current.allowed_to?({:controller => controller, :action => action}, @course)
|
||||
end
|
||||
|
||||
|
||||
def authorize_for_contest(controller, action)
|
||||
User.current.allowed_to?({:controller => controller, :action => action}, @contest)
|
||||
end
|
||||
end
|
||||
|
||||
# Display a link if user is authorized
|
||||
#
|
||||
|
@ -68,6 +68,10 @@ module ApplicationHelper
|
|||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
|
||||
end
|
||||
|
||||
def link_to_if_authorized_course(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_course(options[:controller] || params[:controller], options[:action])
|
||||
end
|
||||
|
||||
def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action])
|
||||
end
|
||||
|
@ -80,11 +84,12 @@ module ApplicationHelper
|
|||
name = h(user.name(options[:format]))
|
||||
end
|
||||
|
||||
if user.active? || (User.current.admin? && user.logged?)
|
||||
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
|
||||
else
|
||||
name
|
||||
end
|
||||
#if user.active? || (User.current.admin? && user.logged?)
|
||||
# link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
|
||||
#else
|
||||
# name
|
||||
#end
|
||||
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
|
||||
else
|
||||
h(user.to_s)
|
||||
end
|
||||
|
@ -256,8 +261,8 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def format_activity_description(text)
|
||||
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')
|
||||
).gsub(/[\r\n]+/, "<br />").html_safe
|
||||
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />").html_safe
|
||||
#h(truncate(text.to_s, :length => 120).gsub(/<\/?.*?>/,"")).html_safe
|
||||
end
|
||||
|
||||
def format_version_name(version)
|
||||
|
@ -304,7 +309,7 @@ module ApplicationHelper
|
|||
s << h(block_given? ? yield(project) : project.name)
|
||||
else
|
||||
end
|
||||
|
||||
|
||||
if project.try(:project_type) == Project::ProjectType_project
|
||||
unless User.current.member_of?(@project)
|
||||
s << "<span style = 'float: right;'>"
|
||||
|
@ -334,7 +339,7 @@ module ApplicationHelper
|
|||
# set the project environment to please macros.
|
||||
@course = course
|
||||
if (ancestors.empty? )#|| course.is_descendant_of?(ancestors.last))
|
||||
s << "<ul class=courses'>\n"
|
||||
s << "<ul class=courses>\n"
|
||||
else
|
||||
ancestors.pop
|
||||
s << "</li>"
|
||||
|
@ -377,7 +382,7 @@ module ApplicationHelper
|
|||
s << "</ul></li>\n"
|
||||
end
|
||||
end
|
||||
classes = (ancestors.empty? ? 'root' : 'child')
|
||||
classes = (ancestors.empty? ? 'root' : 'child')
|
||||
s << h(block_given? ? yield(project) : project.name)
|
||||
ancestors << project
|
||||
end
|
||||
|
@ -473,11 +478,16 @@ module ApplicationHelper
|
|||
def principals_check_box_tags_ex(name, principals)
|
||||
s = ''
|
||||
principals.each do |principal|
|
||||
if principal.has_attribute?(:userInfo)
|
||||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
|
||||
else
|
||||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal}</label>\n"
|
||||
end
|
||||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
#扩展的checkbox生成
|
||||
def principals_radio_box_tags_ex(name, principals)
|
||||
s = ''
|
||||
principals.each do |principal|
|
||||
s << "<label>#{ radio_button_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
@ -535,11 +545,11 @@ module ApplicationHelper
|
|||
def authoring(created, author, options={})
|
||||
l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created)).html_safe
|
||||
end
|
||||
|
||||
|
||||
def added_time(created)
|
||||
l(:label_added_time, :age => time_tag(created)).html_safe
|
||||
end
|
||||
|
||||
|
||||
def user_url_and_time(user_name, user_url, created)
|
||||
unless user_name.nil? || user_name == ''
|
||||
l(:label_added_time_by, :author => link_to(user_name, user_url), :age => time_tag(created)).html_safe
|
||||
|
@ -625,10 +635,15 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def html_title(*args)
|
||||
first_page = FirstPage.where("page_type = 'project'").first
|
||||
if args.empty?
|
||||
title = @html_title || []
|
||||
title << @project.name if @project
|
||||
title << Setting.app_title unless Setting.app_title == title.last
|
||||
if first_page.nil? || first_page.web_title.nil?
|
||||
title << Setting.app_title unless Setting.app_title == title.last
|
||||
else
|
||||
title << first_page.web_title unless first_page.web_title == title.last
|
||||
end
|
||||
title.select {|t| !t.blank? }.join(' - ')
|
||||
else
|
||||
@html_title ||= []
|
||||
|
@ -664,15 +679,15 @@ module ApplicationHelper
|
|||
def textilizable(*args)
|
||||
options = args.last.is_a?(Hash) ? args.pop : {}
|
||||
case args.size
|
||||
when 1
|
||||
obj = options[:object]
|
||||
text = args.shift
|
||||
when 2
|
||||
obj = args.shift
|
||||
attr = args.shift
|
||||
text = obj.send(attr).to_s
|
||||
else
|
||||
raise ArgumentError, 'invalid arguments to textilizable'
|
||||
when 1
|
||||
obj = options[:object]
|
||||
text = args.shift
|
||||
when 2
|
||||
obj = args.shift
|
||||
attr = args.shift
|
||||
text = obj.send(attr).to_s
|
||||
else
|
||||
raise ArgumentError, 'invalid arguments to textilizable'
|
||||
end
|
||||
return '' if text.blank?
|
||||
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
|
||||
|
@ -701,6 +716,48 @@ module ApplicationHelper
|
|||
text.html_safe
|
||||
end
|
||||
|
||||
#
|
||||
#格式化字符串,不转义html代码
|
||||
def textAreailizable(*args)
|
||||
options = args.last.is_a?(Hash) ? args.pop : {}
|
||||
case args.size
|
||||
when 1
|
||||
obj = options[:object]
|
||||
text = args.shift
|
||||
when 2
|
||||
obj = args.shift
|
||||
attr = args.shift
|
||||
text = obj.send(attr).to_s
|
||||
else
|
||||
raise ArgumentError, 'invalid arguments to textilizable'
|
||||
end
|
||||
return '' if text.blank?
|
||||
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
|
||||
only_path = options.delete(:only_path) == false ? false : true
|
||||
|
||||
text = text.dup
|
||||
macros = catch_macros(text)
|
||||
#text = Redmine::WikiFormatting.to_html("CKEditor", text, :object => obj, :attribute => attr)
|
||||
|
||||
@parsed_headings = []
|
||||
@heading_anchors = {}
|
||||
@current_section = 0 if options[:edit_section_links]
|
||||
|
||||
parse_sections(text, project, obj, attr, only_path, options)
|
||||
text = parse_non_pre_blocks(text, obj, macros) do |text|
|
||||
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name|
|
||||
send method_name, text, project, obj, attr, only_path, options
|
||||
end
|
||||
end
|
||||
parse_headings(text, project, obj, attr, only_path, options)
|
||||
|
||||
if @parsed_headings.any?
|
||||
replace_toc(text, @parsed_headings)
|
||||
end
|
||||
|
||||
text.html_safe
|
||||
end
|
||||
|
||||
def parse_non_pre_blocks(text, obj, macros)
|
||||
s = StringScanner.new(text)
|
||||
tags = []
|
||||
|
@ -794,7 +851,7 @@ module ApplicationHelper
|
|||
else
|
||||
wiki_page_id = page.present? ? Wiki.titleize(page) : nil
|
||||
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,
|
||||
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
|
||||
:id => wiki_page_id, :version => nil, :anchor => anchor, :parent => parent)
|
||||
end
|
||||
end
|
||||
|
@ -808,12 +865,15 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def select_option_helper option
|
||||
tmp = Hash.new
|
||||
tmp={"" => ""}
|
||||
option.each do |project|
|
||||
tmp[project.name] = project.id
|
||||
if option.nil?
|
||||
else
|
||||
option.each do |project|
|
||||
tmp[project.name] = project.id
|
||||
end
|
||||
end
|
||||
tmp
|
||||
end
|
||||
|
@ -1117,7 +1177,7 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def lang_options_for_select(blank=true)
|
||||
{ 'Chinese简体中文 '=> 'zh', :English => :en}
|
||||
{ 'Chinese简体中文 '=> 'zh', :English => :en}
|
||||
end
|
||||
|
||||
def label_tag_for(name, option_tags = nil, options = {})
|
||||
|
@ -1157,28 +1217,30 @@ module ApplicationHelper
|
|||
objects = objects.first
|
||||
end
|
||||
# end
|
||||
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|
|
||||
if objects != nil
|
||||
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|
|
||||
###by xianbo
|
||||
if(error!=l(:label_repository_path_not_null))
|
||||
html << "<li>#{h error}</li>\n"
|
||||
end
|
||||
###xianbo
|
||||
end
|
||||
###by xianbo
|
||||
if(error!=l(:label_repository_path_not_null))
|
||||
html << "<li>#{h error}</li>\n"
|
||||
unless params[:repository].nil?
|
||||
if params[:repository][:upassword]==""
|
||||
html << "<li>"+ l(:label_password_not_null) +"</li>\n"
|
||||
end
|
||||
end
|
||||
###xianbo
|
||||
html << "</ul></div>\n"
|
||||
end
|
||||
###by xianbo
|
||||
unless params[:repository].nil?
|
||||
if params[:repository][:upassword]==""
|
||||
html << "<li>"+ l(:label_password_not_null) +"</li>\n"
|
||||
end
|
||||
end
|
||||
###xianbo
|
||||
html << "</ul></div>\n"
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
def delete_link(url, options={})
|
||||
options = {
|
||||
|
@ -1192,8 +1254,8 @@ module ApplicationHelper
|
|||
|
||||
def preview_link(url, form, target='preview', options={})
|
||||
content_tag 'a', l(:label_preview), {
|
||||
:href => "#",
|
||||
:onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
|
||||
:href => "#",
|
||||
:onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
|
||||
:accesskey => accesskey(:preview)
|
||||
}.merge(options)
|
||||
end
|
||||
|
@ -1264,33 +1326,58 @@ module ApplicationHelper
|
|||
javascript_tag "contextMenuInit('#{ url_for(url) }')"
|
||||
end
|
||||
|
||||
def calendar_for(field_id)
|
||||
include_calendar_headers_tags
|
||||
def calendar_for(field_id,start_day=nil)
|
||||
include_calendar_headers_tags(start_day)
|
||||
javascript_tag("$(function() { $('##{field_id}').datepicker(datepickerOptions); });")
|
||||
end
|
||||
|
||||
def include_calendar_headers_tags
|
||||
unless @calendar_headers_tags_included
|
||||
@calendar_headers_tags_included = true
|
||||
content_for :header_tags do
|
||||
start_of_week = Setting.start_of_week
|
||||
start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank?
|
||||
# Redmine uses 1..7 (monday..sunday) in settings and locales
|
||||
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
|
||||
start_of_week = start_of_week.to_i % 7
|
||||
def include_calendar_headers_tags(start_day=nil)
|
||||
if start_day.nil?
|
||||
unless @calendar_headers_tags_included
|
||||
@calendar_headers_tags_included = true
|
||||
content_for :header_tags do
|
||||
start_of_week = Setting.start_of_week
|
||||
start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank?
|
||||
# Redmine uses 1..7 (monday..sunday) in settings and locales
|
||||
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
|
||||
start_of_week = start_of_week.to_i % 7
|
||||
|
||||
tags = javascript_tag(
|
||||
"var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
|
||||
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
|
||||
path_to_image('/images/calendar.png') +
|
||||
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};")
|
||||
jquery_locale = l('jquery.locale', :default => current_language.to_s)
|
||||
unless jquery_locale == 'en'
|
||||
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
|
||||
tags = javascript_tag(
|
||||
"var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
|
||||
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
|
||||
path_to_image('/images/calendar.png') +
|
||||
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};")
|
||||
jquery_locale = l('jquery.locale', :default => current_language.to_s)
|
||||
unless jquery_locale == 'en'
|
||||
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
|
||||
end
|
||||
tags
|
||||
end
|
||||
end
|
||||
else
|
||||
unless @calendar_headers_tags_included
|
||||
@calendar_headers_tags_included = true
|
||||
content_for :header_tags do
|
||||
start_of_week = Setting.start_of_week
|
||||
start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank?
|
||||
# Redmine uses 1..7 (monday..sunday) in settings and locales
|
||||
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
|
||||
start_of_week = start_of_week.to_i % 7
|
||||
|
||||
tags = javascript_tag(
|
||||
"var datepickerOptions={dateFormat: 'yy-mm-dd',minDate: new Date(), firstDay: #{start_of_week}, " +
|
||||
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
|
||||
path_to_image('/images/calendar.png') +
|
||||
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true, onClose: function(dateText, inst) {TimeClose(dateText,inst);}, beforeShow : function(input){TimeBeforeShow(input);} };")
|
||||
jquery_locale = l('jquery.locale', :default => current_language.to_s)
|
||||
unless jquery_locale == 'en'
|
||||
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
|
||||
end
|
||||
tags
|
||||
end
|
||||
tags
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Overrides Rails' stylesheet_link_tag with themes and plugins support.
|
||||
|
@ -1380,6 +1467,8 @@ module ApplicationHelper
|
|||
email = $1
|
||||
end
|
||||
return gravatar(email.to_s.downcase, options) unless email.blank? rescue nil
|
||||
#options ={"class" => ["avatar2"],"width" =>["80px"],"height" =>["80px"]}
|
||||
#return image_tag url_to_avatar(user), options
|
||||
else
|
||||
''
|
||||
end
|
||||
|
@ -1396,7 +1485,7 @@ module ApplicationHelper
|
|||
|
||||
# Returns the javascript tags that are included in the html layout head
|
||||
def javascript_heads
|
||||
tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application')
|
||||
tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application', 'jquery.colorbox-min')
|
||||
unless User.current.pref.warn_on_leaving_unsaved == '0'
|
||||
tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });")
|
||||
end
|
||||
|
@ -1454,18 +1543,37 @@ module ApplicationHelper
|
|||
options
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Add by Tao
|
||||
def url_to_avatar(source)
|
||||
source = nil if source.kind_of?(String)
|
||||
get_avatar(source)
|
||||
end
|
||||
# Endof Tao's code
|
||||
|
||||
|
||||
def date_format_local(time)
|
||||
date = time.strftime("%Y年%m月%d日")
|
||||
end
|
||||
|
||||
#当TAG数量过多时,更多链接
|
||||
#1代表是user类型 2代表是project类型 3代表是issue类型 4代表需求 9代表课程
|
||||
def more_tags id,object_flag
|
||||
a= 1
|
||||
case object_flag
|
||||
when "1"
|
||||
s = link_to l(:label_more_tags),:controller => "users", :action => "show", :id => id
|
||||
when "2"
|
||||
s = link_to l(:label_more_tags),:controller => "projects", :action => "show", :id => id
|
||||
when "3"
|
||||
s = link_to l(:label_more_tags),:controller => "issues", :action => "show", :id => id
|
||||
when "4"
|
||||
s = link_to l(:label_more_tags),:controller => "bids", :action => "show", :id => id
|
||||
when "9"
|
||||
s = link_to l(:label_more_tags),:controller => "courses", :action => "show", :id => id
|
||||
end
|
||||
s
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def wiki_helper
|
||||
|
@ -1477,7 +1585,7 @@ module ApplicationHelper
|
|||
def link_to_content_update(text, url_params = {}, html_options = {})
|
||||
link_to(text, url_params, html_options)
|
||||
end
|
||||
|
||||
|
||||
#added by nie
|
||||
# Display watcher picture
|
||||
def show_more_watchers?(obj)
|
||||
|
@ -1487,7 +1595,7 @@ module ApplicationHelper
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show_watcher_profile(obj)
|
||||
count = 0
|
||||
html = ''
|
||||
|
@ -1512,7 +1620,7 @@ module ApplicationHelper
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show_bid_project(bid)
|
||||
html = ''
|
||||
if bid.projects.where('is_public = 1').count == 0
|
||||
|
@ -1524,15 +1632,15 @@ module ApplicationHelper
|
|||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
def show_bid_fans_picture(obj)
|
||||
html = ''
|
||||
if obj.watcher_users.count == 0
|
||||
html << (content_tag "span", l(:label_project_no_follow))
|
||||
else
|
||||
obj.watcher_users.take(12).each do |user|
|
||||
obj.watcher_users.take(12).each do |user|
|
||||
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
@ -1553,7 +1661,7 @@ module ApplicationHelper
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show_contest_project(bid)
|
||||
html = ''
|
||||
if contest.projects.where('is_public = 1').count == 0
|
||||
|
@ -1565,7 +1673,7 @@ module ApplicationHelper
|
|||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
def show_contest_project(contest)
|
||||
html = ''
|
||||
if contest.projects.where('is_public = 1').count == 0
|
||||
|
@ -1577,7 +1685,7 @@ module ApplicationHelper
|
|||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
def show_contest_softapplication(contest)
|
||||
html = ''
|
||||
if contest.softapplications.where('is_public = 1').count == 0
|
||||
|
@ -1589,19 +1697,19 @@ module ApplicationHelper
|
|||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
def show_contest_fans_picture(obj)
|
||||
html = ''
|
||||
if obj.watcher_users.count == 0
|
||||
html << (content_tag "span", l(:label_project_no_follow))
|
||||
else
|
||||
obj.watcher_users.take(12).each do |user|
|
||||
obj.watcher_users.take(12).each do |user|
|
||||
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#display fans picture
|
||||
def show_more_fans?(obj)
|
||||
if obj.watcher_users.count > 12
|
||||
|
@ -1610,20 +1718,20 @@ module ApplicationHelper
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show_fans_picture(obj)
|
||||
html = ''
|
||||
if obj.watcher_users.count == 0
|
||||
html << (content_tag "span", l(:label_no_current_fans))
|
||||
else
|
||||
obj.watcher_users.take(12).each do |user|
|
||||
obj.watcher_users.take(12).each do |user|
|
||||
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
# added by bai
|
||||
|
||||
# added by bai
|
||||
def show_more_participate?(obj)
|
||||
if obj.join_in_contests.count > 12
|
||||
return true
|
||||
|
@ -1631,7 +1739,7 @@ module ApplicationHelper
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show_participate_picture(obj)
|
||||
html = ''
|
||||
count = 0
|
||||
|
@ -1644,10 +1752,10 @@ module ApplicationHelper
|
|||
if count >= 12
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#end
|
||||
|
||||
# add by huang
|
||||
|
@ -1662,7 +1770,7 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
end
|
||||
# end
|
||||
|
||||
#added by william
|
||||
|
@ -1671,7 +1779,7 @@ module ApplicationHelper
|
|||
end
|
||||
#end
|
||||
|
||||
|
||||
|
||||
def hadcommittedhomework(cur,curb)
|
||||
bid = Bid.find_by_id(curb)
|
||||
return true if bid.nil?
|
||||
|
@ -1686,21 +1794,21 @@ module ApplicationHelper
|
|||
else
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def render_dynamic_nav
|
||||
home_link = link_to l(:field_homepage), {:controller => 'welcome', :action => 'index'}
|
||||
home_link = "<li>" << home_link << "</li>"
|
||||
bootstrap_render_dynamic_nav
|
||||
# bootstrap_render_dynamic_nav
|
||||
content_tag :ul, (home_link.html_safe+bootstrap_render_dynamic_nav)
|
||||
end
|
||||
|
||||
def bootstrap_render_dynamic_nav
|
||||
|
||||
|
||||
main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain}
|
||||
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain}
|
||||
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain}
|
||||
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain}
|
||||
|
||||
course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'}
|
||||
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain}
|
||||
|
@ -1712,30 +1820,30 @@ module ApplicationHelper
|
|||
forum_link = link_to l(:label_project_module_forums), {:controller => "forums", :action => "index"}
|
||||
stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'}
|
||||
|
||||
|
||||
|
||||
school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'}
|
||||
|
||||
|
||||
|
||||
|
||||
#@nav_dispaly_project_label
|
||||
nav_list = Array.new
|
||||
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label
|
||||
nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label
|
||||
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label
|
||||
|
||||
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1
|
||||
nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1
|
||||
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1
|
||||
|
||||
nav_list.push(main_project_link) if @nav_dispaly_main_project_label
|
||||
nav_list.push(main_course_link) if @nav_dispaly_main_course_label
|
||||
nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label
|
||||
|
||||
nav_list.push(courses_link) if @nav_dispaly_course_label
|
||||
nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1
|
||||
nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1
|
||||
|
||||
nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1
|
||||
nav_list.push(projects_link) if @nav_dispaly_project_label
|
||||
nav_list.push(users_link) if @nav_dispaly_user_label
|
||||
nav_list.push(contest_link) if @nav_dispaly_contest_label
|
||||
nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1
|
||||
nav_list.push(bids_link) if @nav_dispaly_bid_label
|
||||
nav_list.push(forum_link) if @nav_dispaly_forum_label
|
||||
nav_list.push(stores_link) if @nav_dispaly_store_all_label
|
||||
|
||||
content_li = ''
|
||||
nav_list.collect do |nav_item|
|
||||
nav_list.collect do |nav_item|
|
||||
content_li << content_tag(:li, nav_item)
|
||||
end
|
||||
content_li.html_safe
|
||||
|
@ -1744,12 +1852,12 @@ module ApplicationHelper
|
|||
def current_user
|
||||
User.current
|
||||
end
|
||||
|
||||
|
||||
# def hadcommittedforcontest(curu)
|
||||
# message = JournalsForMessage.find_by_sql("select * from journals_for_messages where jour_type = 'Softapplication' ")
|
||||
# message.each do |createmessage|
|
||||
# if createmessage.user_id == curu
|
||||
# return true
|
||||
# if createmessage.user_id == curu
|
||||
# return true
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
@ -1762,11 +1870,12 @@ module ApplicationHelper
|
|||
logos.push(link_to image_tag('/images/footer_logo/iscas.png', :alt=>"iscas"), "http://www.iscas.ac.cn" )
|
||||
logos.push(link_to image_tag('/images/footer_logo/inforbus.png', :alt=>"inforbus"), "http://www.inforbus.com" )
|
||||
|
||||
logos.collect! { |logo|
|
||||
logos.collect! { |logo|
|
||||
content_tag(:li, logo.html_safe, :class => li_class.to_s)
|
||||
}
|
||||
|
||||
content_tag(:ul, logos.join("").html_safe, :class => ul_class.to_s).html_safe
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -87,8 +87,9 @@ module AttachmentsHelper
|
|||
@project_id = obj.container_id
|
||||
|
||||
end
|
||||
Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or
|
||||
attachments = Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or
|
||||
(container_id in (select id from versions where project_id =:project_id) and container_type = 'Version')", {:project_id => @project_id})
|
||||
return attachments
|
||||
end
|
||||
|
||||
|
||||
|
@ -109,8 +110,8 @@ module AttachmentsHelper
|
|||
domain = project.nil? ? attachAll : nobelong_attach
|
||||
|
||||
# 搜索到的资源
|
||||
searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
searched_attach = private_filter searched_attach
|
||||
searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
#searched_attach = private_filter searched_attach
|
||||
searched_attach = paginateHelper(searched_attach, 10)
|
||||
|
||||
s = content_tag('div', attachments_check_box_tags('attachment[attach][]', searched_attach), :id => 'attachments')
|
||||
|
@ -148,8 +149,8 @@ module AttachmentsHelper
|
|||
domain = course.nil? ? attachAll : nobelong_attach
|
||||
|
||||
# 搜索到的资源
|
||||
searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
searched_attach = private_filter searched_attach
|
||||
searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
#searched_attach = private_filter searched_attach
|
||||
searched_attach = paginateHelper(searched_attach, 10)
|
||||
|
||||
#testattach = Attachment.public_attachments
|
||||
|
|
|
@ -38,7 +38,7 @@ module AvatarHelper
|
|||
avatar_image(source)
|
||||
else
|
||||
File.join(relative_path,avatar_directory(source.class),'0')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_avatar?(source)
|
||||
|
|
|
@ -173,6 +173,18 @@ module ContestsHelper
|
|||
end
|
||||
tmp
|
||||
end
|
||||
|
||||
|
||||
#作品分类下拉框
|
||||
def work_type_opttion
|
||||
type = []
|
||||
#work_types = WorksCategory.all
|
||||
WorksCategory.all.each do |work_type|
|
||||
option = []
|
||||
option << work_type.category
|
||||
option << work_type.category
|
||||
type << option
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
end
|
|
@ -7,29 +7,30 @@ module CoursesHelper
|
|||
3. define search by roles
|
||||
4. define search member function
|
||||
=end
|
||||
TeacherRoles = [3, 4, 7, 9]
|
||||
StudentRoles = [5, 10]
|
||||
AllPeople = StudentRoles+TeacherRoles
|
||||
#TeacherRoles = [3, 4, 7, 9]
|
||||
#StudentRoles = [5, 10]
|
||||
#AllPeople = StudentRoles+TeacherRoles
|
||||
## return people count
|
||||
|
||||
# 返回x项目成员数量,即roles表中定义的所有成员
|
||||
def projectCount project
|
||||
searchCountByRoles project, AllPeople
|
||||
#searchCountByRoles project, AllPeople
|
||||
project.members.count
|
||||
end
|
||||
|
||||
# 返回教师数量,即roles表中定义的Manager
|
||||
def teacherCount project
|
||||
searchCountByRoles project, TeacherRoles
|
||||
searchTeacherAndAssistant(project).count
|
||||
# or
|
||||
# searchTeacherAndAssistant(project).count
|
||||
end
|
||||
|
||||
# 返回学生数量,即roles表中定义的Reporter
|
||||
def studentCount project
|
||||
searchCountByRoles project,StudentRoles
|
||||
#def studentCount project
|
||||
# searchStudent(project).count
|
||||
# or
|
||||
# searchStudent(project).count
|
||||
end
|
||||
# end
|
||||
|
||||
# 判断用户是否是课程的管理员
|
||||
# add by nwb
|
||||
|
@ -97,16 +98,44 @@ module CoursesHelper
|
|||
end
|
||||
|
||||
|
||||
alias teacherCountOrigin teacherCount
|
||||
def teacherCount project
|
||||
count = teacherCountOrigin project
|
||||
garble count
|
||||
#alias teacherCountOrigin teacherCount
|
||||
#def teacherCount project
|
||||
# count = teacherCountOrigin project
|
||||
# garble count
|
||||
#end
|
||||
|
||||
# 注意:此方法有问题,速度慢且结果不准
|
||||
# alias studentCountOrigin studentCount
|
||||
#def studentCount course
|
||||
# count = studentCountOrigin course
|
||||
#garble count
|
||||
# end
|
||||
|
||||
# 学生人数计算
|
||||
# add by nwb
|
||||
def studentCount course
|
||||
count = searchStudent(course).count#course.student.count
|
||||
if count <= 5
|
||||
result = count.to_s
|
||||
elsif count < 10 && count > 5
|
||||
result = "5+"
|
||||
else
|
||||
result = (count-count % 10).to_s + "+"
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
alias studentCountOrigin studentCount
|
||||
def studentCount course
|
||||
count = studentCountOrigin course
|
||||
garble count
|
||||
#课程成员数计算
|
||||
def memberCount course
|
||||
count = searchStudent(course).count + searchTeacherAndAssistant(course).count
|
||||
if count <= 5
|
||||
result = count.to_s
|
||||
elsif count < 10 && count > 5
|
||||
result = "5+"
|
||||
else
|
||||
result = (count-count % 10).to_s + "+"
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def eventToLanguageCourse event_type, course
|
||||
|
@ -133,29 +162,39 @@ module CoursesHelper
|
|||
# =====================================================================================
|
||||
# return people list
|
||||
def searchTeacherAndAssistant project
|
||||
searchPeopleByRoles(project, TeacherRoles)
|
||||
end
|
||||
|
||||
def searchStudent project
|
||||
searchPeopleByRoles(project, StudentRoles)
|
||||
end
|
||||
# =====================================================================================
|
||||
|
||||
def searchCountByRoles project, roles_id
|
||||
members = searchPeopleByRoles project, roles_id
|
||||
members.count
|
||||
end
|
||||
|
||||
def searchPeopleByRoles project, roles_id
|
||||
#searchPeopleByRoles(project, TeacherRoles)
|
||||
members = []
|
||||
begin
|
||||
members = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id})
|
||||
rescue Exception => e
|
||||
logger.error "[CoursesHelper] ===> #{e}"
|
||||
project.members.each do |m|
|
||||
members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
|
||||
end
|
||||
members
|
||||
end
|
||||
|
||||
def searchStudent project
|
||||
#searchPeopleByRoles(project, StudentRoles)
|
||||
members = []
|
||||
project.members.each do |m|
|
||||
members << m if m && m.user && m.user.allowed_to?(:as_student,project)
|
||||
end
|
||||
members
|
||||
end
|
||||
# =====================================================================================
|
||||
|
||||
#def searchCountByRoles project, roles_id
|
||||
# members = searchPeopleByRoles project, roles_id
|
||||
# members.count
|
||||
#end
|
||||
|
||||
#def searchPeopleByRoles project, roles_id
|
||||
# members = []
|
||||
# begin
|
||||
# members = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id})
|
||||
# rescue Exception => e
|
||||
# logger.error "[CoursesHelper] ===> #{e}"
|
||||
# end
|
||||
# members
|
||||
#end
|
||||
|
||||
def sort_courses(state)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
|
@ -186,15 +225,15 @@ module CoursesHelper
|
|||
end
|
||||
|
||||
#useless
|
||||
def searchMembersByRole project, role_id
|
||||
members = []
|
||||
begin
|
||||
members = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id })
|
||||
rescue Exception => e
|
||||
logger.error "[CoursesHelper] ===> #{e}"
|
||||
end
|
||||
members
|
||||
end
|
||||
#def searchMembersByRole project, role_id
|
||||
# members = []
|
||||
# begin
|
||||
# members = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id })
|
||||
# rescue Exception => e
|
||||
# logger.error "[CoursesHelper] ===> #{e}"
|
||||
# end
|
||||
# members
|
||||
#end
|
||||
|
||||
def sort_course(state, school_id)
|
||||
content = ''.html_safe
|
||||
|
@ -270,9 +309,10 @@ module CoursesHelper
|
|||
def find_by_extra_from_project extra
|
||||
Course.find_by_extra(try(extra))
|
||||
end
|
||||
#判断制定用户是不是当前课程的老师
|
||||
#判断指定用户是不是当前课程的老师
|
||||
def is_course_teacher (user,course)
|
||||
course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{user.id}", {:role_id => TeacherRoles}).count != 0
|
||||
#course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{user.id}", {:role_id => TeacherRoles}).count != 0
|
||||
user.allowed_to?(:as_teacher,course)
|
||||
#修改为根据用户是否有发布任务的权限来判断用户是否是课程的老师
|
||||
#is_teacher = false
|
||||
#@membership = user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
|
@ -287,7 +327,8 @@ module CoursesHelper
|
|||
end
|
||||
#当前用户是不是指定课程的学生
|
||||
def is_cur_course_student course
|
||||
course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0
|
||||
#course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0
|
||||
!(User.current.allowed_to?(:as_teacher,course))
|
||||
#修改:能新建占位且不能新建任务的角色判定为学生
|
||||
#is_student = false
|
||||
#@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
|
@ -329,20 +370,44 @@ module CoursesHelper
|
|||
|
||||
#获取作业的互评得分
|
||||
def student_score_for_homework homework
|
||||
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars")
|
||||
#member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
#if member.nil?
|
||||
# return "0.00"
|
||||
#end
|
||||
#student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars")
|
||||
members = searchStudent(homework.bid.courses.first)
|
||||
user_ids = []
|
||||
members.each do |user|
|
||||
user_ids << user.user_id
|
||||
end
|
||||
student_stars = homework.rates(:quality).where("rater_id in (:user_ids)",{:user_ids => user_ids}).select("stars")
|
||||
student_stars_count = 0
|
||||
student_stars.each do |star|
|
||||
student_stars_count = student_stars_count + star.stars
|
||||
end
|
||||
return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count))
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
#获取作业的教师评分
|
||||
#多个教师只获取一份教师评分
|
||||
def teacher_score_for_homework homework
|
||||
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first
|
||||
return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars)
|
||||
members = searchTeacherAndAssistant(homework.bid.courses.first)#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
#if member.nil?
|
||||
# return "0.00"
|
||||
#end
|
||||
teacher_ids = []
|
||||
members.each do |user|
|
||||
teacher_ids << user.user_id
|
||||
end
|
||||
teacher_stars = homework.rates(:quality).where("rater_id in (:teacher_ids)",{:teacher_ids => teacher_ids}).select("stars")
|
||||
teacher_stars_count = 0
|
||||
teacher_stars.each do |star|
|
||||
teacher_stars_count = teacher_stars_count + star.stars
|
||||
end
|
||||
return format("%.2f",teacher_stars_count)
|
||||
end
|
||||
|
||||
#获取指定项目的得分
|
||||
|
@ -376,7 +441,7 @@ module CoursesHelper
|
|||
def homework_user_of_homework homework,is_teacher
|
||||
homework_users = ""
|
||||
homework.users.each do |user|
|
||||
homework_users = homework_users + (is_teacher ? user.realname : user.name)
|
||||
homework_users = homework_users + (is_teacher ? (user.lastname + user.firstname) : user.login)
|
||||
if user != homework.users.last
|
||||
homework_users = homework_users + "、"
|
||||
end
|
||||
|
@ -388,4 +453,72 @@ module CoursesHelper
|
|||
Course.tagged_with(tag_name).order('updated_at desc')
|
||||
end
|
||||
|
||||
#课程实践年份下拉框
|
||||
def course_time_option
|
||||
type = []
|
||||
#work_types = WorksCategory.all
|
||||
for i in (2008..2020)
|
||||
option = []
|
||||
option << i
|
||||
option << i
|
||||
type << option
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
#课程课时下拉框
|
||||
def course_term_option
|
||||
type = []
|
||||
option1 = []
|
||||
option1 << l(:label_spring)
|
||||
option1 << l(:label_spring)
|
||||
option2 = []
|
||||
option2 << l(:label_autumn)
|
||||
option2 << l(:label_autumn)
|
||||
type << option1
|
||||
type << option2
|
||||
type
|
||||
end
|
||||
|
||||
#获取课程动态
|
||||
def get_course_activity courses, activities
|
||||
@course_ids=activities.keys()
|
||||
|
||||
days = Setting.activity_days_default.to_i
|
||||
date_to ||= Date.today + 1
|
||||
date_from = date_to - days-1.years
|
||||
|
||||
#file_count
|
||||
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
|
||||
activities[attachment.container_id]+=1
|
||||
end
|
||||
|
||||
#message_count
|
||||
Board.where(course_id: @course_ids).each do |board|
|
||||
# activities[board.course_id]+=1
|
||||
activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count
|
||||
end
|
||||
|
||||
#news
|
||||
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
|
||||
activities[news.course_id]+=1
|
||||
end
|
||||
|
||||
#feedbackc_count
|
||||
JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess|
|
||||
activities[jourformess.jour_id]+=1
|
||||
end
|
||||
|
||||
#activities!=0
|
||||
i=0;
|
||||
courses.each do |course|
|
||||
id=course.id
|
||||
if activities[id]==0
|
||||
activities[id]=1
|
||||
end
|
||||
end
|
||||
|
||||
return activities
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,247 @@
|
|||
# Gitlab5.3 API操作接口
|
||||
# Add by nwb
|
||||
# 暂时没支持SSH
|
||||
# 接口通过HTTP协议与服务器交互,理论上只要能安装gitlab的操作系统本接口都能支持
|
||||
# 本机的测试环境是Ubuntu 12.04
|
||||
|
||||
module GitlabHelper
|
||||
|
||||
# gitlab版本库数据本地保存的根目录
|
||||
ROOT_PATH="/home/git/repositories/"
|
||||
PROJECT_PATH_CUT = 40
|
||||
# gitlab版本库所在服务器
|
||||
# 注意REPO_IP_ADDRESS必须以http://开头,暂时只支持HTTP协议,未支持SSH
|
||||
#REPO_IP_ADDRESS = "http://" + Setting.repository_domain
|
||||
REPO_IP_ADDRESS = "http://192.168.137.100"
|
||||
GITLAB_API = "/api/v3"
|
||||
|
||||
# 用户在项目中的权限级别
|
||||
GUEST = 10
|
||||
REPORTER = 20
|
||||
DEVELOPER = 30
|
||||
MASTER = 40
|
||||
|
||||
# gitlab的登录验证信息
|
||||
# add by nwb
|
||||
def self.gitlab_token=(token)
|
||||
Thread.current[:gitlab_token] = token
|
||||
end
|
||||
|
||||
# gitlab的登录验证信息
|
||||
# add by nwb
|
||||
def self.gitlab_token
|
||||
Thread.current[:gitlab_token] ||= nil
|
||||
end
|
||||
|
||||
# 登录gitlab
|
||||
# add by nwb
|
||||
def login_gitlab(email,password)
|
||||
url = REPO_IP_ADDRESS + GITLAB_API + "/session"
|
||||
uri = URI.parse(url)
|
||||
data = {email:email, password:password}
|
||||
begin
|
||||
res = Net::HTTP.post_form(uri, data)
|
||||
if res.code == '201'
|
||||
temp = ActiveSupport::JSON.decode(res.body)
|
||||
GitlabHelper.gitlab_token= temp['private_token']
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 创建项目
|
||||
# add by nwb
|
||||
def create_project(project_name)
|
||||
url = REPO_IP_ADDRESS + GITLAB_API + "/projects"
|
||||
uri = URI.parse(url)
|
||||
data = {name:project_name, private_token:GitlabHelper.gitlab_token}
|
||||
begin
|
||||
res = Net::HTTP.post_form(uri, data)
|
||||
if res.code == '201'
|
||||
temp = ActiveSupport::JSON.decode(res.body)
|
||||
#新创建项目的版本库地址
|
||||
respo = temp['http_url_to_repo']
|
||||
respo['http://localhost'] = REPO_IP_ADDRESS
|
||||
# 新创建项目的web地址
|
||||
webaddress = temp['web_url']
|
||||
webaddress['http://localhost'] = REPO_IP_ADDRESS
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 为指定用户创建版本库
|
||||
# project_name:版本库名称 user_id:Gitlab版本库中的用户编号
|
||||
# add by nwb
|
||||
def create_project_for_user(project_name,user_id)
|
||||
url = REPO_IP_ADDRESS + GITLAB_API + "/projects/user/" + user_id
|
||||
uri = URI.parse(url)
|
||||
data = {user_id:user_id, name:project_name,private_token:GitlabHelper.gitlab_token}
|
||||
begin
|
||||
res = Net::HTTP.post_form(uri, data)
|
||||
if res.code == '201'
|
||||
temp = ActiveSupport::JSON.decode(res.body)
|
||||
#新创建项目的版本库地址
|
||||
respo = temp['http_url_to_repo']
|
||||
respo['http://localhost'] = REPO_IP_ADDRESS
|
||||
# 新创建项目的web地址
|
||||
webaddress = temp['web_url']
|
||||
webaddress['http://localhost'] = REPO_IP_ADDRESS
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 创建用户
|
||||
# loginname:登录名称(版本库路径包含) name:用户姓名
|
||||
# add by nwb
|
||||
def create_user (loginname,name,password,email)
|
||||
url = REPO_IP_ADDRESS + GITLAB_API + "/users"
|
||||
uri = URI.parse(url)
|
||||
data = {email:email,password:password,username:loginname, name:name, private_token:GitlabHelper.gitlab_token}
|
||||
begin
|
||||
res = Net::HTTP.post_form(uri, data)
|
||||
if res.code == '201'
|
||||
temp = ActiveSupport::JSON.decode(res.body)
|
||||
#新创建的gitlab用户编号(需保存)
|
||||
user_id = temp['id']
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 删除用户
|
||||
# user_id:用户在gitlab中的id
|
||||
# add by nwb
|
||||
def delete_user(user_id)
|
||||
url = REPO_IP_ADDRESS + GITLAB_API + "/users/" + user_id
|
||||
uri = URI.parse(url)
|
||||
data = {id:user_id,private_token:GitlabHelper.gitlab_token}
|
||||
http = Net::HTTP.new uri.host, uri.port
|
||||
begin
|
||||
req = Net::HTTP::Delete.new(uri.request_uri)
|
||||
req.form_data = data
|
||||
res= http.start { |http| http.request req }
|
||||
if res.code == '200'
|
||||
temp = ActiveSupport::JSON.decode(res.body)
|
||||
# 删除成功,对应更新trustie用户的gitlab用户编号
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 给用户添加一个可操作的项目
|
||||
# 若用户已在该项目中,权限级别取新权限与现有权限的最大值
|
||||
# project_id:项目在gitlab中的id user_id:用户在gitlab中的id
|
||||
# access_level为用户在项目中的权限级别,对应如下:
|
||||
#GUEST = 10
|
||||
#REPORTER = 20
|
||||
#DEVELOPER = 30
|
||||
#MASTER = 40
|
||||
# add by nwb
|
||||
def add_user_to_project(project_id,user_id,access_level)
|
||||
url = REPO_IP_ADDRESS + GITLAB_API + "/projects/" + project_id +"/members"
|
||||
uri = URI.parse(url)
|
||||
data = {id:project_id,user_id:user_id,access_level:access_level, private_token:GitlabHelper.gitlab_token}
|
||||
begin
|
||||
res = Net::HTTP.post_form(uri, data)
|
||||
if res.code == '201'
|
||||
temp = ActiveSupport::JSON.decode(res.body)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 从项目中删除用户
|
||||
# project_id:项目在gitlab中的ids user_id:用户在gitlab中的id
|
||||
# add by nwb
|
||||
def delete_user_from_project(project_id,user_id)
|
||||
url = REPO_IP_ADDRESS + GITLAB_API + "/projects/" + project_id +"/members/" + user_id
|
||||
uri = URI.parse(url)
|
||||
data = {id:project_id,user_id:user_id,private_token:GitlabHelper.gitlab_token}
|
||||
http = Net::HTTP.new uri.host, uri.port
|
||||
begin
|
||||
req = Net::HTTP::Delete.new(uri.request_uri)
|
||||
req.form_data = data
|
||||
res= http.start { |http| http.request req }
|
||||
if res.code == '200'
|
||||
temp = ActiveSupport::JSON.decode(res.body)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
rescue =>err
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# 发送post消息
|
||||
# add by nwb
|
||||
def post(url, params)
|
||||
uri = URI.parse(url)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
if uri.scheme == 'https'
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
http.use_ssl = true
|
||||
end
|
||||
begin
|
||||
request = Net::HTTP::Post.new(uri.request_uri)
|
||||
request['Content-Type'] = 'application/json;charset=utf-8'
|
||||
request['User-Agent'] = 'Mozilla/5.0 (Windows NT 5.1; rv:29.0) Gecko/20100101 Firefox/29.0'
|
||||
request['X-ACL-TOKEN'] = 'xxx_token'
|
||||
#request.set_form_data(params)
|
||||
request.body = params.to_json
|
||||
response = http.start { |http| http.request(request) }
|
||||
return JSON.parse response.body
|
||||
rescue =>err
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
# 发送get消息
|
||||
# add by nwb
|
||||
def get(url, params)
|
||||
uri = URI.parse(url)
|
||||
uri.query = URI.encode_www_form(params)
|
||||
http = Net::HTTP.new uri.host, uri.port
|
||||
if uri.scheme == 'https'
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
http.use_ssl = true
|
||||
end
|
||||
begin
|
||||
request = Net::HTTP::Get.new uri.request_uri
|
||||
request['Content-Type'] = 'application/json;charset=utf-8'
|
||||
request['User-Agent'] = 'Mozilla/5.0 (Windows NT 5.1; rv:29.0) Gecko/20100101 Firefox/29.0'
|
||||
request['X-ACL-TOKEN'] = 'xxx_token'
|
||||
response = http.start { |http| http.request request }
|
||||
return JSON.parse response.body
|
||||
rescue =>err
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -73,7 +73,7 @@ module IssuesHelper
|
|||
ancestors.each do |ancestor|
|
||||
s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
|
||||
end
|
||||
s << '<div>'
|
||||
s << '<div style="word-wrap: break-word; word-break: normal;">'
|
||||
subject = h(issue.subject)
|
||||
if issue.is_private?
|
||||
subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
|
||||
|
@ -326,7 +326,7 @@ module IssuesHelper
|
|||
if detail.property == 'attr' && detail.prop_key == 'description'
|
||||
s = l(:text_journal_changed_no_detail, :label => label)
|
||||
unless no_html
|
||||
diff_link = link_to 'diff',
|
||||
diff_link = link_to l(:label_diff),
|
||||
{:controller => 'journals', :action => 'diff', :id => detail.journal_id,
|
||||
:detail_id => detail.id, :only_path => options[:only_path]},
|
||||
:title => l(:label_view_diff)
|
||||
|
|
|
@ -31,6 +31,7 @@ module MembersHelper
|
|||
}
|
||||
|
||||
s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
|
@ -53,10 +54,13 @@ module MembersHelper
|
|||
|
||||
# 当前申请加入的成员名单
|
||||
def render_principals_for_applied_members(project)
|
||||
scope = Principal.active.sorted.applied_members(project).like(params[:q])
|
||||
scope = project.applied_projects.map(&:user)
|
||||
principal_count = scope.count
|
||||
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page']
|
||||
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
|
||||
offset ||= principal_pages.offset
|
||||
principals = scope[offset, 10]
|
||||
#principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
|
||||
#principals = ApplicationController.new.paginateHelper scope,10
|
||||
|
||||
s = content_tag('div', principals_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals')
|
||||
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
# encoding: utf-8
|
||||
module ProjectScoreHelper
|
||||
#缺陷数量
|
||||
def issue_num project
|
||||
project.issues.count
|
||||
end
|
||||
|
||||
#缺陷留言数量
|
||||
def issue_journal_num project
|
||||
project.issue_changes.count
|
||||
end
|
||||
|
||||
#新闻数量
|
||||
def news_num project
|
||||
project.news.count
|
||||
end
|
||||
|
||||
#文档数量
|
||||
def documents_num project
|
||||
project.documents.count
|
||||
end
|
||||
|
||||
#代码提交数量
|
||||
def changesets_num project
|
||||
project.changesets.count
|
||||
end
|
||||
|
||||
#讨论区帖子数量
|
||||
def board_message_num project
|
||||
board_message_count = 0
|
||||
project.boards.each do |board|
|
||||
board_message_count += board.messages_count
|
||||
end
|
||||
board_message_count
|
||||
end
|
||||
|
||||
#缺陷得分
|
||||
def issue_score project
|
||||
i_num = issue_num project
|
||||
i_j_num = issue_journal_num project
|
||||
i_num * 4 + i_j_num
|
||||
end
|
||||
|
||||
# 新闻得分
|
||||
def news_score project
|
||||
n_num = news_num project
|
||||
n_num
|
||||
end
|
||||
|
||||
#文档得分
|
||||
def documents_score project
|
||||
d_num = documents_num(project)
|
||||
d_num * 4
|
||||
end
|
||||
|
||||
#代码提交得分
|
||||
def changesets_score project
|
||||
c_num = changesets_num project
|
||||
c_num * 4
|
||||
end
|
||||
|
||||
#讨论区帖子得分
|
||||
def board_message_score project
|
||||
b_m_num = board_message_num project
|
||||
b_m_num * 2
|
||||
end
|
||||
|
||||
#计算项目得分
|
||||
def project_scores project
|
||||
result = (issue_score project) + (news_score project) + (documents_score project) + (changesets_score project) + (board_message_score project)
|
||||
pss = ProjectScore.where("project_id = '#{project.id}'")
|
||||
if pss.nil? || pss.count == 0
|
||||
ps = ProjectScore.new
|
||||
ps.issue_num = issue_num(project)
|
||||
ps.board_message_num = board_message_num(project)
|
||||
ps.changeset_num = changesets_num(project)
|
||||
ps.documents_num = documents_num(project)
|
||||
ps.issue_journal_num = issue_journal_num(project)
|
||||
ps.news_num = news_num(project)
|
||||
|
||||
ps.score = result
|
||||
ps.project = project
|
||||
ps.save
|
||||
else
|
||||
ps = pss.first
|
||||
ps.issue_num = issue_num(project)
|
||||
ps.board_message_num = board_message_num(project)
|
||||
ps.changeset_num = changesets_num(project)
|
||||
ps.documents_num = documents_num(project)
|
||||
ps.issue_journal_num = issue_journal_num(project)
|
||||
ps.news_num = news_num(project)
|
||||
ps.score = result
|
||||
ps.save
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
#读取项目得分
|
||||
def red_project_scores project
|
||||
grade = 0
|
||||
pss = ProjectScore.where("project_id = '#{project.id}'")
|
||||
if pss.nil? || pss.count == 0
|
||||
grade
|
||||
else
|
||||
ps = pss.first
|
||||
grade = ps.score
|
||||
grade
|
||||
end
|
||||
end
|
||||
|
||||
def get_project_score project
|
||||
pss = ProjectScore.where("project_id = '#{project.id}'")
|
||||
ps = nil
|
||||
if pss.nil? || pss.count == 0
|
||||
ps = nil
|
||||
else
|
||||
ps = pss.first
|
||||
end
|
||||
ps
|
||||
end
|
||||
|
||||
end
|
|
@ -175,9 +175,19 @@ module ProjectsHelper
|
|||
render_project_nested_lists(projects) do |project|
|
||||
#Modified by young
|
||||
if (project.try(:project_type) == Project::ProjectType_course )
|
||||
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}").html_safe
|
||||
unless project.is_public == 1
|
||||
s = "<span class='private_project'>#{l(:lable_private)}</span>".html_safe
|
||||
else
|
||||
s = "".html_safe
|
||||
end
|
||||
s += link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}").html_safe
|
||||
else
|
||||
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
|
||||
unless project.is_public
|
||||
s = "<span class='private_project'>#{l(:label_private)}</span>".html_safe
|
||||
else
|
||||
s = "".html_safe
|
||||
end
|
||||
s += link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
|
||||
end
|
||||
#Ended by young
|
||||
if project.description.present?
|
||||
|
@ -339,4 +349,12 @@ module ProjectsHelper
|
|||
return true
|
||||
end
|
||||
end
|
||||
|
||||
def find_project_repository project
|
||||
unless project.repositories.nil?
|
||||
project.repositories.each do |repository|
|
||||
repository.fetch_changesets if Setting.autofetch_changesets?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
module RepositoriesHelper
|
||||
ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/"
|
||||
PROJECT_PATH_CUT = 40
|
||||
REPO_IP_ADDRESS = "repository.trustie.net"
|
||||
REPO_IP_ADDRESS = Setting.repository_domain
|
||||
|
||||
def format_revision(revision)
|
||||
if revision.respond_to? :format_identifier
|
||||
|
|
|
@ -4,13 +4,8 @@ def options_from_select_project(user)
|
|||
@option = []
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
#membership.member_roles.each{|role|
|
||||
# if(role.role_id == 3)
|
||||
# @option << membership.project
|
||||
# end
|
||||
#}
|
||||
#拥有编辑项目权限的可操作该项目
|
||||
if user.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
#可被用户引用的项目
|
||||
if user.allowed_to?(:quote_project, membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,19 @@ module SoftapplicationsHelper
|
|||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
|
||||
#作品分类下拉框
|
||||
def work_type_opttion
|
||||
type = []
|
||||
#work_types = WorksCategory.all
|
||||
WorksCategory.all.each do |work_type|
|
||||
option = []
|
||||
option << work_type.category
|
||||
option << work_type.category
|
||||
type << option
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
# def select_option_helper option
|
||||
# tmp = Hash.new
|
||||
|
|
|
@ -16,6 +16,8 @@ module StoresHelper
|
|||
news_path(container)
|
||||
when 'Project'
|
||||
project_files_path(container)
|
||||
when 'Course'
|
||||
course_files_path(container)
|
||||
when 'Version'
|
||||
# version_path(container)
|
||||
project_files_path(container.project)
|
||||
|
@ -37,15 +39,23 @@ module StoresHelper
|
|||
|
||||
WORD_LIMIT = 100
|
||||
def come_from_local attachment
|
||||
|
||||
container = attachment.container
|
||||
case container.class.to_s
|
||||
when 'Message'
|
||||
# '项目 > zzz > 论坛 > 帖子xxx'
|
||||
# topic_str = container.project.project_type == 0 ? l(:label_board) : l(:label_new_course)
|
||||
topic_list = link_to l(:label_board), project_boards_path(container.project)
|
||||
topic_item = link_to container.subject.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
|
||||
project_link(container.project).push(topic_list, topic_item)
|
||||
|
||||
course = container.course
|
||||
project = container.project
|
||||
if course.nil? # container is belongs to Project
|
||||
topic_list = link_to l(:label_board), project_boards_path(container.project)
|
||||
topic_item = link_to container.subject.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
|
||||
project_link(container.project).push(topic_list, topic_item)
|
||||
else # container is belongs to Course
|
||||
topic_list = link_to l(:label_course_news), course_boards_path(course)
|
||||
topic_item = link_to container.try(:subject).to_s.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
|
||||
project_link(course).push(topic_list, topic_item)
|
||||
end
|
||||
when 'Issue'
|
||||
# '项目 > zzz > 缺陷 > 问题xxx'
|
||||
issue_list = link_to l(:label_project_issues), project_issues_path(container.project)
|
||||
|
@ -58,15 +68,26 @@ module StoresHelper
|
|||
project_link(container.project).push(doc_list, doc_item)
|
||||
when 'News'
|
||||
# '课程 > zzz > 新闻 > 新闻xxx'
|
||||
news_str = container.project.project_type == 0 ? l(:label_news) : l(:label_course_news)
|
||||
news_list = link_to news_str, project_news_index_path(container.project)
|
||||
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
|
||||
project_link(container.project).push(news_list, news_item)
|
||||
course = container.course
|
||||
project = container.project
|
||||
if course.nil? # container is belongs to Project
|
||||
news_list = link_to l(:label_news), project_news_index_path(container.project)
|
||||
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
|
||||
project_link(container.project).push(news_list, news_item)
|
||||
else # container is belongs to Course
|
||||
news_list = link_to l(:label_course_news), course_news_index_path(course)
|
||||
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
|
||||
project_link(course).push(news_list, news_item)
|
||||
end
|
||||
|
||||
when 'Project'
|
||||
# '项目 > zzz '
|
||||
file_str = container.project.project_type == 0 ? l(:project_module_files) : l(:label_course_file)
|
||||
files_list = link_to file_str, project_files_path(container.project)
|
||||
project_link(container).push(files_list)
|
||||
when 'Course'
|
||||
files_list = link_to l(:label_course_file), course_files_path(container)
|
||||
project_link(container).push(files_list)
|
||||
when 'Version'
|
||||
# '项目 > zzz > 里程碑 > xxx'
|
||||
ver_list = link_to l(:label_roadmap), project_roadmap_path(container.project)
|
||||
|
@ -91,7 +112,8 @@ module StoresHelper
|
|||
# '竞赛 > xxx '
|
||||
bid_link(container)
|
||||
else
|
||||
Rails.logger.error "ERROR: attachment type unkown"
|
||||
Rails.logger.error "ERROR: attachment type unkown. file:#{__FILE__}, line:#{__LINE__}"
|
||||
Rails.logger.error "#{container.class.to_s}"
|
||||
[link_to('unkown', '')]
|
||||
end
|
||||
rescue ActionController::RoutingError => e
|
||||
|
@ -99,20 +121,6 @@ module StoresHelper
|
|||
[link_to('unkown', '')]
|
||||
end
|
||||
|
||||
def project_link project
|
||||
if project.nil?
|
||||
Rails.logger.error "ERROR: attachment type unkown #project_link project.nil?"
|
||||
return [link_to('unkown', '')]
|
||||
end
|
||||
project_list = nil
|
||||
if project.project_type == 0
|
||||
project_list = link_to l(:label_project_plural), projects_path
|
||||
else
|
||||
project_list = link_to l(:label_new_course), course_path
|
||||
end
|
||||
project_item = link_to project.to_s, project_path(project)
|
||||
[project_list, project_item]
|
||||
end
|
||||
|
||||
def bid_link bid
|
||||
bid_list = nil
|
||||
|
@ -129,7 +137,7 @@ module StoresHelper
|
|||
Rails.logger.error "ERROR: attachment type unkown #bid_link/when 3"
|
||||
return [link_to('unkown', '#')]
|
||||
end
|
||||
bid_list = link_to l(:label_homework), project_homework_path(bid.courses.first)
|
||||
bid_list = link_to l(:label_homework), homework_course_path(bid.courses.first)
|
||||
bid_item = link_to bid.name, respond_path(bid)
|
||||
return project_link(bid.courses.first).push(bid_list, bid_item)
|
||||
else
|
||||
|
@ -137,4 +145,28 @@ module StoresHelper
|
|||
end
|
||||
[bid_list, bid_item]
|
||||
end
|
||||
|
||||
|
||||
def project_link project
|
||||
if project.nil?
|
||||
Rails.logger.error "ERROR: attachment type unkown #project_link project.nil? file: #{__FILE__}, line: #{__LINE__}"
|
||||
return [link_to('unkown', '')]
|
||||
end
|
||||
project_list = nil
|
||||
klass = project.class.to_s
|
||||
case klass
|
||||
when "Project"
|
||||
project_list = link_to l(:label_project_plural), projects_path
|
||||
project_item = link_to project.to_s, project_path(project)
|
||||
[project_list, project_item]
|
||||
when "Course"
|
||||
course_list = link_to l(:label_new_course), courses_path
|
||||
course_item = link_to project.name, course_path(project)
|
||||
[course_list, course_item]
|
||||
else
|
||||
Rails.logger.error "[StoresHelper]: #{klass} ======================================="
|
||||
[]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,8 @@ module TagsHelper
|
|||
@obj = Issue.find_by_id(obj_id)
|
||||
when '4'
|
||||
@obj = Bid.find_by_id(obj_id)
|
||||
when '5'
|
||||
@obj = Forum.find_by_id(obj_id)
|
||||
when '6'
|
||||
@obj = Attachment.find_by_id(obj_id)
|
||||
when '7'
|
||||
|
@ -44,6 +46,8 @@ module TagsHelper
|
|||
if user.id == obj_id
|
||||
@result = true
|
||||
end
|
||||
when '5'
|
||||
@result = is_forum_manager?(user.id,obj_id)
|
||||
when '7'
|
||||
if user.id == obj_id
|
||||
@result = true
|
||||
|
@ -56,6 +60,17 @@ module TagsHelper
|
|||
|
||||
end
|
||||
|
||||
# 判断用户是否是贴吧的管理员
|
||||
# add by chenmin
|
||||
def is_forum_manager?(user_id,forum_id)
|
||||
@result = false
|
||||
@user_id = Forum.find(forum_id).creator_id;
|
||||
if @user_id == user.id
|
||||
@result = true
|
||||
end
|
||||
return @result
|
||||
end
|
||||
|
||||
def tagname_val
|
||||
("#tag_name_name").value
|
||||
end
|
|
@ -228,16 +228,10 @@ module UserScoreHelper
|
|||
isManager = 0
|
||||
members = Member.where('user_id = ?', user.id)
|
||||
members.each do |m|
|
||||
#roles = m.member_roles
|
||||
#roles.each do |r|
|
||||
# if r.role_id == 3
|
||||
# isManager = 1
|
||||
# end
|
||||
#end
|
||||
@membership = m.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
@membership.each do |membership|
|
||||
#拥有编辑项目权限的可操作该项目
|
||||
if m.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
if m.allowed_to?(:is_manager, membership.project, :global => false)
|
||||
isManager = 1
|
||||
end
|
||||
end
|
||||
|
@ -342,8 +336,619 @@ module UserScoreHelper
|
|||
user.user_score.update_attributes(:collaboration => collaboration, :influence => influence, :skill => skill,
|
||||
:activity => activity, :file => file, :issue => issue, :level => level)
|
||||
end
|
||||
|
||||
|
||||
|
||||
#========================================================================================================
|
||||
#个人得分统计
|
||||
#========================================================================================================
|
||||
#type 1:个人得分、2:个人在项目project中的得分
|
||||
def get_option_number(user,type,project=nil)
|
||||
if project.nil?
|
||||
option_number = OptionNumber.where("user_id = '#{user.id}' and score_type = '#{type}'");
|
||||
else
|
||||
option_number = OptionNumber.where("user_id = '#{user.id}' and score_type = '#{type}' and project_id = '#{project.id}'");
|
||||
end
|
||||
|
||||
result = nil
|
||||
if option_number.nil? || option_number.count == 0
|
||||
result = OptionNumber.new
|
||||
result.user_id = user.id
|
||||
result.memo = 0
|
||||
result.messages_for_issues = 0
|
||||
result.issues_status = 0
|
||||
result.replay_for_message = 0
|
||||
result.replay_for_memo = 0
|
||||
result.follow = 0
|
||||
result.tread = 0
|
||||
result.praise_by_one = 0
|
||||
result.praise_by_two = 0
|
||||
result.praise_by_three = 0
|
||||
result.tread_by_one = 0
|
||||
result.tread_by_two = 0
|
||||
result.tread_by_three = 0
|
||||
result.changeset = 0
|
||||
result.document = 0
|
||||
result.attachment = 0
|
||||
result.issue_done_ratio = 0
|
||||
result.post_issue = 0
|
||||
result.total_score = 0
|
||||
result.score_type =type
|
||||
unless project.nil?
|
||||
result.project_id = project.id
|
||||
end
|
||||
else
|
||||
result = option_number.first
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def get_option_num_by_id(user_id,type,project_id=nil)
|
||||
if project_id.nil?
|
||||
option_number = OptionNumber.where("user_id = '#{user_id}' and score_type = '#{type}'");
|
||||
else
|
||||
option_number = OptionNumber.where("user_id = '#{user_id}' and score_type = '#{type}' and project_id = '#{project_id}'");
|
||||
end
|
||||
|
||||
result = nil
|
||||
if option_number.nil? || option_number.count == 0
|
||||
result = OptionNumber.new
|
||||
result.user_id = user_id
|
||||
result.memo = 0
|
||||
result.messages_for_issues = 0
|
||||
result.issues_status = 0
|
||||
result.replay_for_message = 0
|
||||
result.replay_for_memo = 0
|
||||
result.follow = 0
|
||||
result.tread = 0
|
||||
result.praise_by_one = 0
|
||||
result.praise_by_two = 0
|
||||
result.praise_by_three = 0
|
||||
result.tread_by_one = 0
|
||||
result.tread_by_two = 0
|
||||
result.tread_by_three = 0
|
||||
result.changeset = 0
|
||||
result.document = 0
|
||||
result.attachment = 0
|
||||
result.issue_done_ratio = 0
|
||||
result.post_issue = 0
|
||||
result.total_score = 0
|
||||
result.score_type =type
|
||||
unless project_id.nil?
|
||||
result.project_id = project_id
|
||||
end
|
||||
else
|
||||
result = option_number.first
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
#更新分数
|
||||
def update_score(option_number)
|
||||
option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number)
|
||||
if option_number.total_score < 0
|
||||
option_number.total_score = 0
|
||||
end
|
||||
option_number.save
|
||||
option_number.total_score
|
||||
end
|
||||
|
||||
#协同得分
|
||||
def collaboration(option_number)
|
||||
option_number.memo * 2 + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo
|
||||
end
|
||||
#影响力得分
|
||||
def influence(option_number)
|
||||
option_number.follow * 2
|
||||
end
|
||||
#技术得分
|
||||
def skill(option_number)
|
||||
option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6
|
||||
end
|
||||
#项目贡献得分
|
||||
def active(option_number)
|
||||
option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4
|
||||
end
|
||||
|
||||
#更新发帖数
|
||||
def update_memo_number(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.memo = memo_num(user,project)#Message.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count + Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
#发帖数
|
||||
def memo_num(user,project=nil)
|
||||
if project.nil?
|
||||
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count #+ Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count
|
||||
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM `messages` JOIN `boards` ON boards.project_id != -1 AND messages.board_id = boards.id
|
||||
WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}")
|
||||
result = 0
|
||||
users.each do |user|
|
||||
result = user.m_count
|
||||
end
|
||||
result
|
||||
#user.messages.where("parent_id IS NULL").count
|
||||
else
|
||||
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
|
||||
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM `messages` JOIN `boards` ON boards.project_id = '#{project.id}' AND messages.board_id = boards.id
|
||||
WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}")
|
||||
result = 0
|
||||
users.each do |user|
|
||||
result = user.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def memo_score(user,project=nil)
|
||||
if project.nil?
|
||||
User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 FROM `messages` JOIN `boards` ON boards.project_id != -1 AND messages.board_id = boards.id
|
||||
WHERE messages.parent_id IS NULL AND messages.author_id = `users`.id) AS m_count
|
||||
FROM `users` where id = #{user.id}")
|
||||
else
|
||||
User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 FROM `messages` JOIN `boards` ON boards.project_id = '#{project.id}' AND messages.board_id = boards.id
|
||||
WHERE messages.parent_id IS NULL AND messages.author_id = `users`.id) AS m_count
|
||||
FROM `users` where id = #{user.id}")
|
||||
end
|
||||
end
|
||||
|
||||
#更新对缺陷留言数
|
||||
def update_messges_for_issue(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.messages_for_issues = messges_for_issue_num(user,project)#Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def messges_for_issue_num(user,project=nil)
|
||||
if project.nil?
|
||||
#Journal.includes(:user).where("user_id = '#{user.id}' and notes is not null and notes != ''").all.count
|
||||
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals WHERE journals.user_id = #{user.id} AND journals.notes IS NOT NULL AND journals.notes != ''")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
else
|
||||
#Journal.includes(:user).joins(:issue).where("#{Journal.table_name}.user_id = '#{user.id}' and #{Issue.table_name}.project_id = '#{project.id}' and #{Journal.table_name}.notes != '' and #{Journal.table_name}.notes is not null").all.count
|
||||
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals join issues on #{Journal.table_name}.journalized_type = 'Issue' and #{Journal.table_name}.journalized_id = #{Issue.table_name}.id WHERE journals.user_id = #{user.id} AND journals.notes IS NOT NULL AND journals.notes != ''and #{Issue.table_name}.project_id = '#{project.id}'")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
def messges_for_issue_score(user,project=nil)
|
||||
if project.nil?
|
||||
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals WHERE journals.user_id = users.id AND journals.notes IS NOT NULL AND journals.notes != '') AS m_score FROM users where id = #{user.id}")
|
||||
else
|
||||
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals join issues on #{Journal.table_name}.journalized_type = 'Issue' and #{Journal.table_name}.journalized_id = #{Issue.table_name}.id WHERE journals.user_id = users.id AND journals.notes IS NOT NULL AND journals.notes != ''and #{Issue.table_name}.project_id = '#{project.id}') AS m_score FROM users where id = #{user.id}")
|
||||
end
|
||||
end
|
||||
|
||||
#更新更改缺陷状态状态次数
|
||||
def update_issues_status(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.issues_status = issues_status_num(user,project)#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def issues_status_num(user,project=nil)
|
||||
if project.nil?
|
||||
#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
|
||||
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' and journals.user_id = #{user.id}")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
else
|
||||
#Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
|
||||
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' and journals.user_id = #{user.id} and issues.project_id = '#{project.id}'")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def issues_status_score(user,project=nil)
|
||||
if project.nil?
|
||||
#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
|
||||
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id) AS m_count FROM users WHERE users.id = '#{user.id}'")
|
||||
else
|
||||
#Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
|
||||
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id and issues.project_id = '#{project.id}') AS m_count FROM users WHERE users.id = '#{user.id}'")
|
||||
end
|
||||
end
|
||||
|
||||
#更新对留言的回复数量
|
||||
def update_replay_for_message(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.replay_for_message = replay_for_message_num(user,project)#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def replay_for_message_num(user,project=nil)
|
||||
if project.nil?
|
||||
#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project'").count
|
||||
users = JournalsForMessage.find_by_sql("SELECT COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project'")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
else
|
||||
#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project' and jour_id = '#{project.id}'").count
|
||||
users = JournalsForMessage.find_by_sql("SELECT COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project' and jour_id = '#{project.id}'")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def replay_for_message_score(user,project=nil)
|
||||
if project.nil?
|
||||
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project') as m_score FROM users WHERE users.id = '#{user.id}'")
|
||||
else
|
||||
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project' and jour_id = '#{project.id}') as m_score FROM users WHERE users.id = '#{user.id}'")
|
||||
end
|
||||
end
|
||||
|
||||
#更新对帖子的回复数量
|
||||
def update_replay_for_memo(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.replay_for_memo = replay_for_memo_num(user,project)#Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count #+ Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def replay_for_memo_num(user,project=nil)
|
||||
if project.nil?
|
||||
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count
|
||||
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = #{user.id} AND boards.project_id != -1")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
else
|
||||
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
|
||||
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = #{user.id} AND boards.project_id = #{project.id}")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
def replay_for_memo_score(user,project=nil)
|
||||
if project.nil?
|
||||
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = users.id AND boards.project_id != -1) FROM users WHERE users.id = #{user.id}")
|
||||
else
|
||||
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = users.id AND boards.project_id = #{project.id}) FROM users WHERE users.id = #{user.id}")
|
||||
end
|
||||
end
|
||||
|
||||
#更新被关注的人数
|
||||
def update_follow(user,type)
|
||||
option_number = get_option_number(user,type)
|
||||
option_number.follow = follow_num(user)#Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def follow_num(user)
|
||||
#Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
|
||||
users = Watcher.find_by_sql("SELECT COUNT(*) as m_count FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = #{user.id}")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def follow_score(user)
|
||||
User.find_by_sql("SELECT users.id, (SELECT COUNT(*) * 2 FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = users.id) FROM users WHERE users.id = '#{user.id}'")
|
||||
end
|
||||
|
||||
#更新帖子踩各项数量
|
||||
def update_tread(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
tread_nums = tread_num(user,project)
|
||||
option_number.tread = tread_nums[:tread]
|
||||
option_number.tread_by_one = tread_nums[:tead_by_one]
|
||||
option_number.tread_by_two = tread_nums[:tread_by_two]
|
||||
option_number.tread_by_three = tread_nums[:tread_by_three]
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def tread_num(user,project=nil)
|
||||
if project.nil?
|
||||
result0 = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
|
||||
pts = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 0").all
|
||||
result = []
|
||||
result1 = []
|
||||
result2 = []
|
||||
pts.each do |pt|
|
||||
obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
|
||||
if obj.nil?
|
||||
next
|
||||
end
|
||||
target_user = obj.author
|
||||
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
||||
#project = pt.project
|
||||
if level == 1 && target_user.id == user.id
|
||||
result << pt
|
||||
elsif level == 2 && target_user.id == user.id
|
||||
result1 << pt
|
||||
elsif level == 3 && target_user.id == user.id
|
||||
result2 << pt
|
||||
end
|
||||
end
|
||||
{:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count}
|
||||
else
|
||||
result0 = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
|
||||
pts = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 0").all
|
||||
result = []
|
||||
result1 = []
|
||||
result2 = []
|
||||
pts.each do |pt|
|
||||
obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
|
||||
if obj.nil? || (pt.praise_tread_object_type == "Issue" && obj.project.nil?) || (pt.praise_tread_object_type == "Message" && obj.board.nil?) || (pt.praise_tread_object_type == "Message" && obj.board.project.nil?)
|
||||
next
|
||||
end
|
||||
if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id)
|
||||
next
|
||||
end
|
||||
target_user = obj.author
|
||||
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
||||
#project = pt.project
|
||||
if level == 1 && target_user.id == user.id
|
||||
result << pt
|
||||
elsif level == 2 && target_user.id == user.id
|
||||
result1 << pt
|
||||
elsif level == 3 && target_user.id == user.id
|
||||
result2 << pt
|
||||
end
|
||||
end
|
||||
{:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#更新帖子顶数量
|
||||
def update_praise(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
praise_nums = praise_num(user,project)
|
||||
option_number.praise_by_one = praise_nums[:praise_by_one]
|
||||
option_number.praise_by_two = praise_nums[:praise_by_two]
|
||||
option_number.praise_by_three = praise_nums[:praise_by_three]
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def praise_num(user,project=nil)
|
||||
if !project.nil?
|
||||
pts = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 1").all
|
||||
result = []
|
||||
result1 = []
|
||||
result2 = []
|
||||
pts.each do |pt|
|
||||
obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
|
||||
if obj.nil? || (pt.praise_tread_object_type == "Issue" && obj.project.nil?) || (pt.praise_tread_object_type == "Message" && obj.board.nil?) || (pt.praise_tread_object_type == "Message" && obj.board.project.nil?)
|
||||
next
|
||||
end
|
||||
if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id)
|
||||
next
|
||||
end
|
||||
target_user = obj.author
|
||||
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
||||
#project = pt.project
|
||||
if level == 1 && target_user.id == user.id
|
||||
result << pt
|
||||
elsif level == 2 && target_user.id == user.id
|
||||
result1 << pt
|
||||
elsif level == 3 && target_user.id == user.id
|
||||
result2 << pt
|
||||
end
|
||||
end
|
||||
{:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count}
|
||||
else
|
||||
pts = PraiseTread.where("praise_tread_object_type IN ( 'Issue','Message') and praise_or_tread = 1").all
|
||||
result = []
|
||||
result1 = []
|
||||
result2 = []
|
||||
pts.each do |pt|
|
||||
obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
|
||||
if obj.nil?
|
||||
next
|
||||
end
|
||||
#if obj.project.id == -1
|
||||
# next
|
||||
#end
|
||||
target_user = obj.author
|
||||
level = UserLevels.get_level(pt.user)#pt.user.get_level
|
||||
project = pt.project
|
||||
if level == 1 && target_user.id == user.id
|
||||
result << pt
|
||||
elsif level == 2 && target_user.id == user.id
|
||||
result1 << pt
|
||||
elsif level == 3 && target_user.id == user.id
|
||||
result2 << pt
|
||||
end
|
||||
end
|
||||
{:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#更新提交代码次数
|
||||
def update_changeset(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.changeset = changeset_num(user,project)#Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def changeset_num(user,project=nil)
|
||||
if project.nil?
|
||||
#Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
|
||||
users = Changeset.find_by_sql("SELECT COUNT(*) as m_count FROM #{Changeset.table_name} WHERE user_id = #{user.id}")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
else
|
||||
#Changeset.includes(:user).joins(:repository).where("#{Changeset.table_name}.user_id = '#{user.id}' and #{Repository.table_name}.project_id = #{project.id}").all.count
|
||||
users = Changeset.find_by_sql("SELECT COUNT(*) as m_count FROM #{Changeset.table_name} JOIN #{Repository.table_name} ON #{Changeset.table_name}.repository_id = #{Repository.table_name}.id WHERE #{Changeset.table_name}.user_id = #{user.id} and #{Repository.table_name}.project_id = #{project.id}")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#更新文档提交次数
|
||||
def update_document(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.document = document_num(user,project)#Document.includes(:user).where("user_id = '#{user.id}'").all.count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def document_num(user,project=nil)
|
||||
if project.nil?
|
||||
#Document.includes(:user).where("user_id = '#{user.id}'").all.count
|
||||
users = Document.find_by_sql("SELECT COUNT(*) as m_count FROM #{Document.table_name} WHERE #{Document.table_name}.user_id = #{user.id}")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
else
|
||||
#Document.includes(:user,:project).where("user_id = '#{user.id}' and project_id = '#{project.id}'").all.count
|
||||
users = Document.find_by_sql("SELECT COUNT(*) as m_count FROM #{Document.table_name} WHERE #{Document.table_name}.user_id = #{user.id} and #{Document.table_name}.project_id = '#{project.id}'")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#更新附件提交数量
|
||||
def update_attachment(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.attachment = attachment_num(user,project)#Attachment.includes(:author).where("author_id = '#{user.id}'").all.count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def attachment_num(user,project=nil)
|
||||
if project.nil?
|
||||
#Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project'").all.count
|
||||
users = Attachment.find_by_sql("SELECT COUNT(*) as m_count FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project'")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
else
|
||||
#Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}").all.count
|
||||
users = Attachment.find_by_sql("SELECT COUNT(*) as m_count FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
#更新缺陷完成度次数
|
||||
def update_issue_done_ratio(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.issue_done_ratio = issue_done_ratio_num(user,project) #Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def issue_done_ratio_num(user,project=nil)
|
||||
if project.nil?
|
||||
#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
|
||||
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{Journal.table_name}.user_id = #{user.id}")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
else
|
||||
#Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
|
||||
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{Journal.table_name}.user_id = #{user.id} and #{Issue.table_name}.project_id = '#{project.id}'")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#更新发布缺陷次数
|
||||
def update_post_issue(user,type,project=nil)
|
||||
option_number = get_option_number(user,type,project)
|
||||
option_number.post_issue = post_issue_num(user,project) #Issue.includes(:author).where("author_id = '#{user.id}'").all.count
|
||||
update_score(option_number)
|
||||
end
|
||||
|
||||
def post_issue_num(user,project=nil)
|
||||
if project.nil?
|
||||
#Issue.includes(:author).where("author_id = '#{user.id}'").all.count
|
||||
users = Issue.find_by_sql("SELECT COUNT(*) as m_count FROM #{Issue.table_name} WHERE author_id = #{user.id}")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
else
|
||||
#Issue.includes(:author).where("author_id = '#{user.id}' and project_id = '#{project.id}'").all.count
|
||||
users = Issue.find_by_sql("SELECT COUNT(*) as m_count FROM #{Issue.table_name} WHERE author_id = #{user.id} and project_id = '#{project.id}'")
|
||||
result = 0
|
||||
if users.count > 0
|
||||
result = users.first.m_count
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
#读取项目成员得分
|
||||
def read_user_project_scores(user,project)
|
||||
option_num = get_option_number(user,2,project)
|
||||
option_num.total_score
|
||||
end
|
||||
|
||||
def user_scores(user,type,project=nil)
|
||||
ooption_num = get_option_number(user,type,project)
|
||||
update_memo_number(user,type,project)
|
||||
update_messges_for_issue(user,type,project)
|
||||
update_issues_status(user,type,project)
|
||||
update_replay_for_message(user,type,project)
|
||||
update_replay_for_memo(user,type,project)
|
||||
update_tread(user,type,project)
|
||||
update_praise(user,type,project)
|
||||
update_changeset(user,type,project)
|
||||
update_document(user,type,project)
|
||||
update_attachment(user,type,project)
|
||||
update_issue_done_ratio(user,type,project)
|
||||
update_post_issue(user,type,project)
|
||||
if project.nil?
|
||||
update_follow(user,type)
|
||||
end
|
||||
update_score(ooption_num)
|
||||
ooption_num
|
||||
end
|
||||
end
|
||||
|
|
|
@ -258,4 +258,24 @@ module UsersHelper
|
|||
end
|
||||
return result
|
||||
end
|
||||
|
||||
#获取用户参与的公开的课程列表
|
||||
def user_public_course_list user
|
||||
membership = user.coursememberships.all#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||
memberships = []
|
||||
membership.collect { |e|
|
||||
memberships.push(e)
|
||||
}
|
||||
## 判断课程是否过期 [需封装]
|
||||
memberships_doing = []
|
||||
memberships_done = []
|
||||
memberships.map { |e|
|
||||
if course_endTime_timeout?(e.course)
|
||||
memberships_done.push e
|
||||
else
|
||||
memberships_doing.push e
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -211,13 +211,17 @@ module WatchersHelper
|
|||
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)}".html_safe,
|
||||
:id => "issue_watcher_user_ids_#{user.id}",
|
||||
:class => "floating"
|
||||
end.join.html_safe
|
||||
if users.nil?
|
||||
|
||||
else
|
||||
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)}".html_safe,
|
||||
:id => "issue_watcher_user_ids_#{user.id}",
|
||||
:class => "floating"
|
||||
end.join.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
def applied_css(project)
|
||||
|
@ -246,4 +250,7 @@ module WatchersHelper
|
|||
link_to text, url, :remote => true, :method => method ,:class=>css
|
||||
end
|
||||
|
||||
end
|
||||
def exit_project_link(project)
|
||||
link_to("退出项目",exit_cur_project_path(project.id),:remote => true )
|
||||
end
|
||||
end
|
||||
|
|
|
@ -203,12 +203,12 @@ module WelcomeHelper
|
|||
#end
|
||||
end
|
||||
|
||||
def find_miracle_project(sum, max_rate)
|
||||
def find_miracle_project(sum, max_rate,order)
|
||||
#max = sum*(max_rate.to_f/10)
|
||||
#c1 = find_new_project(sum).to_a.dup
|
||||
#c2 = find_all_hot_project(sum).to_a.dup
|
||||
#(c2.take(sum-max)+c1.take(max)).take(sum)
|
||||
find_all_hot_project(sum).to_a.dup
|
||||
find_all_hot_project(sum,order).to_a.dup
|
||||
end
|
||||
|
||||
def find_new_course limit=15
|
||||
|
@ -220,8 +220,8 @@ module WelcomeHelper
|
|||
end
|
||||
|
||||
|
||||
def find_all_hot_project limit=15
|
||||
sort_project_by_hot limit
|
||||
def find_all_hot_project limit=15,order
|
||||
sort_project_by_hot limit,order
|
||||
end
|
||||
|
||||
def find_all_hot_course limit=15
|
||||
|
@ -231,12 +231,12 @@ module WelcomeHelper
|
|||
# modif by nwb
|
||||
def find_all_new_hot_course limit = 9 ,school_id = 0
|
||||
#sort_project_by_hot_rails 1, 'course_ac_para DESC', limit
|
||||
time_now = Time.new.strftime("%Y");
|
||||
time_now = Time.new.strftime("%Y")
|
||||
if school_id
|
||||
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
|
||||
courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
|
||||
?", school_id).order("course_ac_para DESC").limit(limit).all
|
||||
else
|
||||
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL
|
||||
courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL
|
||||
").order("course_ac_para DESC").limit(limit).all
|
||||
end
|
||||
courses
|
||||
|
@ -366,8 +366,9 @@ module WelcomeHelper
|
|||
|
||||
private
|
||||
|
||||
def sort_project_by_hot limit=15
|
||||
sort_project_by_hot_rails 0, 'grade DESC', limit
|
||||
def sort_project_by_hot limit=15,order
|
||||
#'grade DESC'
|
||||
sort_project_by_hot_rails 0,order , limit
|
||||
end
|
||||
|
||||
def sort_course_by_hot limit=15
|
||||
|
@ -427,13 +428,13 @@ module WelcomeHelper
|
|||
resultSet.take(limit)
|
||||
end
|
||||
|
||||
def sort_project_by_hot_rails project_type=0, order_by='grade DESC', limit=15
|
||||
def sort_project_by_hot_rails project_type=0, order_by='score DESC', limit=15
|
||||
# Project.find_by_sql("
|
||||
# SELECT p.id, p.name, p.description, p.identifier, t.project_id
|
||||
# FROM projects AS p LEFT OUTER JOIN (
|
||||
# SELECT project_id,grade FROM project_statuses
|
||||
# WHERE project_type = #{project_type} ORDER BY #{order_by} LIMIT #{limit} ) AS t ON p.id = t.project_id ")
|
||||
Project.visible.joins(:project_status).where("#{Project.table_name}.project_type = ?", project_type).order(order_by).limit(limit).all
|
||||
Project.visible.joins(:project_status).joins("LEFT JOIN #{ProjectScore.table_name} ON #{Project.table_name}.id = #{ProjectScore.table_name}.project_id").where("#{Project.table_name}.project_type = ?", project_type).order(order_by).limit(limit).all
|
||||
end
|
||||
|
||||
def sort_bid_by_hot_rails reward_type, limit = 10
|
||||
|
|
|
@ -40,4 +40,14 @@ module WikiHelper
|
|||
link_to(h(parent.pretty_title), {:controller => 'wiki', :action => 'show', :id => parent.title, :project_id => parent.project, :version => nil})
|
||||
})
|
||||
end
|
||||
|
||||
def wiki_content_format wiki
|
||||
text = wiki.text.html_safe
|
||||
text = parse_non_pre_blocks(text, wiki, text) do |text|
|
||||
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name|
|
||||
send method_name, text, project, wiki, attr, only_path, options
|
||||
end
|
||||
end
|
||||
text
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,10 +26,12 @@ class Attachment < ActiveRecord::Base
|
|||
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
||||
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
|
||||
|
||||
include UserScoreHelper
|
||||
|
||||
validates_presence_of :filename, :author
|
||||
validates_length_of :filename, :maximum => 255
|
||||
validates_length_of :disk_filename, :maximum => 255
|
||||
validates_length_of :description, :maximum => 255
|
||||
validates_length_of :filename, :maximum => 254
|
||||
validates_length_of :disk_filename, :maximum => 254
|
||||
validates_length_of :description, :maximum => 254
|
||||
validate :validate_max_file_size
|
||||
|
||||
|
||||
|
@ -39,19 +41,22 @@ class Attachment < ActiveRecord::Base
|
|||
|
||||
#课程资源文件
|
||||
acts_as_activity_provider :type => 'course_files',
|
||||
:is_public => 'attachments.is_public',
|
||||
:permission => :view_files,
|
||||
:author_key => :author_id,
|
||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||
:joins => "LEFT JOIN #{Course.table_name} ON ( #{Attachment.table_name}.container_type='Course' AND #{Attachment.table_name}.container_id = #{Course.table_name}.id )"}
|
||||
|
||||
acts_as_activity_provider :type => 'files',
|
||||
:is_public => 'attachments.is_public',
|
||||
:permission => :view_files,
|
||||
:author_key => :author_id,
|
||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||
:find_options => { :select => "#{Attachment.table_name}.*",
|
||||
:joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )"}
|
||||
|
||||
acts_as_activity_provider :type => 'documents',
|
||||
:is_public => 'documents.is_public',
|
||||
:permission => :view_documents,
|
||||
:author_key => :author_id,
|
||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||
|
@ -65,8 +70,9 @@ class Attachment < ActiveRecord::Base
|
|||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||
|
||||
before_save :files_to_final_location
|
||||
before_save :be_user_score # user_score
|
||||
after_destroy :delete_from_disk
|
||||
after_create :be_user_score # user_score
|
||||
after_update :be_user_score
|
||||
after_destroy :delete_from_disk,:down_user_score
|
||||
|
||||
# add by nwb
|
||||
# 获取所有可公开的资源文件列表
|
||||
|
@ -190,12 +196,27 @@ class Attachment < ActiveRecord::Base
|
|||
def show_suffix_type
|
||||
suffix = 'other'
|
||||
temp = self.suffix_type.downcase
|
||||
if self.attachmentstype.suffixArr.include?(temp)
|
||||
if self.attachmentstype && self.attachmentstype.suffixArr.include?(temp)
|
||||
suffix = temp
|
||||
end
|
||||
suffix
|
||||
end
|
||||
|
||||
# 文件密级的字符描述
|
||||
def file_dense_str
|
||||
if self.is_public == 1
|
||||
dense = l(:field_is_public)
|
||||
else
|
||||
dense = l(:field_is_private)
|
||||
end
|
||||
dense
|
||||
end
|
||||
|
||||
# 文件可设置的密级列表
|
||||
def file_dense_list
|
||||
denselist = [l(:field_is_public),l(:field_is_private)]
|
||||
end
|
||||
|
||||
def suffixArr
|
||||
@@SuffixArr
|
||||
end
|
||||
|
@ -209,7 +230,8 @@ class Attachment < ActiveRecord::Base
|
|||
def file=(incoming_file)
|
||||
unless incoming_file.nil?
|
||||
@temp_file = incoming_file
|
||||
if @temp_file.size > 0
|
||||
# 允许上传文件大小为0的文件
|
||||
#if @temp_file.size > 0
|
||||
if @temp_file.respond_to?(:original_filename)
|
||||
self.filename = @temp_file.original_filename
|
||||
self.filename.force_encoding("UTF-8") if filename.respond_to?(:force_encoding)
|
||||
|
@ -221,7 +243,7 @@ class Attachment < ActiveRecord::Base
|
|||
self.content_type = Redmine::MimeType.of(filename)
|
||||
end
|
||||
self.filesize = @temp_file.size
|
||||
end
|
||||
#end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -237,7 +259,8 @@ class Attachment < ActiveRecord::Base
|
|||
# Copies the temporary file to its final location
|
||||
# and computes its MD5 hash
|
||||
def files_to_final_location
|
||||
if @temp_file && (@temp_file.size > 0)
|
||||
# # 允许上传文件大小为0的文件
|
||||
if @temp_file# && (@temp_file.size > 0)
|
||||
self.disk_directory = target_directory
|
||||
self.disk_filename = Attachment.disk_filename(filename, disk_directory)
|
||||
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")
|
||||
|
@ -484,9 +507,23 @@ class Attachment < ActiveRecord::Base
|
|||
type = self.container_type
|
||||
types = %w|Document News Version Project Issue Message WikiPage|
|
||||
if types.include?(type)
|
||||
UserScore.project(:push_file, User.current,self, { attachment_id: self.id })
|
||||
#UserScore.project(:push_file, self.author,self, { attachment_id: self.id })
|
||||
|
||||
end
|
||||
end
|
||||
update_attachment(self.author,1)
|
||||
if self.container_type == 'Project'
|
||||
update_attachment(self.author,2,self.container)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#删除附件时重新统计用户的附件数量得分
|
||||
def down_user_score
|
||||
update_attachment(self.author,1)
|
||||
if self.container_type == 'Project'
|
||||
update_attachment(self.author,2,self.container)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
class Changeset < ActiveRecord::Base
|
||||
belongs_to :repository
|
||||
belongs_to :user
|
||||
|
||||
include UserScoreHelper
|
||||
#after_save :be_user_score # user_score
|
||||
|
||||
has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
|
||||
|
@ -63,7 +63,9 @@ class Changeset < ActiveRecord::Base
|
|||
includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args))
|
||||
}
|
||||
|
||||
after_create :scan_for_issues,:be_user_score # user_score
|
||||
after_create :scan_for_issues,:refresh_changests#:be_user_score # user_score
|
||||
after_update :be_user_score
|
||||
after_destroy :down_user_score
|
||||
before_create :before_create_cs
|
||||
|
||||
# fq
|
||||
|
@ -303,8 +305,27 @@ class Changeset < ActiveRecord::Base
|
|||
# update user score
|
||||
def be_user_score
|
||||
UserScore.project(:push_code, self.user,self, { changeset_id: self.id })
|
||||
#更新用户等级
|
||||
UserLevels.update_user_level(self.user)
|
||||
unless self.user.nil?
|
||||
#更新用户等级
|
||||
UserLevels.update_user_level(self.user)
|
||||
update_changeset(self.user,1)
|
||||
update_changeset(self.user,2,self.repository.project)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#积分刷新
|
||||
def down_user_score
|
||||
UserLevels.update_user_level(self.user)
|
||||
update_changeset(self.user,1)
|
||||
update_changeset(self.user,2,self.repository.project)
|
||||
end
|
||||
|
||||
#刷新本次提交(补全相关信息如:user_id等)
|
||||
def refresh_changests
|
||||
unless self.repository.nil?
|
||||
self.repository.fetch_changesets if Setting.autofetch_changesets?
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class Contest < ActiveRecord::Base
|
|||
has_many :contesting_projects, :dependent => :destroy
|
||||
has_many :projects, :through => :contesting_projects
|
||||
has_many :contesting_softapplications, :dependent => :destroy
|
||||
has_many :softapplications, :through => :contesting_softapplications
|
||||
has_many :softapplications, :through => :contesting_softapplications, :dependent => :destroy
|
||||
has_many :projects_member, :class_name => 'User', :through => :projects
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class ContestNotification < ActiveRecord::Base
|
||||
attr_accessible :content, :title
|
||||
validates_length_of :title, maximum: 30
|
||||
end
|
|
@ -3,7 +3,7 @@ class ContestingSoftapplication < ActiveRecord::Base
|
|||
attr_accessible :contest_id, :description, :softapplication_id, :user_id
|
||||
|
||||
belongs_to :contest
|
||||
belongs_to :softapplication
|
||||
belongs_to :softapplication, :dependent => :destroy
|
||||
belongs_to :user
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class Course < ActiveRecord::Base
|
|||
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :homework_for_courses, :dependent => :destroy
|
||||
has_many :student, :through => :students_for_courses, :source => :user
|
||||
has_many :student, :class_name => 'StudentsForCourse', :source => :user
|
||||
has_many :course_infos, :class_name => 'CourseInfos',:dependent => :destroy
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
||||
|
@ -34,12 +34,12 @@ class Course < ActiveRecord::Base
|
|||
acts_as_attachable :view_permission => :view_files,
|
||||
:delete_permission => :manage_files
|
||||
|
||||
validates_presence_of :password, :term,:name
|
||||
validates_format_of :class_period, :with =>/^[1-9]\d*$/
|
||||
validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/
|
||||
validates_presence_of :password, :term,:name ,:class_period
|
||||
validates_format_of :class_period, :with =>/^\d*$/
|
||||
#validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/
|
||||
|
||||
before_save :self_validate
|
||||
after_save :create_board_sync
|
||||
after_create :create_board_sync
|
||||
before_destroy :delete_all_members
|
||||
|
||||
safe_attributes 'extra',
|
||||
|
@ -90,9 +90,38 @@ class Course < ActiveRecord::Base
|
|||
false
|
||||
end
|
||||
|
||||
# Returns the mail adresses of users that should be always notified on project events
|
||||
def recipients
|
||||
notified_users.collect {|user| user.mail}
|
||||
end
|
||||
|
||||
# Returns the users that should be notified on project events
|
||||
def notified_users
|
||||
# TODO: User part should be extracted to User#notify_about?
|
||||
members.select {|m| m.principal.present? && (m.mail_notification? || m.principal.mail_notification == 'all')}.collect {|m| m.principal}
|
||||
end
|
||||
|
||||
|
||||
# 课程的短描述信息
|
||||
def short_description(length = 255)
|
||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
end
|
||||
|
||||
# 课程的短名称信息
|
||||
def short_name(length = 8)
|
||||
name.gsub(/<\/?.*?>/,"").html_safe if name
|
||||
end
|
||||
|
||||
def strip_html(html)
|
||||
return html if html.empty? || !html.include?('<')
|
||||
output = ""
|
||||
tokenizer = HTML::Tokenizer.new(html)
|
||||
while token = tokenizer.next
|
||||
node = HTML::Node.parse(nil, 0, 0, token, false)
|
||||
output += token unless (node.kind_of? HTML::Tag) or (token =~ /^<!/)
|
||||
end
|
||||
return output
|
||||
end
|
||||
|
||||
def extra_frozen?
|
||||
|
@ -112,6 +141,7 @@ class Course < ActiveRecord::Base
|
|||
@attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
|
||||
end
|
||||
|
||||
|
||||
# 获取资源后缀名列表
|
||||
def contenttypes
|
||||
attachmenttypes
|
||||
|
@ -275,7 +305,7 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
|
||||
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
|
||||
def name
|
||||
read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
||||
end
|
||||
#def name
|
||||
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
||||
#end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class CourseAttachment < ActiveRecord::Base
|
||||
attr_accessible :attachtype, :author_id, :content_type, :description, :digest, :disk_directory, :disk_filename, :downloads, :filename, :filesize, :integer, :is_public
|
||||
end
|
|
@ -20,9 +20,9 @@ class Document < ActiveRecord::Base
|
|||
belongs_to :project
|
||||
belongs_to :user
|
||||
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
||||
|
||||
after_create :be_user_score # user_score
|
||||
|
||||
include UserScoreHelper
|
||||
after_save :be_user_score # user_score
|
||||
after_destroy :down_user_score
|
||||
|
||||
acts_as_attachable :delete_permission => :delete_documents
|
||||
|
||||
|
@ -30,7 +30,8 @@ class Document < ActiveRecord::Base
|
|||
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
|
||||
:author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) },
|
||||
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
|
||||
acts_as_activity_provider :find_options => {:include => :project}
|
||||
acts_as_activity_provider :find_options => {:include => :project},
|
||||
:is_public => 'documents.is_public'
|
||||
|
||||
validates_presence_of :project, :title, :category
|
||||
validates_length_of :title, :maximum => 60
|
||||
|
@ -39,12 +40,16 @@ class Document < ActiveRecord::Base
|
|||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
|
||||
}
|
||||
|
||||
safe_attributes 'category_id', 'title', 'description'
|
||||
safe_attributes 'category_id', 'title', 'description','is_public'
|
||||
|
||||
def visible?(user=User.current)
|
||||
!user.nil? && user.allowed_to?(:view_documents, project)
|
||||
end
|
||||
|
||||
def has_right?(project,user=User.current)
|
||||
user.admin? || user.member_of?(project) || self.is_public==1
|
||||
end
|
||||
|
||||
def initialize(attributes=nil, *args)
|
||||
super
|
||||
if new_record?
|
||||
|
@ -63,5 +68,12 @@ class Document < ActiveRecord::Base
|
|||
# update user score
|
||||
def be_user_score
|
||||
UserScore.project(:push_document, self.user,self,{ document_id: self.id })
|
||||
update_document(self.user,1)
|
||||
update_document(self.user,2,self.project)
|
||||
end
|
||||
|
||||
def down_user_score
|
||||
update_document(self.user,1)
|
||||
update_document(self.user,2,self.project)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
class FirstPage < ActiveRecord::Base
|
||||
attr_accessible :description, :title, :web_title,:page_type,:sort_type
|
||||
validates_presence_of :web_title, :title, :description,:page_type
|
||||
validates_length_of :web_title,:title, maximum: 30
|
||||
validates_inclusion_of :image_width,:in => 50..120, :message => l(:image_width_error_message)
|
||||
validates_inclusion_of :image_height,:in => 50..80, :message => l(:image_height_error_message)
|
||||
#validates_length_of :description, maximum: 100
|
||||
end
|
|
@ -11,7 +11,7 @@ class Forum < ActiveRecord::Base
|
|||
'creator_id'
|
||||
validates_presence_of :name, :creator_id, :description
|
||||
validates_length_of :name, maximum: 50
|
||||
validates_length_of :description, maximum: 255
|
||||
#validates_length_of :description, maximum: 255
|
||||
validates :name, :uniqueness => true
|
||||
|
||||
acts_as_taggable
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
class Issue < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include Redmine::Utils::DateCalculation
|
||||
include UserScoreHelper
|
||||
|
||||
belongs_to :project
|
||||
belongs_to :tracker
|
||||
|
@ -78,6 +79,7 @@ class Issue < ActiveRecord::Base
|
|||
# fq
|
||||
after_create :act_as_activity,:be_user_score_new_issue
|
||||
after_update :be_user_score
|
||||
after_destroy :down_user_score
|
||||
# after_create :be_user_score
|
||||
# end
|
||||
|
||||
|
@ -136,10 +138,10 @@ class Issue < ActiveRecord::Base
|
|||
nil
|
||||
when 'default'
|
||||
user_ids = [user.id] + user.groups.map(&:id)
|
||||
"(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||||
"(#{table_name}.is_private = #{connection.quoted_false}) OR (#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||||
when 'own'
|
||||
user_ids = [user.id] + user.groups.map(&:id)
|
||||
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||||
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||||
else
|
||||
'1=0'
|
||||
end
|
||||
|
@ -158,8 +160,8 @@ class Issue < ActiveRecord::Base
|
|||
true
|
||||
when 'default'
|
||||
!self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
|
||||
when 'own'
|
||||
self.author == user || user.is_or_belongs_to?(assigned_to)
|
||||
when 'own'
|
||||
self.author == user || user.is_or_belongs_to?(assigned_to)
|
||||
else
|
||||
false
|
||||
end
|
||||
|
@ -238,11 +240,14 @@ class Issue < ActiveRecord::Base
|
|||
self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
|
||||
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
|
||||
#赞不提供附件复制功能
|
||||
#unless options[:attachments] == false
|
||||
#self.attachments = issue.attachments.map do |attachement|
|
||||
# a = attachement.copy(:container => self)
|
||||
# #a.save
|
||||
# a
|
||||
#end
|
||||
#end
|
||||
@copied_from = issue
|
||||
@copy_options = options
|
||||
self
|
||||
|
@ -562,6 +567,12 @@ class Issue < ActiveRecord::Base
|
|||
@workflow_rule_by_attribute = result if user.nil?
|
||||
result
|
||||
end
|
||||
# 缺陷的短描述信息
|
||||
def short_description(length = 255)
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
end
|
||||
|
||||
private :workflow_rule_by_attribute
|
||||
|
||||
def done_ratio
|
||||
|
@ -1001,9 +1012,10 @@ class Issue < ActiveRecord::Base
|
|||
s << ' overdue' if overdue?
|
||||
s << ' child' if child?
|
||||
s << ' parent' unless leaf?
|
||||
s << ' private' if is_private?
|
||||
#s << ' private' if is_private?
|
||||
s << ' created-by-me' if User.current.logged? && author_id == User.current.id
|
||||
s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
|
||||
s << ' tracker-id' if User.current.logged? && tracker_id == User.current.id
|
||||
s
|
||||
end
|
||||
|
||||
|
@ -1500,17 +1512,45 @@ class Issue < ActiveRecord::Base
|
|||
def be_user_score
|
||||
#缺陷完成度更新
|
||||
if self.done_ratio_changed?
|
||||
UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id })
|
||||
UserScore.project(:update_issue_ratio, self.author,self,{ issue_id: self.id })
|
||||
#update_issue_done_ratio(self.author,1)
|
||||
end
|
||||
#缺陷状态更改
|
||||
if self.status_id_changed?
|
||||
#协同得分
|
||||
UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id})
|
||||
#协同得分
|
||||
UserScore.joint(:change_issue_status, self.author,nil,self, {issue_id: self.id})
|
||||
#update_issues_status(self.author , 1)
|
||||
end
|
||||
end
|
||||
|
||||
#发布缺陷
|
||||
def be_user_score_new_issue
|
||||
UserScore.project(:post_issue, User.current,self, { issue_id: self.id })
|
||||
UserScore.project(:post_issue, self.author,self, { issue_id: self.id })
|
||||
update_post_issue(self.author,1)
|
||||
update_post_issue(self.author,2,self.project)
|
||||
end
|
||||
|
||||
def down_user_score
|
||||
#缺陷完成度更新
|
||||
#if self.done_ratio_changed?
|
||||
# UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id })
|
||||
# update_issue_done_ratio(User.current,1)
|
||||
#end
|
||||
#缺陷状态更改
|
||||
#if self.status_id_changed?
|
||||
# #协同得分
|
||||
# UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id})
|
||||
# update_issues_status(self.author , 1)
|
||||
#end
|
||||
update_post_issue(self.author,1)
|
||||
#update_issue_done_ratio(self.author,1)
|
||||
#update_issues_status(self.author , 1)
|
||||
|
||||
update_post_issue(self.author,2,self.project)
|
||||
#update_issue_done_ratio(self.author,2,self.project)
|
||||
#update_issues_status(self.author , 2)
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
class IssueOverdue < ActiveRecord::Base
|
||||
#缺陷到期后发送邮件提示
|
||||
#只监听已经提交的未到期的缺陷,已过期的缺陷默认已经发过邮件通知,不再提醒。
|
||||
def self.mail_issue
|
||||
threads = []
|
||||
issues = Issue.where("done_ratio <> 100 and closed_on is null and due_date is not null")
|
||||
puts issues
|
||||
issues.each do |issue|
|
||||
thread = Thread.new do
|
||||
while true
|
||||
cur_issue = Issue.find issue.id
|
||||
if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil
|
||||
break
|
||||
end
|
||||
if Time.now < Time.parse(cur_issue.due_date.to_s)
|
||||
#休眠一个小时。。。
|
||||
puts cur_issue.id.to_s
|
||||
sleep 5
|
||||
else
|
||||
#发邮件
|
||||
#puts "11" + issue.id.to_s
|
||||
#Mailer.issue_expire(issue).deliver
|
||||
Mailer.issue_add(issue).deliver
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
threads << thread
|
||||
end
|
||||
puts threads
|
||||
return threads
|
||||
end
|
||||
end
|
|
@ -132,7 +132,7 @@ class IssueQuery < Query
|
|||
:type => :list_optional, :values => group_values
|
||||
) unless group_values.empty?
|
||||
|
||||
role_values = Role.givable.collect {|r| [r.name, r.id.to_s] }
|
||||
role_values = Role.project_role.collect {|r| [r.name, r.id.to_s] }
|
||||
add_available_filter("assigned_to_role",
|
||||
:type => :list_optional, :values => role_values
|
||||
) unless role_values.empty?
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Journal < ActiveRecord::Base
|
||||
include UserScoreHelper
|
||||
belongs_to :journalized, :polymorphic => true
|
||||
# added as a quick fix to allow eager loading of the polymorphic association
|
||||
# since always associated to an issue, for now
|
||||
|
@ -45,11 +46,11 @@ class Journal < ActiveRecord::Base
|
|||
before_create :split_private_notes
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score
|
||||
after_save :act_as_activity,:be_user_score
|
||||
# end
|
||||
|
||||
#after_destroy :down_user_score
|
||||
#before_save :be_user_score
|
||||
#before_destroy :down_user_score
|
||||
after_destroy :down_user_score
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
user = args.shift || User.current
|
||||
|
@ -157,18 +158,24 @@ class Journal < ActiveRecord::Base
|
|||
|
||||
# 更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建了缺陷留言且留言不为空,不为空白
|
||||
#新建了缺陷留言且留言不为空,不为空白
|
||||
if !self.notes.nil? && self.notes.gsub(' ','') != ''
|
||||
#协同得分加分
|
||||
UserScore.joint(:post_issue_message, User.current,self.issue.author,self, { message_id: self.id })
|
||||
UserScore.joint(:post_issue_message, self.user,self.issue.author,self, { message_id: self.id })
|
||||
update_messges_for_issue(self.user,1)
|
||||
update_messges_for_issue(self.user,2,self.issue.project)
|
||||
end
|
||||
|
||||
end
|
||||
# 减少用户分数 -by zjc
|
||||
def down_user_score
|
||||
#删除有效缺陷留言
|
||||
if !self.notes.nil? && self.notes.gsub(' ','') != ''
|
||||
#协同得分减分
|
||||
UserScore.joint(:delete_issue_message, User.current,self.issue.author, { message_id: self.id })
|
||||
UserScore.joint(:delete_issue_message, self.user,self.issue.author,self, { message_id: self.id })
|
||||
update_messges_for_issue(self.user,1)
|
||||
update_messges_for_issue(self.user,2,self.issue.project)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class JournalDetail < ActiveRecord::Base
|
||||
include UserScoreHelper
|
||||
belongs_to :journal
|
||||
before_save :normalize_values
|
||||
|
||||
after_save :be_user_score
|
||||
after_destroy :down_user_score
|
||||
#before_destroy :down_user_score
|
||||
private
|
||||
|
||||
def normalize_values
|
||||
|
@ -38,4 +41,39 @@ class JournalDetail < ActiveRecord::Base
|
|||
v
|
||||
end
|
||||
end
|
||||
|
||||
def be_user_score
|
||||
#更新缺陷完成度
|
||||
if self.prop_key == 'done_ratio'
|
||||
update_issue_done_ratio(self.journal.user,1)
|
||||
unless self.journal.project.nil?
|
||||
update_issue_done_ratio(self.journal.user,2,self.journal.project)
|
||||
end
|
||||
#更新缺陷状态
|
||||
elsif self.prop_key == 'status_id'
|
||||
update_issues_status(self.journal.user , 1)
|
||||
unless self.journal.project.nil?
|
||||
update_issues_status(self.journal.user,2,self.journal.project)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#更新用户分数
|
||||
def down_user_score
|
||||
|
||||
if self.prop_key == 'done_ratio'
|
||||
update_issue_done_ratio(self.journal.user,1)
|
||||
unless self.journal.project.nil?
|
||||
update_issue_done_ratio(self.journal.user,2,self.journal.project)
|
||||
end
|
||||
|
||||
#更新缺陷状态
|
||||
elsif self.prop_key == 'status_id'
|
||||
update_issues_status(self.journal.user, 1)
|
||||
unless self.journal.project.nil?
|
||||
update_issues_status(self.journal.user,2,self.journal.project)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# 注意reply_id 是提到人的id,不是留言id, Base中叫做 at_user
|
||||
class JournalsForMessage < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include UserScoreHelper
|
||||
safe_attributes "jour_type", # 留言所属类型
|
||||
"jour_id", # 留言所属类型的id
|
||||
"notes", # 留言内容
|
||||
|
@ -53,10 +54,10 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
|
||||
validates :notes, presence: true
|
||||
after_create :act_as_activity #huang
|
||||
after_create :reset_counters!,:be_user_score
|
||||
after_create :reset_counters!
|
||||
after_destroy :reset_counters!
|
||||
#before_save :be_user_score
|
||||
#before_destroy :down_user_score
|
||||
after_save :be_user_score
|
||||
after_destroy :down_user_score
|
||||
|
||||
# default_scope { where('m_parent_id IS NULL') }
|
||||
|
||||
|
@ -67,6 +68,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.remove_by_user? user
|
||||
if( self.user == user ||
|
||||
|
@ -86,6 +88,15 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
def reference_user
|
||||
User.find(reply_id)
|
||||
end
|
||||
|
||||
def delete_by_user?user
|
||||
# 用户可删除自己的留言
|
||||
if self.user.id == user.id || user.admin?
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def self.reference_message(user_id)
|
||||
@user = User.find(user_id)
|
||||
|
@ -131,7 +142,11 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
#新建了留言回复
|
||||
if self.reply_id != 0
|
||||
#协同得分加分
|
||||
UserScore.joint(:reply_message, User.current,User.find(self.reply_id),self, { journals_for_messages_id: self.id })
|
||||
UserScore.joint(:reply_message, self.user,User.find(self.reply_id),self, { journals_for_messages_id: self.id })
|
||||
update_replay_for_message(self.user,1)
|
||||
if self.jour_type == "Project"
|
||||
update_replay_for_message(self.user,2,self.jour)
|
||||
end
|
||||
end
|
||||
end
|
||||
# 更新用户分数 -by zjc
|
||||
|
@ -139,7 +154,11 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
#删除了留言回复
|
||||
if self.reply_id != 0
|
||||
#协同得分减分
|
||||
UserScore.joint(:reply_message_delete, User.current,User.find(self.reply_id), { journals_for_messages_id: self.id })
|
||||
UserScore.joint(:reply_message_delete, self.user,User.find(self.reply_id), { journals_for_messages_id: self.id })
|
||||
update_replay_for_message(self.user,1)
|
||||
if self.jour_type == "Project"
|
||||
update_replay_for_message(self.user,2,self.jour)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -104,7 +104,7 @@ class Mailer < ActionMailer::Base
|
|||
message_id issue
|
||||
@author = issue.author
|
||||
@issue = issue
|
||||
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
|
||||
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
|
||||
recipients = issue.recipients
|
||||
cc = issue.watcher_recipients - recipients
|
||||
mail :to => recipients,
|
||||
|
@ -141,6 +141,19 @@ class Mailer < ActionMailer::Base
|
|||
:subject => s
|
||||
end
|
||||
|
||||
# 用户申请加入项目邮件通知
|
||||
def applied_project(applied)
|
||||
@project =applied.project
|
||||
redmine_headers 'Project' => @project,
|
||||
'User' => applied.user
|
||||
@user = applied.user
|
||||
recipients = @project.manager_recipients
|
||||
s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name)
|
||||
@applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members')
|
||||
mail :to => recipients,
|
||||
:subject => s
|
||||
end
|
||||
|
||||
def reminder(user, issues, days)
|
||||
set_language_if_valid user.language
|
||||
@issues = issues
|
||||
|
@ -152,6 +165,47 @@ class Mailer < ActionMailer::Base
|
|||
:subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
|
||||
end
|
||||
|
||||
#缺陷到期邮件通知
|
||||
def issue_expire issue
|
||||
issue_id = issue.project_index
|
||||
redmine_headers 'Project' => issue.project.identifier,
|
||||
'Issue-Id' => issue_id,
|
||||
'Issue-Author' => issue.author.login
|
||||
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
||||
message_id issue
|
||||
@author = issue.author
|
||||
@issue = issue
|
||||
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
|
||||
recipients = issue.recipients
|
||||
s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}")
|
||||
mail :to => recipients,
|
||||
:subject => s
|
||||
#########################################################################################################
|
||||
#@issues = issues
|
||||
#s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}")
|
||||
#puts s + "////" + issue.assigned_to.mail
|
||||
#@issues_url = url_for(:controller => 'issues', :action => 'show',:id => issue.id)
|
||||
#mail :to => issue.assigned_to.mail,
|
||||
# :subject => s
|
||||
#########################################################################################################
|
||||
#issue_id = issue.project_index
|
||||
#redmine_headers 'Project' => issue.project.identifier,
|
||||
# 'Issue-Id' => issue_id,
|
||||
# 'Issue-Author' => issue.author.login
|
||||
#redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
||||
#message_id issue
|
||||
#@author = issue.author
|
||||
#@issue = issue
|
||||
#@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
|
||||
#recipients = issue.recipients
|
||||
#cc = issue.watcher_recipients - recipients
|
||||
#mail :to => recipients,
|
||||
# :cc => cc,
|
||||
# :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
|
||||
######################################################################################################
|
||||
end
|
||||
|
||||
|
||||
# Builds a Mail::Message object used to email users belonging to the added document's project.
|
||||
#
|
||||
# Example:
|
||||
|
@ -177,25 +231,45 @@ class Mailer < ActionMailer::Base
|
|||
added_to_url = ''
|
||||
@author = attachments.first.author
|
||||
case container.class.name
|
||||
when 'Project'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
|
||||
added_to = "#{l(:label_project)}: #{container}"
|
||||
recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
|
||||
when 'Version'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
|
||||
added_to = "#{l(:label_version)}: #{container.name}"
|
||||
recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
|
||||
when 'Document'
|
||||
added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
|
||||
added_to = "#{l(:label_document)}: #{container.title}"
|
||||
recipients = container.recipients
|
||||
when 'Project'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
|
||||
added_to = "#{l(:label_project)}: #{container}"
|
||||
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
|
||||
when 'Course'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container)
|
||||
added_to = "#{l(:label_course)}: #{container}"
|
||||
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
|
||||
when 'Version'
|
||||
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
|
||||
added_to = "#{l(:label_version)}: #{container.name}"
|
||||
recipients = container.project.notified_users.select { |user| user.allowed_to?(:view_files, container.project) }.collect { |u| u.mail }
|
||||
when 'Document'
|
||||
added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
|
||||
added_to = "#{l(:label_document)}: #{container.title}"
|
||||
recipients = container.recipients
|
||||
end
|
||||
if container.class.name == 'Course'
|
||||
redmine_headers 'Course' => container.id
|
||||
@attachments = attachments
|
||||
@added_to = added_to
|
||||
@added_to_url = added_to_url
|
||||
mail :to => recipients,
|
||||
:subject => "[#{container.name}] #{l(:label_attachment_new)}"
|
||||
elsif container.class.name == 'Project'
|
||||
redmine_headers 'Project' => container.id
|
||||
@attachments = attachments
|
||||
@added_to = added_to
|
||||
@added_to_url = added_to_url
|
||||
mail :to => recipients,
|
||||
:subject => "[#{container.name}] #{l(:label_attachment_new)}"
|
||||
else
|
||||
redmine_headers 'Project' => container.project.identifier
|
||||
@attachments = attachments
|
||||
@added_to = added_to
|
||||
@added_to_url = added_to_url
|
||||
mail :to => recipients,
|
||||
:subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
|
||||
end
|
||||
redmine_headers 'Project' => container.project.identifier
|
||||
@attachments = attachments
|
||||
@added_to = added_to
|
||||
@added_to_url = added_to_url
|
||||
mail :to => recipients,
|
||||
:subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
|
||||
end
|
||||
|
||||
# Builds a Mail::Message object used to email recipients of a news' project when a news item is added.
|
||||
|
@ -508,6 +582,8 @@ class Mailer < ActionMailer::Base
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
|
||||
# Appends a Redmine header field (name is prepended with 'X-Redmine-')
|
||||
|
@ -538,4 +614,6 @@ class Mailer < ActionMailer::Base
|
|||
def mylogger
|
||||
Rails.logger
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class Memo < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include UserScoreHelper
|
||||
belongs_to :forum
|
||||
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
|
||||
|
||||
|
@ -7,12 +8,13 @@ class Memo < ActiveRecord::Base
|
|||
# 若是主题帖,则内容可以是空
|
||||
#validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
|
||||
validates_length_of :subject, maximum: 50
|
||||
validates_length_of :content, maximum: 3072
|
||||
#validates_length_of :content, maximum: 3072
|
||||
validate :cannot_reply_to_locked_topic, :on => :create
|
||||
|
||||
acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC"
|
||||
acts_as_attachable
|
||||
has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id'
|
||||
# acts_as_searchable :column => ['subject', 'content'],
|
||||
# #:include => { :forum => :p}
|
||||
|
@ -41,9 +43,9 @@ class Memo < ActiveRecord::Base
|
|||
"parent_id",
|
||||
"replies_count"
|
||||
|
||||
after_create :add_author_as_watcher, :reset_counters!,:be_user_score
|
||||
after_create :add_author_as_watcher, :reset_counters!#,:be_user_score -- 公共区发帖暂不计入得分
|
||||
# after_update :update_memos_forum
|
||||
after_destroy :reset_counters!
|
||||
after_destroy :reset_counters!#,:down_user_score -- 公共区发帖暂不计入得分
|
||||
# after_create :send_notification
|
||||
# after_save :plusParentAndForum
|
||||
# after_destroy :minusParentAndForum
|
||||
|
@ -144,14 +146,23 @@ class Memo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
def be_user_score
|
||||
#新建memo且无parent的为发帖
|
||||
if self.parent_id.nil?
|
||||
UserScore.joint(:post_message, User.current,nil,self ,{ memo_id: self.id })
|
||||
update_memo_number(User.current,1)
|
||||
|
||||
#新建memo且有parent的为回帖
|
||||
elsif !self.parent_id.nil?
|
||||
UserScore.joint(:reply_posting, User.current,self.parent.author,self, { memo_id: self.id })
|
||||
update_replay_for_memo(User.current,1)
|
||||
end
|
||||
end
|
||||
|
||||
#被删除时更新用户分数
|
||||
def down_user_score
|
||||
update_memo_number(User.current,1)
|
||||
update_replay_for_memo(User.current,1)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
|
||||
class Message < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include UserScoreHelper
|
||||
|
||||
belongs_to :board
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
|
||||
acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
|
||||
acts_as_attachable
|
||||
belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
|
||||
|
@ -57,12 +61,11 @@ class Message < ActiveRecord::Base
|
|||
|
||||
after_create :add_author_as_watcher, :reset_counters!
|
||||
after_update :update_messages_board
|
||||
after_destroy :reset_counters!
|
||||
after_destroy :reset_counters!,:down_user_score
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score
|
||||
#before_save :be_user_score
|
||||
#before_destroy :down_user_score
|
||||
# end
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
@ -124,6 +127,14 @@ class Message < ActiveRecord::Base
|
|||
board.course
|
||||
end
|
||||
|
||||
def course_editable_by?(usr)
|
||||
usr && usr.logged? && (usr.allowed_to?(:edit_messages, course) || (self.author == usr && usr.allowed_to?(:edit_own_messages, course)))
|
||||
end
|
||||
|
||||
def course_destroyable_by?(usr)
|
||||
usr && usr.logged? && (usr.allowed_to?(:delete_messages, course) || (self.author == usr && usr.allowed_to?(:delete_own_messages, course)))
|
||||
end
|
||||
|
||||
def editable_by?(usr)
|
||||
usr && usr.logged? && (usr.allowed_to?(:edit_messages, project) || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)))
|
||||
end
|
||||
|
@ -147,21 +158,36 @@ class Message < ActiveRecord::Base
|
|||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建message且无parent的为发帖
|
||||
if self.parent_id.nil?
|
||||
UserScore.joint(:post_message, User.current,nil,self, { message_id: self.id })
|
||||
if self.parent_id.nil? && !self.board.project.nil?
|
||||
UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id })
|
||||
update_memo_number(self.author,1)
|
||||
if self.board.project_id != -1
|
||||
update_memo_number(self.author,2,self.board.project)
|
||||
end
|
||||
#新建message且有parent的为回帖
|
||||
elsif !self.parent_id.nil?
|
||||
UserScore.joint(:reply_posting, User.current,self.parent.author,self, { message_id: self.id })
|
||||
elsif !self.parent_id.nil? && !self.board.project.nil?
|
||||
UserScore.joint(:reply_posting, self.author,self.parent.author,self, { message_id: self.id })
|
||||
update_replay_for_memo(self.author,1)
|
||||
if self.board.project_id != -1
|
||||
update_replay_for_memo(self.author,2,self.board.project)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#减少用户分数
|
||||
def down_user_score
|
||||
#删除发帖
|
||||
if self.parent_id.nil?
|
||||
UserScore.joint(:delete_message, User.current,nil, { message_id: self.id })
|
||||
#删除留言
|
||||
else
|
||||
UserScore.joint(:reply_deleting, User.current,self.parent.author, { message_id: self.id })
|
||||
if self.parent_id.nil? && !self.board.project.nil?
|
||||
UserScore.joint(:delete_message, self.author,nil,self, { message_id: self.id })
|
||||
update_memo_number(User.current,1)
|
||||
if self.board.project_id != -1
|
||||
update_memo_number(self.author,2,self.board.project)
|
||||
end
|
||||
elsif !self.parent_id.nil? && !self.board.project.nil?
|
||||
UserScore.joint(:reply_deleting, self.author,self.parent.author,self, { message_id: self.id })
|
||||
update_replay_for_memo(User.current,1)
|
||||
if self.board.project_id != -1
|
||||
update_replay_for_memo(self.author,2,self.board.project)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,6 +74,13 @@ class News < ActiveRecord::Base
|
|||
visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all
|
||||
end
|
||||
|
||||
# 新闻的短描述信息
|
||||
def short_description(length = 255)
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
#description
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_author_as_watcher
|
||||
|
|
|
@ -4,6 +4,7 @@ class Notificationcomment < ActiveRecord::Base
|
|||
include Redmine::SafeAttributes
|
||||
belongs_to :notificationcommented, :polymorphic => true#, :counter_cache => true
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
belongs_to :Contestnotification
|
||||
|
||||
validates_presence_of :notificationcommented, :author, :notificationcomments
|
||||
|
||||
|
|
|
@ -85,6 +85,9 @@ class OpenSourceProject < ActiveRecord::Base
|
|||
|
||||
def short_description(length = 255)
|
||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
#description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
# 不再使用短描述
|
||||
# description
|
||||
end
|
||||
|
||||
def applied_by?(user)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class OptionNumber < ActiveRecord::Base
|
||||
attr_accessible :attachment, :changeset, :document, :follow, :issue_done_ratio, :issues_status, :memo, :messages_for_issues, :post_issue, :praise_by_one, :praise_by_three, :praise_by_two, :replay_for_memo, :replay_for_message, :score_type, :total_score, :tread, :tread_by_one, :tread_by_three, :tread_by_two, :user_id
|
||||
|
||||
def self.get_user_option_number user_id
|
||||
result = nil
|
||||
unless user_id.nil?
|
||||
ons = OptionNumber.find_all_by_user_id(user_id);
|
||||
unless (ons .nil? && ons.count > 0)
|
||||
result = ons.first
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
|
@ -3,7 +3,8 @@ class PraiseTread < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :praise_tread_object, polymorphic: true
|
||||
after_create :be_user_score
|
||||
|
||||
after_destroy :down_user_score
|
||||
include UserScoreHelper
|
||||
def self.find_object_by_type_and_id(type,id)
|
||||
@obj = nil
|
||||
case type
|
||||
|
@ -28,7 +29,7 @@ class PraiseTread < ActiveRecord::Base
|
|||
# 获取裁定对象为Message时Message所属的项目或课程
|
||||
def project
|
||||
project = nil
|
||||
if self.praise_tread_object_type == 'Message'
|
||||
if self.praise_tread_object_type == 'Message' || self.praise_tread_object_type == 'Issues'
|
||||
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||
project = obj.project
|
||||
end
|
||||
|
@ -38,15 +39,51 @@ class PraiseTread < ActiveRecord::Base
|
|||
#更新用户分数 - by zjc
|
||||
def be_user_score
|
||||
#踩贴吧或讨论区帖子
|
||||
if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
|
||||
if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
|
||||
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||
target_user = obj.author
|
||||
UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
|
||||
update_tread(self.user,1)
|
||||
update_tread(target_user,1)
|
||||
unless self.project.nil?
|
||||
update_tread(self.user,2,self.project)
|
||||
update_tread(target_user,2,self.project)
|
||||
end
|
||||
#顶贴吧或讨论区帖子
|
||||
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
|
||||
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
|
||||
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||
target_user = obj.author
|
||||
UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
|
||||
update_praise(target_user,1)
|
||||
unless self.project.nil?
|
||||
update_praise(target_user,2,self.project)
|
||||
end
|
||||
#更新用户等级
|
||||
UserLevels.update_user_level(target_user)
|
||||
end
|
||||
end
|
||||
|
||||
def down_user_score
|
||||
#踩贴吧或讨论区帖子
|
||||
if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
|
||||
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||
target_user = obj.author
|
||||
#UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
|
||||
update_tread(self.user,1)
|
||||
update_tread(target_user,1)
|
||||
unless self.project.nil?
|
||||
update_tread(self.user,2,self.project)
|
||||
update_tread(target_user,2,self.project)
|
||||
end
|
||||
#顶贴吧或讨论区帖子
|
||||
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
|
||||
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||
target_user = obj.author
|
||||
#UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
|
||||
update_praise(target_user,1)
|
||||
unless self.project.nil?
|
||||
update_praise(target_user,2,self.project)
|
||||
end
|
||||
#更新用户等级
|
||||
UserLevels.update_user_level(target_user)
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ class Project < ActiveRecord::Base
|
|||
has_many :principals, :through => :member_principals, :source => :principal
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||
has_many :issues, :dependent => :destroy, :include => [:status, :tracker] , :order => "id ASC"
|
||||
has_many :issues, :dependent => :destroy, :include => [:status, :tracker]
|
||||
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 :time_entries, :dependent => :delete_all
|
||||
|
@ -56,13 +56,12 @@ class Project < ActiveRecord::Base
|
|||
#added by xianbo for delete biding_project
|
||||
has_many :biding_projects, :dependent => :destroy
|
||||
has_many :contesting_projects, :dependent => :destroy
|
||||
has_many :projecting_softapplications, :dependent => :destroy
|
||||
has_many :softapplications, :through => :projecting_softapplications
|
||||
#ended by xianbo
|
||||
# added by fq
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :homework_for_courses, :dependent => :destroy
|
||||
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
#has_many :homework_for_courses, :dependent => :destroy
|
||||
#has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
has_many :shares, :dependent => :destroy
|
||||
# has_many :students_for_courses, :dependent => :destroy
|
||||
has_many :student, :through => :students_for_courses, :source => :user
|
||||
|
@ -127,7 +126,7 @@ class Project < ActiveRecord::Base
|
|||
after_save :update_position_under_parent, :if => Proc.new {|project| project.name_changed?}
|
||||
after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
|
||||
# 创建project之后默认创建一个board,之后的board去掉了board的概念
|
||||
after_save :create_board_sync
|
||||
after_create :create_board_sync
|
||||
before_destroy :delete_all_members
|
||||
def remove_references_before_destroy
|
||||
return if self.id.nil?
|
||||
|
@ -156,7 +155,7 @@ class Project < ActiveRecord::Base
|
|||
where(nil)
|
||||
else
|
||||
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||
where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern)
|
||||
where("LOWER(name) LIKE :p ", :p => pattern)
|
||||
end
|
||||
}
|
||||
scope :project_entities, -> { where(project_type: ProjectType_project) }
|
||||
|
@ -207,6 +206,12 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
# end
|
||||
|
||||
# 管理员的邮件列表
|
||||
def manager_recipients
|
||||
notified = project.project_infos.collect(&:user)
|
||||
notified.collect(&:mail)
|
||||
end
|
||||
|
||||
def initialize(attributes=nil, *args)
|
||||
super
|
||||
|
||||
|
@ -623,7 +628,8 @@ class Project < ActiveRecord::Base
|
|||
|
||||
# Returns a short description of the projects (first lines)
|
||||
def short_description(length = 255)
|
||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
end
|
||||
|
||||
def css_classes
|
||||
|
@ -752,6 +758,7 @@ class Project < ActiveRecord::Base
|
|||
'tracker_ids',
|
||||
'issue_custom_field_ids',
|
||||
'project_type',
|
||||
'dts_test',
|
||||
'attachmenttype'
|
||||
|
||||
|
||||
|
@ -1131,13 +1138,13 @@ class Project < ActiveRecord::Base
|
|||
# 创建项目后在项目下同步创建一个讨论区
|
||||
def create_board_sync
|
||||
@board = self.boards.build
|
||||
self.name=" #{l(:label_borad_course) }"
|
||||
self.name=" #{l(:label_borad_project) }"
|
||||
@board.name = self.name
|
||||
@board.description = self.name.to_s
|
||||
if @board.save
|
||||
logger.debug "[Course Model] ===> #{@board.to_json}"
|
||||
logger.debug "[Project Model] ===> #{@board.to_json}"
|
||||
else
|
||||
logger.error "[Course Model] ===> Auto create board when Course saved, because #{@board.full_messages}"
|
||||
logger.error "[Project Model] ===> Auto create board when Project saved, because #{@board.full_messages}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class ProjectScore < ActiveRecord::Base
|
||||
attr_accessible :project_id, :score
|
||||
belongs_to :project, foreign_key: :project_id
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class ProjectStatus < ActiveRecord::Base
|
||||
attr_accessible :changesets_count, :watchers_count, :project_id, :project_type
|
||||
attr_accessible :changesets_count, :watchers_count, :project_id, :project_type,:grade
|
||||
belongs_to :project
|
||||
belongs_to :watchers
|
||||
belongs_to :changesets
|
||||
|
|
|
@ -21,8 +21,8 @@ class Repository < ActiveRecord::Base
|
|||
include Redmine::Ciphering
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
# Maximum length for repository identifiers
|
||||
IDENTIFIER_MAX_LENGTH = 255
|
||||
# Maximum length for repository ideflashntifiers
|
||||
IDENTIFIER_MAX_LENGTH = 254
|
||||
|
||||
belongs_to :project
|
||||
has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
|
||||
|
@ -39,10 +39,11 @@ class Repository < ActiveRecord::Base
|
|||
validates_length_of :password, :maximum => 255, :allow_nil => true
|
||||
validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :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_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
|
||||
validates_uniqueness_of :identifier, :allow_blank => true
|
||||
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
|
||||
# donwcase letters, digits, dashes, underscores but not digits only
|
||||
validates_format_of :identifier, :with => /^[a-zA-Z0-9_\-]+$/, :allow_blank => true
|
||||
validates_format_of :identifier, :with => /^[a-z0-9_\-]+$/, :allow_blank => true
|
||||
# Checks if the SCM is enabled when creating a repository
|
||||
validate :repo_create_validation, :on => :create
|
||||
|
||||
|
|
|
@ -67,6 +67,16 @@ class Role < ActiveRecord::Base
|
|||
:in => ISSUES_VISIBILITY_OPTIONS.collect(&:first),
|
||||
:if => lambda {|role| role.respond_to?(:issues_visibility)}
|
||||
|
||||
#获取项目相关角色
|
||||
def self.project_role
|
||||
self.givable[0..2]
|
||||
end
|
||||
|
||||
#获取课程相关角色
|
||||
def self.course_role
|
||||
self.givable[3..5]
|
||||
end
|
||||
|
||||
# Copies attributes from another role, arg can be an id or a Role
|
||||
def copy_from(arg, options={})
|
||||
return unless arg.present?
|
||||
|
|
|
@ -163,7 +163,7 @@ class Setting < ActiveRecord::Base
|
|||
end
|
||||
|
||||
# fixed domain url in development. tantantan's bug
|
||||
if Rails.env.development?
|
||||
if Rails.env.development? || Rails.env.test?
|
||||
methods.map do |m|
|
||||
define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/
|
||||
end
|
||||
|
|
|
@ -10,7 +10,10 @@ class Softapplication < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :project
|
||||
has_many :contests, :through => :contesting_softapplications
|
||||
belongs_to :project
|
||||
|
||||
validates_length_of :name, :maximum => 25
|
||||
validates_length_of :application_developers, :maximum => 125
|
||||
validates_length_of :android_min_version_available, :maximum => 125
|
||||
|
||||
def add_jour(user, notes, reference_user_id = 0, options = {})
|
||||
if options.count == 0
|
||||
|
|
|
@ -32,6 +32,7 @@ class Tracker < ActiveRecord::Base
|
|||
end
|
||||
|
||||
has_and_belongs_to_many :projects
|
||||
has_and_belongs_to_many :courses
|
||||
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
|
||||
acts_as_list
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue