app/soc/modules/ghop/views/helper/list_info.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Sun, 30 Aug 2009 17:31:02 +0200
changeset 2842 d54ef6eaedc8
permissions -rw-r--r--
Added list_info method for use in the GHOP module. Reviewed by: Lennard de Rijk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2842
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
#
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
#
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     8
#
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
#
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
"""Helpers used for list info functions specific to GHOP.
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
"""
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    20
__authors__ = [
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
  '"Madhusudan.C.S" <madhusudancs@gmail.com>',
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
  ]
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
def getTasksInfo(mentors_list):
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
  """Returns a function that returns the mentors assigned to a task.
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
  Args:
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
    mentors_list: A dictionary containing list of mentors for each task
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    30
  """
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    31
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
  def wrapper(item, _):
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    33
    """Decorator wrapper method.
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    34
    """
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    35
    info = {'mentors': mentors_list[item.key()]}
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
    if len(info['mentors']) > 2:
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
      info['extra_mentors'] = len(info['mentors']) - 2
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
    return info
d54ef6eaedc8 Added list_info method for use in the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    41
  return wrapper