diff --git a/gawa/blog/models.py b/gawa/blog/models.py index d93344b..0550fd3 100644 --- a/gawa/blog/models.py +++ b/gawa/blog/models.py @@ -15,6 +15,6 @@ class BlogPost(Searchable): """ body = models.TextField() category = models.ForeignKey(Category, on_delete=models.SET_NULL, null=True) - thumbnail = models.ImageField(blank=True) + thumbnail = models.ImageField(blank=True, upload_to="img/thumbnails") public = models.BooleanField(default=True) slug = models.SlugField() diff --git a/gawa/blog/templates/blog/blogpost.html b/gawa/blog/templates/blog/blogpost.html index 3695786..d0ddb4f 100644 --- a/gawa/blog/templates/blog/blogpost.html +++ b/gawa/blog/templates/blog/blogpost.html @@ -14,11 +14,12 @@ {% block main %}
-

{{ post.title }}

-

{% translate "Blog" %}

+

{{ post.title }} {{ post.subtitle }}

+ thumbnail
-
+
$$x=\frac{-b+\sqrt{b^2-4ac}}{2a}$$ + {{ post.body | safe }}
{% include 'blog/featured.html' %}
diff --git a/gawa/blog/views.py b/gawa/blog/views.py index cfa878f..baad3aa 100644 --- a/gawa/blog/views.py +++ b/gawa/blog/views.py @@ -34,20 +34,23 @@ class Post(DetailView): category__slug=self.kwargs['category'], # first slug is category slug=self.kwargs['slug'] # second slug is article itself ) - logger.debug(obj) match get_language(): case 'de': - logger.debug("returning blogpost for de") - obj['title'] = obj['title_de'] + logger.debug("setting language unspecific attributes for language: de") + obj.title = obj.title_de + obj.subtitle = obj.subtitle_de + obj.desc = obj.desc_de case 'en': - logger.debug("returning blogpost for en") - obj['title'] = obj['title_en'] + logger.debug("setting language unspecific attributes for language: en") + obj.title = obj.title_en + obj.subtitle = obj.subtitle_en + obj.desc = obj.desc_en case _: # this should not happen, but who knows what dumb stuff users will come up with logger.warning("article for unsupported language was requested") - return obj + return obj class CategoryList(ListView): """ diff --git a/gawa/db.sqlite3 b/gawa/db.sqlite3 deleted file mode 100644 index 176a60b..0000000 Binary files a/gawa/db.sqlite3 and /dev/null differ diff --git a/gawa/gawa/settings.py b/gawa/gawa/settings.py index 9fd1b7f..6e28cf0 100644 --- a/gawa/gawa/settings.py +++ b/gawa/gawa/settings.py @@ -15,6 +15,7 @@ import os # default django from pathlib import Path +from django.conf.global_settings import MEDIA_ROOT from django.utils.log import ServerFormatter # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -288,3 +289,10 @@ LOGGING = { }, } + +# Media stuff +# this is where user uploaded files will go. +# TODO change this for prod +#MEDIA_ROOT = "/home/plex/Documents/code/python/gawa/media" +MEDIA_ROOT = "media/" +MEDIA_URL = "media/" diff --git a/gawa/gawa/urls.py b/gawa/gawa/urls.py index ab47e58..26c88d8 100644 --- a/gawa/gawa/urls.py +++ b/gawa/gawa/urls.py @@ -17,10 +17,12 @@ from django.conf.urls.i18n import i18n_patterns from django.conf.urls import url from django.contrib import admin from django.urls import include, path +from django.conf import settings +from django.conf.urls.static import static urlpatterns = [ url(r'^i18n/', include('django.conf.urls.i18n')), -] +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += i18n_patterns( path("", include("start.urls")), diff --git a/gawa/media/img/thumbnails/echter_ottifant.png b/gawa/media/img/thumbnails/echter_ottifant.png new file mode 100644 index 0000000..8a79151 Binary files /dev/null and b/gawa/media/img/thumbnails/echter_ottifant.png differ diff --git a/gawa/thumbnails/thuglifemathemann.png b/gawa/thumbnails/thuglifemathemann.png new file mode 100644 index 0000000..a6daad6 Binary files /dev/null and b/gawa/thumbnails/thuglifemathemann.png differ