author | Sverre Rabbelier <srabbelier@gmail.com> |
Thu, 26 Feb 2009 16:49:45 +0000 | |
changeset 1513 | 13efb916a73c |
parent 1307 | 091a21cf3627 |
child 1654 | b33f52648efe |
permissions | -rw-r--r-- |
1121
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
1307
091a21cf3627
Update the copyright notice for 2009.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1140
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
1121
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Organization Admin (Model) query functions. |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
21 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
22 |
] |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
25 |
from soc.logic.models import role |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
26 |
from soc.logic.models import organization as org_logic |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
27 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
28 |
import soc.models.org_admin |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
29 |
import soc.models.role |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
30 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
31 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
32 |
class Logic(role.Logic): |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
33 |
"""Logic methods for the Organization Admin model. |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
34 |
""" |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
35 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
36 |
def __init__(self, model=soc.models.org_admin.OrgAdmin, |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
37 |
base_model=soc.models.role.Role, scope_logic=org_logic): |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
38 |
"""Defines the name, key_name and model for this entity. |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
39 |
""" |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
40 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
super(Logic, self).__init__(model=model, base_model=base_model, |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
42 |
scope_logic=scope_logic) |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
43 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
44 |
def _onCreate(self, entity): |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
45 |
"""Marks the Organization for this Org Admin as active if it's status is new. |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
46 |
""" |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
47 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
48 |
org_entity = entity.scope |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
49 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
50 |
if org_entity.status == 'new': |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
51 |
# this org is new so mark as active |
1140
a8eaea0b268d
Style fixes in soc.logic.models modules (basically removing of extra whitespaces).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1121
diff
changeset
|
52 |
fields = {'status': 'active'} |
1121
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
53 |
org_logic.logic.updateEntityProperties(org_entity, fields) |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
54 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
55 |
# call super |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
56 |
super(Logic, self)._onCreate(entity) |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
57 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
58 |
logic = Logic() |