app/soc/views/helper/list_info.py
author Lennard de Rijk <ljvderijk@gmail.com>
Mon, 23 Mar 2009 20:05:00 +0000
changeset 1995 768f533d91e3
parent 1926 d73fe91beeeb
child 2077 fd2e83a297c7
permissions -rw-r--r--
Added check to prevent students from submitting more proposals then allowed by the program settings. Patch by: Lennard de Rijk 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, _):
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    34
    info = {'rank': ranking[item]}
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    35
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    36
    if item in assigned_proposals:
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    37
      info['item_class'] =  'selected'
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    38
    else:
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    39
      info['item_class'] =  'normal'
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    40
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    41
    return info
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    42
  return wrapper