Skip to content

likemcode/Projecto-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Projecto-API

The Projecto API is a RESTful API that allows users to manage projects, tasks, team members, and technical documents. It provides endpoints for creating, retrieving, updating, and deleting these resources.

Table of Contents

Installation

To run the Projecto API locally, follow these steps:

  1. Clone the repository: git clone https://github.com/your-repo.git
  2. Navigate to the project directory: cd projets
  3. Install the dependencies: pip install -r requirements.txt
  4. Set up the database: python manage.py migrate
  5. Start the development server: python manage.py runserver

The API will be accessible at http://localhost:8000/.

Usage

To use the Projecto API, you can make HTTP requests to the provided endpoints using a tool like cURL or an API testing tool like Postman.

Before making requests, make sure to authenticate yourself and obtain an access token (see Authentication section).

Authentication

The Projecto API uses token-based authentication. To authenticate yourself and obtain an access token, follow these steps:

  1. Send a POST request to /api/login/ with your username and password in the request body.
  2. If the credentials are valid, you will receive a response with an access token.
  3. Include the access token in the Authorization header of subsequent requests as Bearer {access_token}.

Endpoints

The Projecto API provides the following endpoints:

Projects

  • GET /api/projects/: Retrieve a list of projects.
  • POST /api/projects/: Create a new project.
  • GET /api/projects/{project_id}/: Retrieve a specific project.
  • PUT /api/projects/{project_id}/: Update a specific project.
  • DELETE /api/projects/{project_id}/: Delete a specific project.

Tasks

  • GET /api/projects/{project_id}/tasks/: Retrieve a list of tasks in a project.
  • POST /api/projects/{project_id}/tasks/: Create a new task in a project.
  • GET /api/projects/{project_id}/tasks/{task_id}/: Retrieve a specific task in a project.
  • PUT /api/projects/{project_id}/tasks/{task_id}/: Update a specific task in a project.
  • DELETE /api/projects/{project_id}/tasks/{task_id}/: Delete a specific task in a project.

Team Members

  • GET /api/projects/{project_id}/team-members/: Retrieve a list of team members in a project.
  • POST /api/projects/{project_id}/team-members/: Add a new team member to a project.
  • GET /api/projects/{project_id}/team-members/{team_member_id}/: Retrieve a specific team member in a project.
  • PUT /api/projects/{project_id}/team-members/{team_member_id}/: Update a specific team member in a project.
  • DELETE /api/projects/{project_id}/team-members/{team_member_id}/: Remove a specific team member from a project.

Technical Documents

  • GET /api/projects/{project_id}/tasks/{task_id}/technical-documents/: Retrieve a list of technical documents for a task.
  • POST /api/projects/{project_id}/tasks/{task_id}/technical-documents/: Create a new technical document for a task.
  • GET /api/projects/{project_id}/tasks/{task_id}/technical-documents/{document_id}/: Retrieve a specific technical document for a task.
  • PUT /api/projects/{project_id}/tasks/{task_id}/technical-documents/{document_id}/: Update a specific technical document for a task.
  • DELETE /api/projects/{project_id}/tasks/{task_id}/technical-documents/{document_id}/: Delete a specific technical document for a task.

Registration

  • POST /api/register/: Register a user.

Authentication

  • POST /api/login/: Log in and obtain an access token.
  • POST /api/logout/: Log out.

Permissions

IsProjectManager

  • Checks if the user is authenticated and belongs to the 'project_managers' group.
  • For object-level permission, allows PUT, PATCH, DELETE requests only if the user is a project manager and is the owner of the project.

IsEngineer

  • Checks if the user is authenticated and belongs to the 'engineers' group.
  • For object-level permission, allows PUT, PATCH, DELETE requests only if the user is an engineer and is the owner of the task.

The admin can manage user groups ('project_managers', 'engineers') assigning the corresponding permissions to enable users to access endpoints based on their roles.

Error Handling

The Projecto API follows standard HTTP status codes for indicating the success or failure of a request. In case of an error, the response will include an error message in the body.

Common error codes and their meanings:

  • 400 Bad Request: The request was invalid or missing required parameters.
  • 401 Unauthorized: The request requires authentication or the provided credentials are invalid.
  • 403 Forbidden: The authenticated user does not have permission to access the requested resource.
  • 404 Not Found: The requested resource was not found.
  • 500 Internal Server Error: An unexpected error the server.

Management Commands

populate_sample_data.py

  • Use this command to populate the database with sample data.
  • Run: python manage.py populate_sample_data

clear_data.py

  • Use this command to clear the database and remove all existing data.
  • Run: python manage.py clear_data

Contributing

If you would like to contribute to the development of the projecto API, follow these steps:

  1. Fork the repository on GitHub.
  2. Create a new branch for your feature or bug fix: git checkout -b feature/your-feature-name or git checkout -b bugfix/your-bug-fix-name.
  3. Make your changes and commit them: git commit -m "Your commit message".
  4. Push your changes to your forked repository: git push origin feature/your-feature-name or git push origin bugfix/your-bug-fix-name.
  5. Submit a pull request on GitHub.

Please make sure to follow the existing code style and include tests for your changes.

Contact

If you have any questions or need further assistance, please contact us at [[email protected]].

Thank you for using the Projecto API!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages