Skip to content
Open
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ WORKDIR /src

# root is used as a hotfix for package introspection problem
# https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000373944/comments/7286554132370
USER root
USER root
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lint:

# запуск автоматических тестов
test:
docker compose run app ./manage.py test
docker compose run app python manage.py test

# запуск всех функций поддержки качества кода
all: format lint test
all: format lint test docs-html
1 change: 1 addition & 0 deletions docs/source/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
portfolio
jobs
blog
author
Empty file added src/__init__.py
Empty file.
Empty file added src/author/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions src/author/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Register your models here.
from django.contrib import admin

from author.models import Author


@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
list_display = (
"resume_url",
"github_url",
"email",
"created_at",
"updated_at",
)

search_fields = ("email",)

list_filter = (
"created_at",
"updated_at",
)
7 changes: 7 additions & 0 deletions src/author/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.apps import AppConfig


class AuthorConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "author"
verbose_name = "Автор"
61 changes: 61 additions & 0 deletions src/author/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 4.1.7 on 2023-02-25 18:43

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="Author",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"created_at",
models.DateTimeField(
auto_now_add=True, verbose_name="Время создания записи"
),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Время обновления записи"
),
),
(
"resume_url",
models.URLField(
help_text="Ссылка на резюме автора", verbose_name="Резюме"
),
),
(
"github_url",
models.URLField(
help_text="Ссылка на гитхаб автора", verbose_name="GitHub"
),
),
(
"email",
models.EmailField(
help_text="Почта автора", max_length=254, verbose_name="Почта"
),
),
],
options={
"verbose_name": "Данные об авторе",
"verbose_name_plural": "Данные об авторе",
},
),
]
Empty file.
32 changes: 32 additions & 0 deletions src/author/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Create your models here.

from django.db import models

from base.models import TimeStampMixin


class Author(TimeStampMixin):
"""
Модель для хранения данных об авторе.
"""

resume_url = models.URLField(
verbose_name="Резюме",
help_text="Ссылка на резюме автора",
)
github_url = models.URLField(
verbose_name="GitHub",
help_text="Ссылка на гитхаб автора",
)

email = models.EmailField(
verbose_name="Почта",
help_text="Почта автора",
)

class Meta:
verbose_name = "Данные об авторе"
verbose_name_plural = "Данные об авторе"

def __str__(self) -> str:
return f'Объект "Автор" (id={self.pk})'
11 changes: 11 additions & 0 deletions src/author/templates/author/author_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends 'base.html' %}

{% load static %}

{% block author_content %}
<ul class="list-unstyled">
<li><a href="{{ author.resume_url }}" class="text-white">Резюме</a></li>
<li><a href="{{ author.github_url }}" target="_blank" class="text-white">GitHub</a></li>
<li><a href="mailto:{{ author.email }}" class="text-white">Email</a></li>
</ul>
{% endblock %}
13 changes: 13 additions & 0 deletions src/author/templates/author/author_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends 'base.html' %}

{% load static %}

{% block author_content %}
{% for author in object_list %}
<ul class="list-unstyled">
<li><a href="{{ author.resume_url }}" class="text-white">Резюме</a></li>
<li><a href="{{ author.github_url }}" target="_blank" class="text-white">GitHub</a></li>
<li><a href="mailto:{{ author.email }}" class="text-white">Email: {{ author.email }}</a></li>
</ul>
{% endfor %}
{% endblock %}
32 changes: 32 additions & 0 deletions src/author/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.test import TestCase

from author.models import Author


class JobTestCase(TestCase):
"""
Тестирование функций работы
"""

def setUp(self) -> None:
"""
Настройка перед тестированием.
:return:
"""

Author.objects.create(
resume_url="https://test.test",
github_url="https://test.test",
email="test@test.test",
)

def test_job_messages_creation(self) -> None:
"""
Тестирование моделей работы.
:return:
"""

author = Author.objects.get(resume_url="https://test.test")
self.assertEqual(author.github_url, "https://test.test")
self.assertEqual(author.email, "test@test.test")
self.assertEqual(str(author), f'Объект "Автор" (id={author.pk})')
9 changes: 9 additions & 0 deletions src/author/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path

