Skip to content

Commit 3dcf241

Browse files
committed
Update some views
1 parent 09bb68b commit 3dcf241

File tree

6 files changed

+55
-29
lines changed

6 files changed

+55
-29
lines changed

blog/static/style.css

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
margin: 10px 10px;
2828
}
2929
.auth-form {
30-
margin: 10px;
3130
display: flex;
3231
flex-direction: column;
3332
align-items: center;
@@ -46,5 +45,26 @@
4645
}
4746

4847
.blog-small-image {
49-
max-width: 100px;
48+
max-width: 150px;
49+
}
50+
51+
.btn-index-form {
52+
width: 160px;
53+
height: 40px;
54+
align-content: center;
55+
font-size: 18px;
56+
margin-top: 10px;
57+
}
58+
59+
.product-item {
60+
margin-bottom: 20px;
61+
height: 100%;
62+
display: flex;
63+
flex-direction: column;
64+
}
65+
66+
.product-item .panel-body {
67+
flex: 1;
68+
display: flex;
69+
flex-direction: column;
5070
}

blog/templates/blog/navbar.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
<button class="btn btn-primary" type="button">Create new article</button>
2626
</a>
2727
</div>
28+
<div>
29+
<a href="{% url 'profile' user.id %}">
30+
<button class="btn btn-secondary" type="button" style="font-size: 16px">
31+
<i class="bi bi-person-fill"></i>
32+
</button>
33+
</a>
34+
</div>
2835
<form class="d-flex" action="{% url 'logout' %}" method="post">
2936
{% csrf_token %}
3037
<!-- Используйте Bootstrap Icons -->

blog/templates/blog/profile.html

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,26 @@
33
{% block title %}Profile{% endblock %}
44

55
{% block content %}
6+
{% include 'blog\navbar.html' %}
67

78
<div class="index-form center-block">
8-
<div class="product-item panel panel-default">
9-
<div class="panel-body">
10-
<div class="center-block" style="font-size: 35px">
11-
<span class="glyphicon glyphicon-user"></span>
9+
<div class="product-item card">
10+
<div class="card-body">
11+
<div class="d-flex justify-content-center" style="font-size: 55px">
12+
<i class="bi bi-person-fill"></i>
1213
</div>
1314

14-
<p><b>Username</b>: {{ user.username }}</p>
15-
<p><b>Email</b>: {{ user.email }}</p>
16-
<p><b>Balance</b>: {{ user.balance }}$</p>
15+
<p><b>Username</b>: {{ profile.username }}</p>
16+
<p><b>Email</b>: {{ profile.email }}</p>
1717

18-
<form class="center-block" action="{% url 'password_change' %}" method="POST">
19-
{% csrf_token %}
20-
<button type="submit" class="btn btn-primary btn-index-form">Reset Password</button>
21-
</form>
18+
{% if profile.id == user.id %}
19+
<form class="d-flex justify-content-center mt-4" action="{% url 'password_change' %}" method="POST">
20+
{% csrf_token %}
21+
<button type="submit" class="btn btn-primary btn-index-form">Reset Password</button>
22+
</form>
23+
{% endif %}
2224
</div>
2325
</div>
24-
25-
<a style="font-size: 30px;" href="{% url 'blog:index' %}">
26-
<span class="glyphicon glyphicon-home"></span>
27-
</a>
2826
</div>
2927

3028
{% endblock %}

blog/templates/blog/write_article.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
{% include 'blog\navbar.html' %}
88

9-
<div class="container mt-5 d-flex justify-content-center align-items-center full-height">
9+
<div class="container mt-10 d-flex justify-content-center align-items-center full-height">
1010
<form method="POST" class="w-50">
1111
{% csrf_token %}
1212

blog/templates/registration/signup.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
<h2><b>Sign up</b></h2>
88
<form class="auth-form" method="post">
99
{% csrf_token %}
10-
<div class="form-group">
10+
<div class="mt-3 mb-3">
1111
<div>
12-
<label for="id_username">Username:</label>
12+
<label class="form-label" for="id_username">Username:</label>
1313
<div class="helptext" id="id_username_helptext">Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.</div>
1414
<input style="width: 470px" class="form-control" type="text" name="username" autocapitalize="none" autocomplete="username" autofocus="" required="" aria-describedby="id_username_helptext" id="id_username">
1515
</div>
1616
</div>
1717

18-
<div class="form-group">
19-
<div>
20-
<label for="id_password1">Password:</label>
18+
<div class="mt-3 mb-3">
19+
<div style="max-width: 470px">
20+
<label class="form-label" for="id_password1">Password:</label>
2121
<div class="helptext" id="id_password1_helptext">
2222
<ul>
2323
<li>Your password can’t be too similar to your other personal information.</li><li>Your password must contain at least 8 characters.</li>
@@ -28,17 +28,17 @@ <h2><b>Sign up</b></h2>
2828
</div>
2929
</div>
3030

31-
<div class="form-group">
31+
<div class="mt-3 mb-3">
3232
<div>
33-
<label for="id_password2">Password confirmation:</label>
33+
<label class="form-label" for="id_password2">Password confirmation:</label>
3434
<div class="helptext" id="id_password2_helptext">Enter the same password as before, for verification.</div>
3535
<input style="width: 470px" class="form-control" type="password" name="password2" autocomplete="new-password" required="" aria-describedby="id_password2_helptext" id="id_password2">
3636
</div>
3737
</div>
3838

39-
<button class="btn btn-default btn-lg" type="submit">Sign Up</button>
39+
<button class="btn btn-primary btn-lg mt-2" type="submit">Sign Up</button>
4040
</form>
4141

42-
<a style="margin-top: 20px" class="btn-sm btn-default" href="{% url 'index' %}">Back</a>
42+
<a style="margin-top: 20px" class="btn btn-secondary" href="{% url 'index' %}">Back</a>
4343
</div>
4444
{% endblock %}

blog/views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.contrib import messages
22
from django.contrib.auth.decorators import permission_required, login_required
33
from django.contrib.auth.forms import UserCreationForm
4-
from django.shortcuts import render
4+
from django.shortcuts import render, get_object_or_404
55
from django.urls import reverse, reverse_lazy
66
from django.views import generic
77
from django.views.generic import CreateView
@@ -26,7 +26,8 @@ def index(request):
2626

2727
# Not implemented yet
2828
def profile(request, id):
29-
return render(request, "blog/index.html", {"articles": Article.objects.all()})
29+
profile = get_object_or_404(BlogUser, id=id)
30+
return render(request, "blog/profile.html", {"profile": profile})
3031

3132

3233
def get_article(request, link: str): # TODO: Добавить проверку на method ендпоинта

0 commit comments

Comments
 (0)