app/soc/modules/ghop/logic/models/student.py
changeset 2818 4107ff19203a
equal deleted inserted replaced
2817:c31428f08daa 2818:4107ff19203a
       
     1 #!/usr/bin/python2.5
       
     2 #
       
     3 # Copyright 2009 the Melange authors.
       
     4 #
       
     5 # Licensed under the Apache License, Version 2.0 (the "License");
       
     6 # you may not use this file except in compliance with the License.
       
     7 # You may obtain a copy of the License at
       
     8 #
       
     9 #   http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 # Unless required by applicable law or agreed to in writing, software
       
    12 # distributed under the License is distributed on an "AS IS" BASIS,
       
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 # See the License for the specific language governing permissions and
       
    15 # limitations under the License.
       
    16 
       
    17 """GHOPStudent (Model) query functions.
       
    18 """
       
    19 
       
    20 __authors__ = [
       
    21     '"Madhusudan.C.S" <madhusudancs@gmail.com>'
       
    22   ]
       
    23 
       
    24 
       
    25 from google.appengine.api.labs import taskqueue
       
    26 
       
    27 from soc.logic.models import student
       
    28 
       
    29 import soc.models.student
       
    30 
       
    31 from soc.modules.ghop.logic.models import task as ghop_task_logic
       
    32 
       
    33 import soc.modules.ghop.logic.models.program
       
    34 import soc.modules.ghop.models.student
       
    35 
       
    36 
       
    37 class Logic(student.Logic):
       
    38   """Logic methods for the GHOPStudent model.
       
    39   """
       
    40 
       
    41   def __init__(self, model=soc.modules.ghop.models.student.GHOPStudent,
       
    42                base_model=soc.models.student.Student,
       
    43                scope_logic=soc.modules.ghop.logic.models.program,
       
    44                role_name='ghop_student', disallow_last_resign=False):
       
    45     """Defines the name, key_name and model for this entity.
       
    46     """
       
    47 
       
    48     super(Logic, self).__init__(model, base_model=base_model,
       
    49                                 scope_logic=scope_logic, role_name=role_name,
       
    50                                 disallow_last_resign=disallow_last_resign)
       
    51 
       
    52   def _onCreate(self, entity):
       
    53     """Update all the tasks the student has claimed or are awaiting
       
    54     registration.
       
    55     """
       
    56 
       
    57     task_params = {
       
    58         'student_key': entity.key().id_or_name(),
       
    59         }
       
    60     task_url = '/tasks/ghop/task/update/student_status'
       
    61 
       
    62     new_task = taskqueue.Task(params=task_params, url=task_url)
       
    63     new_task.add('ghop-update')
       
    64 
       
    65     super(Logic, self)._onCreate(entity)
       
    66 
       
    67 
       
    68 logic = Logic()