Skip to content

Commit

Permalink
Add search in Postmortem names
Browse files Browse the repository at this point in the history
  • Loading branch information
Pasha Radchenko committed Mar 25, 2021
1 parent 6741f2b commit 5605314
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 12 deletions.
5 changes: 5 additions & 0 deletions autopsy_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ class SupportForm(FlaskForm):
validators=[FileAllowed(['jpg', 'png'],
'Images only!')])
submit = SubmitField('Request for help')


class SearchForm(FlaskForm):
title = StringField('Type to search', validators=[DataRequired(), Length(max=100)])
submit = SubmitField('help')
12 changes: 9 additions & 3 deletions autopsy_app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,16 @@ def update_postmortem(url):
return render_template('update_postmortem.html', mortem=mortem, form=form)


@app.route('/notifications')
@app.route('/search', methods=['GET', 'POST'])
@login_required
def notify():
pass
def search():
if request.method == 'POST':
query = request.form['search_query']
mortems = Mortem.query.filter(
Mortem.mortem_name.like(f"%{query}%") ).all()
else:
mortems = None
return render_template('search.html', mortems=mortems)


@app.route('/support', methods=['GET', 'POST'])
Expand Down
17 changes: 14 additions & 3 deletions autopsy_app/static/autopsy.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@
}

.btn-outline-autopsy {
border: 0.05rem solid #8a2be2;
color: #fff;
background-color: #8a2be2;
}

.btn-outline-autopsy:hover{
border: 0.05rem solid #8a2be2;
color: #fff;
background-color: #8a2be2;
}

/*
Expand Down Expand Up @@ -128,11 +128,22 @@
border-top-right-radius: 0;
}

.menuprofile {
color: #fff;
}

.menuprofile img{
width: 35%;
vertical-align: middle;
border-radius: 50%;
border: 0.15rem solid #d2d2;
}

.userava {
width: 35%;
vertical-align: middle;
border-radius: 50%;
border: 1px solid #d2d2;
border: 0.15rem solid #d2d2;
}

.ava {
Expand Down
10 changes: 6 additions & 4 deletions autopsy_app/templates/base/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
Autopsy
</a>
</div>
<form class="d-flex col-3 mx-5 px-3">
<input class="form-control col-1" type="text" placeholder="Type to search" aria-label="Search">
<button class="btn form-control btn-outline-autopsy" type="submit">Search</button>
</form>
<div class="d-flex col-1 align-items-center justify-content-end menuprofile">
<h5 class="align-center">{{ current_user.user_name }}</h5>
<a href="{{ url_for('profile') }}">
<img src="{{ url_for('static', filename="ava/"+current_user.user_image) }}">
</a>
</div>
</div>
</nav>

Expand Down
10 changes: 8 additions & 2 deletions autopsy_app/templates/base/top_layer.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ <h6 class="sidebar-heading d-flex justify-content-between align-items-center mt-
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('notify') }}">
<a class="nav-link" href="{{ url_for('search') }}">
<span data-feather="search"></span>
Search
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="bell"></span>
Notifications
Notifications?
</a>
</li>
</ul>
Expand Down
41 changes: 41 additions & 0 deletions autopsy_app/templates/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% extends "base/middle_layer.html" %}

{% block title %}
<title>Autopsy: Search</title>
{% endblock title %}

{% block content_top %}
<div class="flex-row d-flex">
<form class="d-flex col-8 mx-5 px-5" action="" method="POST">
<input class="form-control col-1" type="text" name="search_query" placeholder="Type to search" aria-label="Search">
<button class="btn form-control btn-outline-autopsy" name="search" type="submit">Search</button>
</form>
</div>
</div>
{% endblock content_top %}


{% block content_body %}
{% if mortems %}
<div class="flex-row">
{% for mortem in mortems|reverse() %}
<div class="mortem m-2 p-3">
<h5>
<img class="small-ava" src="{{ url_for('static', filename="ava/"+mortem.author.user_image) }}">
<a href="mailto:{{ mortem.author.user_email }}?subject=Mail from Autopsy regarding {{ mortem.mortem_url }}">{{ mortem.author.user_name }}</a>
</h5>
<h3>
<a href="postmortems/{{ mortem.mortem_url }}">{{ mortem.mortem_name | truncate(60, True) }}</a>
</h3>
<p>
<small>Created: {{ mortem.mortem_created }} </small>
</p>
<p>
<small>Last updated: {{ mortem.mortem_created }}</small>
</p>
</div>
{% endfor %}
</div>
{% endif %}
{% endblock content_body %}

0 comments on commit 5605314

Please sign in to comment.