From 7e446bcbec7f3dac22a3b3931a060a316edfc198 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Thu, 10 Mar 2022 11:33:06 +0100 Subject: [PATCH] Using bootstrap and better view resolution --- .../templates/container/container_delete.html | 32 +++++ .../templates/container/container_detail.html | 32 +++++ .../container/container_details.html | 4 - .../templates/container/container_edit.html | 32 +++++ .../templates/container/container_index.html | 33 +++++ .../container/container_type_detail.html | 47 ++++++++ .../container/container_type_details.html | 8 -- .../container/container_type_index.html | 21 ++++ container/templates/container/index.html | 24 ---- container/urls.py | 10 +- container/views.py | 46 ++++--- homelog/settings.py | 2 +- homelog/templates/base.html | 113 ++++++++++++++++++ homelog/templates/homelog/about.html | 8 ++ homelog/templates/homelog/home.html | 11 ++ homelog/urls.py | 8 ++ homelog/views.py | 14 +++ static/css/project.css | 13 ++ static/fonts/.gitkeep | 0 static/images/favicons/favicon.ico | Bin 0 -> 8348 bytes static/js/project.js | 1 + static/sass/custom_bootstrap_vars.scss | 0 static/sass/project.scss | 37 ++++++ 23 files changed, 438 insertions(+), 58 deletions(-) create mode 100644 container/templates/container/container_delete.html create mode 100644 container/templates/container/container_detail.html delete mode 100644 container/templates/container/container_details.html create mode 100644 container/templates/container/container_edit.html create mode 100644 container/templates/container/container_index.html create mode 100644 container/templates/container/container_type_detail.html delete mode 100644 container/templates/container/container_type_details.html create mode 100644 container/templates/container/container_type_index.html delete mode 100644 container/templates/container/index.html create mode 100644 homelog/templates/base.html create mode 100644 homelog/templates/homelog/about.html create mode 100644 homelog/templates/homelog/home.html create mode 100644 homelog/views.py create mode 100644 static/css/project.css create mode 100644 static/fonts/.gitkeep create mode 100644 static/images/favicons/favicon.ico create mode 100644 static/js/project.js create mode 100644 static/sass/custom_bootstrap_vars.scss create mode 100644 static/sass/project.scss diff --git a/container/templates/container/container_delete.html b/container/templates/container/container_delete.html new file mode 100644 index 0000000..6908a4a --- /dev/null +++ b/container/templates/container/container_delete.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} +{% load static %} + +{% block title %}Delete Container: {{ object.named_id }}{% endblock %} + +{% block content %} +
+ +
+
+ +

Container: {{ container.named_id }}

+
{{ container.description }}
+
Color: {{ container.color }}
+
Container Type: {{ container.container_type.named_id }}
+
+
+ + +
+ +
+ Edit + Delete +
+ +
+ + +
+{% endblock content %} + diff --git a/container/templates/container/container_detail.html b/container/templates/container/container_detail.html new file mode 100644 index 0000000..ce3ba4b --- /dev/null +++ b/container/templates/container/container_detail.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} +{% load static %} + +{% block title %}Container: {{ container.named_id }}{% endblock %} + +{% block content %} +
+ +
+
+ +

Container: {{ container.named_id }}

+
{{ container.description }}
+
Color: {{ container.color }}
+
Container Type: {{ container.container_type.named_id }}
+
+
+ + +
+ +
+ Edit + Delete +
+ +
+ + +
+{% endblock content %} + diff --git a/container/templates/container/container_details.html b/container/templates/container/container_details.html deleted file mode 100644 index 0b38c24..0000000 --- a/container/templates/container/container_details.html +++ /dev/null @@ -1,4 +0,0 @@ -

Container: {{ container.named_id }}

-
{{ container.description }}
-
Color: {{ container.color }}
-
Container Type: {{ container.container_type.named_id }}
diff --git a/container/templates/container/container_edit.html b/container/templates/container/container_edit.html new file mode 100644 index 0000000..ecf3a9d --- /dev/null +++ b/container/templates/container/container_edit.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} +{% load static %} + +{% block title %}Edit Container: {{ object.named_id }}{% endblock %} + +{% block content %} +
+ +
+
+ +

Container: {{ container.named_id }}

