From ac2eba006c6db91de577dc411c459c122587fdf3 Mon Sep 17 00:00:00 2001 From: Pawel Date: Tue, 3 Sep 2024 15:19:47 +0100 Subject: [PATCH 1/3] [Models] Added hobby model --- bartczak_tech/portfolio/admin.py | 6 +++++- bartczak_tech/portfolio/models.py | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bartczak_tech/portfolio/admin.py b/bartczak_tech/portfolio/admin.py index 846f6b4..f050823 100644 --- a/bartczak_tech/portfolio/admin.py +++ b/bartczak_tech/portfolio/admin.py @@ -1 +1,5 @@ -# Register your models here. +from django.contrib import admin + +from .models import Hobby + +admin.site.register(Hobby) diff --git a/bartczak_tech/portfolio/models.py b/bartczak_tech/portfolio/models.py index 6b20219..ac14e76 100644 --- a/bartczak_tech/portfolio/models.py +++ b/bartczak_tech/portfolio/models.py @@ -1 +1,15 @@ -# Create your models here. +from django.db import models + + +class Hobby(models.Model): + name = models.CharField(max_length=50) + description = models.TextField(max_length=300) + icon = models.CharField(max_length=50, default="fas fa-code") + link = models.URLField(max_length=200, blank=True) + link_text = models.CharField(max_length=30, blank=True) + + class Meta: + verbose_name_plural = "Hobbies" + + def __str__(self): + return self.name From c5ed2c40fa866b9c4558eea9f58cd545197762ff Mon Sep 17 00:00:00 2001 From: Pawel Date: Tue, 3 Sep 2024 15:39:37 +0100 Subject: [PATCH 2/3] [Views] Added hobbies context to view --- .../portfolio/migrations/0001_initial.py | 28 ++++++++++++ bartczak_tech/portfolio/urls.py | 7 +++ bartczak_tech/portfolio/views.py | 14 +++++- .../templates/portfolio/hobbies.html | 30 +++++++++++++ .../templates/portfolio/portfolio.html | 44 +------------------ config/urls.py | 4 +- 6 files changed, 80 insertions(+), 47 deletions(-) create mode 100644 bartczak_tech/portfolio/migrations/0001_initial.py create mode 100644 bartczak_tech/portfolio/urls.py create mode 100644 bartczak_tech/templates/portfolio/hobbies.html diff --git a/bartczak_tech/portfolio/migrations/0001_initial.py b/bartczak_tech/portfolio/migrations/0001_initial.py new file mode 100644 index 0000000..53a8d74 --- /dev/null +++ b/bartczak_tech/portfolio/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.13 on 2024-09-03 14:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Hobby', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ('description', models.TextField(max_length=300)), + ('icon', models.CharField(default='fas fa-code', max_length=50)), + ('link', models.URLField(blank=True)), + ('link_text', models.CharField(blank=True, max_length=30)), + ], + options={ + 'verbose_name_plural': 'Hobbies', + }, + ), + ] diff --git a/bartczak_tech/portfolio/urls.py b/bartczak_tech/portfolio/urls.py new file mode 100644 index 0000000..6299e3d --- /dev/null +++ b/bartczak_tech/portfolio/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from .views import home + +urlpatterns = [ + path("", home, name="home"), +] diff --git a/bartczak_tech/portfolio/views.py b/bartczak_tech/portfolio/views.py index 60f00ef..7e9a655 100644 --- a/bartczak_tech/portfolio/views.py +++ b/bartczak_tech/portfolio/views.py @@ -1 +1,13 @@ -# Create your views here. +from django.shortcuts import render + +from .models import Hobby + + +def home(request): + hobbies = Hobby.objects.all() + + context = { + "hobbies_list": hobbies, + } + + return render(request, "portfolio/portfolio.html", context) diff --git a/bartczak_tech/templates/portfolio/hobbies.html b/bartczak_tech/templates/portfolio/hobbies.html new file mode 100644 index 0000000..0fbe7d2 --- /dev/null +++ b/bartczak_tech/templates/portfolio/hobbies.html @@ -0,0 +1,30 @@ +{% load static i18n %} + +{% if hobbies %} +
+
+
+
+
HOBBIES
+

What are my passions?

+
+
+
+ {% for hobby in hobbies %} +
+
+
+ +
+
{{ hobby.name }}
+

{{ hobby.description }}

+ {% if hobby.link and hobby.link_text %} + {{ hobby.link_text }} + {% endif %} +
+
+ {% endfor %} +
+
+
+{% endif %} diff --git a/bartczak_tech/templates/portfolio/portfolio.html b/bartczak_tech/templates/portfolio/portfolio.html index cba9705..8a82c31 100644 --- a/bartczak_tech/templates/portfolio/portfolio.html +++ b/bartczak_tech/templates/portfolio/portfolio.html @@ -25,49 +25,7 @@

- -
-
-
-
-
HOBBIES
-

What are my passions?

-
-
-
-
-
-
- -
-
Software Development
-

I create Python applications for my personal use and learning coding teamwork

- Read More -
-
-
-
-
- -
-
Photography
-

I enjoy sharing my view on the world using lens eye

- Read More -
-
-
-
-
- -
-
Music
-

I"m doing first steps with creating music on bass guitar

- Read More -
-
-
-
-
+ {% include 'portfolio/hobbies.html' with hobbies=hobbies_list %}
diff --git a/config/urls.py b/config/urls.py index c1e4e10..1361afe 100644 --- a/config/urls.py +++ b/config/urls.py @@ -12,9 +12,7 @@ from rest_framework.authtoken.views import obtain_auth_token urlpatterns = [ - path( - "", TemplateView.as_view(template_name="portfolio/portfolio.html"), name="home" - ), + path("", include("bartczak_tech.portfolio.urls")), path( "about/", TemplateView.as_view(template_name="pages/about.html"), From 9ba3c6e9d82dba65fdfe0c0e2bc5d3f4415ad992 Mon Sep 17 00:00:00 2001 From: Pawel Date: Tue, 3 Sep 2024 15:53:24 +0100 Subject: [PATCH 3/3] [Templates] Replaced hardcoded hobby icon --- bartczak_tech/templates/portfolio/hobbies.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bartczak_tech/templates/portfolio/hobbies.html b/bartczak_tech/templates/portfolio/hobbies.html index 0fbe7d2..12340d7 100644 --- a/bartczak_tech/templates/portfolio/hobbies.html +++ b/bartczak_tech/templates/portfolio/hobbies.html @@ -14,7 +14,7 @@

What are my passions?

- +
{{ hobby.name }}

{{ hobby.description }}