app/soc/tasks/surveys.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sat, 11 Jul 2009 23:53:30 +0200
changeset 2601 1f575a1e82d5
parent 2595 4c00831ef55c
child 2614 dbc8a50dbce0
permissions -rw-r--r--
Fixed the redirect for Survey reminder emails.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2595
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     2
#
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     4
#
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     8
#
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    10
#
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    16
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    17
"""Tasks related to Surveys.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    18
"""
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    19
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    20
__authors__ = [
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    21
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    22
  ]
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    23
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    24
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    25
import logging
2601
1f575a1e82d5 Fixed the redirect for Survey reminder emails.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2595
diff changeset
    26
import os
2595
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    27
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    28
from google.appengine.api.labs import taskqueue
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    29
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    30
from django import http
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    31
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    32
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    33
def getDjangoURLPatterns():
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    34
  """Returns the URL patterns for the tasks in this module.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    35
  """
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    36
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    37
  patterns = [(r'tasks/surveys/projects/send_reminder/spawn$',
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    38
               'soc.tasks.surveys.spawnRemindersForProjectSurvey'),
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    39
              (r'tasks/surveys/projects/send_reminder/send$',
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    40
               'soc.tasks.surveys.sendSurveyReminderForProject')]
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    41
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    42
  return patterns
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    43
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    44
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    45
def spawnRemindersForProjectSurvey(request, *args, **kwargs):
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    46
  """Spawns tasks for each StudentProject in the given Program.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    47
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    48
  Expects the following to be present in the POST dict:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    49
    program_key: Specifies the program key name for which to loop over all the
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    50
                 StudentProjects for
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    51
    survey_key: specifies the key name for the ProjectSurvey to send reminders
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    52
                for
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    53
    survey_type: either project or grading depending on the type of Survey
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    54
    project_key: optional to specifiy which project was the last for which a
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    55
                 task was spawn
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    56
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    57
  Args:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    58
    request: Django Request object
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    59
  """
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    60
  
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    61
  from google.appengine.ext import db
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    62
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    63
  from soc.logic.models.program import logic as program_logic
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    64
  from soc.logic.models.student_project import logic as student_project_logic
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    65
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    66
  # set default batch size
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    67
  batch_size = 10
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    68
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    69
  post_dict = request.POST
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    70
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    71
  # retrieve the program_key and survey_key from POST data
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    72
  program_key = post_dict.get('program_key')
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    73
  survey_key = post_dict.get('survey_key')
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    74
  survey_type = post_dict.get('survey_type')
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    75
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    76
  if not (program_key and survey_key and survey_type):
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    77
    # invalid task data, log and return OK
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    78
    return logErrorAndReturnOK(
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    79
        'Invalid sendRemindersForProjectSurvey data: %s' % post_dict)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    80
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    81
  # get the program for the given keyname
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    82
  program_entity = program_logic.getFromKeyName(program_key)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    83
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    84
  if not program_entity:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    85
    # invalid program specified, log and return OK
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    86
    return logErrorAndReturnOK('Invalid program specified: %s' % program_key)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    87
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    88
  # check and retrieve the project_key that has been done last
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    89
  if 'project_key' in post_dict:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    90
    project_start_key = post_dict['project_key']
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    91
  else:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    92
    project_start_key = None
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    93
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    94
  # get all valid surveys from starting key
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    95
  fields = {'program': program_entity,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    96
            'status': 'accepted'}
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    97
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    98
  if project_start_key:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    99
    # retrieve the last project that was done
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   100
    project_start = student_project_logic.getFromKeyName(project_start_key)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   101
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   102
    if not project_start:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   103
      # invalid starting project key specified, log and return OK
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   104
      return logErrorAndReturnOK('Invalid Student Project Key specified: %s' %(
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   105
          project_start_key))
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   106
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   107
    fields['__key__ >'] = project_start.key()
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   108
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   109
  project_entities = student_project_logic.getForFields(fields,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   110
                                                        limit=batch_size)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   111
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   112
  for project_entity in project_entities:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   113
    # pass along these params as POST to the new task
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   114
    task_params = {'survey_key': survey_key,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   115
                   'survey_type': survey_type,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   116
                   'project_key': project_entity.key().id_or_name()}
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   117
    task_url = '/tasks/surveys/projects/send_reminder/send'
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   118
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   119
    new_task = taskqueue.Task(params=task_params, url=task_url)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   120
    new_task.add('mail')
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   121
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   122
  if len(project_entities) == batch_size:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   123
    # spawn new task starting from the last
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   124
    new_project_start = project_entities[batch_size-1].key().id_or_name()
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   125
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   126
    # pass along these params as POST to the new task
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   127
    task_params = {'program_key': program_key,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   128
                   'survey_key': survey_key,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   129
                   'survey_type': survey_type,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   130
                   'project_key': new_project_start}
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   131
    task_url = '/tasks/surveys/projects/send_reminder/spawn'
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   132
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   133
    new_task = taskqueue.Task(params=task_params, url=task_url)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   134
    new_task.add()
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   135
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   136
  # return OK
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   137
  return http.HttpResponse()
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   138
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   139
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   140
def sendSurveyReminderForProject(request, *args, **kwargs):
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   141
  """Sends a reminder mail for a given StudentProject and Survey.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   142
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   143
  A reminder is only send if no record is on file for the given Survey and 
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   144
  StudentProject.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   145
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   146
  Expects the following to be present in the POST dict:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   147
    survey_key: specifies the key name for the ProjectSurvey to send reminders
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   148
                for
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   149
    survey_type: either project or grading depending on the type of Survey
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   150
    project_key: key which specifies the project to send a reminder for
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   151
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   152
  Args:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   153
    request: Django Request object
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   154
  """
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   155
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   156
  from soc.logic import mail_dispatcher
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   157
  from soc.logic.models.org_admin import logic as org_admin_logic
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   158
  from soc.logic.models.site import logic as site_logic
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   159
  from soc.logic.models.student_project import logic as student_project_logic
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   160
  from soc.logic.models.survey import grading_logic
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   161
  from soc.logic.models.survey import project_logic
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   162
  from soc.views.helper import redirects
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   163
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   164
  post_dict = request.POST
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   165
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   166
  project_key = post_dict.get('project_key')
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   167
  survey_key = post_dict.get('survey_key')
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   168
  survey_type = post_dict.get('survey_type')
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   169
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   170
  if not (project_key and survey_key and survey_type):
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   171
    # invalid task data, log and return OK
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   172
    return logErrorAndReturnOK(
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   173
        'Invalid sendSurveyReminderForProject data: %s' % post_dict)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   174
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   175
  # set logic depending on survey type specified in POST
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   176
  if survey_type == 'project':
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   177
    survey_logic = project_logic
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   178
  elif survey_type == 'grading':
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   179
    survey_logic = grading_logic
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   180
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   181
  # retrieve the project and survey
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   182
  student_project = student_project_logic.getFromKeyName(project_key)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   183
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   184
  if not student_project:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   185
    # no existing project found, log and return OK
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   186
    return logErrorAndReturnOK('Invalid project specified %s:' % project_key)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   187
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   188
  survey = survey_logic.getFromKeyName(survey_key)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   189
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   190
  if not survey:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   191
    # no existing survey found, log and return OK
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   192
    return logErrorAndReturnOK('Invalid survey specified %s:' % survey_key)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   193
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   194
  # try to retrieve an existing record
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   195
  record_logic = survey_logic.getRecordLogic()
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   196
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   197
  fields = {'project': student_project,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   198
            'survey': survey}
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   199
  record_entity = record_logic.getForFields(fields, unique=True)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   200
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   201
  if not record_entity:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   202
    # send reminder email because we found no record
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   203
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   204
    student_entity = student_project.student
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   205
    site_entity = site_logic.getSingleton()
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   206
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   207
    if survey_type == 'project':
