continue migration: make website working

This commit is contained in:
bkfox
2019-08-05 23:45:20 +02:00
parent 432467ec8d
commit 324cf2ef0f
54 changed files with 8658 additions and 115 deletions

View File

@ -2,6 +2,23 @@ import datetime
import django.utils.timezone as tz
__all__ = ['Redirect', 'redirect', 'date_range', 'cast_date',
'date_or_default', 'to_timedelta', 'seconds_to_time']
class Redirect(Exception):
""" Redirect exception -- see `redirect()`. """
def __init__(self, url):
self.url = url
def redirect(url):
"""
Raise a Redirect exception in order to response a redirection to client.
AircoxMiddleware must be enabled. """
raise Redirect(url)
def date_range(date, delta=None, **delta_kwargs):
"""
Return a range of provided date such as `[date-delta, date+delta]`.
@ -53,6 +70,11 @@ def to_timedelta(time):
)
def to_seconds(time):
""" Return total seconds for provided time """
return 3600 * time.hour + 60 * time.minute + time.second
def seconds_to_time(seconds):
"""
Seconds to datetime.time