-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1798] Updated document list element
- Added date - Added 'new' indicator to documents created no more than 24h in the past
- Loading branch information
Showing
12 changed files
with
133 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#documents { | ||
justify-content: left; | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
Utility functions/classes related to (date-)times | ||
""" | ||
|
||
import datetime as dt | ||
from typing import Sequence | ||
|
||
from django.utils import timezone | ||
|
||
|
||
def is_fresh(instance: object, attribute_name: str, delta: dt.timedelta) -> bool: | ||
""" | ||
Return `True` if `instance` is "fresh", `False` otherwise | ||
An object is fresh iff it has an attribute named `$attribute_name` | ||
which has been set no earlier than some point in the past calculated | ||
on the basis of `delta`. | ||
""" | ||
fresh = False | ||
|
||
date_time = getattr(instance, attribute_name, None) | ||
|
||
if not date_time: | ||
return False | ||
try: | ||
fresh = (timezone.now() - date_time) <= delta | ||
except TypeError: # instance has naive datetime | ||
fresh = (dt.datetime.now() - date_time) <= delta | ||
|
||
return fresh | ||
|
||
|
||
def has_fresh_elements( | ||
collection: Sequence, attribute_name: str, delta: dt.timedelta | ||
) -> bool: | ||
""" | ||
Return `True` if `collection` has at least one "fresh" element, `False` | ||
otherwise | ||
""" | ||
return any(is_fresh(elem, attribute_name, delta) for elem in collection) |