app/soc/views/helper/list_info.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Fri, 03 Apr 2009 17:43:41 +0000
changeset 2077 fd2e83a297c7
parent 1926 d73fe91beeeb
child 2202 f6a1c141f51e
permissions -rw-r--r--
Style fixes, add missing docstring, fix some wrong calls to super classes and removal of unused imports in soc.views.helper. Patch by: Pawel Solyga Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    25
def getStudentProposalInfo(ranking, assigned_proposals):
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.
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    27
  
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    28
  Args:
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    29
    ranking: dict with a mapping from Student Proposal to rank
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    30
    assigned_proposals: list of proposals assigned a slot
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
    """
1926
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    36
    info = {'rank': ranking[item]}
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    37
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    38
    if item in assigned_proposals:
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