app/soc/views/helper/list_info.py
author Lennard de Rijk <ljvderijk@gmail.com>
Thu, 30 Jul 2009 10:01:57 +0200
changeset 2689 18d8486fd411
parent 2687 1e2bcc7f6d3a
child 2691 f8e0a007d99b
permissions -rw-r--r--
Renamed hasAtLeastOneRecord to hasRecord.
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
2687
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
    25
from soc.views.helper import redirects
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
    26
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
    27
2202
f6a1c141f51e Use proposal key instead of raw proposal
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2077
diff changeset
    28
def getStudentProposalInfo(ranking, proposals_keys):
1926
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    29
  """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
    30
1926
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    31
  Args:
2202
f6a1c141f51e Use proposal key instead of raw proposal
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2077
diff changeset
    32
    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
    33
    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
    34
  """
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
  def wrapper(item, _):
2685
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    37
    """Wrapper method.
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
    38
    """
2202
f6a1c141f51e Use proposal key instead of raw proposal
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2077
diff changeset
    39
    info = {'rank': ranking[item.key()]}
1926
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    40
2202
f6a1c141f51e Use proposal key instead of raw proposal
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2077
diff changeset
    41
    if item.key() in proposals_keys:
1926
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    42
      info['item_class'] =  'selected'
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    43
    else:
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    44
      info['item_class'] =  'normal'
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    45
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    46
    return info
d73fe91beeeb Added list_info helper module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    47
  return wrapper
2685
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    48
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    49
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    50
def getStudentProjectSurveyInfo(program_entity):
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    51
  """Returns a function that returns information used in a Student Project
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    52
  table to show how many evaluations have been available and how
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    53
  many have been taken.
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    54
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    55
  Args:
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    56
    program_entity: the program to check the total amount of
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    57
                    (Grading)ProjctSurveys for
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    58
  """
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    59
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    60
  from soc.logic.models.survey import grading_logic as grading_survey_logic
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    61
  from soc.logic.models.survey import project_logic as project_survey_logic
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    62
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    63
  fields = {'scope_path': program_entity.key().id_or_name()}
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    64
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    65
  # count the number of have been active ProjectSurveys
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    66
  project_surveys = project_survey_logic.getForFields(fields)
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    67
  project_survey_count = len(project_surveys)
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    68
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    69
  for project_survey in project_surveys:
2689
18d8486fd411 Renamed hasAtLeastOneRecord to hasRecord.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2687
diff changeset
    70
    if not project_survey_logic.hasRecord(project_survey):
2685
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    71
      project_survey_count = project_survey_count - 1
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    72
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    73
  # count the number of have been active GradingProjectSurveys
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    74
  grading_surveys = grading_survey_logic.getForFields(fields)
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    75
  grading_survey_count = len(grading_surveys)
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    76
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    77
  for grading_survey in grading_surveys:
2689
18d8486fd411 Renamed hasAtLeastOneRecord to hasRecord.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2687
diff changeset
    78
    if not grading_survey_logic.hasRecord(grading_survey):
2685
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    79
      grading_survey_count = grading_survey_count - 1
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    80
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    81
  def wrapper(item, _):
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    82
    """Wrapper method.
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    83
    """
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    84
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    85
    from soc.logic.models.survey_record import grading_logic
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    86
    from soc.logic.models.survey_record import project_logic
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    87
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    88
    fields = {'project': item}
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    89
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    90
    # count the amount of records we have on store for this project
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    91
    project_record_count = project_logic.getQueryForFields(fields).count()
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    92
    grading_record_count = grading_logic.getQueryForFields(fields).count()
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    93
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    94
    info = {'project_surveys_total': project_survey_count,
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    95
            'project_surveys_completed': project_record_count,
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    96
            'grading_project_surveys_total': grading_survey_count,
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    97
            'grading_project_surveys_completed': grading_record_count}
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    98
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
    99
    return info
506cda0463e8 Added columns to the manage project page that show the amount of evaluations.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2206
diff changeset
   100
  return wrapper
2687
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   101
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   102
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   103
def getProjectSurveyInfoForProject(project_entity, survey_params):
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   104
  """Returns a function that returns info for listing Surveys and if possible
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   105
  their accompanying record.
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   106
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   107
  Args:
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   108
    project_entity: a StudentProject entity
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   109
    survey_params: params for the view of the type of Survey that is listed
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   110
  """
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   111
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   112
  survey_logic = survey_params['logic']
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   113
  record_logic = survey_logic.getRecordLogic()
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   114
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   115
  def wrapper(survey_entity, _):
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   116
    """Wrapper method.
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   117
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   118
    Args:
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   119
      survey_entity: a ProjectSurvey (or subclass) entity
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   120
    """
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   121
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   122
    # try to retrieve the SurveyRecord for the given Survey and Project
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   123
    fields = {'survey': survey_entity,
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   124
              'project': project_entity}
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   125
    record_entity = record_logic.getForFields(fields, unique=True)
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   126
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   127
    info = {'record': record_entity}
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   128
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   129
    if record_entity:
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   130
      # SurveyRecord has been found store the import data in info
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   131
      info['taken_by'] = record_entity.user.name
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   132
      info['taken_on'] = record_entity.modified
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   133
    else:
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   134
      info['taken_by'] = 'No Record Available'
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   135
      info['taken_on'] = 'No Record Available'
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   136
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   137
    take_redirect_info = {'survey': survey_entity,
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   138
                          'params': survey_params}
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   139
    info['take_url'] = redirects.getTakeProjectSurveyRedirect(
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   140
        project_entity, take_redirect_info)
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   141
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   142
    return info
1e2bcc7f6d3a Added getProjectSurveyInfoForProject to list_info helper.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2685
diff changeset
   143
  return wrapper