From 10103c1ab8a1cdc3c89bcfed833de61cf0aef20d Mon Sep 17 00:00:00 2001 From: Ching Date: Tue, 9 Jul 2019 17:16:57 +0800 Subject: [PATCH] [A] added base.html for timer --- timer/models.py | 2 +- timer/templates/base.html | 7 +++++++ timer/templates/index.html | 29 ++++++++++++++++++++--------- timer/views.py | 1 - 4 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 timer/templates/base.html diff --git a/timer/models.py b/timer/models.py index e65e786..9a3a91a 100644 --- a/timer/models.py +++ b/timer/models.py @@ -24,4 +24,4 @@ class OfficeHours(models.Model): @property def get_ends_at_str(self): - return localtime(self.ends_at).strftime('%Y-%m-%d %H:%M') + return localtime(self.ends_at).strftime('%H:%M') diff --git a/timer/templates/base.html b/timer/templates/base.html new file mode 100644 index 0000000..6079024 --- /dev/null +++ b/timer/templates/base.html @@ -0,0 +1,7 @@ + + + + + {% block content %} + {% endblock %} + diff --git a/timer/templates/index.html b/timer/templates/index.html index 514b8f1..0fcdec9 100644 --- a/timer/templates/index.html +++ b/timer/templates/index.html @@ -1,9 +1,20 @@ - - - - Office Hour - - -

office hour ends at: {{ today_oh.get_ends_at_str }}

- - +{% extends 'base.html' %} +{% block content %} +Office Hour +
+

office hour ends at:

+

{{ today_oh.get_ends_at_str }}

+
+ +
+ {% csrf_token %} + {% for f in form %} +
+ + +
+ {% endfor %} +
+{% endblock content %} diff --git a/timer/views.py b/timer/views.py index 36491f5..7a2bfc8 100644 --- a/timer/views.py +++ b/timer/views.py @@ -22,7 +22,6 @@ class OfficeHoursAPI(CreateAPIView): permission_classes = (permissions.IsAuthenticated,) queryset = timer.models.OfficeHours.objects.all() - # serializer_class = timer.serializers.GroupSerializer def create(self, request, *args, **kwargs): begins_at = request.data.get('begins_at')