Skip to content

Conversation

@billyvg
Copy link
Member

@billyvg billyvg commented Feb 1, 2018

Mostly existing code from remove_account.py:

Takes a list of organization slugs and removes the orgs if they are an owner, also removes ALL orgs of which user is the sole owner of.

@ghost
Copy link

ghost commented Feb 1, 2018

1 Warning
⚠️ You should update CHANGES due to the size of this PR

Generated by 🚫 danger

@billyvg billyvg requested review from a team and macqueen February 1, 2018 21:16
@billyvg billyvg self-assigned this Feb 1, 2018
Also removes organizations if they are an owner
:pparam string user_id: user id
:param list organizations: List of organization ids to remove
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm wondering if we should actually have people send a list or if we should just delete all of the ones that should be deleted automatically? do we allow people to delete their account without removing the single owner orgs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was thinking the same thing - the existing behavior is that single owner orgs get listed and always get deleted.

If it is an org w/ multiple owners, you can choose to delete it (but maybe it's better to not be able to delete those at all?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh interesting. i didn't realize that you could also delete non-single owner orgs from here. hmmmm i mean i think in the interest of plowing through the setting stuff, it's probably a bad idea to change behavior, but seems like it'd be better if we forced people through the delete org flow when it's not single owner since it's so destructive. soo i'll defer to you/maybe you could check with chris to see if he's against removing the ability to delete those orgs from here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make it explicit (send the list of orgs to remove). Otherwise it should probably:

  • delete orgs explicitly selected
  • delete orgs with no owners
  • retain orgs with owners and not selected

Org deletion at least queues for 24 hours and emails all owners a way to undo it.

status=OrganizationStatus.VISIBLE,
)
org_results = []
for org in sorted(org_list, key=lambda x: x.name):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you aren't displaying this to the user, you probably don't need to sort

})

avail_org_slugs = set([o['organization'].slug for o in org_results])
orgs_to_remove = set(request.DATA.get('organizations')).intersection(avail_org_slugs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should do set(request.DATA.get('organizations', [])) because set(None) raises a TypeError

and actually, you should probably do at least some minimal validation that if the key does exist, it's a list

Copy link
Member

@dcramer dcramer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests look like they cover what id expect

Also removes organizations if they are an owner
:pparam string user_id: user id
:param list organizations: List of organization ids to remove
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make it explicit (send the list of orgs to remove). Otherwise it should probably:

  • delete orgs explicitly selected
  • delete orgs with no owners
  • retain orgs with owners and not selected

Org deletion at least queues for 24 hours and emails all owners a way to undo it.

"""

# be strict since we're removing orgs
if 'organizations' not in request.DATA or not isinstance(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use a validation/serializer thing to make this a bit more concise (and move the code into that)


# from `frontend/remove_account.py`
org_list = Organization.objects.filter(
member_set__role=roles.get_top_dog().id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should just change this to be like member_set__role__in=[roles_with_org_delete_scope]

@billyvg billyvg force-pushed the feat/api/remove-account branch from 8e67727 to bb1f479 Compare February 2, 2018 20:45
@billyvg billyvg merged commit 27e9482 into master Feb 2, 2018
@billyvg billyvg deleted the feat/api/remove-account branch February 2, 2018 21:38
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants