author | Sverre Rabbelier <srabbelier@gmail.com> |
Wed, 02 Sep 2009 10:24:10 +0200 | |
changeset 2854 | 003a84e774e2 |
parent 2673 | cecb3a669527 |
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, |
1955
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1654
diff
changeset
|
37 |
base_model=soc.models.role.Role, scope_logic=org_logic, |
2673
cecb3a669527
Added missing role_name to org_admin Logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1955
diff
changeset
|
38 |
role_name='org_admin', disallow_last_resign=True): |
1121
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
39 |
"""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
|
40 |
""" |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
42 |
super(Logic, self).__init__(model=model, base_model=base_model, |
1955
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1654
diff
changeset
|
43 |
scope_logic=scope_logic, |
2673
cecb3a669527
Added missing role_name to org_admin Logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1955
diff
changeset
|
44 |
role_name=role_name, |
1955
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1654
diff
changeset
|
45 |
disallow_last_resign=disallow_last_resign) |
1121
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 |
def _onCreate(self, entity): |
1654
b33f52648efe
Fix too long lines in soc.logic.models.org_admin module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1307
diff
changeset
|
48 |
"""Marks the Organization for this Org Admin as active |
b33f52648efe
Fix too long lines in soc.logic.models.org_admin module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1307
diff
changeset
|
49 |
if it's status is new. |
1121
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
50 |
""" |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
51 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
52 |
org_entity = entity.scope |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
53 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
54 |
if org_entity.status == 'new': |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
55 |
# 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
|
56 |
fields = {'status': 'active'} |
1121
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
57 |
org_logic.logic.updateEntityProperties(org_entity, fields) |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
58 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
59 |
# call super |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
60 |
super(Logic, self)._onCreate(entity) |
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
61 |
|
77c602de9248
Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
62 |
logic = Logic() |