Skip to content

Commit

Permalink
Minor graphical updates and add datefield for backdating posts (#401)
Browse files Browse the repository at this point in the history
* minor graphical updates and add datefield for backdating posts

* blacken files and fix dep problem

* Bump version number

* date in form should be optional

* oh look more formatting changes that aren't relevant to what I'm working on AT ALL

Co-authored-by: itsthejoker <itsthejoker@users.noreply.github.com>
  • Loading branch information
itsthejoker and itsthejoker committed Apr 19, 2022
1 parent 0b1d247 commit d438478
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 155 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on: [pull_request]

jobs:
build:
environment: Default
runs-on: ubuntu-18.04
strategy:
max-parallel: 4
Expand Down
22 changes: 16 additions & 6 deletions blossom/middleware.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import sys
from typing import Callable

from better_exceptions import excepthook
from django.http import HttpRequest, HttpResponse


# For debug purposes only. Link to local_settings by adding
# `blossom.middleware.BetterExceptionsMiddleware`
# to the top of the middleware stack.
class BetterExceptionsMiddleware(object):
def __init__(self, get_response):
def __init__(self, get_response: Callable) -> None:
"""
For debug purposes only.
Link to local_settings by adding
`blossom.middleware.BetterExceptionsMiddleware`
to the top of the middleware stack.
"""
self.get_response = get_response

def __call__(self, request):
def __call__(self, request: HttpRequest) -> HttpResponse:
"""Override call functionality."""
return self.get_response(request)

def process_exception(self, request, exception):
def process_exception(self, request: HttpRequest, exception: Exception) -> None:
"""Allow BetterExceptions to hook into the running process."""
excepthook(exception.__class__, exception, sys.exc_info()[2])
return None
6 changes: 5 additions & 1 deletion blossom/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {"console": {"class": "logging.StreamHandler",},}, # noqa: E231
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
}, # noqa: E231
"loggers": {
"django": {
"handlers": ["console"],
Expand Down
10 changes: 8 additions & 2 deletions blossom/settings/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
)

CACHES = {
"default": {"BACKEND": "django.core.cache.backends.dummy.DummyCache",} # noqa: E231
"default": {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
} # noqa: E231
}

DATABASES = {
Expand All @@ -27,7 +29,11 @@
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {"console": {"class": "logging.StreamHandler",},}, # noqa: E231
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
}, # noqa: E231
"loggers": {
"django": {
"handlers": ["console"],
Expand Down
5 changes: 4 additions & 1 deletion blossom/strings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""The place where all of our user-facing strings live."""

import os

import toml
from django.conf import settings


def translation(lang='en_US'):
def translation(lang: str = "en_US") -> dict:
"""Load and provide the strings file."""
with open(os.path.join(settings.BASE_DIR, "strings", f"{lang}.toml"), "r") as f:
return toml.loads(f.read())
26 changes: 26 additions & 0 deletions blossom/templates/website/generic_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
{% load string_helpers %}

{% block content %}
<!-- Popperjs -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.2/dist/umd/popper.min.js"
crossorigin="anonymous"></script>
<!-- Tempus Dominus JavaScript -->
<script src="https://cdn.jsdelivr.net/gh/Eonasdan/tempus-dominus@master/dist/js/tempus-dominus.js"
crossorigin="anonymous"></script>

<!-- Tempus Dominus Styles -->
<link href="https://cdn.jsdelivr.net/gh/Eonasdan/tempus-dominus@master/dist/css/tempus-dominus.css"
rel="stylesheet" crossorigin="anonymous">
<div class="container mt-4">
{% if slim_form %}
<div class="row">
Expand Down Expand Up @@ -232,6 +242,22 @@ <h4>{{ subheader }}</h4>
}
});
})
new tempusDominus.TempusDominus(document.getElementById('id_date'), {
display: {
components: {
calendar: true,
date: true,
month: true,
year: true,
decades: true,
clock: true,
hours: true,
minutes: true,
seconds: false,
useTwentyfourHour: false,
}
}
});
</script>

{% if enable_trumbowyg %}
Expand Down
2 changes: 1 addition & 1 deletion blossom/templates/website/partials/footer.partial
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>
<div class="col-xs-0 col-sm-4"></div>
<div class="col-xs-12 col-sm-4">
<span class="text-muted">Disclaimer:<br>Grafeas Group, Ltd. is a registered 501(c)(3) nonprofit in the state of Indiana, U.S.A. Continued use of content associated with Grafeas Group indicates acceptance of our <a
<span class="text-muted">Grafeas Group, Ltd. is recognized by the IRS as a 501(c)(3) tax-exempt charity. Continued use of content associated with Grafeas Group indicates acceptance of our <a
href="{{ tos.get_absolute_url }}" class="real-link text-muted">terms of service.</a></span>
</div>
</div>
Expand Down
Loading

0 comments on commit d438478

Please sign in to comment.