author | Pawel Solyga <Pawel.Solyga@gmail.com> |
Mon, 02 Feb 2009 10:07:34 +0000 | |
changeset 1171 | 26998a171c49 |
parent 1115 | 0a723ff3d27c |
child 1292 | cf8b099bd787 |
permissions | -rw-r--r-- |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Club (Model) query functions. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
] |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
25 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
26 |
from soc.logic.models import group |
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
871
diff
changeset
|
27 |
from soc.logic.models import club_app as club_app_logic |
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
28 |
from soc.logic.models import request as request_logic |
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
29 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
30 |
import soc.models.club |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
31 |
import soc.models.group |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
32 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
33 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
34 |
class Logic(group.Logic): |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
35 |
"""Logic methods for the Club model. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
36 |
""" |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
37 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
38 |
def __init__(self, model=soc.models.club.Club, |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
39 |
base_model=soc.models.group, scope_logic=None): |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
40 |
"""Defines the name, key_name and model for this entity. |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
""" |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
42 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
43 |
super(Logic, self).__init__(model, base_model=base_model, |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
44 |
scope_logic=scope_logic) |
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
45 |
|
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
46 |
def _onCreate(self, entity): |
804
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
47 |
"""Invites the group admin and backup admin. |
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
48 |
""" |
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
49 |
|
1115
0a723ff3d27c
Cleanups in base.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1085
diff
changeset
|
50 |
fields = { |
0a723ff3d27c
Cleanups in base.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1085
diff
changeset
|
51 |
'link_id': entity.link_id |
0a723ff3d27c
Cleanups in base.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1085
diff
changeset
|
52 |
} |
0a723ff3d27c
Cleanups in base.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1085
diff
changeset
|
53 |
|
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
54 |
# Find their application |
1115
0a723ff3d27c
Cleanups in base.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1085
diff
changeset
|
55 |
application = club_app_logic.logic.getFromKeyFields(fields) |
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
56 |
|
804
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
57 |
if application: |
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
58 |
# only if there is an application send out the invites |
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
59 |
properties = { |
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
60 |
'scope': entity, |
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
61 |
'scope_path': entity.key().name(), |
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
62 |
'role': 'club_admin', |
917
fb82d4357552
Added missing role_verbose.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
892
diff
changeset
|
63 |
'role_verbose' : 'Club Admin', |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
64 |
'status': 'group_accepted', |
804
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
65 |
} |
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
66 |
|
804
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
67 |
for admin in [application.applicant, application.backup_admin]: |
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
68 |
properties['link_id'] = admin.link_id |
1115
0a723ff3d27c
Cleanups in base.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1085
diff
changeset
|
69 |
key_fields = request_logic.logic.getKeyFieldsFromFields(properties) |
804
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
70 |
request_logic.logic.updateOrCreateFromFields(properties, key_fields) |
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
71 |
|
13fcbd8598a4
Fixed a bug that was triggered on manual club creation without an application.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
801
diff
changeset
|
72 |
# set the application to completed |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1080
diff
changeset
|
73 |
fields = {'status' : 'completed'} |
986
e9611a2288ca
Rename ModelProperties to EntityProperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
966
diff
changeset
|
74 |
club_app_logic.logic.updateEntityProperties(application, fields) |
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
75 |
|
991
becede26c37f
Added cache flush for the user who creates a group and the user whose role has been activated.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
76 |
super(Logic, self)._onCreate(entity) |
becede26c37f
Added cache flush for the user who creates a group and the user whose role has been activated.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
986
diff
changeset
|
77 |
|
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
78 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
79 |
logic = Logic() |