This Django application provides a comprehensive user and organization management system. It consists of two main models: Organization and User. Organizations serve as entities to group users, and the User model represents individuals belonging to these organizations. Users come with specific roles such as Administrator, Viewer, and the standard User. Each role has different permissions for CRUD operations on the models.
-
Clone the repository:
git clone https://github.com/sowbobo12000/fusus_django.git
-
Navigate to the project directory:
## dev environment cd fusus/test ## prod environment cd fusus/
-
Create .env file
## dev cd fusus mkdir ENV && cd ENV touch .env.dev ## prod cd fusus mkdir ENV && cd ENV touch .env.prod ## both plain text ENV={ENV (Dev or Prod)} DB_NAME={DB NAME} DB_NAME={DB NAME} DB_USER={DB USER} DB_PASSWORD={DB PASSWORD} DB_HOST=db DB_PORT=3306
-
Run Docker Container
## dev cd fusus/test docker-compose --env-file ../ENV/.env.dev -f docker-compose-dev.yml up -d ## prod docker-compose --env-file ENV/.env.prod up -d
-
Run Migration for Production (Auto migration for Dev)
## Wait For 15 seconds after starting the django container docker exec -it fusus-web-1 /bin/bash python manage.py migrate
-
Down the docker container
## dev cd fusus/test docker-compose -f docker-compose-dev.yml down -v ## prod docker-compose down -v
API supports JWT authentication.
- [POST]
/api/auth/login/
: Authenticate using email address. - [GET]
/api/auth/groups/
: Returns authentication groups.- Administrator: Full access to CRUD any user in his organization and RU Organization.
- Viewer: List and retrieve any user in his organization.
- User: CRU his own user details.
- [GET]
/api/users/
: List all users within the authenticated user's organization (only if the user isAdministrator
orViewer
). Supports search by name, email, and filter by phone. - [GET]
/api/users/{id}/
: Retrieve specific user's information, including organization ID and name. - [POST]
/api/users/
: Create a new user for the organization. The request user must be an Administrator. - [PATCH]
/api/users/{id}
: Update information of the user if the request user is anAdministrator
or the user himself. - [DELETE]
/api/users/{id}
: Delete a user. Accessible only by theAdministrator
of his organization.
- [GET]
/api/organizations/{id}/
: Retrieve information of a specific organization if the request user is anAdministrator
orViewer
. - [PATCH]
/api/organizations/{id}
: Update organization details. Only accessible byAdministrator
. - [GET]
/api/organization/{id}/users
: List all users in a specific organization. Returns just user ID and name. - [GET]
/api/organization/{id}/users/{id}/
: Retrieve specific user's ID and name within an organization.
- [GET]
/api/info/
: Returns system details such as authenticated user's name, ID, organization name, and server's public IP.
- Run the tests:
cd fusus/test docker-compose -f docker-compose-dev.yml down -v docker-compose --env-file ../ENV/.env.dev -f docker-compose-dev.yml up -d docker ps docker exec -it test-web-1 /bin/bash python manage.py test user org