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()
def closeTaskTxn(): task.put() comment_txn() startUpdatingTask(task, transactional=True) confirmation() org_score_txn()
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()