from author.views import AutorListView
from author.views import AutorDetailView

urlpatterns = [
path("", AutorListView.as_view(), name="authors"),
path("<int:pk>/", AutorDetailView.as_view(), name="author"),
]
12 changes: 12 additions & 0 deletions src/author/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Create your views here.
from django.views.generic import DetailView, ListView

from author.models import Author


class AuthorListView(ListView):
model = Author


class AuthorDetailView(DetailView):
model = Author
16 changes: 11 additions & 5 deletions src/blog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Generated by Django 4.1.1 on 2022-09-20 15:45
from typing import List
# Generated by Django 4.1.7 on 2023-02-25 12:45

import ckeditor_uploader.fields
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies: List = []
dependencies = []

operations = [
migrations.CreateModel(
Expand Down Expand Up @@ -36,7 +36,12 @@ class Migration(migrations.Migration):
),
),
("title", models.CharField(max_length=255, verbose_name="Заголовок")),
("content", models.TextField(verbose_name="Содержимое сообщения")),
(
"content",
ckeditor_uploader.fields.RichTextUploadingField(
verbose_name="Содержимое сообщения"
),
),
(
"image",
models.ImageField(upload_to="images/", verbose_name="Изображение"),
Expand All @@ -47,7 +52,8 @@ class Migration(migrations.Migration):
),
],
options={
"abstract": False,
"verbose_name": "Сообщение блога",
"verbose_name_plural": "Сообщения блога",
},
),
]
28 changes: 0 additions & 28 deletions src/blog/migrations/0002_alter_blog_options_alter_blog_content.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/jobs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class JobAdmin(admin.ModelAdmin):
"updated_at",
)

search_fields = ("description",)
search_fields = ("description", "content")

list_filter = (
"created_at",
Expand Down
12 changes: 9 additions & 3 deletions src/jobs/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Generated by Django 4.1.1 on 2022-09-20 15:45
from typing import List
# Generated by Django 4.1.7 on 2023-02-25 12:45

import ckeditor_uploader.fields
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies: List = []
dependencies: list = []

operations = [
migrations.CreateModel(
Expand Down Expand Up @@ -51,6 +51,12 @@ class Migration(migrations.Migration):
verbose_name="Описание",
),
),
(
"content",
ckeditor_uploader.fields.RichTextUploadingField(
verbose_name="Подробное описание"
),
),
],
options={
"verbose_name": "Выполненная работа",
Expand Down
13 changes: 12 additions & 1 deletion src/jobs/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Модели для приложения "Jobs" (выполненные работы).
"""

from ckeditor_uploader.fields import RichTextUploadingField
from django.db import models

from base.models import TimeStampMixin
Expand All @@ -22,10 +22,21 @@ class Job(TimeStampMixin):
verbose_name="Описание",
help_text="Краткое описание выполненной работы",
)
content = RichTextUploadingField(
verbose_name="Подробное описание",
)

class Meta:
verbose_name = "Выполненная работа"
verbose_name_plural = "Выполненные работы"

def __str__(self) -> str:
return f'Объект "Выполненная работа" (id={self.pk})'

def summary(self) -> str:
"""
Краткое содержание описания работы.

:return:
"""
return self.content[:100] + "..."
10 changes: 5 additions & 5 deletions src/jobs/templates/jobs/job_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
{% block content %}

<div class="container">
<h1 class="text-center pt-3 display-4">{{ blog.title }}</h1>
<p class="text-center">{{ blog.pub_date }}</p>
<p><img src="{{ blog.image.url }}" class="img-fluid" alt="{{ blog.title }}"></p>
<p>{{ blog.content }}</p>
<a href="{% url 'blogs' %}" class="btn btn-light" role="button">Вернуться в блог</a>
<h1 class="text-center pt-3 display-4">{{ job.title }}</h1>
<p class="text-center">{{ job.pub_date }}</p>
<p><img src="{{ job.image.url }}" class="img-fluid" alt="{{ job.description }}"></p>
{{ job.content|safe }}
<a href="/" class="btn btn-light" role="button">На главную</a>
</div>

{% endblock %}
Loading