hw3
- Введены типы данных в models.py, сайт переписан под django модели
- DB переведена на PostgreSQL
- Переписан docker compose файл, настроены network и volume
- Добавлена команда генерации рандомных данных в db
hw4
- Добавлены формы login, signup, logout, profile
- Добавлены вопросы и ответы и их модели и формы
hw5
- Добавлена загрузка и отображение аватарок
- Добавлены лайки и дизайки, отметка правильного ответа
This commit is contained in:
redtea committed 2026-05-10 22:56:49 +03:00
1 parent 33379408ba
commit 466555ce05
26 files changed
+1722 -178

No files matched your search

+17 -10
View File
@@ -6,22 +6,29 @@
<div class="main-title">
<h1>Ask a Question</h1>
</div>
<form class="form" method="post">
{% csrf_token %}
{{ form.non_field_errors }}
<form class="form">
<div class="form-row">
<label for="title">Title</label>
<input id="title" type="text" value="How to build a moon park ?">
<label>Title</label>
{{ form.title }}
{{ form.title.errors }}
</div>
<div class="form-row">
<label for="text">Text</label>
<textarea id="text">Really, how ? Have no idea about it</textarea>
<label>Text</label>
{{ form.body }}
{{ form.body.errors }}
</div>
<div class="form-row">
<label for="tags">Tags</label>
<input id="tags" type="text" value="moon, park, puzzle">
</div>
<div>
<button class="button" type="button">ASK IT</button>
<label>Tags</label>
{{ form.tags }}
{{ form.tags.errors }}
</div>
<button class="button" type="submit">ASK IT</button>
</form>
{% endblock %}
+20 -15
View File
@@ -6,6 +6,7 @@
<title>VkDesk | Fresh Questions</title>
<meta name="description" content="VkDesk Q&A">
<link rel="stylesheet" href="{% static 'core/css/style.css' %}">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<header class="site-header">
@@ -15,13 +16,27 @@
<a class="button button--ask" href="ask">ASK IT</a>
</form>
<div class="user-block">
<div class="avatar-box small">avatar</div>
<div class="avatar-box small">
{% if request.user.profile.avatar %}
<img src="{{ request.user.profile.avatar.url }}" width="40">
{% else %}
<img src="{% static 'core/img/profile.webp' %}" width="40">
{% endif %}
</div>
<div class="user-links">
<a href="profile" class="user-name">Dr. Pepper</a>
{% if request.user.is_authenticated %}
<a href="{% url 'profile' %}" class="user-name">
{{ request.user.profile.nickname }}
</a>
<div>
<a href="profile">settings</a>
<a href="login">log out</a>
<a href="{% url 'logout' %}">log out</a>
</div>
{% else %}
<div>
<a href="{% url 'login' %}">log in</a>
<a href="{% url 'signup' %}">sign up</a>
</div>
{% endif %}
</div>
</div>
</header>
@@ -39,21 +54,11 @@
{% endfor %}
</div>
</div>
<div class="sidebar-section">
<h2>Top Members</h2>
<div class="member-list">
<a href="#">Mr. Freeman</a>
<a href="#">Dr. House</a>
<a href="#">Bender</a>
<a href="#">Queen Victoria</a>
<a href="#">V. Pupkin</a>
</div>
</div>
</aside>
</div>
<footer class="footer">2026</footer>
</body>
<script src="{% static 'core/js/script.js' %}"></script>
</html>
+18 -8
View File
@@ -8,21 +8,31 @@
<h1>Sign In</h1>
</div>
<p class="error">Sorry, wrong password!</p>
<form class="form">
<form class="form" method="post">
{% csrf_token %}
{{ form.non_field_errors }}
<div class="form-row">
<label for="login">Login</label>
<input id="login" type="text" placeholder="Enter your login here">
<label>Login</label>
{{ form.username }}
{{ form.username.errors }}
</div>
<div class="form-row">
<label for="password">Password</label>
<input id="password" type="password" value="********">
<label>Password</label>
{{ form.password }}
{{ form.password.errors }}
</div>
<input type="hidden" name="next" value="{{ next }}">
<div>
<button class="button" type="button">Sign In!</button>
<button class="button" type="submit">Sign In!</button>
</div>
<a href="signup">create new account</a>
<a href="{% url 'signup' %}">create new account</a>
</form>
+77 -10
View File
@@ -1,21 +1,88 @@
<article class="card">
<div>
<div class="avatar-box">avatar</div>
<div class="avatar-box">
{% if question.user.profile.avatar %}
<img src="{{ question.user.profile.avatar.url }}" width="80">
{% else %}
avatar
{% endif %}
</div>
<div class="vote-box">
<span>5</span>
<span class="vote-arrows">^</span>
<span
class="question-rating"
id="question-rating-{{ question.id }}"
>
{{ question.rating }}
</span>
{% if request.user.is_authenticated %}
{% if question.id not in user_reactions %}
<button
class="question-like"
data-id="{{ question.id }}"
>
+
</button>
<button
class="question-dislike"
data-id="{{ question.id }}"
>
-
</button>
{% else %}
<span>voted</span>
{% endif %}
{% endif %}
</div>
</div>
<div>
<a class="question-title" href="question">{{ question.title }}</a>
<p>{{ question.text }}</p>
<a
class="question-title"
href="/question?question_id={{ question.id }}"
>
{{ question.title }}
</a>
<p>{{ question.body }}</p>
<div class="meta">
<a href="question">answer (3)</a>
<a href="/question?question_id={{ question.id }}">
answer
</a>
<span>Tags:</span>
{% for tag in question.tags %}
<a class="tag" href="/?tag={{ tag }}">{{ tag }}</a>
{% for tag in question.tags.all %}
<a
class="tag"
href="/?tag={{ tag }}"
>
{{ tag }}
</a>
{% endfor %}
</div>
</div>
</article>
</article>
+24 -17
View File
@@ -6,30 +6,37 @@
<h1>Profile: Dr. Pepper</h1>
</div>
<form class="form">
<form class="form" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.non_field_errors }}
<div class="form-row">
<label for="login">Login</label>
<input id="login" type="text" value="dr_pepper">
<label>Email</label>
{{ form.email }}
{{ form.email.errors }}
</div>
<div class="form-row">
<label for="email">Email</label>
<input id="email" type="email" value="drpepper@mail.ru">
<label>Nickname</label>
{{ form.nickname }}
{{ form.nickname.errors }}
</div>
<div class="form-row">
<label for="nickname">NickName</label>
<input id="nickname" type="text" value="Dr. Pepper">
<label>Avatar</label>
{{ form.avatar }}
</div>
<div class="form-row">
<label>Upload avatar</label>
<div class="avatar-box">avatar</div>
</div>
<div class="form-row">
<span></span>
<input type="file">
</div>
<div>
<button class="button" type="button">Save</button>
<div class="avatar-preview">
{% if request.user.profile.avatar %}
<img src="{{ request.user.profile.avatar.url }}" width="120">
{% else %}
<img src="{% static 'core/img/profile.webp' %}" width="120">
{% endif %}
</div>
<button class="button" type="submit">Save</button>
</form>
{% endblock %}
+160 -36
View File
@@ -4,63 +4,187 @@
{% block content %}
<article class="card">
<div>
<div class="avatar-box">avatar</div>
<div class="vote-box">
<span>5</span>
<span class="vote-arrows">^<span>'</span></span>
<div class="avatar-box">
{% if question.user.profile.avatar %}
<img src="{{ question.user.profile.avatar.url }}" width="80">
{% else %}
avatar
{% endif %}
</div>
<div class="vote-box">
<span id="question-rating-{{ question.id }}">
{{ question.rating }}
</span>
{% if request.user.is_authenticated %}
{% if not question_reaction %}
<button
class="question-like"
data-id="{{ question.id }}"
>
+
</button>
<button
class="question-dislike"
data-id="{{ question.id }}"
>
-
</button>
{% else %}
<span>voted</span>
{% endif %}
{% endif %}
</div>
</div>
<div>
<div class="question-title">How to build a moon park ?</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<div class="question-title">
{{ question.title }}
</div>
<p>{{ question.body }}</p>
<div class="meta">
<span>Tags:</span>
<a class="tag" href="#">black-jack</a>
<a class="tag" href="#">bender</a>
{% for tag in question.tags.all %}
<a
class="tag"
href="/?tag={{ tag }}"
>
{{ tag }}
</a>
{% endfor %}
</div>
</div>
</article>
<article class="answer-card">
{% for answer in answers %}
<article
class="answer-card"
id="answer-{{ answer.id }}"
>
<div>
<div class="avatar-box">avatar</div>
<div class="avatar-box">
{% if answer.user.profile.avatar %}
<img src="{{ answer.user.profile.avatar.url }}" width="80">
{% else %}
avatar
{% endif %}
</div>
<div class="vote-box">
<span>5</span>
<span class="vote-arrows">^<span>'</span></span>
<span id="answer-rating-{{ answer.id }}">
{{ answer.rating }}
</span>
{% if request.user.is_authenticated %}
{% if answer.id not in answer_reactions %}
<button
class="answer-like"
data-id="{{ answer.id }}"
>
+
</button>
<button
class="answer-dislike"
data-id="{{ answer.id }}"
>
-
</button>
{% else %}
<span>voted</span>
{% endif %}
{% endif %}
</div>
</div>
<div>
<p>First of all I would like to thank you for the invitation to participate in such a ... Russia is the huge territory which in many respects needs to be render habitable.</p>
<p>{{ answer.body }}</p>
<div class="answer-controls">
<input type="checkbox" checked>
<span>Correct!</span>
{% if question.correct_answer_id == answer.id %}
<span class="correct-label">
✔ Correct
</span>
{% endif %}
</div>
{% if request.user == question.user %}
<button
class="correct-answer-btn"
data-question="{{ question.id }}"
data-answer="{{ answer.id }}"
>
Correct
</button>
{% endif %}
</div>
</article>
<article class="answer-card">
<div>
<div class="avatar-box">avatar</div>
<div class="vote-box">
<span>3</span>
<span class="vote-arrows">^<span>'</span></span>
</div>
</div>
<div>
<p>First of all I would like to thank you for the invitation to participate in such a ... Russia is the huge territory which in many respects needs to be render habitable.</p>
<div class="answer-controls">
<input type="checkbox">
<span>Correct!</span>
</div>
</div>
</article>
{% endfor %}
<form method="post">
{% csrf_token %}
{{ form.body }}
{{ form.body.errors }}
<button type="submit">
Answer
</button>
<form class="form">
<label for="answer">Enter your answer here..</label>
<textarea id="answer"></textarea>
<button class="button" type="button">Answer</button>
</form>
{% endblock %}
+29 -16
View File
@@ -7,38 +7,51 @@
<h1>Create Account</h1>
</div>
<p class="error">Sorry, this email address already registered!</p>
<form class="form" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.non_field_errors }}
<form class="form">
<div class="form-row">
<label for="login">Login</label>
<input id="login" type="text" value="dr_pepper">
<label>Login</label>
{{ form.username }}
{{ form.username.errors }}
</div>
<div class="form-row">
<label for="email">Email</label>
<input id="email" type="email" value="drpepper@mail.ru">
<label>Email</label>
{{ form.email }}
{{ form.email.errors }}
</div>
<div class="form-row">
<label for="nickname">NickName</label>
<input id="nickname" type="text" value="Dr. Pepper">
<label>NickName</label>
{{ form.nickname }}
{{ form.nickname.errors }}
</div>
<div class="form-row">
<label for="password">Password</label>
<input id="password" type="password" value="********">
<label>Password</label>
{{ form.password }}
{{ form.password.errors }}
</div>
<div class="form-row">
<label for="repeat">Repeat password</label>
<input id="repeat" type="password" value="********">
<label>Repeat password</label>
{{ form.password_repeat }}
{{ form.password_repeat.errors }}
</div>
<div class="form-row">
<label>Upload avatar</label>
<input type="file">
<label>Avatar</label>
{{ form.avatar }}
{{ form.avatar.errors }}
</div>
<div>
<button class="button" type="button">Register!</button>
<button class="button" type="submit">Register!</button>
</div>
</form>
{% endblock %}