author | Sverre Rabbelier <srabbelier@gmail.com> |
Sun, 02 Nov 2008 22:56:52 +0000 | |
changeset 434 | a4fc430fefac |
parent 432 | 1851d67a1004 |
child 481 | 94834a1e6c01 |
permissions | -rw-r--r-- |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
318
e8eeccd7ef0f
Fix typos in doc string in sponsor.py and settings.py
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
316
diff
changeset
|
17 |
"""Sponsor (Model) query functions. |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
429
e50e18936f06
Fixed typo in e-mail address
Sverre Rabbelier <srabbelier@gmail.com>
parents:
410
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
from soc.logic import key_name |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
from soc.logic.models import base |
316
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
308
diff
changeset
|
27 |
|
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
import soc.models.sponsor |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
class Logic(base.Logic): |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
"""Logic methods for the Sponsor model |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
""" |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
def __init__(self): |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
"""Defines the name, key_name and model for this entity. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
""" |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
|
432
1851d67a1004
Add a generic method for getting a Keyname
Sverre Rabbelier <srabbelier@gmail.com>
parents:
429
diff
changeset
|
39 |
self._name = "Sponsor" |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
self._model = soc.models.sponsor.Sponsor |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
self._skip_properties = [] |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
|
410
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
43 |
def getKeyValues(self, entity): |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
44 |
"""See base.Logic.getKeyNameValues. |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
45 |
""" |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
46 |
|
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
47 |
return [entity.link_name] |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
48 |
|
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
49 |
def getKeyValuesFromFields(self, fields): |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
50 |
"""See base.Logic.getKeyValuesFromFields. |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
51 |
""" |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
52 |
|
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
53 |
return [fields['link_name']] |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
54 |
|
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
55 |
def getKeyFieldNames(self): |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
56 |
"""See base.Logic.getKeyFieldNames |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
57 |
""" |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
58 |
|
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
59 |
return ['link_name'] |
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
60 |
|
2af7f84f4fc7
Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents:
368
diff
changeset
|
61 |
|
368
f90f9b22751a
Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
318
diff
changeset
|
62 |
def isDeletable(self, entity): |
f90f9b22751a
Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
318
diff
changeset
|
63 |
"""Returns whether the specified Sponsor entity can be deleted. |
f90f9b22751a
Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
318
diff
changeset
|
64 |
|
f90f9b22751a
Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
318
diff
changeset
|
65 |
Args: |
f90f9b22751a
Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
318
diff
changeset
|
66 |
entity: an existing Sponsor entity in datastore |
f90f9b22751a
Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
318
diff
changeset
|
67 |
""" |
f90f9b22751a
Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
318
diff
changeset
|
68 |
# TODO(pawel.solyga): Check if Sponsor can be deleted (no Hosts, Programs) |
f90f9b22751a
Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
318
diff
changeset
|
69 |
return True |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
71 |
logic = Logic() |