Добавлена страница отображения информации о пользователе по адресу: "user/<login>", страница ошибок была унифицирована и теперь используется для всех ошибок, прописанных в main.py. При нажатии на пользователя, сайт перекидывает на страницу отображения информации о нем.
This commit is contained in:
parent
22da6ee3ef
commit
25e24462ff
19
main.py
19
main.py
@ -64,6 +64,25 @@ def delete_project(id_project):
|
||||
return redirect('/login')
|
||||
|
||||
|
||||
@app.route('/user/<string:_login>', methods=['GET', 'POST'])
|
||||
def user_view(_login):
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
user = data_session.query(User).filter(User.login == _login).first()
|
||||
if user:
|
||||
projects = data_session.query(Projects).filter(or_(Projects.creator == user.id, Projects.id.in_(
|
||||
list(map(lambda x: x[0], data_session.query(
|
||||
StaffProjects.project).filter(
|
||||
StaffProjects.user == user.id).all()))))).all()
|
||||
resp = list(map(lambda x: get_projects_data(x), projects))
|
||||
return render_template('user_view.html', title=user.name + ' ' + user.surname, user=user,
|
||||
list_projects=resp)
|
||||
else:
|
||||
abort(404)
|
||||
else:
|
||||
return redirect('/login')
|
||||
|
||||
|
||||
@app.route('/projects/new', methods=['GET', 'POST'])
|
||||
def new_project():
|
||||
if current_user.is_authenticated:
|
||||
|
||||
@ -232,6 +232,7 @@
|
||||
margin-left: 9px;
|
||||
margin-top: 10px;
|
||||
overflow-x: auto;
|
||||
color: #000000 !important;
|
||||
}
|
||||
.new_project_button {
|
||||
width: 13vw;
|
||||
@ -263,4 +264,17 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.link_to_user {
|
||||
width: 16vw;
|
||||
height: 3.5vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex-direction: row;
|
||||
flex-wrap: no-wrap;
|
||||
text-decoration: none;
|
||||
}
|
||||
.link_to_user:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
217
static/css/user_view.css
Normal file
217
static/css/user_view.css
Normal file
@ -0,0 +1,217 @@
|
||||
.user_view_page {
|
||||
height: 120vw;
|
||||
background-color: #dcb495;
|
||||
}
|
||||
.user_data_block {
|
||||
width: 85%;
|
||||
height: 65vw;
|
||||
margin-left: 7.5%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
background-color:#a8886f;
|
||||
border-radius: 4vw;
|
||||
}
|
||||
.user_photo {
|
||||
margin-top: 30px;
|
||||
width: 15vw;
|
||||
height: 15vw;
|
||||
border: 0.2vw solid #ffffff;
|
||||
border-radius: 2vw;
|
||||
}
|
||||
.first_data_block {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
.user_data {
|
||||
width: 95%;
|
||||
height: 30vw;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.data_header {
|
||||
font-size: 2vw;
|
||||
color: #ffffff;
|
||||
font-weight: bold;
|
||||
}
|
||||
.data_block {
|
||||
background-color:#f5d3b8;
|
||||
width: 25vw;
|
||||
height: 5vw;
|
||||
border-radius: 5vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.data_text {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-top: 5px;
|
||||
font-size: 1.5vw;
|
||||
color: #000000;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.surname_block, .about_block {
|
||||
width: 90%;
|
||||
}
|
||||
.about_bottom {
|
||||
border-radius: 3vw;
|
||||
height: 20vw !important;
|
||||
}
|
||||
.data_bottom {
|
||||
width: 100% !important;
|
||||
}
|
||||
.list_project {
|
||||
width: 95%;
|
||||
margin-left: 2.5%;
|
||||
margin-top: 2vw;
|
||||
overflow-y: hidden;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.project_header_button {
|
||||
height: 5.5vw;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
border-radius: 5vw;
|
||||
background-color: #9E795A;
|
||||
border-color: #9E795A;
|
||||
border-bottom-color: #9E795A;
|
||||
color: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.project_description_block {
|
||||
background-color: #9E795A;
|
||||
width: 100%;
|
||||
height: 20vw;
|
||||
border-radius: 2vw;
|
||||
}
|
||||
.project_logo_block {
|
||||
width: 4.5vw;
|
||||
height: 4.5vw;
|
||||
border: 0.3vw solid #ffffff;
|
||||
background-color: #ffffff;
|
||||
border-radius: 2vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.project_logo {
|
||||
width: 4vw;
|
||||
height: 4vw;
|
||||
border-radius: 5vw;
|
||||
}
|
||||
.project_title_block {
|
||||
width: 70%;
|
||||
height: 4vw;
|
||||
}
|
||||
.project_title {
|
||||
font-size: 3.5vw;
|
||||
}
|
||||
.project_button_block_one {
|
||||
width: 50%;
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.project_description {
|
||||
width: 98%;
|
||||
height: 100%;
|
||||
margin-left: 1%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
.collaborator_block {
|
||||
width: 22%;
|
||||
height: 90%;
|
||||
background-color: #EDCBB0;
|
||||
border-radius: 2vw;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.description_block {
|
||||
width: 48%;
|
||||
height: 90%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
.description_header_text {
|
||||
font-size: 2vw;
|
||||
}
|
||||
.description_block_text {
|
||||
width: 90% !important;
|
||||
height: 80% !important;
|
||||
width: 50%;
|
||||
background-color: #dcb495;
|
||||
border-radius: 2vw;
|
||||
}
|
||||
.description_text {
|
||||
width: 100% !important;
|
||||
height: 100%;
|
||||
font-size: 1.5vw;
|
||||
overflow-wrap: normal; /* не поддерживает IE, Firefox; является копией word-wrap */
|
||||
word-wrap: normal;
|
||||
word-break: normal; /* не поддерживает Opera12.14, значение keep-all не поддерживается IE, Chrome */
|
||||
line-break: auto; /* нет поддержки для русского языка */
|
||||
hyphens: manual; /* значение auto не поддерживается Chrome */
|
||||
margin: 2vw;
|
||||
}
|
||||
.user_projects_block {
|
||||
margin-top: 35px;
|
||||
margin-left: 3%;
|
||||
border: 0.2vw solid #694a2d;
|
||||
border-radius: 4.5vw;
|
||||
width: 94%;
|
||||
height: 45vw;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.user {
|
||||
width: 16vw;
|
||||
height: 3.5vw;
|
||||
background-color: #ffffff;
|
||||
border: 2px solid #9E795A;
|
||||
border-radius: 3vw;
|
||||
margin-top: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex-direction: row;
|
||||
flex-wrap: no-wrap;
|
||||
}
|
||||
.user_logo {
|
||||
margin-left: 3px;
|
||||
width: 3vw;
|
||||
height: 3vw;
|
||||
border-radius: 5vw;
|
||||
background-color: #000000;
|
||||
}
|
||||
.user_names {
|
||||
margin-left: 9px;
|
||||
margin-top: 10px;
|
||||
overflow-x: auto;
|
||||
color: #000000 !important;
|
||||
}
|
||||
.link_to_user {
|
||||
width: 16vw;
|
||||
height: 3.5vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex-direction: row;
|
||||
flex-wrap: no-wrap;
|
||||
text-decoration: none;
|
||||
}
|
||||
.link_to_user:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
@ -42,8 +42,10 @@
|
||||
<div class="staff_block">
|
||||
{% for user in project.staff %}
|
||||
<div class="user">
|
||||
<img class="user_logo" src="{{user.photo}}">
|
||||
<p class="user_names">{{user.name}}</p>
|
||||
<a class="link_to_user" href="/user/{{ user.login }}">
|
||||
<img class="user_logo" src="{{user.photo}}">
|
||||
<p class="user_names">{{user.name}}</p>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
86
templates/user_view.html
Normal file
86
templates/user_view.html
Normal file
@ -0,0 +1,86 @@
|
||||
<link rel="stylesheet" href="../static/css/user_view.css"/>
|
||||
{% extends "base.html" %} {% block content %}
|
||||
<div class="user_view_page">
|
||||
<div class="user_data_block">
|
||||
<div class="header_user">
|
||||
<img class="user_photo" src="../{{user.photo}}"/>
|
||||
</div>
|
||||
<div class="user_data">
|
||||
<div class="first_data_block">
|
||||
<div class="name_block">
|
||||
<p class="data_header">Имя</p>
|
||||
<div class="data_block">
|
||||
<p class="data_text">{{ user.name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login_block">
|
||||
<p class="data_header">Логин</p>
|
||||
<div class="data_block">
|
||||
<p class="data_text">{{ user.login }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="surname_block">
|
||||
<p class="data_header">Фамилия</p>
|
||||
<div class="data_block data_bottom">
|
||||
<p class="data_text">{{ user.surname }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="about_block">
|
||||
<p class="data_header">О себе</p>
|
||||
<div class="data_block data_bottom about_bottom">
|
||||
<p class="data_text">{{ user.about }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="user_projects_block">
|
||||
{% for project in list_projects %}
|
||||
<div class="accordion list_project" id="accordionPanelsStayOpen{{ project.id }}">
|
||||
<div class="accordion-item project">
|
||||
<h2 class="accordion-header project_header" id="panelsStayOpen-heading{{ project.id }}">
|
||||
<button class="accordion-button project_header_button" type="button" data-bs-toggle="collapse"
|
||||
data-bs-target="#panelsStayOpen-collapse{{ project.id }}" aria-expanded="true"
|
||||
aria-controls="panelsStayOpen-collapse{{ project.id }}">
|
||||
<div class="project_button_block_one">
|
||||
<div class="project_logo_block">
|
||||
<img src="../{{ project.logo }}" class="project_logo">
|
||||
</div>
|
||||
<div class="project_title_block">
|
||||
<p class="project_title">{{ project.name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="panelsStayOpen-collapse{{ project.id }}"
|
||||
class="accordion-collapse collapse project_description_block"
|
||||
aria-labelledby="panelsStayOpen-heading{{ project.id }}">
|
||||
<div class="accordion-body project_description">
|
||||
<div class="collaborator_block">
|
||||
<div class="staff_block">
|
||||
{% for user in project.staff %}
|
||||
<div class="user">
|
||||
<a class="link_to_user" href="/user/{{ user.login }}">
|
||||
<img class="user_logo" src="../{{user.photo}}">
|
||||
<p class="user_names">{{user.name}}</p>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="description_block">
|
||||
<div class="description_header_block">
|
||||
<p class="description_header_text">Описание</p>
|
||||
</div>
|
||||
<div class="description_block_text">
|
||||
<p class="description_text">{{ project.description }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Loading…
x
Reference in New Issue
Block a user