author | Lennard de Rijk <ljvderijk@gmail.com> |
Tue, 14 Jul 2009 16:46:42 +0200 | |
changeset 2643 | 222be0eb4aab |
parent 2160 | 3f9dd37d98a8 |
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 |
1623
8b70d6bb3f8f
Renamed rankerroot to ranker_root and made some changes due to comments.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1609
diff
changeset
|
31 |
from soc.logic.models.ranker_root import logic as ranker_root_logic |
682 | 32 |
|
33 |
import soc.models.group |
|
34 |
import soc.models.organization |
|
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): |
1623
8b70d6bb3f8f
Renamed rankerroot to ranker_root and made some changes due to comments.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1609
diff
changeset
|
55 |
"""Invites the group admin and backup admin and creates a RankerRoot entity. |
1154
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 |
|
1609
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1512
diff
changeset
|
58 |
from soc.models import student_proposal |
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1512
diff
changeset
|
59 |
|
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1512
diff
changeset
|
60 |
# create a new ranker |
1623
8b70d6bb3f8f
Renamed rankerroot to ranker_root and made some changes due to comments.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1609
diff
changeset
|
61 |
ranker_root_logic.create(student_proposal.DEF_RANKER_NAME, entity, |
1609
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1512
diff
changeset
|
62 |
student_proposal.DEF_SCORE, 100) |
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1512
diff
changeset
|
63 |
|
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
64 |
fields = { |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
65 |
'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
|
66 |
'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
|
67 |
} |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
68 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
69 |
# Find their application |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
70 |
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
|
71 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
72 |
if application: |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
73 |
# 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
|
74 |
properties = { |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
75 |
'scope': entity, |
2160
3f9dd37d98a8
Use key().id_or_name() instead of key().name()
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
76 |
'scope_path': entity.key().id_or_name(), |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
77 |
'role': 'org_admin', |
1171
26998a171c49
Style fixes in soc.logic.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1154
diff
changeset
|
78 |
'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
|
79 |
'status': 'group_accepted', |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
80 |
} |
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
81 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
82 |
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
|
83 |
if not admin: |
cf8b099bd787
Fixed a bug in club and org logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1171
diff
changeset
|
84 |
continue |
cf8b099bd787
Fixed a bug in club and org logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1171
diff
changeset
|
85 |
|
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
86 |
properties['link_id'] = admin.link_id |
1512
97c4a718d6f4
Remove updateOrCreateFromFields and it's uses
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1511
diff
changeset
|
87 |
key_name = request_logic.logic.getKeyNameFromFields(properties) |
97c4a718d6f4
Remove updateOrCreateFromFields and it's uses
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1511
diff
changeset
|
88 |
request_logic.logic.updateOrCreateFromKeyName(properties, key_name) |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
89 |
|
1511
3342ce7a495c
Fix some whitespace damadge and a style fix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
90 |
# set the application to completed |
1171
26998a171c49
Style fixes in soc.logic.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1154
diff
changeset
|
91 |
fields = {'status': 'completed'} |
1154
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
92 |
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
|
93 |
|
77276e2c46f7
Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1124
diff
changeset
|
94 |
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
|
95 |
|
682 | 96 |
logic = Logic() |