2601
1f575a1e82d5 Fixed the redirect for Survey reminder emails.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2595
diff changeset
   208
      survey_redirect = redirects.getTakeSurveyRedirect(
2595
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   209
          survey,{'url_name': 'project_survey'})
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   210
      to_role = student_entity
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   211
      mail_template = 'soc/project_survey/mail/reminder_gsoc.html'
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   212
    elif survey_type == 'grading':
2601
1f575a1e82d5 Fixed the redirect for Survey reminder emails.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2595
diff changeset
   213
      survey_redirect = redirects.getTakeSurveyRedirect(
2595
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   214
          survey,{'url_name': 'grading_project_survey'})
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   215
      to_role = student_project.mentor
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   216
      mail_template = 'soc/grading_project_survey/mail/reminder_gsoc.html'
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   217
2601
1f575a1e82d5 Fixed the redirect for Survey reminder emails.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2595
diff changeset
   218
    survey_url = "http://%(host)s%(redirect)s" % {
1f575a1e82d5 Fixed the redirect for Survey reminder emails.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2595
diff changeset
   219
      'redirect': survey_redirect,
1f575a1e82d5 Fixed the redirect for Survey reminder emails.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2595
diff changeset
   220
      'host': os.environ['HTTP_HOST'],
1f575a1e82d5 Fixed the redirect for Survey reminder emails.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2595
diff changeset
   221
      }
1f575a1e82d5 Fixed the redirect for Survey reminder emails.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2595
diff changeset
   222
2595
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   223
    # set the context for the mail template
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   224
    mail_context = {
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   225
        'student_name': student_entity.name(),
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   226
        'project_title': student_project.title,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   227
        'survey_url': survey_url,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   228
        'survey_end': survey.survey_end,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   229
        'to_name': to_role.name(),
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   230
        'site_name': site_entity.site_name,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   231
    }
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   232
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   233
    # set the sender
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   234
    (sender, sender_address) = mail_dispatcher.getDefaultMailSender()
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   235
    mail_context['sender'] = sender_address
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   236
    # set the receiver and subject
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   237
    mail_context['to'] = to_role.email
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   238
    mail_context['subject'] = 'Evaluation Survey "%s" Reminder' %(survey.title)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   239
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   240
    # find all org admins for the project's organization
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   241
    org_entity = student_project.scope
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   242
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   243
    fields = {'scope': org_entity,
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   244
              'status': 'active'}
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   245
    org_admin_entities = org_admin_logic.getForFields(fields)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   246
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   247
    # collect email addresses for all found org admins
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   248
    org_admin_addresses = []
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   249
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   250
    for org_admin_entity in org_admin_entities:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   251
      org_admin_addresses.append(org_admin_entity.email)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   252
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   253
    if org_admin_addresses:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   254
      mail_context['cc'] = org_admin_addresses
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   255
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   256
    # send out the email
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   257
    mail_dispatcher.sendMailFromTemplate(mail_template, mail_context)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   258
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   259
  # return OK
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   260
  return http.HttpResponse()
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   261
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   262
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   263
def logErrorAndReturnOK(error_msg='Error found in Survey Task'):
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   264
  """Logs the given error message and returns a HTTP OK response.
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   265
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   266
  Args:
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   267
    error_msg: Error message to log
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   268
  """
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   269
  logging.error(error_msg)
4c00831ef55c Added Surveys Tasks module to send reminders.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   270
  return http.HttpResponse()