27 |
27 |
28 def completeRequestForRole(role_entity, role_name): |
28 def completeRequestForRole(role_entity, role_name): |
29 """Marks the request that leads to the given role_entity as completed. |
29 """Marks the request that leads to the given role_entity as completed. |
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 |
33 role_name : The name in the request that is used to describe the type of the role_entity |
33 of the role model |
|
34 role_name: The name in the request that is used to describe the |
|
35 type of the role_entity |
34 |
36 |
35 """ |
37 """ |
36 |
38 |
37 # get the request logic so we can query the datastore |
39 # get the request logic so we can query the datastore |
38 request_logic = model_logic.request.logic |
40 request_logic = model_logic.request.logic |
39 |
41 |
40 # create the query properties for the specific role |
42 # create the query properties for the specific role |
41 properties = {'scope_path' : role_entity.scope_path, |
43 properties = {'scope_path' : role_entity.scope_path, |
42 'link_id' : role_entity.link_id, |
44 'link_id': role_entity.link_id, |
43 'role' : role_name} |
45 'role': role_name} |
44 |
46 |
45 # get the request that complies with properties |
47 # get the request that complies with properties |
46 request_entity = request_logic.getForFields(properties, unique=True) |
48 request_entity = request_logic.getForFields(properties, unique=True) |
47 |
49 |
48 # mark the request completed, if there is any |
50 # mark the request completed, if there is any |
49 if request_entity: |
51 if request_entity: |
50 request_logic.updateModelProperties(request_entity, |
52 request_logic.updateModelProperties(request_entity, |
51 {'state' : 'completed'}) |
53 {'state': 'completed'}) |