-
Notifications
You must be signed in to change notification settings - Fork 4
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
Django4 timezones: Enable & migrate ikhaya article model to DateTime field #1379
Merged
Conversation
This file contains 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
Prevent to make aware timezone objecs naive.
``` /inyoka/inyoka/markup/macros.py:295: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC). self.date = datetime.utcfromtimestamp(int(date)) ```
an example ``` inyoka/tests/apps/forum/test_views.py:1824: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). now_utc = datetime.datetime.utcnow().replace(tzinfo=zoneinfo.ZoneInfo("UTC"), microsecond=0) ```
`Now()` seems not to work for dates
Explicitly, use `as_div` to remove warning, even if it is the new default. Warning was ``` inyoka/portal/jinja2/portal/user_edit_groups.html:57: RemovedInDjango50Warning: The "default.html" templates for forms and formsets will be removed. These were proxies to the equivalent "table.html" templates, but the new "div.html" templates will be the default from Django 5.0. Transitional renderers are provided to allow you to opt-in to the new output style now. See https://docs.djangoproject.com/en/4.2/releases/4.1/ for more details ```
Test that very old topcis/posts are not shown.
It is already enforced by the ORM. If these fields are NULL, an IntegrityError is raised.
Slugs are always in UTC. Even if the articles display a date of the next day in localtime. Examples from production: https://ikhaya.ubuntuusers.de/2006/11/20/eine-kleine-geschichte-ueber-fremde-paketquellen/ https://ikhaya.ubuntuusers.de/2006/06/24/das-webteam-sucht-verstaerkung/ https://ikhaya.ubuntuusers.de/2013/07/30/ubuntuforums-org-wieder-verfuegbar/ https://ikhaya.ubuntuusers.de/2022/09/05/ubuntu-wochenrueckblick-2022-35/ https://ikhaya.ubuntuusers.de/2023/08/28/ubuntu-wochenrueckblick-2023-34/ found with the code snippet ``` for a in Article.objects.all(): utc_dt = datetime.combine(a.pub_date, a.pub_time, timezone.utc) local_dt = utc_dt.astimezone() if utc_dt.date() != local_dt.date(): print(a.id, a.subject, ' ', utc_dt, local_dt) ```
Before, a 404 was raised.
- define used form fields and their order in python - style `.helptext` like `.notes` (latter is used for 'old style' forms for the helptext)
…leForm` The old way lacked a little corner case, when the date in UTC vs local time was different. Found via the new written tests for the `EditArticleForm`.
Ideally, `Article.save` could also use this. However, `find_next_increment` does not allow annotations. Tests are added to document the behaviour.
The view `detail` uses UTC dates.
Saves a DB query. For anonymous user the status will be always False.
Only is a hidden performance overhead. All other locations define an `order_by()` itself.
Fieldsets are used by django rendered forms. See for example - edit an ikhaya article (like http://ikhaya.ubuntuusers.local:8080/2025/01/02/c/edit/) - http://ubuntuusers.local:8080/user/user/edit/groups/
The margins uses an similar spacing like paragraphs. Also the specific margin on usercp forms were removed The following were checked inyoka/portal/jinja2/portal/group_edit.html inyoka/portal/jinja2/portal/group_edit_global_permissions.html inyoka/portal/jinja2/portal/user_edit_groups.html inyoka/portal/jinja2/portal/usercp/profile.html inyoka/portal/jinja2/portal/usercp/settings.html inyoka/portal/jinja2/portal/usercp/subscriptions.html
The forms were the classes were added used a lot of bold.
``` python manage.py squashmigrations ikhaya 0011 0018 --squashed-name article_publication_datetime ``` Old migration files were removed, as no instance should be in in-between state.
Otherwise, the second more likely changes until an answer from the server and parsing the feed was done
chris34
added a commit
to chris34/theme-ubuntuusers-pub
that referenced
this pull request
Jan 12, 2025
chris34
added a commit
to inyokaproject/theme-ubuntuusers
that referenced
this pull request
Jan 19, 2025
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.
see
CHANGELOG
for the points that were changed along the waybased on #1309