Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Search minutes #635

Merged
merged 1 commit into from
Feb 26, 2018
Merged

Search minutes #635

merged 1 commit into from
Feb 26, 2018

Conversation

julkw
Copy link
Collaborator

@julkw julkw commented Feb 5, 2018

add a search bar in minutes lists with which you ca search through all minutes at once

@janno42 janno42 mentioned this pull request Feb 11, 2018
Copy link
Collaborator

@janno42 janno42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for working on this and especially for nice test writing :)
please have a look at my comments and the linter errors.

<form action="{% url 'minutes:search' group_id %}" method="post" id="text_search">
{% csrf_token %}
{{search_form}}
</form>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add some additional space after the search field

@@ -0,0 +1,62 @@
{% extends 'minutes_list.html' %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this copies quite a lot of code. please think of a way to reuse more of the existing minutes_list.html file.

search_text = form.cleaned_data['search_phrase']

# filter for documents that contain the searched for string
minutes = MinutesDocument.objects.filter(text__icontains=search_text).prefetch_related('labels').order_by('-date')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fails if the page was requested via GET instead of POST (e.g., because the search url was manually requested again), because search_phrase is then unbound. you should handle this case and display an error message or just redirect to the minutes list.

for m in minutes:
# find line with the searched for string
document_content = m.text
lines = document_content.splitlines()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please combine the two lines above to just lines = m.text.splitlines()?

text2 = "in both minutes notO \n one notB \n substring notB notO"
text3 = "this will never show up notB notO"

cls.minutes_document1 = mommy.make(MinutesDocument, text = text1, title = "MinutesOne")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and at some other places the code doesn't follow our styleguide. please check the linter errors for more information. the linter is part of the travis checks and you can run it locally via python manage.py lint.

@@ -78,6 +78,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is likely the reason why the tests fail.

it's needed for using the postgres full text search functionality (see here and here, but that's not used right now in this PR as far as i can see.

by using that you would gain stuff like searching for multiple words which would then not need to be adjacent, and weighting the results by some relevancy metric, so it might be worth checking out?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i would suggest that for #212

<td style="width: 55%;">
<a href="{{ minute.get_view_url }}">{{ minute.title }}</a>
{% for line in lines %}
<br>{{line}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<br /> please

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and {{ line }}

Copy link
Collaborator

@janno42 janno42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could display all lines as <li> elements so that it gets clear which text belongs to the same snippet. Also it would be really nice to highlight (e.g. in bold text) where the search term occurs in the respective line.

i think we're done after that - you could then squash all your commits into one and rebase it on the current master branch.

<em>
{% blocktrans %} No documents containing "{{ phrase }}" found.{% endblocktrans %}
</em>
{% endblock %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a newline at the end of the file

@@ -8,6 +8,10 @@
{% block sidebar %}
<div class="toc hidden-print">
<ul>
<form class="pb-2" action="{% url 'minutes:search' group_id %}" method="post" id="text_search">
{% csrf_token %}
{{search_form}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{ search_form }}

<tr>
<td style="width: 15%;">
<a href="{{ minute.get_view_url }}">{{ minute.date | date:"d.m.Y" }}</a>
</td>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the empty line



def search(request, groupid):

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the empty line


if(request.method == 'POST'):
form = SearchForm(request.POST)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the empty line

@julkw julkw force-pushed the search_minutes branch 3 times, most recently from 8808d4c to 3aa4aba Compare February 26, 2018 20:33
@Bartzi Bartzi merged commit 6916f87 into fsr-de:master Feb 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants