-
Notifications
You must be signed in to change notification settings - Fork 9
Upgrade Python from 3.8 to 3.12 #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
tobiascadee
wants to merge
11
commits into
VOKO-Utrecht:master
from
tobiascadee:tobias/update-python-to-3.12
Closed
Upgrade Python from 3.8 to 3.12 #390
tobiascadee
wants to merge
11
commits into
VOKO-Utrecht:master
from
tobiascadee:tobias/update-python-to-3.12
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This feature automatically creates new order rounds based on a configurable schedule, eliminating the need for manual creation every other Sunday. ## How It Works The system uses a cron job that runs every 6 hours to check if a new order round should be created. When the conditions are met, it automatically creates a new order round with all the proper dates calculated based on your configuration. ## Configuration All settings are managed through the Django admin interface under **Constance Config**: ### Core Settings - **AUTO_CREATE_ORDERROUNDS**: Enable/disable the automation (default: False) - **ORDERROUND_INTERVAL_WEEKS**: How often to create new rounds (default: 2 weeks) - **ORDERROUND_CREATE_DAYS_AHEAD**: How far in advance to create rounds (default: 7 days) ### Timing Settings - **ORDERROUND_OPEN_HOUR**: Hour when order rounds open, 24h format (default: 12) - **ORDERROUND_CLOSE_HOUR**: Hour when order rounds close, 24h format (default: 3) - **ORDERROUND_DURATION_HOURS**: How long order rounds stay open (default: 63 hours) - **ORDERROUND_COLLECT_DAYS_AFTER**: Days after closing when products can be collected (default: 0) - **ORDERROUND_COLLECT_HOUR**: Hour when products can be collected (default: 18) ### Coordinator Settings - **ORDERROUND_DEFAULT_TRANSPORT_COORDINATOR**: Default transport coordinator user ID (default: 986) - **ORDERROUND_DEFAULT_PICKUP_LOCATION**: Default pickup location ID (default: 1) ## Setup Instructions 1. **Enable the feature**: - Go to Django Admin → Constance Config - Set `AUTO_CREATE_ORDERROUNDS` to `True` 2. **Configure your schedule**: - Adjust the timing settings to match your current manual schedule - Current defaults: Opens Sunday at 12:00, closes Wednesday at 03:00, collect Wednesday at 18:00 - Transport coordinator automatically set to user ID 986 - Pickup location automatically set to location ID 1 3. **Set up cron** (if not already running): - The system uses django-cron which should already be configured - Make sure your deployment runs: `python manage.py runcrons` ## Manual Controls ### Admin Interface - Go to Django Admin → Ordering → Order Rounds - Select any order round and use the action "Create next order round automatically" - This respects your automation settings but bypasses the timing checks ### Management Command ```bash # Create the next order round python manage.py create_orderround # Preview what would be created (dry run) python manage.py create_orderround --dry-run # Force creation even if disabled or not needed python manage.py create_orderround --force ``` ## How Dates Are Calculated The system calculates dates based on: 1. **Next Opening Date**: - If there's a previous round: adds the interval (e.g., 2 weeks) to the last round's opening date - If no previous rounds: uses the next Sunday 2. **Closing Date**: Opening date + duration hours (e.g., 72 hours later) 3. **Collection Date**: Closing date + collection days (e.g., same day if 0 days after) **Example Schedule**: - **Opens**: Sunday at 12:00 (noon) - **Closes**: Wednesday at 03:00 (3 AM) - 63 hours later - **Collect**: Wednesday at 18:00 (6 PM) - same day as closing ## Safety Features - **No Duplicates**: Won't create a round if one already exists within the configured timeframe - **Manual Override**: You can always create rounds manually - automation won't interfere - **Configuration Checks**: Won't create rounds if automation is disabled - **Error Logging**: All creation attempts are logged for troubleshooting ## Monitoring - Check the **Log** section in Django admin for creation events - Use the management command with `--dry-run` to preview upcoming rounds - The cron job prints status messages that appear in your application logs ## Troubleshooting ### Order rounds aren't being created automatically 1. Check that `AUTO_CREATE_ORDERROUNDS` is set to `True` 2. Verify that django-cron is running (`python manage.py runcrons`) 3. Check if there's already a future round within your `ORDERROUND_CREATE_DAYS_AHEAD` setting 4. Look at the application logs for any error messages from the `AutoCreateOrderRounds` cron job ### Dates are wrong 1. Review your timing configuration in Constance Config 2. Use `python manage.py create_orderround --dry-run` to preview the next round 3. Check that your server timezone is set correctly ### Need to disable temporarily 1. Set `AUTO_CREATE_ORDERROUNDS` to `False` in Constance Config 2. The cron job will continue to run but won't create any rounds 3. You can still use manual creation methods ## Migration from Manual Process 1. **Before enabling**: Make sure your current manual schedule matches the configuration 2. **Enable gradually**: Start with `AUTO_CREATE_ORDERROUNDS = False` and test with the management command 3. **Monitor first few rounds**: Check that the automatically created rounds have the correct dates 4. **Keep manual backup**: You can always create rounds manually if needed
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
- Update pyproject.toml to require Python >= 3.12 - Update Dockerfile to use python:3.12-bookworm base image - Update GitHub Actions workflows to use Python 3.12 - Update .python-version file to 3.12 - Remove django-nose and nose dependencies (not compatible with Python 3.12) - Remove django_nose from Django settings and use default test runner - Upgrade factory-boy to 3.3.1 and Faker to 37.5.3 for Python 3.12 compatibility - Regenerate uv.lock file for Python 3.12 dependencies - All tests passing with Python 3.12.11
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR upgrades the project from Python 3.8 to Python 3.12, bringing performance improvements, better error messages, security updates, and access to modern Python features.
Changes Made
Core Configuration
requires-pythonfrom>=3.8to>=3.12python:3.8-bullseyetopython:3.12-bookworm(more secure)3.8to3.12GitHub Actions
Testing Framework Modernization
django-noseandnose(not compatible with Python 3.12 due to removed `imp` module)Dependencies
Testing
Benefits of Python 3.12
This upgrade maintains all existing functionality while providing the benefits of Python 3.12.