+
{{ container.description }}
+
Color: {{ container.color }}
+
Container Type: {{ container.container_type.named_id }}
+
+
+ + +
+ +
+ Edit + Delete +
+ +
+ + +
+{% endblock content %} + diff --git a/container/templates/container/container_index.html b/container/templates/container/container_index.html new file mode 100644 index 0000000..d61d75a --- /dev/null +++ b/container/templates/container/container_index.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} +{% load static %} + +{% block title %}Container: {{ container.named_id }}{% endblock %} + +{% block content %} +
+
New Container:
+ {% if container_list %} + + {% else %} +

No container are available.

+ {% endif %} +
+
+ {% if container_type_list %} +
New Container Types:
+ +
+ {% else %} +

No container types are available.

+ {% endif %} + +{% endblock content %} + diff --git a/container/templates/container/container_type_detail.html b/container/templates/container/container_type_detail.html new file mode 100644 index 0000000..81c4021 --- /dev/null +++ b/container/templates/container/container_type_detail.html @@ -0,0 +1,47 @@ +{% extends "base.html" %} +{% load static %} + +{% block title %}Container Type: {{ container_type.named_id }}{% endblock %} + +{% block content %} +
+ +
+
+ +

Container Type: {{ container_type.named_id }}

+
{{ container_type.description }}
+
+
+
+
+
+
Size:
{{ container_type.width }}mm x {{ container_type.length }}mm x {{ container_type.height }}mm
+
Inner Size:
+ {% if container_type.inner_width and container_type.inner_length and container_type.inner_height %} + {{ container_type.inner_width }}mm x {{ container_type.inner_length }}mm x {{ container_type.inner_height }}mm + {% endif %} +
+
+
+
Has Cover:
{% if container_type.has_cover %} yes {% else %} no {% endif %}
+
Can hold Containers:
{% if container_type.contains_container %} yes {% else %} no {% endif %}
+
+
+
+ + +
+ + +
+ +
+
+ +
+ + +
+{% endblock content %} + diff --git a/container/templates/container/container_type_details.html b/container/templates/container/container_type_details.html deleted file mode 100644 index 0ca9326..0000000 --- a/container/templates/container/container_type_details.html +++ /dev/null @@ -1,8 +0,0 @@ -

Container: {{ container_type.named_id }}

-
{{ container_type.description }}
- - - - - -
Width:{{ container_type.width }} mmInner Width:{{ container_type.inner_width }} mm
Length:{{ container_type.length }} mmInner Length:{{ container_type.inner_length }} mm
Height:{{ container_type.height }} mmInner Height:{{ container_type.inner_height }} mm
Has Cover:{% if container_type.has_cover %} yes {% else %} no {% endif %}Can hold Containers:{% if container_type.contains_container %} yes {% else %} no {% endif %}
diff --git a/container/templates/container/container_type_index.html b/container/templates/container/container_type_index.html new file mode 100644 index 0000000..acfde6d --- /dev/null +++ b/container/templates/container/container_type_index.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% load static %} + +{% block title %}Container: {{ container.named_id }}{% endblock %} + +{% block content %} +
+ {% if container_type_list %} +
New Container Types:
+ +
+ {% else %} +

No container types are available.

+ {% endif %} + +{% endblock content %} + diff --git a/container/templates/container/index.html b/container/templates/container/index.html deleted file mode 100644 index f398ceb..0000000 --- a/container/templates/container/index.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
New Container:
-{% if container_list %} - -{% else %} -

No container are available.

-{% endif %} -
-
-
New Container Types:
-{% if container_type_list %} - -{% else %} -

No container types are available.

