author | Sverre Rabbelier <srabbelier@gmail.com> |
Sat, 12 Sep 2009 00:36:49 +0200 | |
changeset 2898 | ac5f77cd6046 |
parent 2673 | cecb3a669527 |
permissions | -rw-r--r-- |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@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. |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""Club Admin (Model) query functions. |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
916
f18c0a56da8b
Redid removeRequestForRole to completeRequestForRole.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
802
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
] |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
from soc.logic.models import role |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
from soc.logic.models import club as club_logic |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
import soc.models.club_admin |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
import soc.models.role |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
class Logic(role.Logic): |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
"""Logic methods for the Club Admin model. |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
""" |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
def __init__(self, model=soc.models.club_admin.ClubAdmin, |
1955
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1307
diff
changeset
|
38 |
base_model=soc.models.role.Role, scope_logic=club_logic, |
2664
06d4f4d06f64
Added registerRole to Role Logic where all roles are registered.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1955
diff
changeset
|
39 |
role_name='club_admin', disallow_last_resign=True): |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
"""Defines the name, key_name and model for this entity. |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
""" |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
|
2673
cecb3a669527
Added missing role_name to org_admin Logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2664
diff
changeset
|
43 |
super(Logic, self).__init__(model=model, base_model=base_model, |
cecb3a669527
Added missing role_name to org_admin Logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2664
diff
changeset
|
44 |
scope_logic=scope_logic, |
cecb3a669527
Added missing role_name to org_admin Logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2664
diff
changeset
|
45 |
role_name=role_name, |
1955
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1307
diff
changeset
|
46 |
disallow_last_resign=disallow_last_resign) |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
|
1062
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
48 |
def _onCreate(self, entity): |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1062
diff
changeset
|
49 |
"""Marks the Club for this Club Admin as active it's status is new. |
1062
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
50 |
""" |
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
51 |
|
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
52 |
club_entity = entity.scope |
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
53 |
|
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1062
diff
changeset
|
54 |
if club_entity.status == 'new': |
1062
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
55 |
# this club 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:
1085
diff
changeset
|
56 |
fields = {'status': 'active'} |
1062
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
57 |
club_logic.logic.updateEntityProperties(club_entity, fields) |
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
58 |
|
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
59 |
# call super |
f7ee38ebfe1c
Creating a new host or club_admin will set the group state to active if it's new.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
944
diff
changeset
|
60 |
super(Logic, self)._onCreate(entity) |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
logic = Logic() |