- Updated LanguageMiddleware and UserIdentityMiddleware to always set cookies for language and user ID, respectively, removing conditional checks for existing cookies. This streamlines the cookie management process and ensures consistent behavior across sessions.
- Enhanced the download_scale_results function to include a Content-Disposition header, specifying the filename for the "psychoscales.db" file download. This improves the user experience by prompting the correct file name during downloads.
- Updated the download_scale_results function to return additional cache control headers for the "psychoscales.db" file download, improving client-side caching behavior.
- Ensured consistent response headers for CSV file downloads, enhancing the overall file handling experience.
- Added UserIdentityMiddleware to manage user sessions by generating a unique user ID stored in a cookie.
- Implemented logic to update the last seen timestamp for existing users in the database.
- Enhanced ScaleResult model to associate responses with users, improving data tracking and user experience.
- Updated LanguageMiddleware in app.py to retrieve the user's language preference from cookies if not provided in query parameters.
- Added logic to set a cookie for the language, ensuring consistent language detection and user experience across sessions.
- Updated scale and result endpoints in app.py to consistently call load_all_scales with the language parameter, improving code clarity and maintaining uniformity in scale data retrieval.
- Updated scale and result endpoints in app.py to call load_all_scales without the language parameter, streamlining the function usage.
- This change enhances code clarity and maintains consistency in scale data retrieval.
- Updated app.py to load the README content from language-specific markdown files located in the templates directory.
- Added new index.md files for English and Chinese, providing localized information about PsychoScales.Org and its resources.
- Updated load_all_scales to accept an optional language parameter, allowing for the loading of scales based on the specified language.
- Modified calls to load_all_scales in various endpoints to pass the user's detected language, ensuring consistent language handling across the application.
- Updated app.py to dynamically load Jinja2 templates based on the detected language.
- Created new template files for English and Chinese, including base, index, list, scale, and result pages.
- Modified template rendering logic to utilize the appropriate language-specific templates based on user preferences.
- Implemented LanguageMiddleware to determine the user's language based on query parameters, Accept-Language header, or IP address.
- Updated the FastAPI app to include the middleware and pass the detected language to templates.
- Modified base.html to dynamically set the HTML language attribute based on the detected language.
- Modified the sitemap generation logic in app.py to prepend 'www.' to the base URL for static routes, tag routes, and scale routes.
- This change ensures consistency in URL formatting and improves SEO by standardizing the domain used in the sitemap.
- Changed the scale ID check in the download_scale_results function from "database" to "psychoscales.db" for improved clarity and accuracy in file retrieval.
- This adjustment ensures the correct database file is accessed when downloading scale results.
- Updated the download_scale_results function to eliminate the token parameter, simplifying the endpoint's signature.
- This change enhances clarity and aligns with the current requirements for accessing scale results.
- Implemented a new endpoint to download scale results as a CSV file.
- The endpoint retrieves responses based on the scale ID and formats the data, including question IDs and subscale scores, into a CSV format.
- Updated database URL to remove the public directory reference for better file access.
- Moved the public_path assignment to ensure it is set before checking for the file's existence.
- This change resolves potential issues when accessing files in the public directory.
- Introduced created_at field in the ScaleResult model to track response creation time.
- Updated result handling logic in app.py to populate created_at with the current UTC time when saving responses.
- Updated the database model from RawResponse to ScaleResult to better reflect its purpose.
- Adjusted the result handling logic in app.py to utilize the new ScaleResult model for storing user responses.
- Renamed RawResponse model to Response for clarity.
- Changed location field type from String to JSON in the Response model.
- Updated result handling logic to store location as a JSON object instead of a string.