Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Each user should have one organization only #14

Closed
OmarIthawi opened this issue Feb 7, 2022 · 0 comments · Fixed by #24
Closed

fix: Each user should have one organization only #14

OmarIthawi opened this issue Feb 7, 2022 · 0 comments · Fixed by #24
Assignees

Comments

@OmarIthawi
Copy link
Contributor

OmarIthawi commented Feb 7, 2022

I noticed that we're investing a lot of time in supporting and testing for multiple-organizations per user.

This goes against the Tahoe 2.0 architecture of having one LMS organization per user.

Here's what we need to do:

  • Helpers should expect only one organization per user.
  • No multi-org helpers should be created.
  • Multi-org tests should be removed.

@shadinaif I know that we're re-using existing models which limit our freedom in changing them, but is this model fix possible?

 class UserOrganizationMapping(models.Model):
-    user = models.ForeignKey(settings.AUTH_USER_MODEL, ...)
+    user = models.OneToOneField(settings.AUTH_USER_MODEL, ...)
     organization = models.ForeignKey(Organization, ...)

Required test changes:

The helper tests below adds two organizations for a single user, this shouldn't be done:

def _prepare_mapping_data(self):
"""
mapping:
default_org --> default_user
Org1 --> default_user -----> self.mapping points here
Org1 --> user2
Org2 --> user2
Org3 --> None
"""
self.org1 = self._create_organization(name='Org1', short_name='O1')
create_organization_mapping(user=self.default_user, organization=self.default_org)
self.mapping = create_organization_mapping(user=self.default_user, organization=self.org1)
self.org2 = self._create_organization(name='Org2', short_name='O2')
self.user2 = UserFactory.create()
create_organization_mapping(user=self.user2, organization=self.org1)
create_organization_mapping(user=self.user2, organization=self.org2)
self._create_organization(name='Org3', short_name='O3')
# We have four organizations
assert Organization.objects.count() == 4

@shadinaif shadinaif linked a pull request Feb 9, 2022 that will close this issue
@shadinaif shadinaif removed a link to a pull request Feb 9, 2022
@shadinaif shadinaif linked a pull request Feb 23, 2022 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants