FIX: some localtime issues.
This commit is contained in:
@@ -30,5 +30,5 @@ class EventFlag(models.Model):
|
||||
s = '{status} - {timestamp}'
|
||||
if self.user:
|
||||
s += ' by user {user}'
|
||||
return s.format(status=self.status, timestamp=self.timestamp.strftime('%d.%m.%Y %H:%M:%S'),
|
||||
return s.format(status=self.status, timestamp=self.timestamp.strftime('%d.%m.%Y %H:%M:%S %Z'),
|
||||
user=self.user)
|
||||
|
||||
@@ -85,7 +85,7 @@ class OneClickAction(models.Model):
|
||||
' von %(user)s'
|
||||
' auf \'%(status)s\' gesetzt.') % {
|
||||
'status': flag.status.label,
|
||||
'date': flag.timestamp.strftime('%d.%m.%Y %H:%M:%S'),
|
||||
'date': timezone.localtime(flag.timestamp).strftime('%d.%m.%Y %H:%M:%S'),
|
||||
'user': flag.user.get_full_name(),
|
||||
})
|
||||
else:
|
||||
|
||||
@@ -95,8 +95,8 @@ class Registration(models.Model):
|
||||
eventnumber=self.event.get_number(),
|
||||
name=self.get_full_name(),
|
||||
registration_id=self.hexstr,
|
||||
created=self.created_at.strftime('%d.%m.%Y %H:%M'),
|
||||
purge=self.purge_at.strftime('%d.%m.%Y %H:%M')
|
||||
created=self.created_at.strftime('%d.%m.%Y %H:%M %Z'),
|
||||
purge=self.purge_at.strftime('%d.%m.%Y %H:%M %Z')
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
||||
@@ -4,6 +4,7 @@ from babel.dates import format_datetime
|
||||
from django.apps import apps
|
||||
from django.core import mail as django_mail
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import get_language
|
||||
|
||||
from dav_base.tests.generic import EmailTestMixin
|
||||
@@ -131,8 +132,10 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
||||
trainer_full_name=trainer.get_full_name(),
|
||||
trainer_first_name=trainer.first_name,
|
||||
registration_hexstr=registration.hexstr,
|
||||
registration_at=format_datetime(registration.created_at, 'EEEE, dd. MMMM yyyy, H:mm', locale=locale),
|
||||
purge_at=format_datetime(registration.purge_at, 'EEEE, dd. MMMM yyyy', locale=locale),
|
||||
registration_at=format_datetime(timezone.localtime(registration.created_at),
|
||||
'EEEE, dd. MMMM yyyy, H:mm', locale=locale),
|
||||
purge_at=format_datetime(timezone.localtime(registration.purge_at),
|
||||
'EEEE, dd. MMMM yyyy', locale=locale),
|
||||
)
|
||||
self.assertBody(mail, body)
|
||||
|
||||
@@ -226,8 +229,10 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
||||
event_formated_date=event.get_formated_date(),
|
||||
trainer_first_name=trainer.first_name,
|
||||
registration_hexstr=registration.hexstr,
|
||||
registration_at=format_datetime(registration.created_at, 'EEEE, dd. MMMM yyyy, H:mm', locale=locale),
|
||||
purge_at=format_datetime(registration.purge_at, 'EEEE, dd. MMMM yyyy', locale=locale),
|
||||
registration_at=format_datetime(timezone.localtime(registration.created_at),
|
||||
'EEEE, dd. MMMM yyyy, H:mm', locale=locale),
|
||||
purge_at=format_datetime(timezone.localtime(registration.purge_at),
|
||||
'EEEE, dd. MMMM yyyy', locale=locale),
|
||||
)
|
||||
self.assertBody(mail, body)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from django.apps import apps
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views import generic
|
||||
|
||||
@@ -68,7 +69,7 @@ class UploadView(generic.edit.FormView):
|
||||
base_path = app_config.settings.upload_path
|
||||
|
||||
subdir_format_str = u'{datetime}--{title}'
|
||||
now = datetime.datetime.now()
|
||||
now = timezone.now()
|
||||
subdir_format_kwargs = {'datetime': now.strftime('%Y-%m-%d--%H%M%S'),
|
||||
'date': now.strftime('%Y-%m-%d'),
|
||||
'time': now.strftime('%H-%M-%S'),
|
||||
@@ -95,8 +96,8 @@ Beschreibung:
|
||||
{description}
|
||||
"""
|
||||
metadata_format_kwargs = {
|
||||
'date': now.strftime('%d.%m.%Y'),
|
||||
'time': now.strftime('%H:%M:%S'),
|
||||
'date': timezone.localtime(now).strftime('%d.%m.%Y'),
|
||||
'time': timezone.localtime(now).strftime('%H:%M:%S %Z'),
|
||||
'name': form.cleaned_data['name'],
|
||||
'email_address': form.cleaned_data['email_address'],
|
||||
'group': form.cleaned_data['group'],
|
||||
|
||||
Reference in New Issue
Block a user