-{% endif %} -
diff --git a/container/urls.py b/container/urls.py index 7821b28..b4917ca 100644 --- a/container/urls.py +++ b/container/urls.py @@ -4,9 +4,11 @@ from . import views app_name = 'container' urlpatterns = [ - path('', views.index, name='index'), - path('/', views.container_details, name='container_details'), - path('type//', views.container_type_details, name='container_type_details'), - # path('type//', views.container_type_details, name='container_type_details'), + path('', views.IndexView.as_view(), name='index'), + path('/', views.DetailView.as_view(), name='detail'), + path('edit//', views.EditView.as_view(), name='edit'), + path('delete//', views.DeleteView.as_view(), name='delete'), + path('type/', views.TypeIndexView.as_view(), name='container_type_index'), + path('type//', views.TypeDetailView.as_view(), name='container_type_detail'), ] diff --git a/container/views.py b/container/views.py index 070f6c3..3b9016f 100644 --- a/container/views.py +++ b/container/views.py @@ -2,27 +2,39 @@ from django.shortcuts import render from django.http import HttpResponse from django.template import loader from django.http import Http404 +from django.urls import reverse +from django.views import generic from .models import Container, ContainerType -def index(request): - container_list = Container.objects.order_by('-created_ts')[:5] - container_type_list = ContainerType.objects.order_by('-created_ts')[:5] - ctx = {'container_list': container_list, 'container_type_list': container_type_list} - return render(request, 'container/index.html', ctx) +class IndexView(generic.ListView): + template_name = 'container/container_index.html' + context_object_name = 'container_list' -def container_type_details(request, container_type_id): - try: - ctype = ContainerType.objects.get(pk=container_type_id) - except ContainerType.DoesNotExist: - raise Http404("Container Type does not exist") - return render(request, 'container/container_type_details.html', {'container_type': ctype}) + def get_queryset(self): + # Return the last five created containers + return Container.objects.order_by('-created_ts')[:5] -def container_details(request, container_id): - try: - container = Container.objects.get(pk=container_id) - except Container.DoesNotExist: - raise Http404("Container does not exist") - return render(request, 'container/container_details.html', {'container': container}) +class TypeIndexView(generic.ListView): + template_name = 'container/container_type_index.html' + context_object_name = 'container_type_list' + def get_queryset(self): + # Return the last five created container types + return ContainerType.objects.order_by('-created_ts')[:5] + +class DetailView(generic.DetailView): + model = Container + # template_name = 'container/detail.html' + +class TypeDetailView(generic.DetailView): + model = ContainerType + context_object_name = 'container_type' + template_name = 'container/container_type_detail.html' + +class EditView(generic.DetailView): + model = Container + +class DeleteView(generic.DetailView): + model = Container diff --git a/homelog/settings.py b/homelog/settings.py index 10309b1..368dc60 100644 --- a/homelog/settings.py +++ b/homelog/settings.py @@ -55,7 +55,7 @@ ROOT_URLCONF = 'homelog.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [ BASE_DIR / 'homelog/templates' ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/homelog/templates/base.html b/homelog/templates/base.html new file mode 100644 index 0000000..e3c1f40 --- /dev/null +++ b/homelog/templates/base.html @@ -0,0 +1,113 @@ +{% load static i18n %} +{% get_current_language as LANGUAGE_CODE %} + + + + + {% block title %}homelog{% endblock title %} + + + + + + + {% block css %} + + + + + + + {% endblock %} + + {# Placed at the top of the document so pages load faster with defer #} + {% block javascript %} + + + + + + + + {% endblock javascript %} + + + + + +
+ + +
+ +
+ + {% if messages %} + {% for message in messages %} +
+ {{ message }} + +
+ {% endfor %} + {% endif %} + + {% block content %} +

Use this document as a way to quick start any new project.

+ {% endblock content %} + +
+ + {% block modal %}{% endblock modal %} + + {% block inline_javascript %} + {% comment %} + Script tags with only code, no src (defer by default). To run + with a "defer" so that you run inline code: + + {% endcomment %} + {% endblock inline_javascript %} + + diff --git a/homelog/templates/homelog/about.html b/homelog/templates/homelog/about.html new file mode 100644 index 0000000..3fe0a17 --- /dev/null +++ b/homelog/templates/homelog/about.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} +{% load static %} + +{% block content %} + +This is ABOUT + +{% endblock %} diff --git a/homelog/templates/homelog/home.html b/homelog/templates/homelog/home.html new file mode 100644 index 0000000..31a7027 --- /dev/null +++ b/homelog/templates/homelog/home.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} +{% load static %} + +{% block content %} + +

This is HOME

