Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Hobbies model and view #38

Merged
merged 4 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bartczak_tech/portfolio/admin.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Register your models here.
from django.contrib import admin

from .models import Hobby

admin.site.register(Hobby)
28 changes: 28 additions & 0 deletions bartczak_tech/portfolio/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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',
},
),
]
16 changes: 15 additions & 1 deletion bartczak_tech/portfolio/models.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions bartczak_tech/portfolio/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path

from .views import home

urlpatterns = [
path("", home, name="home"),
]
14 changes: 13 additions & 1 deletion bartczak_tech/portfolio/views.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# Create your views here.
from django.shortcuts import render

from .models import Hobby


def home(request):
hobbies = Hobby.objects.all()

bartczak-pa marked this conversation as resolved.
Show resolved Hide resolved
context = {
"hobbies_list": hobbies,
}

return render(request, "portfolio/portfolio.html", context)
30 changes: 30 additions & 0 deletions bartczak_tech/templates/portfolio/hobbies.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% load static i18n %}

{% if hobbies %}
bartczak-pa marked this conversation as resolved.
Show resolved Hide resolved
<section id="services" class="full-height px-lg-5">
<div class="container">
<div class="row pb-4" data-aos="fade-up">
<div class="col-lg-8">
<h6 class="text-brand">HOBBIES</h6>
<h1>What are my passions?</h1>
</div>
</div>
<div class="row gy-4">
{% for hobby in hobbies %}
<div class="col-md-4" data-aos="fade-up">
<div class="service p-4 bg-base rounded-4 shadow-effect">
<div class="iconbox rounded-4">
<i class="{{ hobby.icon }}"></i>
</div>
<h5 class="mt-4 mb-2">{{ hobby.name }}</h5>
<p>{{ hobby.description }}</p>
{% if hobby.link and hobby.link_text %}
<a href="{{ hobby.link }}" class="link-custom">{{ hobby.link_text }}</a>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
</section>
{% endif %}
44 changes: 1 addition & 43 deletions bartczak_tech/templates/portfolio/portfolio.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,7 @@ <h1 class="display-4 fw-bold" data-aos="fade-up">
</div>
</section>
<!-- //HOME -->
<!-- SERVICES -->
<section id="services" class="full-height px-lg-5">
<div class="container">
<div class="row pb-4" data-aos="fade-up">
<div class="col-lg-8">
<h6 class="text-brand">HOBBIES</h6>
<h1>What are my passions?</h1>
</div>
</div>
<div class="row gy-4">
<div class="col-md-4" data-aos="fade-up">
<div class="service p-4 bg-base rounded-4 shadow-effect">
<div class="iconbox rounded-4">
<i class="las la-laptop-code"></i>
</div>
<h5 class="mt-4 mb-2">Software Development</h5>
<p>I create Python applications for my personal use and learning coding teamwork</p>
<a href="#" class="link-custom">Read More</a>
</div>
</div>
<div class="col-md-4" data-aos="fade-up" data-aos-delay="300">
<div class="service p-4 bg-base rounded-4 shadow-effect">
<div class="iconbox rounded-4">
<i class="las la-camera"></i>
</div>
<h5 class="mt-4 mb-2">Photography</h5>
<p>I enjoy sharing my view on the world using lens eye</p>
<a href="#" class="link-custom">Read More</a>
</div>
</div>
<div class="col-md-4" data-aos="fade-up" data-aos-delay="600">
<div class="service p-4 bg-base rounded-4 shadow-effect">
<div class="iconbox rounded-4">
<i class="las la-guitar"></i>
</div>
<h5 class="mt-4 mb-2">Music</h5>
<p>I"m doing first steps with creating music on bass guitar</p>
<a href="#" class="link-custom">Read More</a>
</div>
</div>
</div>
</div>
</section>
{% include 'portfolio/hobbies.html' with hobbies=hobbies_list %}
<!-- SERVICES -->
<!-- WORK -->
<section id="work" class="full-height px-lg-5">
Expand Down
4 changes: 1 addition & 3 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
bartczak-pa marked this conversation as resolved.
Show resolved Hide resolved
path(
"about/",
TemplateView.as_view(template_name="pages/about.html"),
Expand Down
Loading