Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Conversation

@mudassir-hafeez
Copy link
Contributor

@mudassir-hafeez mudassir-hafeez commented Oct 17, 2021

This PR implements the code base changes to return user main(or actual) organization in user and course api.

return []

return user.organizations.all()
main_user_organization = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Lines 1469-1502 seems duplicate code(used in serializer as well).
can we remove this duplication as both are related with each other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed

user_organizations_set = user.organizations.all()
if main_user_organization:
user_organizations_set = user_organizations_set.exclude(id=main_user_organization.id)
user_organizations_set = [main_user_organization] + list(user_organizations_set)
Copy link
Contributor

Choose a reason for hiding this comment

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

You are excluding main_user_organization from user_organizations_set and then re-adding it is there a reason?

Copy link
Contributor

Choose a reason for hiding this comment

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

user.organizations.all().order_by('-user_organizations__is_main_company')

May be we can use some thing similar to this not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of re-adding was to set the main company at first index. However, updated it with the suggested one.

user_organizations_set = user.organizations.all()
if main_user_organization:
user_organizations_set = user_organizations_set.exclude(id=main_user_organization.id)
user_organizations_set = [main_user_organization] + list(user_organizations_set)
Copy link
Contributor

Choose a reason for hiding this comment

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

user.organizations.all().order_by('-user_organizations__is_main_company')

May be we can use some thing similar to this not sure.

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.

3 participants