-
Notifications
You must be signed in to change notification settings - Fork 137
fix(event): set event end date by default #1126
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @Gagan-Ram, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where event end dates (date_to) were not being automatically set when only a start date (date_from) was provided. The fix ensures that if an event has a start date but no end date, the end date defaults to 24 hours after the start date.
Key changes:
- Added automatic
date_tocalculation in thesave()method whendate_tois missing butdate_fromexists - Applied the fix to two different model classes in the event.py file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hongquan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect to see DB migration to change date_to to non-nullable.
16d6bf0 to
ebf976a
Compare
ebf976a to
3086c72
Compare
|
This PR requires us to drop all tables of our database. Then in the PostgreSQL prompt: |
|
You should do it in one of these two ways:
Your current implement is bad because it modifies an existing DB migration file. The 1st option is Ok for us because we don't serve any real event yet. |
Thank you, this is what I was looking for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mariobehling wants to have a production system running end of this week.
We should have a fresh DB. Please delete all DB migration files and recreate from 0001. We don't have many chances to do clean up of DB migration files.
|
|
||
| def fill_date_to(apps, _schema_editor): | ||
| Event = apps.get_model('base', 'Event') | ||
| for event in Event.objects.filter(date_to__isnull=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of calling .save() in a for loop, you can just use Event.objects.update() with F(). It runs faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
|
@Sak1012 We need to drop all tables of our database because of newly created migration files Then in the PostgreSQL prompt: |
fixes: #1113