Closed Juknum closed 2 years ago
In GitLab by @tleb on Apr 17, 2020, 22:40
An aside: is core/templates/core/poster_list.jinja ever used? A global search brings up nothing. It seems like a duplicate (not exactly the same though) to com/templates/com/poster_list.jinja.
In GitLab by @tleb on Apr 18, 2020, 08:56
added 1 commit
In GitLab by @tleb on Apr 18, 2020, 13:18
fixes #102
In GitLab by @sli on Apr 20, 2020, 18:29
Really nice job ! I was thinking, since we are making a wrapper in core, why also not harmonizing the input format so we don't have this wierd copy and paste all over the codebase :)
In GitLab by @tleb on Apr 21, 2020, 08:47
added 1 commit
In GitLab by @tleb on Apr 21, 2020, 08:49
Done! I did it through default values in the constructor.
In GitLab by @tleb on Apr 21, 2020, 09:00
added 1 commit
In GitLab by @sli on Apr 21, 2020, 17:57
Commented on core/views/forms.py line 409
You can also do
def __init__(self, input_formats=["format"], widget=SelectDateTime, **kwargs):
In GitLab by @sli on Apr 21, 2020, 17:58
Except for my last comment, really nice job, if you could rename your commit to match our pseudo naming convention that would be nice (module_touched1/module_touched2: change).
In GitLab by @sli on Apr 22, 2020, 23:16
Moved to https://ae-dev.utbm.fr/ae/Sith/-/merge_requests/270
In GitLab by @sli on Apr 22, 2020, 23:16
closed
In GitLab by @skia on Sep 29, 2021, 15:53
mentioned in commit 007157e2e8aae7b2313614a65805b27090e6dffd
In GitLab by @tleb on Apr 17, 2020, 22:38
Merges datetime-hell -> master
The broken behaviour that was previously observed and that this MR tries to fix:
/com/news/create
with start date2020-04-17 20:00:00
and end date2020-04-17 22:00:00
./com/news/admin
it gets displayed correctly./com/news/:id/edit
it show2020-04-17 18:00:00
and2020-04-17 20:00:00
as start and end dates (assuming the current timezone is UTC+2).Timezone issue! What I understood from a (loooooong) debugging session (and django's doc) is that the database stores the datetime as UTC (
2020-04-17 18:00:00
in our case). When it is displayed in a template, we use thelocaltime
filter to adjust to the current timezone. However, aforms.DateTimeField
is passed the datetime to display as a string. It was initially displayed as is (coming from the database) and therefore the UTC value was displayed. To solve this, the value which comes from the database must be parsed into a datetime to adjust the timezone.It is done in three steps in the
prepare_value(self, value)
method which is used to prepare the database value to be displayed in the form (this MR changes nothing for the form validation and database insertion steps):django.utils.dateparse.parse_datetime(string_dt)
, which returns a naive datetime storing the UTC time.django.utils.timezone.make_aware(naive_dt, timezone.utc)
which turns the naive datetime into an aware datetime which is "located" in UTC.django.forms.utils.to_current_timezone(aware_dt)
which turns an aware datetime into a naive datetime with the datetime which corresponds in the current timezone.Example usage:
It is then turned back into a string to be displayed. It's important because otherwise it is automatically converted using the locale and on my PC it becomes
17/04/2020 20:00:00
(I'd say it's django's settings and not GNU/Linux's locale setting because mine isen_US.UTF-8
) and the front-end doesn't support this format (the backend neither btw).It's a WIP because I would like to have opinions on the approach and it needs to be tested by other people! An exhaustive list of pages this MR concerns:
/club/:id/sellings
: the sellings page of a club (id=1 for the AE club)./com/news/create
: the news creation page./com/news/:id/edit
: the news edit page (create on on/com/news/create
then test editing it)./counter/admin/cash_summary/list
: by default there is nothing in local (but there is something on the prod). I don't know what needs to be done to have something in local./election/add
: the election creation page./election/:id/edit
: the election edit page (id=1 is populated)./subscription/stats
: the subscription statistics page./subscription
: the subscription creation page.I await (async hehe) your reviews. :)