Also covers revoking / removing user / member Adds a user to a project Checks 1. User adding has permission to add user to project (ie is admin) 2. If user being added is existing 3. Chooses appropriate method to execute request If user is existing calls permissions_u
(project_string_id)
| 17 | methods = ['POST']) |
| 18 | @Project_permissions.user_has_project(["admin"]) |
| 19 | def share_member_project_api(project_string_id): |
| 20 | """ |
| 21 | |
| 22 | Also covers revoking / removing user / member |
| 23 | |
| 24 | Adds a user to a project |
| 25 | Checks |
| 26 | 1. User adding has permission to add user to project (ie is admin) |
| 27 | 2. If user being added is existing |
| 28 | 3. Chooses appropriate method to execute request |
| 29 | |
| 30 | If user is existing calls permissions_update_user_exists() |
| 31 | else calls permissions_invite_user() |
| 32 | |
| 33 | Returns {"success" : True} if successful , {"success" : False} otherwise |
| 34 | |
| 35 | user is user to be added... is there a better name for that? |
| 36 | """ |
| 37 | |
| 38 | spec_list = [ |
| 39 | {'member_list': None}, |
| 40 | {'mode': str}, |
| 41 | {'user_dict': None}, |
| 42 | {'notify': { |
| 43 | 'default': True, |
| 44 | 'kind': bool |
| 45 | } |
| 46 | } |
| 47 | ] |
| 48 | |
| 49 | log, input, untrusted_input = regular_input.master(request = request, |
| 50 | spec_list = spec_list) |
| 51 | if len(log["error"].keys()) >= 1: |
| 52 | return jsonify(log = log), 400 |
| 53 | |
| 54 | with sessionMaker.session_scope() as session: |
| 55 | |
| 56 | member = get_member(session) |
| 57 | share_project = Share_Project( |
| 58 | session = session, |
| 59 | member = member, |
| 60 | member_list = input['member_list'], |
| 61 | user_dict = input['user_dict'], |
| 62 | mode = input['mode'], |
| 63 | project = Project.get(session, project_string_id), |
| 64 | notify = input['notify'] |
| 65 | ) |
| 66 | |
| 67 | share_project.user_who_made_request = User.get(session) |
| 68 | |
| 69 | share_project.main() |
| 70 | |
| 71 | if len(share_project.log["error"].keys()) >= 1: |
| 72 | return jsonify(log = share_project.log), 400 |
| 73 | |
| 74 | share_project.log["success"] = True |
| 75 | |
| 76 | # Set cache dirty |
nothing calls this directly
no test coverage detected