コード例 #1
0
ファイル: task_update.py プロジェクト: SRabbelier/Melange
def updateTasksPostStudentSignUp(request, *args, **kwargs):
  """Appengine task that updates the GCI Tasks after the student signs up.

  Expects the following to be present in the POST dict:
    student_key: Specifies the student key name who registered

  Args:
    request: Django Request object
  """
  from soc.modules.gci.logic.models import student as gci_student_logic

  post_dict = request.POST

  student_key = post_dict.get('student_key')

  if not student_key:
    # invalid student data, log and return OK
    return error_handler.logErrorAndReturnOK(
        'Invalid Student data: %s' % post_dict)

  student_entity = gci_student_logic.logic.getFromKeyNameOr404(student_key)

  # retrieve all tasks currently assigned to the user
  task_fields = {
      'user': student_entity.user,
      }
  task_entities = gci_task_logic.logic.getForFields(task_fields)

  # TODO(madhusudan) move this to the Task Logic
  # Make sure the tasks store references to the student as well as
  # closing all tasks that are AwaitingRegistration.
  for task_entity in task_entities:
    task_entity.student = student_entity
    if task_entity.status == 'AwaitingRegistration':
      task_entities.remove(task_entity)

      properties = {
          'status': 'Closed',
          'closed_on': datetime.datetime.utcnow()
          }
      changes = [ugettext('User-MelangeAutomatic'),
                 ugettext('Action-Student registered'),
                 ugettext('Status-%s' % (properties['status']))]

      comment_properties = {
          'parent': task_entity,
          'scope_path': task_entity.key().name(),
          'created_by': None,
          'changes': changes,
          'content': ugettext(
              '(The Melange Automated System has detected that the student '
              'has signed up for the program and hence has closed this task.'),
          }

      gci_task_logic.logic.updateEntityPropertiesWithCWS(
          task_entity, properties, comment_properties)

      ranking_update.startUpdatingTask(task_entity)

  db.put(task_entities)

  # return OK
  return http.HttpResponse()
コード例 #2
0
ファイル: task.py プロジェクト: rhyolight/nupic.son
 def closeTaskTxn():
     task.put()
     comment_txn()
     startUpdatingTask(task, transactional=True)
     confirmation()
     org_score_txn()
コード例 #3
0
def updateTasksPostStudentSignUp(request, *args, **kwargs):
    """Appengine task that updates the GCI Tasks after the student signs up.

  Expects the following to be present in the POST dict:
    student_key: Specifies the student key name who registered

  Args:
    request: Django Request object
  """
    from soc.modules.gci.logic.models import student as gci_student_logic

    post_dict = request.POST

    student_key = post_dict.get('student_key')

    if not student_key:
        # invalid student data, log and return OK
        return error_handler.logErrorAndReturnOK('Invalid Student data: %s' %
                                                 post_dict)

    student_entity = gci_student_logic.logic.getFromKeyNameOr404(student_key)

    # retrieve all tasks currently assigned to the user
    task_fields = {
        'user': student_entity.user,
    }
    task_entities = gci_task_logic.logic.getForFields(task_fields)

    # TODO(madhusudan) move this to the Task Logic
    # Make sure the tasks store references to the student as well as
    # closing all tasks that are AwaitingRegistration.
    for task_entity in task_entities:
        task_entity.student = student_entity
        if task_entity.status == 'AwaitingRegistration':
            task_entities.remove(task_entity)

            properties = {
                'status': 'Closed',
                'closed_on': datetime.datetime.utcnow()
            }
            changes = [
                ugettext('User-MelangeAutomatic'),
                ugettext('Action-Student registered'),
                ugettext('Status-%s' % (properties['status']))
            ]

            comment_properties = {
                'parent':
                task_entity,
                'scope_path':
                task_entity.key().name(),
                'created_by':
                None,
                'changes':
                changes,
                'content':
                ugettext(
                    '(The Melange Automated System has detected that the student '
                    'has signed up for the program and hence has closed this task.'
                ),
            }

            gci_task_logic.logic.updateEntityPropertiesWithCWS(
                task_entity, properties, comment_properties)

            ranking_update.startUpdatingTask(task_entity)

    db.put(task_entities)

    # return OK
    return http.HttpResponse()
コード例 #4
0
ファイル: task.py プロジェクト: rhyolight/nupic.son
 def closeTaskTxn():
   task.put()
   comment_txn()
   startUpdatingTask(task, transactional=True)
   confirmation()
   org_score_txn()