From 15a7929506bcb8fff9c2e941ddf41a135edca826 Mon Sep 17 00:00:00 2001 From: Sophie Fitzpatrick Date: Sun, 28 Feb 2021 15:35:28 +0000 Subject: [PATCH 1/4] fixes --- README.md | 5 +- marvelcli/group/group_commands.py | 88 +++++++++------- marvelcli/marvelcli.py | 5 +- marvelcli/project/project_commands.py | 121 +++++++++++++++------- marvelcli/user/user_commands.py | 12 +-- marvelcli/user/user_queries.py | 40 ------- marvelcli/workspace/workspace_commands.py | 25 +++-- marvelcli/workspace/workspace_queries.py | 18 ---- 8 files changed, 155 insertions(+), 159 deletions(-) diff --git a/README.md b/README.md index 42cbd0e..ecb40af 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ To unauth: To invite users to your workspace: - marvelcli invite-users-to-workspace --email "janis@bigbrotherandtheholdingcompany.com" --email "stevie@fleetwoodmac.com" --email "grace@jeffersonairplane.com" + marvelcli add-collabs-to-project --project 12345 --email "janis@bigbrotherandtheholdingcompany.com" --email "stevie@fleetwoodmac.com" --email "grace@jeffersonairplane.com" ## Commands available: @@ -48,14 +48,11 @@ You can find out how to use each command with: delete-project Delete a project get-billing-info Get billing information get-personal-projects List all projects owned by you - invite-users-to-workspace Invite users to your workspace remove-collabs-from-project Remove collaborators from a project remove-groups-from-project Remove groups from a project remove-members-from-group Remove members from a group remove-users-from-workspace Remove users from your workspace - update-account-password Update your account password update-group-name Update a group name - update-user Update your email, username and occuption ## Feature requests diff --git a/marvelcli/group/group_commands.py b/marvelcli/group/group_commands.py index bee5636..f080d7d 100644 --- a/marvelcli/group/group_commands.py +++ b/marvelcli/group/group_commands.py @@ -15,16 +15,21 @@ def delete_groups(group_pk: list, auth: str): if r.status_code != 200: click.echo(json_data['data']['deleteGroups']['error']['message']) else: - data_success = json_data['data']['deleteGroups']['succeeded'] - data_failed = json_data['data']['deleteGroups']['failed'] + if not group_pk: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + data_success = json_data['data']['deleteGroups']['succeeded'] + data_failed = json_data['data']['deleteGroups']['failed'] + + if data_success: + click.echo("\nThe following groups were deleted from your workspace successfully: %s" % data_success) - if data_success: - click.echo("\nThe following groups were deleted from your workspace successfully: %s." % ', '.join(data_success)) + if data_failed: + click.echo('\nThe following groups could not be deleted from your workspace:') + for f in data_failed: + click.echo("%s - %s" % (f.get('groupPk'), f.get('message'))) - if data_failed: - click.echo('\nThe following groups could not be deleted from your workspace:') - for f in data_failed: - click.echo("%s - %s\n" % (f.get('groupPk'), f.get('message'))) + click.echo("\n") @click.option('-n', '--name', type=str, help='Name of group') @click.option('-a', '--auth', type=str, help='Auth your request') @@ -47,57 +52,68 @@ def create_group(name: str, auth: str): @click.option('-e', '--email', type=str, multiple=True, help='Use this flag for each email address you want added to your group') @click.option('-a', '--auth', type=str, help='Auth your request') @click.command() -def add_members_to_group(group_pk: int, emails: list, auth: str): +def add_members_to_group(group_pk: int, email: list, auth: str): """Add members to a group""" - params = {'teamPk': group_pk,'emails': emails} + params = {'teamPk': group_pk,'emails': email} query = group_queries.add_members_query r, json_data = utils.make_request(auth, query, params) if r.status_code != 200: - click.echo(json_data['data']['addMembersToTeam']['error']['message']) + if not group_pk: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + click.echo(json_data['data']['addMembersToTeam']['error']['message']) else: - data_success = json_data['data']['addMembersToTeam']['succeeded'] - data_failed = json_data['data']['addMembersToTeam']['failed'] + if not email: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + data_success = json_data['data']['addMembersToTeam']['succeeded'] + data_failed = json_data['data']['addMembersToTeam']['failed'] + if data_success: + successful_emails = [] + for s in data_success: + successful_emails.append(s.get('email')) - if data_success: - successful_emails = [] - for s in data_success: - successful_emails.append(s.get('email')) + click.echo("\nThe following people were successfully added to group %s: %s" % (group_pk, ', '.join(successful_emails))) - click.echo("\n The following people were successfully added to group %s: %s" % (pk, ', '.join(successful_emails))) + if data_failed: + click.echo('\nThe following people could not be added to group %s for the following reasons:' % (group_pk)) + for f in data_failed: + click.echo("%s - %s" % (f.get('email'), f.get('message'))) - if data_failed: - click.echo('The following people could not be added to group %s:' % (pk)) - for f in data_failed: - click.echo("%s - %s \n " % (f.get('email'), f.get('message'))) + click.echo("\n") @click.option('-g', '--group-pk', type=int, help='Pk of the group you want to remove members from') @click.option('-e', '--email', type=str, multiple=True, help='Use this flag for each email address you want removed from your group') @click.option('-a', '--auth', type=str, help='Auth your request') @click.command() -def remove_members_from_group(group_pk: int, emails: list, auth: str): +def remove_members_from_group(group_pk: int, email: list, auth: str): """Remove members from a group""" - params = {'teamPk': group_pk,'emails': emails} + params = {'teamPk': group_pk,'emails': email} query = group_queries.remove_members_query r, json_data = utils.make_request(auth, query, params) if r.status_code != 200: - click.echo(json_data['data']['removeMembersFromTeam']['error']['message']) + if not group_pk: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + click.echo(json_data['data']['removeMembersFromTeam']['error']['message']) else: - data_success = json_data['data']['removeMembersFromTeam']['succeeded'] - data_failed = json_data['data']['removeMembersFromTeam']['failed'] + if not email: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + data_success = json_data['data']['removeMembersFromTeam']['succeeded'] + data_failed = json_data['data']['removeMembersFromTeam']['failed'] - if data_success: - successful_emails = [] - for s in data_success: - successful_emails.append(s.get('email')) + if data_success: + click.echo("\nThe following people were successfully removed from group %s: %s" % (group_pk, data_success)) - click.echo("The following people were successfully removed from group %s: %s" % (pk, ', '.join(successful_emails))) + if data_failed: + click.echo('\nThe following people could not be removed from group %s:' % (group_pk)) + for f in data_failed: + click.echo("%s - %s" % (f.get('email'), f.get('message'))) - if data_failed: - click.echo('The following people could not be removed from group %s:' % (pk)) - for f in data_failed: - click.echo("%s - %s" % (f.get('email'), f.get('message'))) + click.echo("\n") @click.option('-g', '--group-pk', type=int, help='Pk of the group you want to update the name for') @click.option('-n', '--name', type=str, help='New name for your group') diff --git a/marvelcli/marvelcli.py b/marvelcli/marvelcli.py index 3217c7f..1d6980e 100644 --- a/marvelcli/marvelcli.py +++ b/marvelcli/marvelcli.py @@ -28,14 +28,11 @@ def marvelcli(args=None): """ # User -marvelcli.add_command(user_commands.update_account_password) -marvelcli.add_command(user_commands.update_user) marvelcli.add_command(user_commands.about_user) # Workspace marvelcli.add_command(workspace_commands.get_billing_info) marvelcli.add_command(workspace_commands.remove_users_from_workspace) -marvelcli.add_command(workspace_commands.invite_users_to_workspace) # Project marvelcli.add_command(project_commands.delete_project) @@ -57,4 +54,4 @@ def marvelcli(args=None): marvelcli.add_command(folder_commands.create_folder) if __name__ == "__main__": - marvelcli() + marvelcli() diff --git a/marvelcli/project/project_commands.py b/marvelcli/project/project_commands.py index 4239394..758a070 100644 --- a/marvelcli/project/project_commands.py +++ b/marvelcli/project/project_commands.py @@ -14,10 +14,13 @@ def delete_project(project_pk: str, auth: str): r, json_data = utils.make_request(auth, query, params) if r.status_code == 200: - if not json_data['data']['deleteproject']['ok']: - click.echo('\n' + json_data['data']['deleteproject']['error']['message'] + '\n') + if json_data['data']['deleteProject'] is None: + click.echo("\nProject '%s' has not been deleted for the following reason: %s\n" % ( + project_pk, + json_data['errors'][0]['message'] + )) else: - click.echo('\n"%s" has been successfully deleted from your Marvel account\n' % pk) + click.echo("\n'%s' has been successfully deleted from your Marvel account\n" % project_pk) else: click.echo("\nTry 'marvelcli delete_project --help' to make sure you are not missing any args.\n") @@ -32,7 +35,10 @@ def add_groups_to_project(project_pk: int, group_pk: list, auth: str): r, json_data = utils.make_request(auth, query, params) if r.status_code != 200: - click.echo('\n' + json_data['data']['addTeamsToProject']['error']['message'] + '\n') + if not project_pk or not group_pk: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + click.echo('\n' + json_data['data']['addTeamsToProject']['error']['message'] + '\n') else: data_success = json_data['data']['addTeamsToProject']['succeeded'] data_failed = json_data['data']['addTeamsToProject']['failed'] @@ -41,12 +47,14 @@ def add_groups_to_project(project_pk: int, group_pk: list, auth: str): successful_groups = [] for s in data_success: successful_groups.append(s.get('pk')) - click.echo("\nThe following groups were successfully added to project %s: %s " % (project_pk, successful_groups)) + click.echo("\nThe following groups were successfully added to project %s: %s \n" % (project_pk, successful_groups)) if data_failed: click.echo('\nThe following groups could not be added to project %s:' % (project_pk)) for f in data_failed: - click.echo("%s - %s \n" % (f.get('teamPk'), f.get('message'))) + click.echo("%s - %s" % (f.get('teamPk'), f.get('message'))) + + click.echo("\n") @click.option('-p', '--project-pk', type=int, help='Pk of the project you want to remove groups from') @click.option('-g', '--group_pk', type=int, multiple=True, help='Use this flag for each group you want removed from your project') @@ -59,7 +67,10 @@ def remove_groups_from_project(project_pk: int, group_pk: list, auth: str): r, json_data = utils.make_request(auth, query, params) if r.status_code != 200: - click.echo('\n' + json_data['data']['removeTeamsFromProject']['error']['message'] + '\n') + if not project_pk or not group_pk: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + click.echo('\n' + json_data['data']['removeTeamsFromProject']['error']['message'] + '\n') else: data_success = json_data['data']['removeTeamsFromProject']['succeeded'] data_failed = json_data['data']['removeTeamsFromProject']['failed'] @@ -68,12 +79,14 @@ def remove_groups_from_project(project_pk: int, group_pk: list, auth: str): successful_groups = [] for s in data_success: successful_groups.append(s.get('pk')) - click.echo("\nThe following groups were successfully removed from project %s: %s" % (project_pk, successful_groups)) + click.echo("\nThe following groups were successfully removed from project %s: %s\n" % (project_pk, successful_groups)) if data_failed: click.echo('\nThe following groups could not be removed from project %s:' % (project_pk)) for f in data_failed: - click.echo("%s - %s \n" % (f.get('teamPk'), f.get('message'))) + click.echo("%s - %s" % (f.get('teamPk'), f.get('message'))) + + click.echo("\n") @click.option('-p', '--project-pk', type=int, help='Pk of the project you want to add collaborators to') @click.option('-e', '--email', type=str, multiple=True, help='Use this flag for each email address you want added to your project') @@ -86,21 +99,30 @@ def add_collabs_to_project(project_pk: int, email: list, auth: str): r, json_data = utils.make_request(auth, query, params) if r.status_code != 200: - click.echo('\n' + json_data['data']['addCollaboratorsToProject']['error']['message'] + '\n') + if not project_pk: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + click.echo('\n' + json_data['data']['addCollaboratorsToProject']['error']['message'] + '\n') else: - data_success = json_data['data']['addCollaboratorsToProject']['succeeded'] - data_failed = json_data['data']['addCollaboratorsToProject']['failed'] + # status_code 200 without all args + if not email: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + data_success = json_data['data']['addCollaboratorsToProject']['succeeded'] + data_failed = json_data['data']['addCollaboratorsToProject']['failed'] - if data_success: - successful_emails = [] - for s in data_success: - successful_emails.append(s.get('email')) - click.echo("\nThe following people were successfully added to project %s: %s" % (pk, ', '.join(successful_emails))) + if data_success: + successful_emails = [] + for s in data_success: + successful_emails.append(s.get('email')) + click.echo("\nThe following people were successfully added to project %s: %s" % (project_pk, ', '.join(successful_emails))) - if data_failed: - click.echo('\nThe following people could not be added to project %s:' % (pk)) - for f in data_failed: - click.echo("%s - '%s' \n" % (f.get('email'), f.get('message'))) + if data_failed: + click.echo('\nThe following people could not be added to project %s for the following reasons:' % (project_pk)) + for f in data_failed: + click.echo("%s - '%s'" % (f.get('email'), f.get('message'))) + + click.echo("\n") @click.option('-p', '--project-pk', type=int, help='Pk of the project you want to remove collaborators from') @@ -114,16 +136,25 @@ def remove_collabs_from_project(project_pk: int, email: list, auth: str): r, json_data = utils.make_request(auth, query, params) if r.status_code != 200: - click.echo('\n' + json_data['data']['removeCollaboratorsFromProject']['error']['message'] + '\n') + if not project_pk: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + click.echo('\n' + json_data['data']['removeCollaboratorsFromProject']['error']['message'] + '\n') else: - if json_data['data']['removeCollaboratorsFromProject']['succeeded']: - click.echo("\nThe following people were successfully removed from project %s: %s" % (pk, ', '.join(data_success))) + if not email: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") + else: + data_success = json_data['data']['removeCollaboratorsFromProject']['succeeded'] + if json_data['data']['removeCollaboratorsFromProject']['succeeded']: + click.echo("\nThe following people were successfully removed from project %s: %s" % (project_pk, data_success)) - data_failed = json_data['data']['removeCollaboratorsFromProject']['failed'] - if data_failed: - click.echo('\nThe following people could not be removed from project %s:' % (pk)) - for f in data_failed: - click.echo("%s - '%s' \n" % (f.get('email'), f.get('message'))) + data_failed = json_data['data']['removeCollaboratorsFromProject']['failed'] + if data_failed: + click.echo('\nThe following people could not be removed from project %s for the following reasons:' % (project_pk)) + for f in data_failed: + click.echo("%s - '%s'" % (f.get('email'), f.get('message'))) + + click.echo("\n") @click.option('-n', '--name', type=str, help='Name of project') @@ -132,16 +163,26 @@ def remove_collabs_from_project(project_pk: int, email: list, auth: str): @click.command() def create_project(name: str, password: str, auth: str): """Create a new project""" - params = {'name': name,'password': password} - if not password: - params['password'] = '' - query = project_queries.create_project_query - r, json_data = utils.make_request(auth, query, params) - - if r.status_code != 200: - click.echo('\n' + 'A new project could not be created at this time."' + '\n') + if not name: + click.echo("\nLooks like you might be missing some args, add `--help` to your command to see the options.\n") else: - click.echo('\n"%s" has been successfully created in your Marvel account \n' % name) + user_query = workspace_queries.get_billing_info_query + req, json_data_user = utils.make_request(auth, user_query) + plan = json_data_user['data']['user']['company']['billing']['plan']['title'] + proj_used = json_data_user['data']['user']['company']['billing']['projectQuantityUsed'] + if plan == 'Free' and proj_used == 1: + click.echo("\nYou have maxed out your allowances, either delete a project then run the command again or upgrade for unlimited projects: https://marvelapp.com/plans \n") + else: + params = {'name': name,'password': password} + if not password: + params['password'] = '' + query = project_queries.create_project_query + r, json_data = utils.make_request(auth, query, params) + + if r.status_code != 200: + click.echo('\n' + 'A new project could not be created at this time."' + '\n') + else: + click.echo('\n"%s" has been successfully created in your Marvel account \n' % name) @click.option('-a', '--auth', type=str, help='Auth your request') @click.command() @@ -160,7 +201,9 @@ def get_personal_projects(auth: str): urls.append(url) project_count = len(json_data['data']['user']['projects']['edges']) - click.echo('\nYou have %s project(s)' % project_count) + click.echo('\nYou have %s project(s):' % project_count) for url in urls: click.echo(url) + + click.echo("\n") diff --git a/marvelcli/user/user_commands.py b/marvelcli/user/user_commands.py index 7a0e8e3..577fd99 100644 --- a/marvelcli/user/user_commands.py +++ b/marvelcli/user/user_commands.py @@ -53,16 +53,8 @@ def about_user(auth: str): last_active = user['lastActiveAt'] last_active = datetime.datetime(int(last_active[0:4]), int(last_active[5:7]), int(last_active[8:10]), 0, 0) - click.echo(utils.colour.BOLD + '\nYour Account: \n' + utils.colour.END) + click.echo(utils.colour.BOLD + '\nYour Account:' + utils.colour.END) click.echo('Email: %s' % user['email']) click.echo('Last Active: %s' % last_active) - click.echo('Has Password: %s' % user['hasPassword'] ) click.echo('Status: %s' % user['status']) - click.echo('Username: %s' % user['username']) - click.echo(utils.colour.BOLD + '\nYour Statistics: \n' + utils.colour.END) - click.echo('Number of Folders created by you: %s' % user['properties']['foldersOwnedCount']) - click.echo('Number of Hotspots created by you: %s' % user['properties']['hotspotsOwnedCount']) - click.echo('Number of Projects created by you: %s' % user['properties']['prototypeProjectsOwnedCount']) - click.echo('Number of Groups created by you: %s' % user['properties']['teamsOwnedCount']) - click.echo('Number of Screens created by you: %s' % user['properties']['screensOwnedCount']) - click.echo('Number of Usertest Projects created by you: %s\n' % user['properties']['userTestProjectsOwnedCount']) + click.echo('Username: %s \n' % user['username']) diff --git a/marvelcli/user/user_queries.py b/marvelcli/user/user_queries.py index 672dfbb..17ffd48 100644 --- a/marvelcli/user/user_queries.py +++ b/marvelcli/user/user_queries.py @@ -1,51 +1,11 @@ -password_update_query = ''' - mutation updateUserPassword($existingPassword: String!, $newPassword: String!) { - updateUserPassword(input: {existingPassword: $existingPassword, newPassword: $newPassword}) { - error { - message - code - } - ok - } - } -''' - -user_update_query = ''' - mutation updateCurrentUser($username: String, $email: String, $password: String, $occupation: OccupationEnum) { - updateCurrentUser(input: {username: $username, email: $email, password: $password, occupation: $occupation}) { - ok - user { - pk - email - username - occupation - } - error { - message - code - } - } - } -''' - about_user_query = ''' query myquery { user { - hasPassword email status lastActiveAt avatarUrl username - properties { - enableCommentNotifications - prototypeProjectsOwnedCount - userTestProjectsOwnedCount - screensOwnedCount - hotspotsOwnedCount - foldersOwnedCount - teamsOwnedCount - } } } ''' diff --git a/marvelcli/workspace/workspace_commands.py b/marvelcli/workspace/workspace_commands.py index b651fc7..203ee27 100644 --- a/marvelcli/workspace/workspace_commands.py +++ b/marvelcli/workspace/workspace_commands.py @@ -37,8 +37,13 @@ def remove_users_from_workspace(email: list, auth: str): query = workspace_queries.remove_users_from_workspace_query r, json_data = utils.make_request(auth, query, params) + if not email: + click.echo('Looks like you are missing some args, add `--help` to the command to see the options') if r.status_code != 200: - click.echo('\n' + json_data['data']['removeUsersFromWorkspace']['error']['message'] + '\n') + if not email: + click.echo('Looks like you are missing some args, add `--help` to the command to see the options') + else: + click.echo('\n' + json_data['data']['removeUsersFromWorkspace']['error']['message'] + '\n') else: data_success = json_data['data']['removeUsersFromWorkspace']['succeeded'] data_failed = json_data['data']['removeUsersFromWorkspace']['failed'] @@ -75,11 +80,12 @@ def get_billing_info(auth: str): click.echo(utils.colour.BOLD + "\nYour Plan" + utils.colour.END) click.echo("Type: %s" % plan['title']) - click.echo("Price: %s %s" % (price, billing['currency'].upper())) - click.echo("Seats: %s (%s %s per user)" % (plan['teamMembers'], price_per_seat, billing['currency'].upper())) if plan['title'] != 'Free': + click.echo("Price: %s %s" % (price, billing['currency'].upper())) + click.echo("Seats: %s (%s %s per user)" % (plan['teamMembers'], price_per_seat, billing['currency'].upper())) click.echo("Projects: Unlimited \n") else: + click.echo("Seats: %s " % (plan['teamMembers'])) click.echo("Projects: 1 \n") click.echo(utils.colour.BOLD + "Your Usage" + utils.colour.END) @@ -87,8 +93,11 @@ def get_billing_info(auth: str): click.echo("Seats Used: %s" % billing['seatQuantityUsed']) click.echo("Projects: %s \n" % billing['projectQuantityUsed']) - next_payment_date = billing['nextPaymentDate'] - dt = datetime.datetime(int(next_payment_date[0:4]), int(next_payment_date[5:7]), int(next_payment_date[8:10]), 0, 0) - next_payment_date = "%s-%s-%s" % (dt.day, dt.month, dt.year) - next_payment_amount = price_per_seat * billing['seatQuantityPurchased'] - click.echo("Your next payment date is %s for %s %s for %s seats\n" % (next_payment_date, next_payment_amount, billing['currency'].upper(), billing['seatQuantityPurchased'])) + if plan['title'] != 'Free': + next_payment_date = billing['nextPaymentDate'] + dt = datetime.datetime(int(next_payment_date[0:4]), int(next_payment_date[5:7]), int(next_payment_date[8:10]), 0, 0) + next_payment_date = "%s-%s-%s" % (dt.day, dt.month, dt.year) + next_payment_amount = price_per_seat * billing['seatQuantityPurchased'] + click.echo("Your next payment date is %s. You'll be paying %s %s for %s seats.\n" % (next_payment_date, next_payment_amount, billing['currency'].upper(), billing['seatQuantityPurchased'])) + else: + click.echo("Upgrade to create more projects and add more team members: https://marvelapp.com/plans\n") diff --git a/marvelcli/workspace/workspace_queries.py b/marvelcli/workspace/workspace_queries.py index 383efc3..2f7d345 100644 --- a/marvelcli/workspace/workspace_queries.py +++ b/marvelcli/workspace/workspace_queries.py @@ -27,24 +27,6 @@ } ''' -invite_users_to_workspace_query = ''' - mutation inviteUsersToWorkspace ($emails: [String!]!, $role: RoleEnum) { - inviteUsersToWorkspace (input: {emails: $emails, role: $role}) { - succeeded - failed { - email - message - code - } - error { - message - code - email - } - } - } -''' - remove_users_from_workspace_query = ''' mutation removeUsersFromWorkspace($emails: [String!]!,) { removeUsersFromWorkspace(input: {emails: $emails,}) { From 3b642eb79c3dbc7b261672ab4a3d3b65bd9bc703 Mon Sep 17 00:00:00 2001 From: Sophie Fitzpatrick Date: Sun, 28 Feb 2021 15:40:55 +0000 Subject: [PATCH 2/4] tweak --- marvelcli/project/project_commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/marvelcli/project/project_commands.py b/marvelcli/project/project_commands.py index 758a070..7234e6d 100644 --- a/marvelcli/project/project_commands.py +++ b/marvelcli/project/project_commands.py @@ -3,6 +3,7 @@ from marvelcli import utils from marvelcli.project import project_queries +from marvelcli.workspace import workspace_queries @click.option('-p', '--project-pk', type=str, help='Pk of the project you want to delete') @click.option('-a', '--auth', type=str, help='Auth your request') From 7a45d8a12f0769c183a5f4aed93f14e3b595cb79 Mon Sep 17 00:00:00 2001 From: Sophie Fitzpatrick Date: Sun, 28 Feb 2021 15:42:56 +0000 Subject: [PATCH 3/4] Remove commands that wont work cos of api limitations --- marvelcli/user/user_commands.py | 35 --------------------------------- 1 file changed, 35 deletions(-) diff --git a/marvelcli/user/user_commands.py b/marvelcli/user/user_commands.py index 577fd99..67c8303 100644 --- a/marvelcli/user/user_commands.py +++ b/marvelcli/user/user_commands.py @@ -4,41 +4,6 @@ from marvelcli import utils from marvelcli.user import user_queries -@click.option('-o', '--old-password', type=str, help='Your old account password') -@click.option('-n', '--new-password', type=str, help='Your new account password') -@click.option('-a', '--auth', help='Auth your request') -@click.command() -def update_account_password(new_password: str, old_password: str, auth: str): - """Update your account password""" - params = {'newPassword': new_password,'oldPassword': old_password} - query = user_queries.password_update_query - r, json_data = utils.make_request(auth, query, params) - - if r.status_code != 200: - click.echo('\n' + json_data['data']['updateUserPassword']['error']['message'] + '\n') - else: - click.echo("\nYour account updated with the new password successfully!\n") - -@click.option('-p', '--password', type=str, help='Your account password to auth the change') -@click.option('-e', '--email', type=str, help='Your new email address') -@click.option('-o', '--occupation', type=str, help='Your occupation') -@click.option('-u', '--username', type=str, help='Your new username') -@click.option('-a', '--auth', help='Auth your request') -@click.command() -def update_user(password: str, occupation: str, email: str, username: str, auth: str): - """Update your email, username and occuption""" - params = {'email': email,'username': username,'occupation': occupation,'password': password} - query = user_queries.user_update_query - r, json_data = utils.make_request(auth, query, params) - - if r.status_code == 200: - if not json_data['data']['updateCurrentUser']['ok']: - click.echo('\n' + json_data['data']['updateCurrentUser']['error']['message'] + '\n') - else: - click.echo("\nYour account updated successfully!\n") - else: - click.echo("\nTry 'marvelcli update_user --help' to make sure you are not missing any args.\n") - @click.option('-a', '--auth', help='Auth your request') @click.command() def about_user(auth: str): From 25899284dbbbf266ef92c3cf700e379a3838d18a Mon Sep 17 00:00:00 2001 From: Sophie Fitzpatrick Date: Sun, 28 Feb 2021 15:44:24 +0000 Subject: [PATCH 4/4] tweak --- marvelcli/workspace/workspace_commands.py | 24 ----------------------- 1 file changed, 24 deletions(-) diff --git a/marvelcli/workspace/workspace_commands.py b/marvelcli/workspace/workspace_commands.py index 203ee27..a75ba3d 100644 --- a/marvelcli/workspace/workspace_commands.py +++ b/marvelcli/workspace/workspace_commands.py @@ -4,30 +4,6 @@ from marvelcli import utils from marvelcli.workspace import workspace_queries -@click.option('-e', '--email', type=str, multiple=True, help='Use this flag for each email address you want invited to your workspace') -@click.option('-a', '--auth', type=str, help='Auth your request') -@click.command() -def invite_users_to_workspace(email: list, auth: str): - """Invite users to your workspace""" - params = {'emails': email, 'role': 'EDITOR'} - query = workspace_queries.invite_users_to_workspace_query - r, json_data = utils.make_request(auth, query, params) - - if r.status_code != 200: - click.echo('\n' + json_data['data']['inviteUsersToWorkspace']['error']['message'] + '\n') - else: - data_success = json_data['data']['inviteUsersToWorkspace']['succeeded'] - data_failed = json_data['data']['inviteUsersToWorkspace']['failed'] - - if data_success: - succeeded = "\nThe following people were successfully invited to your workspace: %s." % ', '.join(data_success) - click.echo(succeeded + "They've been assigned the role of 'EDITOR'. \n") - - if data_failed: - click.echo('\nThe following people could not be invited to your workspace:') - for f in data_failed: - click.echo("%s - '%s'\n" % (f.get('email'), f.get('message'))) - @click.option('-e', '--email', type=str, multiple=True, help='Use this flag for each email address you want removed from your workspace') @click.option('-a', '--auth', type=str, help='Auth your request') @click.command()