author | Sverre Rabbelier <sverre@rabbelier.nl> |
Thu, 04 Jun 2009 23:21:33 +0200 | |
changeset 2393 | 7fe19ebfe0d3 |
parent 2206 | 4daf85a152ca |
child 2685 | 506cda0463e8 |
permissions | -rw-r--r-- |
1926
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Helpers used for list info functions. |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
21 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
22 |
] |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
|
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
2202
f6a1c141f51e
Use proposal key instead of raw proposal
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2077
diff
changeset
|
25 |
def getStudentProposalInfo(ranking, proposals_keys): |
1926
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
26 |
"""Returns a function that returns information about the rank and assignment. |
2206
4daf85a152ca
White space fix in list_info module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2202
diff
changeset
|
27 |
|
1926
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
28 |
Args: |
2202
f6a1c141f51e
Use proposal key instead of raw proposal
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2077
diff
changeset
|
29 |
ranking: dict with a mapping from Student Proposal key to rank |
f6a1c141f51e
Use proposal key instead of raw proposal
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2077
diff
changeset
|
30 |
proposals_keys: list of proposal keys assigned a slot |
1926
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
31 |
""" |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
32 |
|
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
33 |
def wrapper(item, _): |
2077
fd2e83a297c7
Style fixes, add missing docstring, fix some wrong calls to super classes and removal of unused imports in soc.views.helper.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1926
diff
changeset
|
34 |
"""Decorator wrapper method. |
fd2e83a297c7
Style fixes, add missing docstring, fix some wrong calls to super classes and removal of unused imports in soc.views.helper.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1926
diff
changeset
|
35 |
""" |
2202
f6a1c141f51e
Use proposal key instead of raw proposal
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2077
diff
changeset
|
36 |
info = {'rank': ranking[item.key()]} |
1926
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
37 |
|
2202
f6a1c141f51e
Use proposal key instead of raw proposal
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2077
diff
changeset
|
38 |
if item.key() in proposals_keys: |
1926
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
39 |
info['item_class'] = 'selected' |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
40 |
else: |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
info['item_class'] = 'normal' |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
42 |
|
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
43 |
return info |
d73fe91beeeb
Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
44 |
return wrapper |