Skip to content

Conversation

@amriith
Copy link

@amriith amriith commented Apr 22, 2025

This change implements a comprehensive organization management system for Ontrack. The feature allows administrators to create and manage organizations, and users can be members of multiple organizations. Users can also set their current active organization, which enables organization-specific views and functionality.

Organization CRUD operations (create, read, update, delete)
User membership management (add/remove members)
Organization switching functionality
User search for adding members
Authorization controls for organization management

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration


#Run these Migration commands in your terminal 
rails generate migration CreateOrganizations name:string description:text


rails generate migration CreateUserOrganizations user:references organization:references



rails generate migration AddCurrentOrganizationToUsers current_organization:references

After creating the migration, you can run it with:
rails db:migrate

Test A
Rails console testing for model relationships

From the bash terminal run- rails console
 # Create an organization

org = Organization.create(name: "Test Organization", description: "Testing")
 # Find an admin user
 admin = User.find_by(role_id: Role.admin_id)

# Add user to organization

 org.users << admin

# Check if user is in organization

org.users.include?(admin) # Should return true

# Test organization switching (if you've added current_organization_id to User)

admin.update(current_organization_id: org.id)

Test B

Can Alternatively test from the backend Using Postman

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if appropriate
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have created or extended unit tests to address my new additions
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

If you have any questions, please contact @macite or @jakerenzella.

@amriith amriith changed the base branch from development to 9.x April 22, 2025 02:45
Copy link

@ibi420 ibi420 left a comment

Choose a reason for hiding this comment

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

The code is well-structured and follows best practices for associations, validations, and authorisation, providing clear endpoints for organisation management. Database migrations are well-executed, and API serialisation ensures maintainable output. The newly implemented API allows for viewing, creating, updating, and deleting users' organisations. I successfully tested this using Postman and confirmed its proper implementation. Thank you for the opportunity to review your work.

@LovleenKala
Copy link

LovleenKala commented Apr 30, 2025

Hey Amrith,

I was able to pull your PR and test it in my local environment. Everything worked as expected.

I ran the migrations to create the organizations, user_organizations, and current_organization_id fields.
I tested organization creation, user membership assignment, and organization switching through the Rails console.
The organization CRUD operations, membership management, and switching functionality all worked correctly during testing. Great job on the implementation.
Screenshot 2025-04-30 at 8 45 57 PM

@aNebula
Copy link

aNebula commented Jun 12, 2025

LGTM.
@amriith Please open a PR against doubtfire-lms/doubtfire-api with 9.x branch.
Remember to include description and context.

@amriith
Copy link
Author

amriith commented Jul 14, 2025

Hi @aNebula I have opened a new pr on doubtfire-lms/doubtfire-api with 9.x branch , url-

doubtfire-lms#471

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 this pull request may close these issues.

4 participants