Commit Graph

94 Commits

Author SHA1 Message Date
Felipe Cardoso
0cf5498762 Refactor storage URL retrieval to use get_uploaded_file_url.
Some checks failed
Build and Push Docker Images / build-frontend (push) Blocked by required conditions
Build and Push Docker Images / changes (push) Successful in 3s
Build and Push Docker Images / build-backend (push) Has been cancelled
Replaced calls to get_file_url with get_uploaded_file_url where appropriate. Added the get_uploaded_file_url method to the StorageProvider class and its implementations for more specific URL generation. Updated corresponding tests and API routes to reflect this change.
2025-03-14 00:05:07 +01:00
Felipe Cardoso
b46533b18f Add operation_id to upload endpoints for improved OpenAPI docs
The `operation_id` field was added to the `generate_presigned_url` and `upload_file` endpoints. This enhances the OpenAPI documentation by providing unique identifiers for better API clarity and client generation.
2025-03-13 07:51:13 +01:00
Felipe Cardoso
03f643895d Add comprehensive test cases for theme creation API
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 50s
Build and Push Docker Images / build-frontend (push) Has been skipped
Implemented various tests to validate the theme creation process, including tests for successful creation, validation failures, image relocation, large data handling, and error scenarios such as database issues. Introduced mock dependencies to simulate behaviors like file relocation and database operations. Ensured all edge cases are covered to improve robustness and reliability.
2025-03-13 07:32:22 +01:00
Felipe Cardoso
0eabd9e5dd Refactor theme creation and update for file management
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 52s
Build and Push Docker Images / build-frontend (push) Has been skipped
Enhanced theme creation and update logic to include proper file organization by relocating and managing URLs for images and assets. Introduced roles validation to restrict access to superusers for these operations. Updated tests to align with the refactored logic and dependencies.
2025-03-12 21:16:49 +01:00
Felipe Cardoso
9fdf8971e3 Add function to relocate theme files in storage
Introduce `_relocate_theme_file` to handle moving files to theme-specific directories in the storage system. This ensures better organization of uploaded files by associating them with a theme ID and file type, improving maintainability and structure.
2025-03-12 21:16:42 +01:00
Felipe Cardoso
2993d0942c Add presigned URL and file upload functionality
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Implemented endpoints for generating presigned URLs and handling file uploads. Added corresponding test cases to ensure proper functionality and error handling. Updated the main router to include the new uploads API.
2025-03-12 18:59:39 +01:00
Felipe Cardoso
e50fdb66df Add schemas for presigned URL requests and responses
Introduced two Pydantic models: `PresignedUrlRequest` and `PresignedUrlResponse`. These define the request and response structures for presigned URL generation, including fields for filenames, content types, and expiration details. This provides a clear contract for handling presigned URL functionality.
2025-03-12 18:59:27 +01:00
Felipe Cardoso
00c5af9cc6 Add file utility functions for filename and path handling
Introduce helper functions to generate unique filenames, create date-based storage paths, and validate image content types. These utilities centralize and streamline file-related operations for consistency and reusability.
2025-03-12 18:59:22 +01:00
Felipe Cardoso
38acdb78a1 Add storage utilities and tests for file handling and tokens
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduced new fixtures and tests for storage functionality, including saving files, generating URLs, and token creation/verification. Refactored `get_storage_provider` into a separate dependency module. Enhanced test coverage for improved reliability.
2025-03-12 18:50:30 +01:00
Felipe Cardoso
9879353ac1 Refactor storage to rename base_dir to upload_folder.
Renamed `base_dir` to `upload_folder` for better clarity and alignment with its purpose. Adjusted references and settings variable to reflect the updated naming convention. This enhances code readability and consistency.
2025-03-12 18:37:16 +01:00
Felipe Cardoso
095aa1e7da Add local storage provider implementation
Introduce an abstract `StorageProvider` class and a
2025-03-12 18:35:51 +01:00
Felipe Cardoso
07f8435fcd Add utility functions for creating and verifying upload tokens
Introduced `create_upload_token` and `verify_upload_token` functions to handle secure file uploads. These utilities generate signed tokens with expiration and content validation, ensuring upload security. Verification includes signature integrity and expiration checks.
2025-03-12 18:35:47 +01:00
Felipe Cardoso
e27e2b75ee Update config structure and enhance file handling
Renamed API_V1_STR to API_VERSION_STR for consistency. Introduced 'UPLOAD_FOLDER' and ensured its creation, added logging for the data directory path, and implemented allowed image content type validation. Adjusted related references in `main.py`.
2025-03-12 18:35:42 +01:00
Felipe Cardoso
5ad886a53e Add support for serving static files from DATA_FILES_DIR
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 53s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduce a new environment variable, `DATA_FILES_DIR`, for configuring static file storage. Updated `docker-compose` files to mount the host directory and propagate the variable. Implemented FastAPI `StaticFiles` to serve files from this directory under the `/files` route.
2025-03-12 18:23:42 +01:00
Felipe Cardoso
288e09202d Add background and foreground image URLs to event themes
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 50s
Build and Push Docker Images / build-frontend (push) Has been skipped
Extended the event theme schema to include `background_image_url`
2025-03-12 16:20:12 +01:00
Felipe Cardoso
efb1dfd2a4 Add new fields to event theme model for asset handling
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 50s
Build and Push Docker Images / build-frontend (push) Has been skipped
Added `background_image_url`, `foreground_image_url`, and `asset_image_urls` fields to enhance theme customization. Updated `asset_image_urls` to use `MutableDict` with a default empty dictionary and ensured consistency in the model and migration script.
2025-03-12 16:14:07 +01:00
Felipe Cardoso
4b01d6f58f Add delete functionality for event themes
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 50s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduce a new endpoint to delete event themes, supporting both soft and hard deletes. Hard deletes are restricted to superusers, while soft deletes deactivate the theme. Also, improve error handling and user permission checks for this operation.
2025-03-12 15:21:47 +01:00
Felipe Cardoso
525d1b8012 Add is_active field to EventTheme model and test fixture.
The `is_active` field was introduced to the `EventTheme` model to indicate whether a theme is active. The corresponding test fixture in `conftest.py` was updated to include this new field, ensuring consistency in tests. This change enhances flexibility for managing event themes.
2025-03-12 15:21:28 +01:00
Felipe Cardoso
f245145087 Refactor event retrieval and improve test coverage
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Removed redundant code for event retrieval and standardized logic by introducing a unified method for generating event endpoints. Updated tests to align with these changes, adding support for slug-based access and handling finer permission cases. Minor issues with test formatting and comments were also addressed.
2025-03-11 06:47:58 +01:00
Felipe Cardoso
e1145525ff Refactor event access validation and enhance endpoint logic
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 55s
Build and Push Docker Images / build-frontend (push) Has been skipped
Centralized event access validation into a reusable `validate_event_access` function, eliminating duplicated code across endpoints. Updated the logic in `get_event` and `get_event_by_slug` to use this function. Adjusted tests to align with the refactored logic and fixed permission-based response statuses.
2025-03-10 09:18:46 +01:00
Felipe Cardoso
c5915e57b1 Restrict event access and add extensive event tests
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Updated event API to enforce stricter access controls based on user roles, including creators, managers, superusers, and guests. Added robust test cases for creating, fetching, and handling event access scenarios to ensure consistent behavior across endpoints.
2025-03-09 17:37:48 +01:00
Felipe Cardoso
4192911538 Add authentication check to event-related API routes
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 52s
Build and Push Docker Images / build-frontend (push) Has been skipped
Ensure that all event-related endpoints verify the presence of a valid authenticated user before proceeding. Raise a 401 Unauthorized error if authentication credentials are missing or invalid, enhancing the security of API routes.
2025-03-09 16:25:48 +01:00
Felipe Cardoso
c2cdc3c110 Refactor event API and extend authentication utilities
All checks were successful
Build and Push Docker Images / changes (push) Successful in 6s
Build and Push Docker Images / build-backend (push) Successful in 55s
Build and Push Docker Images / build-frontend (push) Has been skipped
Refactored the event API routes to improve error handling, add logging, and provide enhanced response structures with pagination. Updated tests to use new fixtures and include additional authentication utilities to facilitate testing with FastAPI's dependency injection. Also resolved issues with timezone awareness in event schemas.
2025-03-09 16:04:51 +01:00
Felipe Cardoso
fe2bcbd6e7 Add event counting methods and generic pagination schema
Introduce methods to count user, public, and upcoming events to enhance CRUD functionality for events. Additionally, add a `PaginatedResponse` schema to simplify and standardize paginated API responses. These updates support improved data querying and response handling.
2025-03-09 10:56:22 +01:00
Felipe Cardoso
5c73f2720e Add event routes and enhance routing structure
Introduced routes for event management, including CRUD operations and querying by user or public visibility. Updated event themes routes with operation IDs for better documentation. Refactored `api/main.py` to `api/router.py` and integrated events routing into the API.
2025-03-05 18:57:24 +01:00
Felipe Cardoso
4a9a37f507 Add CRUD operations and tests for Event model
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 50s
Build and Push Docker Images / build-frontend (push) Has been skipped
This commit introduces a new CRUDEvent class to manage event-related database operations, including retrieval, creation, updating, and deletion of events. It includes corresponding unit tests to ensure the correctness of these functionalities, updates event schemas for enhanced validation, and refines timezone handling for event dates and deadlines.
2025-03-05 14:58:15 +01:00
Felipe Cardoso
a517df1eab ```
Switch to timezone.utc for event date validation

Replaced ZoneInfo('UTC') with timezone.utc in event date validation to ensure consistency and compatibility with standard libraries. Simplifies datetime handling and avoids potential issues with external dependencies.
```
2025-03-05 14:50:24 +01:00
Felipe Cardoso
0b6f47a602 Add event schema models and corresponding test cases
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 50s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduce Pydantic models for event creation, updates, and responses, including validation for fields such as timezone, event date, and RSVP deadline. Add comprehensive pytest test cases to ensure correct behavior and data validation. This provides a robust foundation for event-related functionalities.
2025-03-05 12:48:25 +01:00
Felipe Cardoso
cbcd04d8e1 Rename schema and test files for consistency
Renamed `event_theme` and `test_user_schema` file paths and imports to follow consistent plural naming conventions. This improves code clarity and aligns file and import naming across the project.
2025-03-05 12:48:18 +01:00
Felipe Cardoso
b384512b9c Add tests for event theme API functionality
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 52s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduces comprehensive tests for creating, listing, updating, and retrieving event themes. Includes scenarios with valid data, invalid data, and pagination to ensure robust API behavior. Adds necessary fixtures to support the new test cases.
2025-03-05 12:42:06 +01:00
Felipe Cardoso
b3a4c45202 Add event themes API routes for CRUD operations
Implemented API endpoints for creating, reading, updating, and listing event themes. Integrated the new routes into the FastAPI application router under the '/event_themes' prefix.
2025-03-05 12:42:00 +01:00
Felipe Cardoso
6884cbbf64 Rename test file to correct singular form for consistency
Updated the filename from `test_user_schemas.py` to `test_user_schema.py` to align with naming conventions. This ensures consistency across the test suite and improves maintainability.
2025-03-05 12:41:51 +01:00
Felipe Cardoso
d65d1f3164 Add tests and validation for EventTheme schema
Introduced extensive test cases to validate `EventTheme` schemas, ensuring proper handling of valid and invalid inputs, optional fields, and partial updates. Enhanced schema validation by adding constraints for `name`, `color_palette`, and `fonts` fields, as well as updating `id` to use `UUID` type for consistency. These changes improve data integrity and increase confidence in schema-related functionality.
2025-03-05 12:41:31 +01:00
Felipe Cardoso
c5478e45b6 Refactor AuthService for better error handling and CRUD usage
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 52s
Build and Push Docker Images / build-frontend (push) Has been skipped
Replaced raw database queries with CRUD operations for consistency and modularity. Enhanced error handling by adding detailed exception messages and logging for failed actions, such as authentication and registration. Updated tests to reflect new exception-based error handling approach.
2025-03-05 12:00:23 +01:00
Felipe Cardoso
658ef1c7c2 Add CRUD operations and tests for EventTheme management
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduced CRUD implementation, schema definitions, and tests for EventTheme. This allows creation, retrieval, updating, deletion, and querying of active event themes. Comprehensive tests ensure functionality works as intended, including edge cases for nonexistent themes.
2025-03-05 11:43:14 +01:00
Felipe Cardoso
b019511a1f Add operation_id to all API route handlers
This commit adds the `operation_id` parameter to all relevant API endpoints in the `auth` routes. These identifiers enhance API documentation and make routes easier to distinguish in tools like Swagger or OpenAPI. No functionality is altered, but these additions improve clarity and maintainability.
2025-03-05 09:16:27 +01:00
Felipe Cardoso
4f06c95eda Refactor tests to remove redundant user validation cases.
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Removed tests for missing `first_name` and `last_name` in `test_user` as database integrity constraints already ensure these validations. This reduces duplication and simplifies the test suite.
2025-03-04 19:11:13 +01:00
Felipe Cardoso
a88ebd40a7 Add database initialization for first superuser setup
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduced a script to create the initial superuser during app startup if none exists. Updated the entrypoint to call this script and added stricter logging for passlib. Adjusted .env.template for a stronger default superuser password.
2025-03-04 18:54:00 +01:00
Felipe Cardoso
67f1dfbd9d Make last_name optional and add default for first_name.
Updated the schemas and models to make `last_name` optional and set a default value of "user" for `first_name`. This change enhances flexibility for user data handling and ensures proper defaults when values are not provided.
2025-03-04 18:53:49 +01:00
Felipe Cardoso
7d9f4ee4b2 Add CRUD operations for users with tests and fixtures
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 54s
Build and Push Docker Images / build-frontend (push) Has been skipped
Implemented user CRUD operations including creation, retrieval, updating, and deletion through a generic CRUD base class. Enhanced user schemas with additional attributes and created tests to verify functionality, covering edge cases such as duplicates and pagination. Updated the test suite with new fixtures and methods to support the tests.
2025-03-04 18:33:33 +01:00
Felipe Cardoso
c6fe040f21 Add authentication routes and tests for API
Some checks failed
Build and Push Docker Images / build-frontend (push) Blocked by required conditions
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Has been cancelled
Implemented comprehensive authentication endpoints including user registration, login, token refresh, password change, and user info retrieval. Added extensive test cases for these endpoints to ensure functionality and error handling.
2025-03-04 18:33:16 +01:00
Felipe Cardoso
5ddf5cab6d Remove unused token schemas from the backend.
Eliminated redundant token-related schemas to simplify the codebase. These models were not actively utilized and their removal helps improve maintainability and reduce clutter in the project.
2025-03-04 18:08:05 +01:00
Felipe Cardoso
f2851bcb7a Refactor phone number validation and enhance test coverage
All checks were successful
Build and Push Docker Images / changes (push) Successful in 6s
Build and Push Docker Images / build-backend (push) Successful in 54s
Build and Push Docker Images / build-frontend (push) Has been skipped
Improved phone number validation logic with stricter rules and better error messages in `UserBase`. Updated access token expiration to 1 day in config. Added extensive tests for phone number validation, including valid and invalid cases across different formats.
2025-03-04 17:34:15 +01:00
Felipe Cardoso
b6006d5218 Refactor auth dependencies and add comprehensive tests
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 52s
Build and Push Docker Images / build-frontend (push) Has been skipped
Moved `auth` module from `dependencies.py` to `dependencies/auth.py` for better organization. Added extensive unit tests for authentication services and API dependencies to ensure robust verification of users, tokens, and permissions.
2025-03-02 11:08:06 +01:00
Felipe Cardoso
cd92cd9780 Remove token revocation logic and unused dependencies
Eliminated the `RevokedToken` model and associated logic for managing token revocation. Removed unused files, related tests, and outdated dependencies in authentication modules. Simplified token decoding, user validation, and dependency injection by streamlining the flow and enhancing maintainability.
2025-03-02 11:04:12 +01:00
Felipe Cardoso
453016629f Refactor and enhance token decoding error handling
Improved the `decode_token` function to clarify and extend error handling for token validation and decoding. Enhanced error messages for invalid tokens, added checks for missing claims, and ensured clear differentiation of failure scenarios. Updated imports and added a `scope` field to token response for completeness.
2025-02-28 19:05:08 +01:00
Felipe Cardoso
0bc9263d24 Refactor and enhance token decoding error handling
Improved the `decode_token` function to clarify and extend error handling for token validation and decoding. Enhanced error messages for invalid tokens, added checks for missing claims, and ensured clear differentiation of failure scenarios. Updated imports and added a `scope` field to token response for completeness.
2025-02-28 18:12:39 +01:00
Felipe Cardoso
8814dc931f Add token revocation mechanism and support for logout APIs
This commit introduces a system to revoke tokens by storing their `jti` in a new `RevokedToken` model. It includes APIs for logging out (revoking a current token) and logging out from all devices (revoking all tokens). Additionally, token validation now checks revocation status during the decode process.
2025-02-28 17:45:33 +01:00
Felipe Cardoso
aa77752981 Refactor imports and remove unused code in test_security.py
Cleaned up unused imports including `timezone` and `ExpiredSignatureError`. Streamlined the import structure to improve readability and maintainability. These changes do not affect functionality but enhance code clarity.
2025-02-28 17:39:39 +01:00
Felipe Cardoso
af53b52c0c Refactor token creation logic and fix datetime usage
Adjusted `datetime.utcnow` to `datetime.now` for consistency and refactored token creation functions for cleaner structure. Removed duplicated `create_access_token` and `create_refresh_token` definitions by consolidating them into a single location.
2025-02-28 17:32:20 +01:00