23 |
23 |
24 |
24 |
25 import soc.logic.models as model_logic |
25 import soc.logic.models as model_logic |
26 |
26 |
27 |
27 |
28 def removeRequestForRole(role_entity): |
28 def completeRequestForRole(role_entity, role_name): |
29 """Removes the request that leads to the creation of the given entity. |
29 """Marks the request that leads to the given role_entity as completly accepted. |
30 |
30 |
31 Args: |
31 Args: |
32 role_entity : A datastore entity that is either a role or a subclass of the role model |
32 role_entity : A datastore entity that is either a role or a subclass of the role model |
|
33 role_name : The name in the request that is used to describe the type of the role_entity |
33 |
34 |
34 """ |
35 """ |
35 |
36 |
36 # get the type of the role entity using the classname |
|
37 role_type = role_entity.__class__.__name__ |
|
38 |
|
39 # get the request logic so we can query the datastore |
37 # get the request logic so we can query the datastore |
40 request_logic = model_logic.request.logic |
38 request_logic = model_logic.request.logic |
41 |
39 |
42 # create the query properties for the specific role |
40 # create the query properties for the specific role |
43 properties = {'scope' : role_entity.scope, |
41 properties = {'scope_path' : role_entity.scope_path, |
44 'link_id' : role_entity.link_id, |
42 'link_id' : role_entity.link_id, |
45 'role' : role_type.lower() } |
43 'role' : role_name} |
46 |
44 |
47 # get the request that complies with properties |
45 # get the request that complies with properties |
48 request_entity = request_logic.getForFields(properties, unique=True) |
46 request_entity = request_logic.getForFields(properties, unique=True) |
49 |
47 |
50 # delete the request from the datastore, if there is any |
48 # mark the request completed, if there is any |
51 if request_entity: |
49 if request_entity: |
52 request_logic.delete(request_entity) |
50 request_logic.updateModelProperties(request_entity, |
53 |
51 {'completed' : True, 'group_accepted' : True, 'user_accepted' : True}) |
54 |
|