Переместил кнопку редактирования задачи, добавил возможность менять статус шаблона у проекта
This commit is contained in:
parent
34462d76ee
commit
2f995f3ec9
66
main.py
66
main.py
@ -64,6 +64,8 @@ def base():
|
||||
|
||||
@app.route('/admin', methods=['GET', 'POST'])
|
||||
def admin():
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
if current_user.role == 1:
|
||||
data_session = db_session.create_session()
|
||||
@ -94,7 +96,9 @@ def admin():
|
||||
|
||||
@app.route('/template/<int:id_template>/create')
|
||||
def create_by_template(id_template):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
current_template = data_session.query(Projects).filter(Projects.id == id_template).first()
|
||||
if current_template:
|
||||
@ -120,7 +124,9 @@ def create_by_template(id_template):
|
||||
|
||||
@app.route('/template/<int:id_template>')
|
||||
def template_project(id_template):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
current_project = data_session.query(Projects).filter(Projects.id == id_template).first()
|
||||
if current_project:
|
||||
@ -136,7 +142,9 @@ def template_project(id_template):
|
||||
|
||||
@app.route('/showcase/link/<int:id_link>/delete')
|
||||
def delete_link(id_link):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
if current_user.role in [1, 4]:
|
||||
data_session = db_session.create_session()
|
||||
link = data_session.query(ShowCaseLink).filter(ShowCaseLink.id == id_link).first()
|
||||
@ -153,7 +161,9 @@ def delete_link(id_link):
|
||||
|
||||
@app.route('/showcase', methods=['GET', 'POST'])
|
||||
def showcase():
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
form = AddLink() if current_user.role in [1, 4] else None
|
||||
data_session = db_session.create_session()
|
||||
if request.method == 'POST' and current_user.role in [1, 4]:
|
||||
@ -171,14 +181,16 @@ def showcase():
|
||||
data_session.query(Projects).filter(Projects.is_template == 1).all()))
|
||||
list_links = data_session.query(ShowCaseLink).all()
|
||||
return render_template('showcase.html', title='Витрина', list_template=list_template, list_links=list_links,
|
||||
form=form, type=type)
|
||||
form=form)
|
||||
else:
|
||||
return redirect('/login')
|
||||
|
||||
|
||||
@app.route('/project/<int:id_project>/quest/<int:id_task>/edit', methods=['GET', 'POST'])
|
||||
def edit_quest(id_project, id_task):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
current_project = data_session.query(Projects).filter(Projects.id == id_project).first()
|
||||
current_task = data_session.query(Quests).filter(Quests.id == id_task).first()
|
||||
@ -215,7 +227,9 @@ def edit_quest(id_project, id_task):
|
||||
|
||||
@app.route('/project/<int:id_project>/file/<int:id_file>/delete')
|
||||
def delete_file(id_project, id_file):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
from_path = request.args.get('from') if request.args.get('from') else ''
|
||||
data_session = db_session.create_session()
|
||||
current_project = data_session.query(Projects).filter(Projects.id == id_project).first()
|
||||
@ -246,7 +260,9 @@ def delete_file(id_project, id_file):
|
||||
|
||||
@app.route('/project/<int:id_project>/quest/<int:id_task>', methods=['GET', 'POST'])
|
||||
def task_project(id_project, id_task):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
current_project = data_session.query(Projects).filter(Projects.id == id_project).first()
|
||||
current_task = data_session.query(Quests).filter(Quests.id == id_task).first()
|
||||
@ -314,7 +330,9 @@ def task_project(id_project, id_task):
|
||||
|
||||
@app.route('/project/<int:id_project>/quest/new', methods=['GET', 'POST'])
|
||||
def new_task_project(id_project):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
current_project = data_session.query(Projects).filter(Projects.id == id_project).first()
|
||||
if current_project:
|
||||
@ -345,7 +363,9 @@ def new_task_project(id_project):
|
||||
|
||||
@app.route('/project/<int:id_project>/edit', methods=['GET', 'POST'])
|
||||
def edit_project(id_project):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
current_project = data_session.query(Projects).filter(Projects.id == id_project).first()
|
||||
if current_project:
|
||||
@ -382,6 +402,7 @@ def edit_project(id_project):
|
||||
data_session.commit()
|
||||
current_project.name = form.name.data
|
||||
current_project.description = form.description.data
|
||||
current_project.is_template = form.is_template.data
|
||||
data_session.commit()
|
||||
return redirect(f'/project/{current_project.id}')
|
||||
if form.del_photo.data:
|
||||
@ -391,6 +412,7 @@ def edit_project(id_project):
|
||||
return redirect(f'/project/{current_project.id}/edit')
|
||||
form.name.data = current_project.name
|
||||
form.description.data = current_project.description
|
||||
form.is_template.data = current_project.is_template
|
||||
return render_template('edit_project.html', title='Изменение проекта', form=form, list_users=list_users,
|
||||
staff=staff, project=current_project)
|
||||
else:
|
||||
@ -403,7 +425,9 @@ def edit_project(id_project):
|
||||
|
||||
@app.route('/project/<int:id_project>', methods=['POST', 'GET'])
|
||||
def project(id_project):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
current_project = data_session.query(Projects).filter(Projects.id == id_project).first()
|
||||
if current_project:
|
||||
@ -486,7 +510,9 @@ def recovery():
|
||||
|
||||
@app.route('/project/<int:id_project>/delete', methods=['GET', 'POST'])
|
||||
def delete_project(id_project):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
project_del = data_session.query(Projects).filter(Projects.id == id_project).first()
|
||||
if project_del:
|
||||
@ -511,7 +537,9 @@ def delete_project(id_project):
|
||||
|
||||
@app.route('/user/<string:_login>', methods=['GET', 'POST'])
|
||||
def user_view(_login):
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
user = data_session.query(User).filter(User.login == _login).first()
|
||||
if user:
|
||||
@ -532,7 +560,9 @@ def user_view(_login):
|
||||
|
||||
@app.route('/projects/new', methods=['GET', 'POST'])
|
||||
def new_project():
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
form = ProjectForm()
|
||||
data_session = db_session.create_session()
|
||||
list_users = list(
|
||||
@ -569,7 +599,9 @@ def new_project():
|
||||
|
||||
@app.route('/projects', methods=['GET', 'POST'])
|
||||
def projects():
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
find = False
|
||||
form = FindProjectForm()
|
||||
data_session = db_session.create_session()
|
||||
@ -597,7 +629,9 @@ def projects():
|
||||
|
||||
@app.route('/profile', methods=['GET', 'POST'])
|
||||
def profile():
|
||||
if current_user.is_authenticated and not current_user.banned:
|
||||
if current_user.banned:
|
||||
return redirect('/logout')
|
||||
if current_user.is_authenticated:
|
||||
data_session = db_session.create_session()
|
||||
form = EditProfileForm(
|
||||
CombinedMultiDict((request.files, request.form)),
|
||||
|
||||
@ -26,35 +26,6 @@ body {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.link_edit_block {
|
||||
margin-left: 0.5vw;
|
||||
background-color: #9E795A;
|
||||
border: #9E795A;
|
||||
width: 13vw;
|
||||
height: 4.5vw;
|
||||
color: #ffffff;
|
||||
border-radius: 5vw;
|
||||
vertical-align: middle;
|
||||
font-size: 1.5vw;
|
||||
}
|
||||
.link_edit {
|
||||
width: 13vw;
|
||||
height: 4.5vw;
|
||||
}
|
||||
.link_edit:hover {
|
||||
text-decoration: none;
|
||||
color: #000000;
|
||||
}
|
||||
.link_edit_text {
|
||||
width: 13vw;
|
||||
height: 4.5vw;
|
||||
text-align: center;
|
||||
font-size: 1.5vw;
|
||||
color: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.link_back {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
|
||||
@ -309,7 +309,6 @@
|
||||
background-color: #000000;
|
||||
border: 2px solid #ffffff;
|
||||
border-radius: 3vw;
|
||||
margin-left: 2vw;
|
||||
}
|
||||
.quest_solve_link:hover {
|
||||
text-decoration: none;
|
||||
@ -328,14 +327,14 @@
|
||||
#quest_solve_link_id {
|
||||
display: none;
|
||||
}
|
||||
.link_back_block {
|
||||
.link_back_block, .link_edit_block {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
.link_back {
|
||||
.link_back, .link_edit {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
width: 15vw;
|
||||
@ -346,11 +345,14 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.link_back:hover {
|
||||
.link_edit {
|
||||
width: 13vw;
|
||||
}
|
||||
.link_back:hover, .link_edit:hover {
|
||||
text-decoration: none;
|
||||
color: #000000;
|
||||
}
|
||||
.link_back_text {
|
||||
.link_back_text, .link_edit_text {
|
||||
font-size: 1.5vw;
|
||||
margin-top: 15px;
|
||||
display: flex;
|
||||
@ -415,4 +417,15 @@
|
||||
}
|
||||
.button_text {
|
||||
font-size: 1.3vw;
|
||||
}
|
||||
.quest_buttons_block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 15vw;
|
||||
margin-top: 3vw;
|
||||
}
|
||||
.link_edit_block {
|
||||
margin-top: 1vw;
|
||||
}
|
||||
@ -7,13 +7,6 @@
|
||||
<p class="link_back_text">К проекту</p>
|
||||
</a>
|
||||
</div>
|
||||
{% if task.creator == current_user.id or project.creator == current_user.id %}
|
||||
<div class="link_edit_block">
|
||||
<a class="link_edit" href="{{ task.id }}/edit">
|
||||
<p class="link_edit_text">Редактировать</p>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="name_block">
|
||||
<div class="title_block">
|
||||
|
||||
@ -46,6 +46,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttons_form_block">
|
||||
<div class="box">
|
||||
{{ form.is_template(class="is_template")}} {{form.is_template.label }}<br/>
|
||||
{% for error in form.is_template.errors %}
|
||||
<div class="alert alert-danger" role="alert">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if 'none' in project.photo %}
|
||||
<div class="form_data">
|
||||
<label class="form_label">{{ form.logo.label }}</label>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<p style="width: 12vw;"> </p>
|
||||
<p style="width: 12vw;"></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="brand_block">
|
||||
@ -62,10 +62,11 @@
|
||||
data-bs-target="#panelsStayOpen-collapse{{ quest.id }}" aria-expanded="true"
|
||||
aria-controls="panelsStayOpen-collapse{{ quest.id }}">
|
||||
<div class="quest_button_block_one">
|
||||
<div class="quest_title_block"{% if project.is_template %}style="width:100%;!important"{% endif %}>
|
||||
<div class="quest_title_block" {% if project.is_template
|
||||
%}style="width:100%;!important" {% endif %}>
|
||||
<p class="quest_title">{{ quest.name }}</p>
|
||||
</div>
|
||||
{% if not project.is_template %}
|
||||
{% if not project.is_template %}
|
||||
</div>
|
||||
{% if quest.overdue == 'yes' and quest.realized != 1 %}
|
||||
<div class="deadline_block alert alert-danger" role="alert">
|
||||
@ -103,11 +104,20 @@
|
||||
<p class="quest_description_text">{{ quest.description }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="quest_buttons_block">
|
||||
<div class="quest_solve_button">
|
||||
<a class="quest_solve_link" href="{{ project.id }}/quest/{{ quest.id }}">
|
||||
<p class="quest_solve_text">Решить</p>
|
||||
</a>
|
||||
</div>
|
||||
{% if quest.creator == current_user.id or project.creator == current_user.id %}
|
||||
<div class="link_edit_block">
|
||||
<a class="link_edit" href="{{ project.id }}/quest/{{ quest.id }}/edit">
|
||||
<p class="link_edit_text">Редактировать</p>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="quest_body">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user