author | Lennard de Rijk <ljvderijk@gmail.com> |
Fri, 30 Jan 2009 09:31:56 +0000 | |
changeset 1076 | 063194eaf87b |
parent 991 | becede26c37f |
child 1080 | d533408811ba |
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 |
|
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
50 |
# Find their application |
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
871
diff
changeset
|
51 |
application = club_app_logic.logic.getFromFields(link_id=entity.link_id) |
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
52 |
|
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
|
53 |
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
|
54 |
# 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
|
55 |
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
|
56 |
'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
|
57 |
'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
|
58 |
'role': 'club_admin', |
917
fb82d4357552
Added missing role_verbose.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
892
diff
changeset
|
59 |
'role_verbose' : 'Club Admin', |
966
d45172b64f2b
Fixed a bug in _oncreate in soc/logic/models/club.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
917
diff
changeset
|
60 |
'state': '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
|
61 |
} |
801
06a84103ed8b
Invite (backup-)admin when creating a club
Sverre Rabbelier <srabbelier@gmail.com>
parents:
782
diff
changeset
|
62 |
|
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
|
63 |
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
|
64 |
properties['link_id'] = admin.link_id |
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 |
key_fields = request_logic.logic.getKeyFieldsFromDict(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
|
66 |
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
|
67 |
|
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 |
# set the application to completed |
892
c3cdb581ffd2
Replaced boolean properties in soc/models/group_app with status property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
69 |
fields = {'status' : 'completed'} |
986
e9611a2288ca
Rename ModelProperties to EntityProperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
966
diff
changeset
|
70 |
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
|
71 |
|
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
|
72 |
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
|
73 |
|
782
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
74 |
|
27924b0f13cd
Fixed missing files in r1364.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
75 |
logic = Logic() |