From f0888c4168a2da166a0b2412f7ef47932913ea65 Mon Sep 17 00:00:00 2001 From: Superredstone Date: Wed, 16 Sep 2026 17:45:08 +0200 Subject: [PATCH] feat(portfolio): add project search --- portfolio/templates/project_list.html | 50 +++++++-------------- portfolio/templates/project_list_query.html | 35 +++++++++++++++ portfolio/urls.py | 1 + portfolio/views.py | 15 ++++++- 4 files changed, 64 insertions(+), 37 deletions(-) create mode 100644 portfolio/templates/project_list_query.html diff --git a/portfolio/templates/project_list.html b/portfolio/templates/project_list.html index a3bfbbd..fbab364 100644 --- a/portfolio/templates/project_list.html +++ b/portfolio/templates/project_list.html @@ -2,40 +2,20 @@ {% load i18n %} {% block content %}
-
- {% for project in object_list %} -
- {% if project.url %} - -
-

{{ project.name }}

-

{{ project.short_description }}

-
- {% for t in project.tags.all %} -
{{ t }}
- {% endfor %} -
-
-
- {% else %} -
-
-

{{ project.name }}

-

{{ project.short_description }}

-
- {% for t in project.tags.all %} -
{{ t }}
- {% endfor %} -
-
-
- {% endif %} -
- {% endfor %} -
+
+
+ + +
+
+
{% endblock %} diff --git a/portfolio/templates/project_list_query.html b/portfolio/templates/project_list_query.html new file mode 100644 index 0000000..319293e --- /dev/null +++ b/portfolio/templates/project_list_query.html @@ -0,0 +1,35 @@ +
+ {% for project in object_list %} +
+ {% if project.url %} + +
+

{{ project.name }}

+

{{ project.short_description }}

+
+ {% for t in project.tags.all %} +
{{ t }}
+ {% endfor %} +
+
+
+ {% else %} +
+
+

{{ project.name }}

+

{{ project.short_description }}

+
+ {% for t in project.tags.all %} +
{{ t }}
+ {% endfor %} +
+
+
+ {% endif %} +
+ {% endfor %} +
diff --git a/portfolio/urls.py b/portfolio/urls.py index 5ecbac2..a647a9c 100644 --- a/portfolio/urls.py +++ b/portfolio/urls.py @@ -5,6 +5,7 @@ from portfolio import views urlpatterns = [ path("", views.PortfolioView.as_view(), name="portfolio"), path("projects/", views.ProjectList.as_view(), name="projects"), + path("projects/query/", views.ProjectListQuery.as_view(), name="projects-query"), path("contact/", views.ContactSend.as_view(), name="contact"), path("company//logo/", views.CompanyLogo.as_view(), name="company-logo"), ] diff --git a/portfolio/views.py b/portfolio/views.py index ef134f0..f3945a0 100644 --- a/portfolio/views.py +++ b/portfolio/views.py @@ -18,9 +18,8 @@ class PortfolioView(TemplateView): } -class ProjectList(ListView): +class ProjectList(TemplateView): template_name = "project_list.html" - model = models.Project class ContactSend(TemplateView): @@ -49,3 +48,15 @@ class CompanyLogo(DetailView): def get(self, request, *args, **kwargs): company = self.get_object() return FileResponse(company.logo) + + +class ProjectListQuery(ListView): + template_name = "project_list_query.html" + model = models.Project + + def get_queryset(self): + query = self.request.GET.get("query") + if not query: + return super().get_queryset() + + return super().get_queryset().filter(name__contains=query)