25 |
25 |
26 from soc.logic.models import presence_with_tos |
26 from soc.logic.models import presence_with_tos |
27 from soc.logic.models import sponsor as sponsor_logic |
27 from soc.logic.models import sponsor as sponsor_logic |
28 |
28 |
29 import gsoc.logic.models.timeline |
29 import gsoc.logic.models.timeline |
|
30 import soc.logic.models.timeline |
30 import soc.models.program |
31 import soc.models.program |
31 |
|
32 import soc.modules.ghop.logic.models.timeline |
|
33 |
32 |
34 |
33 |
35 class Logic(presence_with_tos.Logic): |
34 class Logic(presence_with_tos.Logic): |
36 """Logic methods for the Program model. |
35 """Logic methods for the Program model. |
37 """ |
36 """ |
38 |
37 |
|
38 TIMELINE_LOGIC = {'gsoc' : gsoc.logic.models.timeline.logic, |
|
39 'ghop' : soc.logic.models.timeline.logic} |
|
40 |
39 def __init__(self, model=soc.models.program.Program, |
41 def __init__(self, model=soc.models.program.Program, |
40 base_model=None, scope_logic=sponsor_logic): |
42 base_model=None, scope_logic=sponsor_logic): |
41 """Defines the name, key_name and model for this entity. |
43 """Defines the name, key_name and model for this entity. |
42 """ |
44 """ |
43 |
45 |
44 self.timeline_logic = gsoc.logic.models.timeline.logic |
|
45 |
|
46 super(Logic, self).__init__(model=model, base_model=base_model, |
46 super(Logic, self).__init__(model=model, base_model=base_model, |
47 scope_logic=scope_logic) |
47 scope_logic=scope_logic) |
48 |
48 |
49 def createTimelineForType(self, fields): |
|
50 """Creates and stores a timeline model for the given type of program. |
|
51 """ |
|
52 |
|
53 properties = self.timeline_logic.getKeyFieldsFromFields(fields) |
|
54 key_name = self.timeline_logic.getKeyNameFromFields(properties) |
|
55 |
|
56 properties['scope'] = fields['scope'] |
|
57 |
|
58 timeline = self.timeline_logic.updateOrCreateFromKeyName(properties, |
|
59 key_name) |
|
60 return timeline |
|
61 |
|
62 |
49 |
63 logic = Logic() |
50 logic = Logic() |