Skip to content

Inconsistent add_user and related functions #286

Description

@dwasyl

In OrganizationBase, the add_user function has this signature: def add_user(self, user, **kwargs) and creates a new OrganizationUser with the kwargs:

        org_user = self._org_user_model.objects.create(
            user=user, organization=self, **kwargs
        )

However, in AbstractOrganization, the add_user function has this signature: def add_user(self, user, is_admin=False) and creates a new OrganizationUser with:

        org_user = self._org_user_model.objects.create(
            user=user, organization=self, is_admin=is_admin
        )

And finally, also in AbstractOrganization, there is a get_or_add_user function with this signature: def get_or_add_user(self, user, **kwargs), except it only checks for is_admin in kwargs, ignoring anything else creating a new OrganizationUser with:

        org_user, created = self._org_user_model.objects.get_or_create(
            organization=self, user=user, defaults={"is_admin": is_admin}
        )

Mostly, it doesn't make much sense to me why there are essentially three different ways of doing the same thing (aside from the get_or), but three very different way of treating any additional user kwargs and it should likely be made consistent.

Unless there's good reason for this current setup?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions