Skip to content

Commit

Permalink
Change the way the control list filter view is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Sep 17, 2024
1 parent fbabbcf commit c6c0a15
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
28 changes: 16 additions & 12 deletions app/control_lists/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,6 @@ def information_read(control_list_id):
@login_required
@cl_editable("control_list_id")
def ignore_terms_filter(control_list_id, control_list):
current_controlList = ControlLists.query.filter_by(**{"id":control_list.id}).first_or_404()
print(current_controlList.filter_punct, current_controlList.filter_ignore)
list_filter = []
if request.method == "POST":
list_filter.append(request.form.get("punct"))
Expand All @@ -393,18 +391,24 @@ def ignore_terms_filter(control_list_id, control_list):
if el is not None:
filtered_filter.append(el)

current_controlList.filter_punct = 'punct' in filtered_filter
current_controlList.filter_metadata = 'metadata' in filtered_filter
current_controlList.filter_numeral = 'numeral' in filtered_filter
current_controlList.filter_ignore = 'ignore' in filtered_filter
db.session.add(current_controlList)
control_list.filter_punct = 'punct' in filtered_filter
control_list.filter_metadata = 'metadata' in filtered_filter
control_list.filter_numeral = 'numeral' in filtered_filter
control_list.filter_ignore = 'ignore' in filtered_filter
db.session.add(control_list)
db.session.commit()


flash('The filters have been updated.', 'success')
current_controlList = ControlLists.query.filter_by(**{"id":control_list_id}).first_or_404()
print(current_controlList.filter_punct, current_controlList.filter_ignore)
return render_template_with_nav_info('control_lists/ignore_filter.html', control_list_id=control_list_id,
current_control_list=current_controlList)
db.session.refresh(control_list)
return render_template_with_nav_info(
'control_lists/ignore_filter.html',
control_list_id=control_list_id,
control_list=control_list
)

return render_template_with_nav_info('control_lists/ignore_filter.html', control_list_id=control_list_id, current_control_list=current_controlList)
return render_template_with_nav_info(
'control_lists/ignore_filter.html',
control_list_id=control_list_id,
control_list=control_list
)
12 changes: 6 additions & 6 deletions app/templates/control_lists/ignore_filter.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{% extends 'layouts/base.html' %}
{% import 'macros/nav_macros.html' as nav %}

{% block page_title %}Control List {{current_control_list.name}}{% endblock %}
{% block page_title %}Control List {{control_list.name}}{% endblock %}

{% block content %}
<h1>{{current_control_list.name}}</h1>
<h1>{{control_list.name}}</h1>
<h2>{{ _('Change the filters for Control List') }}</h2>
<div class="row ">
<form method="POST">
<ul>
<li>
<label>
<input type="checkbox" name="punct" value="punct" {% if current_control_list.filter_punct %}checked{% endif %}>
<input type="checkbox" name="punct" value="punct" {% if control_list.filter_punct %}checked{% endif %}>
Punctuation
</label>
</li>
<li>
<label>
<input type="checkbox" name="numeral" value="numeral" {% if current_control_list.filter_numeral %}checked{% endif %}>
<input type="checkbox" name="numeral" value="numeral" {% if control_list.filter_numeral %}checked{% endif %}>
Numeral
</label>
</li>
<li>
<label>
<input type="checkbox" name="metadata" value="metadata" {% if current_control_list.filter_metadata %}checked{% endif %}>
<input type="checkbox" name="metadata" value="metadata" {% if control_list.filter_metadata %}checked{% endif %}>
Metadata
</label>
</li>
<li>
<label>
<input type="checkbox" name="ignore" value="ignore" {% if current_control_list.filter_ignore %}checked{% endif %}>
<input type="checkbox" name="ignore" value="ignore" {% if control_list.filter_ignore %}checked{% endif %}>
Ignore
</label>
</li>
Expand Down

0 comments on commit c6c0a15

Please sign in to comment.