author | Sverre Rabbelier <srabbelier@gmail.com> |
Sat, 21 Feb 2009 00:43:56 +0000 | |
changeset 1417 | 8b9e256a3abe |
parent 1308 | 35b75ffcbb37 |
child 1511 | 3342ce7a495c |
permissions | -rw-r--r-- |
682 | 1 |
#!/usr/bin/python2.5 |
2 |
# |
|
1308
35b75ffcbb37
Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
682 | 4 |
# |
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 |
# you may not use this file except in compliance with the License. |
|
7 |
# You may obtain a copy of the License at |
|
8 |
# |
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
|
10 |
# |
|
11 |
# Unless required by applicable law or agreed to in writing, software |
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 |
# See the License for the specific language governing permissions and |
|
15 |
# limitations under the License. |
|
16 |
||
17 |
"""Organization (Model) query functions. |
|
18 |
""" |
|
19 |
||
20 |
__authors__ = [ |
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
682 | 23 |
] |
24 |
||
25 |
||
1124
d456f50af0d2
Reverting a change from r1732 for reasons stated in soc/logic/models/group.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1122
diff
changeset
|
26 |
from soc.logic.models import base |
682 | 27 |
from soc.logic.models import group |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
28 |
from soc.logic.models import org_app as org_app_logic |
682 | 29 |
from soc.logic.models import program as program_logic |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
30 |
from soc.logic.models import request as request_logic |
682 | 31 |
|
32 |
import soc.models.group |
|
33 |
import soc.models.organization |
|
34 |
||
35 |
||
36 |
class Logic(group.Logic): |
|
37 |
"""Logic methods for the Organization model. |
|
38 |
""" |
|
39 |
||
40 |
def __init__(self, model=soc.models.organization.Organization, |
|
41 |
base_model=soc.models.group.Group, scope_logic=program_logic): |
|
42 |
"""Defines the name, key_name and model for this entity. |
|
43 |
""" |
|
44 |
||
45 |
super(Logic, self).__init__(model=model, base_model=base_model, |
|
46 |
scope_logic=scope_logic) |
|
47 |
||
1124
d456f50af0d2
Reverting a change from r1732 for reasons stated in soc/logic/models/group.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1122
diff
changeset
|
48 |
# Restore base.Logic key field related methods |
d456f50af0d2
Reverting a change from r1732 for reasons stated in soc/logic/models/group.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1122
diff
changeset
|
49 |
getKeyValuesFromEntity = base.Logic.getKeyValuesFromEntity |
d456f50af0d2
Reverting a change from r1732 for reasons stated in soc/logic/models/group.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1122
diff
changeset
|
50 |
getKeyValuesFromFields = base.Logic.getKeyValuesFromFields |
d456f50af0d2
Reverting a change from r1732 for reasons stated in soc/logic/models/group.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1122
diff
changeset
|
51 |
getKeyFieldNames = base.Logic.getKeyFieldNames |
d456f50af0d2
Reverting a change from r1732 for reasons stated in soc/logic/models/group.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1122
diff
changeset
|
52 |
|
682 | 53 |
|
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
54 |
def _onCreate(self, entity): |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
55 |
"""Invites the group admin and backup admin. |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
56 |
""" |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
57 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
58 |
fields = { |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
59 |
'link_id': entity.link_id, |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
60 |
'scope_path': entity.scope_path |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
61 |
} |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
62 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
63 |
# Find their application |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
64 |
application = org_app_logic.logic.getFromKeyFields(fields) |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
65 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
66 |
if application: |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
67 |
# only if there is an application send out the invites |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
68 |
properties = { |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
69 |
'scope': entity, |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
70 |
'scope_path': entity.key().name(), |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
71 |
'role': 'org_admin', |
1171
26998a171c49
Style fixes in soc.logic.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1154
diff
changeset
|
72 |
'role_verbose': 'Organization Admin', |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
73 |
'status': 'group_accepted', |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
74 |
} |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
75 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
76 |
for admin in [application.applicant, application.backup_admin]: |
1292
cf8b099bd787
Fixed a bug in club and org logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1171
diff
changeset
|
77 |
if not admin: |
cf8b099bd787
Fixed a bug in club and org logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1171
diff
changeset
|
78 |
continue |
cf8b099bd787
Fixed a bug in club and org logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1171
diff
changeset
|
79 |
|
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
80 |
properties['link_id'] = admin.link_id |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
81 |
key_fields = request_logic.logic.getKeyFieldsFromFields(properties) |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
82 |
request_logic.logic.updateOrCreateFromFields(properties, key_fields) |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
83 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
84 |
# set the application to completed |
1171
26998a171c49
Style fixes in soc.logic.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1154
diff
changeset
|
85 |
fields = {'status': 'completed'} |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
86 |
org_app_logic.logic.updateEntityProperties(application, fields) |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
87 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
88 |
super(Logic, self)._onCreate(entity) |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
89 |
|
682 | 90 |
logic = Logic() |