diff --git a/judge/widgets/datetime.py b/judge/widgets/datetime.py
index 15bb383..7b95d4e 100644
--- a/judge/widgets/datetime.py
+++ b/judge/widgets/datetime.py
@@ -1,24 +1,19 @@
from django import forms
+from django.templatetags.static import static
+from django.utils.html import format_html
+from django.forms.utils import flatatt
class DateTimePickerWidget(forms.DateTimeInput):
- template_name = "widgets/datetimepicker.html"
+ input_type = "datetime-local"
- def get_context(self, name, value, attrs):
- datetimepicker_id = "datetimepicker_{name}".format(name=name)
- if attrs is None:
- attrs = dict()
- attrs["data-target"] = "#{id}".format(id=datetimepicker_id)
- attrs["class"] = "form-control datetimepicker-input"
- context = super().get_context(name, value, attrs)
- context["widget"]["datetimepicker_id"] = datetimepicker_id
- return context
+ def render(self, name, value, attrs=None, renderer=None):
+ if value is None:
+ value = ""
+ else:
+ value = value.strftime("%Y-%m-%dT%H:%M")
- @property
- def media(self):
- css_url = "/static/datetime-picker/datetimepicker.min.css"
- js_url = "/static/datetime-picker/datetimepicker.full.min.js"
- return forms.Media(
- js=[js_url],
- css={"screen": [css_url]},
+ final_attrs = self.build_attrs(
+ attrs, {"type": self.input_type, "name": name, "value": value}
)
+ return format_html("", flatatt(final_attrs))
diff --git a/resources/blog.scss b/resources/blog.scss
index 265ebb9..ea3ac14 100644
--- a/resources/blog.scss
+++ b/resources/blog.scss
@@ -262,6 +262,13 @@
border-radius: 1em;
}
+.post-content-header {
+ margin-left: 0;
+ display: inline-flex;
+ align-items: center;
+ gap: 0.2em;
+}
+
@media (max-width: 799px) {
.blog-sidebar,
diff --git a/resources/widgets.scss b/resources/widgets.scss
index c52c991..d6400b8 100644
--- a/resources/widgets.scss
+++ b/resources/widgets.scss
@@ -143,7 +143,7 @@
}
input {
- &[type=text], &[type=password], &[type=email], &[type=number] {
+ &[type=text], &[type=password], &[type=email], &[type=number], &[type=datetime-local] {
padding: 4px 8px;
color: #555;
background: #FFF none;
diff --git a/templates/blog/content.html b/templates/blog/content.html
index 04b10f3..6d36fc8 100644
--- a/templates/blog/content.html
+++ b/templates/blog/content.html
@@ -1,7 +1,7 @@
{% for post in posts%}