-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: Minor style adjustments to context processors
- Loading branch information
Showing
2 changed files
with
13 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
"""Context for template""" | ||
"""Context processors to add data to template context.""" | ||
from django.contrib.sites.models import Site | ||
from django.utils import timezone | ||
|
||
from constance import config | ||
|
||
|
||
def site(request): # pylint: disable=unused-argument | ||
# type: (...) -> dict | ||
"""Return the site.""" | ||
return { | ||
'site': Site.objects.get_current() | ||
} | ||
|
||
|
||
def organisation(request): # pylint: disable=unused-argument | ||
# type: (...) -> dict | ||
"""Return the organisation.""" | ||
return { | ||
'organisation_name': config.ORGANISATION_NAME, | ||
'organisation_website': config.ORGANISATION_WEBSITE, | ||
} | ||
|
||
|
||
def maintenance(request): # pylint: disable=unused-argument | ||
"""Return true if default maintancance time.""" | ||
# type: (...) -> dict | ||
"""Return whether current time is within scheduled maintenance period.""" | ||
now = timezone.now() | ||
|
||
if now.weekday() == config.MAINTENANCE_DAY and now.hour == config.MAINTENANCE_HOUR: | ||
return {"is_maintenance_time": True} | ||
|
||
return {"is_maintenance_time": False} | ||
return { | ||
'is_maintenance_time': now.weekday() == config.MAINTENANCE_DAY and now.hour == config.MAINTENANCE_HOUR | ||
} |