app/soc/logic/models/program.py
changeset 2812 9280179e34fd
parent 2811 c8901482dc9c
equal deleted inserted replaced
2811:c8901482dc9c 2812:9280179e34fd
    16 
    16 
    17 """Program (Model) query functions.
    17 """Program (Model) query functions.
    18 """
    18 """
    19 
    19 
    20 __authors__ = [
    20 __authors__ = [
       
    21     '"Madhusudan.C.S" <madhusudancs@gmail.com>',
    21     '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    22     '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    22     '"Lennard de Rijk" <ljvderijk@gmail.com>',
    23     '"Lennard de Rijk" <ljvderijk@gmail.com>',
    23   ]
    24   ]
    24 
    25 
    25 
    26 
    26 from soc.logic.models import presence_with_tos
    27 from soc.logic.models import presence_with_tos
    27 from soc.logic.models import sponsor as sponsor_logic
    28 from soc.logic.models import sponsor as sponsor_logic
    28 
    29 
    29 import soc.logic.models.timeline
       
    30 import soc.models.program
    30 import soc.models.program
    31 
    31 
    32 from gsoc.logic.models.timeline import logic as gsoc_timeline_logic
    32 from gsoc.logic.models.timeline import logic as gsoc_timeline_logic
    33 
    33 
    34 
    34 
    35 class Logic(presence_with_tos.Logic):
    35 class Logic(presence_with_tos.Logic):
    36   """Logic methods for the Program model.
    36   """Logic methods for the Program model.
    37   """
    37   """
    38 
       
    39   TIMELINE_LOGIC = {'gsoc' : gsoc.logic.models.timeline.logic,
       
    40                     'ghop' : soc.logic.models.timeline.logic}
       
    41 
       
    42 
    38 
    43   def __init__(self, model=soc.models.program.Program, 
    39   def __init__(self, model=soc.models.program.Program, 
    44                base_model=None, scope_logic=sponsor_logic,
    40                base_model=None, scope_logic=sponsor_logic,
    45                timeline_logic=gsoc_timeline_logic):
    41                timeline_logic=gsoc_timeline_logic):
    46     """Defines the name, key_name and model for this entity.
    42     """Defines the name, key_name and model for this entity.
    49     self.timeline_logic = timeline_logic
    45     self.timeline_logic = timeline_logic
    50 
    46 
    51     super(Logic, self).__init__(model=model, base_model=base_model,
    47     super(Logic, self).__init__(model=model, base_model=base_model,
    52                                 scope_logic=scope_logic)
    48                                 scope_logic=scope_logic)
    53 
    49 
       
    50   def createTimelineForType(self, fields):
       
    51     """Creates and stores a timeline model for the given type of program.
       
    52     """
       
    53 
       
    54     properties = self.timeline_logic.getKeyFieldsFromFields(fields)
       
    55     key_name = self.timeline_logic.getKeyNameFromFields(properties)
       
    56 
       
    57     properties['scope'] = fields['scope']
       
    58 
       
    59     timeline = self.timeline_logic.updateOrCreateFromKeyName(properties,
       
    60                                                              key_name)
       
    61     return timeline
       
    62 
    54 
    63 
    55 logic = Logic()
    64 logic = Logic()