author | Daniel Diniz <ajaksu@gmail.com> |
Mon, 06 Jul 2009 16:13:27 +0200 | |
changeset 2560 | a944c0169ad8 |
parent 1955 | 06ed84dbb1ed |
child 2664 | 06d4f4d06f64 |
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, |
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1307
diff
changeset
|
39 |
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 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
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:
1307
diff
changeset
|
44 |
scope_logic=scope_logic, |
06ed84dbb1ed
Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1307
diff
changeset
|
45 |
disallow_last_resign=disallow_last_resign) |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
|
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
|
47 |
def _onCreate(self, entity): |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1062
diff
changeset
|
48 |
"""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
|
49 |
""" |
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 |
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
|
52 |
|
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1062
diff
changeset
|
53 |
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
|
54 |
# 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
|
55 |
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
|
56 |
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
|
57 |
|
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 |
# 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
|
59 |
super(Logic, self)._onCreate(entity) |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
logic = Logic() |