Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
f30f91b4
Unverified
Commit
f30f91b4
authored
Apr 02, 2017
by
Joost Rijneveld
Browse files
announcements: bound on datetime instead of date
parent
0e21c0e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
website/announcements/migrations/0002_auto_20170402_1339.py
0 → 100644
View file @
f30f91b4
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-04-02 11:39
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.utils.timezone
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'announcements'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'announcement'
,
name
=
'since'
,
field
=
models
.
DateTimeField
(
default
=
django
.
utils
.
timezone
.
now
,
help_text
=
'Hide this announcement before this time.'
,
verbose_name
=
'Display since'
),
),
migrations
.
AlterField
(
model_name
=
'announcement'
,
name
=
'until'
,
field
=
models
.
DateTimeField
(
blank
=
True
,
help_text
=
'Hide this announcement after this time.'
,
null
=
True
,
verbose_name
=
'Display until'
),
),
]
website/announcements/models.py
View file @
f30f91b4
...
...
@@ -14,13 +14,13 @@ class Announcement(models.Model, metaclass=ModelTranslateMeta):
max_length
=
500
,
)
since
=
models
.
DateField
(
since
=
models
.
Date
Time
Field
(
verbose_name
=
_
(
'Display since'
),
help_text
=
_
(
"Hide this announcement before this time."
),
default
=
timezone
.
now
,
)
until
=
models
.
DateField
(
until
=
models
.
Date
Time
Field
(
verbose_name
=
_
(
'Display until'
),
help_text
=
_
(
"Hide this announcement after this time."
),
blank
=
True
,
...
...
@@ -47,5 +47,5 @@ class Announcement(models.Model, metaclass=ModelTranslateMeta):
@
property
def
is_visible
(
self
):
"""Is this announcement currently visible"""
return
((
self
.
until
is
None
or
self
.
until
>
timezone
.
now
()
.
date
()
)
and
(
self
.
since
is
None
or
self
.
since
<=
timezone
.
now
()
.
date
()
))
return
((
self
.
until
is
None
or
self
.
until
>
timezone
.
now
())
and
(
self
.
since
is
None
or
self
.
since
<=
timezone
.
now
()))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment