author | Lennard de Rijk <ljvderijk@gmail.com> |
Sat, 24 Oct 2009 15:14:11 -0700 | |
changeset 3036 | c703f3802841 |
parent 2812 | 9280179e34fd |
permissions | -rw-r--r-- |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
1308
35b75ffcbb37
Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
643 | 17 |
"""Program (Model) query functions. |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
2812
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
21 |
'"Madhusudan.C.S" <madhusudancs@gmail.com>', |
2811
c8901482dc9c
Added timeline_logic keyword argument to Program logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2787
diff
changeset
|
22 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
c8901482dc9c
Added timeline_logic keyword argument to Program logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2787
diff
changeset
|
23 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
] |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
|
1053
3b9552cf748a
Rename the confusing Tossed Model class to PresenceWithToS.
Todd Larsen <tlarsen@google.com>
parents:
1051
diff
changeset
|
27 |
from soc.logic.models import presence_with_tos |
1474
5eaf734fb178
Set proper scope_logic for program and timeline
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
28 |
from soc.logic.models import sponsor as sponsor_logic |
620
e74e0b74625f
Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
611
diff
changeset
|
29 |
|
643 | 30 |
import soc.models.program |
620
e74e0b74625f
Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
611
diff
changeset
|
31 |
|
2811
c8901482dc9c
Added timeline_logic keyword argument to Program logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2787
diff
changeset
|
32 |
from gsoc.logic.models.timeline import logic as gsoc_timeline_logic |
c8901482dc9c
Added timeline_logic keyword argument to Program logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2787
diff
changeset
|
33 |
|
620
e74e0b74625f
Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
611
diff
changeset
|
34 |
|
1053
3b9552cf748a
Rename the confusing Tossed Model class to PresenceWithToS.
Todd Larsen <tlarsen@google.com>
parents:
1051
diff
changeset
|
35 |
class Logic(presence_with_tos.Logic): |
784
23eaf3aa19b1
Fix missing dots at the end of sentences in docstring and fix wrong import sorting in soc.logic.helper.notifications module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
778
diff
changeset
|
36 |
"""Logic methods for the Program model. |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
""" |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
|
671
2c02178037ff
Apply DI on the scope logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
667
diff
changeset
|
39 |
def __init__(self, model=soc.models.program.Program, |
2811
c8901482dc9c
Added timeline_logic keyword argument to Program logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2787
diff
changeset
|
40 |
base_model=None, scope_logic=sponsor_logic, |
c8901482dc9c
Added timeline_logic keyword argument to Program logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2787
diff
changeset
|
41 |
timeline_logic=gsoc_timeline_logic): |
643 | 42 |
"""Defines the name, key_name and model for this entity. |
43 |
""" |
|
655
9635cbaa2dcd
Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
643
diff
changeset
|
44 |
|
2811
c8901482dc9c
Added timeline_logic keyword argument to Program logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2787
diff
changeset
|
45 |
self.timeline_logic = timeline_logic |
c8901482dc9c
Added timeline_logic keyword argument to Program logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2787
diff
changeset
|
46 |
|
671
2c02178037ff
Apply DI on the scope logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
667
diff
changeset
|
47 |
super(Logic, self).__init__(model=model, base_model=base_model, |
2c02178037ff
Apply DI on the scope logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
667
diff
changeset
|
48 |
scope_logic=scope_logic) |
620
e74e0b74625f
Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
611
diff
changeset
|
49 |
|
2812
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
50 |
def createTimelineForType(self, fields): |
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
51 |
"""Creates and stores a timeline model for the given type of program. |
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
52 |
""" |
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
53 |
|
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
54 |
properties = self.timeline_logic.getKeyFieldsFromFields(fields) |
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
55 |
key_name = self.timeline_logic.getKeyNameFromFields(properties) |
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
56 |
|
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
57 |
properties['scope'] = fields['scope'] |
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
58 |
|
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
59 |
timeline = self.timeline_logic.updateOrCreateFromKeyName(properties, |
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
60 |
key_name) |
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
61 |
return timeline |
9280179e34fd
Moved createTimelineForType to Program Logic.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2811
diff
changeset
|
62 |
|
620
e74e0b74625f
Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
611
diff
changeset
|
63 |
|
643 | 64 |
logic = Logic() |