+Container Types
+Container
+ + +{% endblock %} diff --git a/homelog/urls.py b/homelog/urls.py index 8950837..7b5904e 100644 --- a/homelog/urls.py +++ b/homelog/urls.py @@ -15,8 +15,16 @@ Including another URLconf """ from django.contrib import admin from django.urls import include, path +from django.views.generic import TemplateView +from homelog import views urlpatterns = [ +] + +urlpatterns = [ + path('', TemplateView.as_view(template_name="homelog/home.html"), name='index'), + path('home/', TemplateView.as_view(template_name="homelog/home.html"), name='home'), + path('about/', TemplateView.as_view(template_name="homelog/about.html"), name='about'), path('container/', include('container.urls')), path('admin/', admin.site.urls), ] diff --git a/homelog/views.py b/homelog/views.py new file mode 100644 index 0000000..354c6c6 --- /dev/null +++ b/homelog/views.py @@ -0,0 +1,14 @@ +from django.shortcuts import render +from django.http import HttpResponse +from django.template import loader +from django.http import Http404 + + +""" +def home(request): + return render(request, 'homelog/home.html') + +def about(request): + return render(request, 'homelog/about.html') +""" + diff --git a/static/css/project.css b/static/css/project.css new file mode 100644 index 0000000..f1d543d --- /dev/null +++ b/static/css/project.css @@ -0,0 +1,13 @@ +/* These styles are generated from project.scss. */ + +.alert-debug { + color: black; + background-color: white; + border-color: #d6e9c6; +} + +.alert-error { + color: #b94a48; + background-color: #f2dede; + border-color: #eed3d7; +} diff --git a/static/fonts/.gitkeep b/static/fonts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/static/images/favicons/favicon.ico b/static/images/favicons/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..e1c1dd1a32a3a077c41a21e52bc7fb5ac90d3afb GIT binary patch literal 8348 zcmeHLX-gGh6rQ3V&`92%;lcmGu`Jl^WK@OV`^XKh08PZoaH%l?rdiiWq>kJ2@6vM zhAH8L6=kTRD1!xR`-2o^hS&}loN!U1#gF+=YxEq~uqf5#iBw%p0;w;5ehm+6a!sSu zh;X+$+}oF$X1Q6DwS~>Y_Hpw^(&QvJO<5ZCPrn5laNp%s{B3x1hf%*?eW>oS{<{4s^u_yG zpDyG!_iV#~G=q<~slG@0Sx47XXQ%O;HY7ILVf}B-)R$6GV^A78)t0tN9`tu3r9Z+xM?NgUd8geu=c`0?r;-KR&IQjKs zSB#VCpg8CPW&M}$sth@H=VS%t;23!!j};F)bb;W3EkA!4QmCsY_p81^TK0{;$g>e1Hl998^0M+r0-7ZSN+l_cMSRuEALTE@|d6+3{GMP^;_|<yhubb{FF1IPgH|0>SH%pC!c)uFI)H z?jv4y0uO{P5WE>~I<$r!RFo0lN4r{xm;Jy4p$h~b3S*a#)$Z*nI}&Kc_C+*zZHz1v zIR8TBVH7Y?Mp~ zofpsr+SP@>EX4e*bQ{nAUYtKrQ&-5d4j;FF{^-^Dt2^5I`HSb!|22PN26n3>hKPOy zW2D*A*v+c{bFKCwozbB{dObp~e&1Nxrj<4Ih4~w)M`nl08o}Wq2 z#Jt(k+M>+}JY(=2gm(gdUq)^@e%tX(F)RBtotnB2^y>YKz-5eg_qO&n%lJ1nuQmTY zxmyE1NWjl1EGvD?Z|n;neT;sa?Q;Ef-#%$BYxXAhD4xF+@M>*qrR!x^sPN98|BX4; z!$NJcKF`^C7f(<_vlp%b>`pxL^8Y<&?KFx{n_!5C9VqLA*CP@zhXs2t#dmrAKu?d_ y^&_r5_e@uesG}CO*g!3o?-kB+I^cA`>44J#rvpw0oDMi0a5~_0!0Eu>4*Uj$LD0AW literal 0 HcmV?d00001 diff --git a/static/js/project.js b/static/js/project.js new file mode 100644 index 0000000..d26d23b --- /dev/null +++ b/static/js/project.js @@ -0,0 +1 @@ +/* Project specific Javascript goes here. */ diff --git a/static/sass/custom_bootstrap_vars.scss b/static/sass/custom_bootstrap_vars.scss new file mode 100644 index 0000000..e69de29 diff --git a/static/sass/project.scss b/static/sass/project.scss new file mode 100644 index 0000000..3c8f261 --- /dev/null +++ b/static/sass/project.scss @@ -0,0 +1,37 @@ + + + + +// project specific CSS goes here + +//////////////////////////////// + //Variables// +//////////////////////////////// + +// Alert colors + +$white: #fff; +$mint-green: #d6e9c6; +$black: #000; +$pink: #f2dede; +$dark-pink: #eed3d7; +$red: #b94a48; + +//////////////////////////////// + //Alerts// +//////////////////////////////// + +// bootstrap alert CSS, translated to the django-standard levels of +// debug, info, success, warning, error + +.alert-debug { + background-color: $white; + border-color: $mint-green; + color: $black; +} + +.alert-error { + background-color: $pink; + border-color: $dark-pink; + color: $red; +}