diff --git a/oioioi/problems/fixtures/test_problem_search.json b/oioioi/problems/fixtures/test_problem_search.json
index e5c35f4aa..05c8aed30 100644
--- a/oioioi/problems/fixtures/test_problem_search.json
+++ b/oioioi/problems/fixtures/test_problem_search.json
@@ -33,8 +33,8 @@
"pk": 3,
"model": "problems.problem",
"fields": {
- "legacy_name": "Znacznik",
- "ascii_name": "Znacznik",
+ "legacy_name": "Znaczn1k",
+ "ascii_name": "Znaczn1k",
"short_name": "zna1",
"visibility": "PU"
}
diff --git a/oioioi/problems/static/common/tag_selection.js b/oioioi/problems/static/common/tag_selection.js
index 928a117ba..5ade7751f 100644
--- a/oioioi/problems/static/common/tag_selection.js
+++ b/oioioi/problems/static/common/tag_selection.js
@@ -116,10 +116,10 @@ function init_search_selection(id) {
} else if (item.trigger !== 'problem') {
// At this point for anything other than a problem we
// want to create a search tag
- const value = item.value || item.name;
+ const value = item.value;
// Only create new search tag if it doesn't exist yet
- const tag = $(".search-tag-text:contains('" + value + "')");
+ const tag = $("input[name='" + item.prefix + "'][value='" + value + "']");
if (tag.length === 0) {
const tag = value.split('_')[0];
diff --git a/oioioi/problems/templates/problems/problemset/base.html b/oioioi/problems/templates/problems/problemset/base.html
index b9234971c..30784c843 100644
--- a/oioioi/problems/templates/problems/problemset/base.html
+++ b/oioioi/problems/templates/problems/problemset/base.html
@@ -62,25 +62,26 @@
+ {% if show_tags %}
{% with delete_me="this.parentNode.parentNode.remove()" %}
{% include "problems/problemset/search-tag.html" with input_class="collapse" input_attr="disabled" %}
{% for tag in difficulty_tags %}
- {% include "problems/problemset/search-tag.html" with input_name="difficulty" input_text=tag.full_name input_attr="readonly" input_script=delete_me %}
+ {% include "problems/problemset/search-tag.html" with input_name="difficulty" input_value=tag input_text=tag.full_name input_attr="readonly" input_script=delete_me %}
{% endfor %}
{% for tag in algorithm_tags %}
- {% include "problems/problemset/search-tag.html" with input_name="algorithm" input_text=tag input_attr="readonly" input_script=delete_me %}
+ {% include "problems/problemset/search-tag.html" with input_name="algorithm" input_value=tag input_text=tag input_attr="readonly" input_script=delete_me %}
{% endfor %}
{% for tag, origininfo in origin_tags.items %}
- {% include "problems/problemset/search-tag.html" with input_name="origin" input_text=tag input_attr="readonly" input_script="this.parentNode.parentNode.parentNode.remove()" %}
+ {% include "problems/problemset/search-tag.html" with input_name="origin" input_value=tag input_text=tag input_attr="readonly" input_script="this.parentNode.parentNode.parentNode.remove()" %}
{% for info in origininfo %}
{% include "problems/problemset/search-tag.html" with input_name="origin" input_value=tag|add:"_"|add:info input_text=info input_attr="readonly" input_script=delete_me %}
{% endfor %}
{% endfor %}
-
{% endwith %}
+ {% endif %}
{% endif %}
diff --git a/oioioi/problems/tests/test_problem.py b/oioioi/problems/tests/test_problem.py
index a460d6060..6d0b59763 100644
--- a/oioioi/problems/tests/test_problem.py
+++ b/oioioi/problems/tests/test_problem.py
@@ -740,6 +740,7 @@ def test_search_permissions_all(self):
self.assert_contains_only(response, self.task_names)
+@override_settings(PROBLEM_TAGS_VISIBLE=True)
class TestProblemSearch(TestCase, AssertContainsOnlyMixin):
fixtures = ['test_problem_search']
url = reverse('problemset_main')
@@ -747,7 +748,7 @@ class TestProblemSearch(TestCase, AssertContainsOnlyMixin):
'Prywatne',
'Zadanko',
'Żółć',
- 'Znacznik',
+ 'Znaczn1k',
'Algorytm',
'Trudność',
'Bajtocja',
@@ -797,7 +798,7 @@ def test_search_name_multiple(self):
response = self.client.get(self.url, {'q': 'a'})
self.assertEqual(response.status_code, 200)
self.assert_contains_only(
- response, ('Zadanko', 'Znacznik', 'Algorytm', 'Byteland')
+ response, ('Zadanko', 'Znaczn1k', 'Algorytm', 'Byteland')
)
def _test_search_name_localized(self, queries, exp_names):
@@ -833,7 +834,7 @@ def test_search_short_name_multiple(self):
self.client.get('/c/c/')
response = self.client.get(self.url, {'q': '1'})
self.assertEqual(response.status_code, 200)
- self.assert_contains_only(response, ('Zadanko', 'Żółć', 'Znacznik'))
+ self.assert_contains_only(response, ('Zadanko', 'Żółć', 'Znaczn1k'))
def test_search_tags_basic(self):
self.client.get('/c/c/')
diff --git a/oioioi/problems/tests/test_problem_statistics.py b/oioioi/problems/tests/test_problem_statistics.py
index 4db5442d4..136f1ae13 100644
--- a/oioioi/problems/tests/test_problem_statistics.py
+++ b/oioioi/problems/tests/test_problem_statistics.py
@@ -228,13 +228,25 @@ def test_statistics_imported(self):
self.assertTrue(ps.avg_best_score == 100)
-@override_settings(PROBLEM_STATISTICS_AVAILABLE=True)
+@override_settings(
+ PROBLEM_STATISTICS_AVAILABLE=True,
+ PROBLEM_TAGS_VISIBLE=False,
+)
class TestProblemStatisticsDisplay(TestCase):
fixtures = ['test_users', 'test_statistics_display']
- problem_columns = [
+ problem_columns_tags_invisible = [
+ 'short_name',
+ 'name',
+ 'submitted',
+ 'solved_pc',
+ 'avg_best_score',
+ 'user_score',
+ ]
+ problem_columns_tags_visible = [
'short_name',
'name',
+ 'tags',
'submitted',
'solved_pc',
'avg_best_score',
@@ -315,7 +327,7 @@ def test_statistics_problem_list(self):
def test_statistics_sorting(self):
self.assertTrue(self.client.login(username='test_user'))
- for i, column in enumerate(self.problem_columns):
+ for i, column in enumerate(self.problem_columns_tags_invisible):
url_main = reverse('problemset_main')
response = self.client.get(url_main, {'order_by': column})
self.assertEqual(response.status_code, 200)
@@ -344,7 +356,7 @@ def test_statistics_nulls(self):
self.assertTrue(self.client.login(username='test_user'))
- for column in self.problem_columns[2:]:
+ for column in self.problem_columns_tags_invisible[2:]:
url_main = reverse('problemset_main')
response = self.client.get(url_main, {'order_by': column})
self.assertEqual(response.status_code, 200)
@@ -363,7 +375,7 @@ def test_statistics_sort_nulls(self):
self.assertTrue(self.client.login(username='test_user'))
- for i, column in enumerate(self.problem_columns):
+ for i, column in enumerate(self.problem_columns_tags_invisible):
url_main = reverse('problemset_main')
response = self.client.get(url_main, {'order_by': column})
self.assertEqual(response.status_code, 200)
@@ -378,12 +390,13 @@ def test_statistics_sort_nulls(self):
self._assert_rows_sorted(rows, order_by=i, desc=True)
# Check that the query and the ordering are correctly preserved in links
+ @override_settings(PROBLEM_TAGS_VISIBLE=True)
def test_statistics_sorting_with_query(self):
self.assertTrue(self.client.login(username='test_user'))
- col_no = 3
+ col_no = 4
q = 'Bbbb'
- order = self.problem_columns[col_no - 1]
+ order = self.problem_columns_tags_visible[col_no - 1]
url_main = reverse('problemset_main')
response = self.client.get(
diff --git a/oioioi/problems/tests/test_tags.py b/oioioi/problems/tests/test_tags.py
index 6b8e5569f..bac5d26cc 100644
--- a/oioioi/problems/tests/test_tags.py
+++ b/oioioi/problems/tests/test_tags.py
@@ -53,6 +53,7 @@ def test_algorithm_tag_label_view(self):
self.assertEqual(response.status_code, 404)
+@override_settings(PROBLEM_TAGS_VISIBLE=True)
class TestProblemSearchOrigin(TestCase, AssertContainsOnlyMixin):
fixtures = ['test_problem_search_origin']
url = reverse('problemset_main')
@@ -127,6 +128,7 @@ def test_search_origininfovalue_multiple(self):
self.assert_contains_only(response, [])
+@override_settings(PROBLEM_TAGS_VISIBLE=True)
class TestProblemSearchHintsTags(TestCase, AssertContainsOnlyMixin):
fixtures = [
'test_origin_tags',
@@ -159,6 +161,38 @@ class TestProblemSearchHintsTags(TestCase, AssertContainsOnlyMixin):
def get_query_url(self, parameters):
return self.url + '?' + urllib.parse.urlencode(parameters)
+ @override_settings(LANGUAGE_CODE="en", PROBLEM_TAGS_VISIBLE=False)
+ def test_search_no_hints_tags_basic(self):
+ self.client.get('/c/c/')
+
+ response = self.client.get(self.get_query_url({'q': 'najdłuższy'}))
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ response = self.client.get(self.get_query_url({'q': 'easy'}))
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ response = self.client.get(self.get_query_url({'q': 'Mediu'}))
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ response = self.client.get(self.get_query_url({'q': 'PROGRA'}))
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ response = self.client.get(self.get_query_url({'q': 'dYNAM'}))
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ response = self.client.get(self.get_query_url({'q': 'dp'}))
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ response = self.client.get(self.get_query_url({'q': 'increasing'}))
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
@override_settings(LANGUAGE_CODE="en")
def test_search_hints_tags_basic(self):
self.client.get('/c/c/')
@@ -191,6 +225,26 @@ def test_search_hints_tags_basic(self):
self.assertEqual(response.status_code, 200)
self.assert_contains_only(response, ['lcis'])
+ @override_settings(LANGUAGE_CODE="en", PROBLEM_TAGS_VISIBLE=False)
+ def test_search_no_hints_origininfo(self):
+ self.client.get('/c/c/')
+ response = self.client.get(self.url, {'q': 'pa_'})
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ response = self.client.get(self.url, {'q': '2011'})
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ response = self.client.get(self.url, {'q': 'Round'})
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ response = self.client.get(self.url, {'q': 'Potyczki Algorytmiczne'})
+ self.assertEqual(response.status_code, 200)
+ self.assert_contains_only(response, [])
+
+ @override_settings(LANGUAGE_CODE="en")
def test_search_hints_origininfo(self):
self.client.get('/c/c/')
response = self.client.get(self.url, {'q': 'pa_'})
diff --git a/oioioi/problems/views.py b/oioioi/problems/views.py
index 8b8b60245..e30bd597a 100644
--- a/oioioi/problems/views.py
+++ b/oioioi/problems/views.py
@@ -305,7 +305,10 @@ def generate_problemset_tabs(request):
def problemset_get_problems(request):
- problems = search_problems_in_problemset(request.GET)
+ if settings.PROBLEM_TAGS_VISIBLE:
+ problems = search_problems_in_problemset(request.GET)
+ else:
+ problems = Problem.objects.all()
if settings.PROBLEM_STATISTICS_AVAILABLE:
# We annotate all of the statistics to assure that the display
@@ -1181,9 +1184,11 @@ def get_search_hints_view(request, view_type):
result = []
result.extend(list(get_problem_hints(query, view_type, request.user)))
- result.extend(get_algorithm_and_difficulty_tag_hints(query))
- result.extend(get_nonselected_origintag_hints(query))
- result.extend(get_origininfovalue_hints(query))
+
+ if settings.PROBLEM_TAGS_VISIBLE:
+ result.extend(get_algorithm_and_difficulty_tag_hints(query))
+ result.extend(get_nonselected_origintag_hints(query))
+ result.extend(get_origininfovalue_hints(query))
# Convert category names in results from lazy translation to strings,
# since jsonify throws error if given lazy translation objects.