From 1050fc71afca1ed83bb5190ee3b23ace45171368 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 6 Sep 2014 17:27:33 -0400 Subject: [PATCH 1/4] Fix tag properties reference --- mayan/apps/tags/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mayan/apps/tags/views.py b/mayan/apps/tags/views.py index 4a0d3022c7..b87bee614a 100644 --- a/mayan/apps/tags/views.py +++ b/mayan/apps/tags/views.py @@ -220,7 +220,7 @@ def tag_edit(request, tag_id): else: form = TagForm(initial={ 'name': tag.name, - 'color': tag.tagproperties_set.get().color + 'color': tag.properties.get().color }) return render_to_response('generic_form.html', { From 0b153f0c7e1620c4f57a46f78e0a23755e2c2c08 Mon Sep 17 00:00:00 2001 From: Mathias Behrle Date: Tue, 23 Sep 2014 00:28:25 +0200 Subject: [PATCH 2/4] Skip page key in advanced search (#46). --- mayan/apps/dynamic_search/classes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mayan/apps/dynamic_search/classes.py b/mayan/apps/dynamic_search/classes.py index ab264e4bb3..c9a16bd075 100644 --- a/mayan/apps/dynamic_search/classes.py +++ b/mayan/apps/dynamic_search/classes.py @@ -104,6 +104,8 @@ class SearchModel(object): logger.debug('key: %s' % key) logger.debug('value: %s' % value) + if key == 'page': + continue if value: search_field = self.get_search_field(key) logger.debug('search_field: %s' % search_field) From 03e5c7732a62fdd7f12052d30ae0b0268ef8aa6c Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 30 Sep 2014 14:43:46 -0400 Subject: [PATCH 3/4] Ignore the 'page' key when recreating the advanced search string --- mayan/apps/dynamic_search/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mayan/apps/dynamic_search/models.py b/mayan/apps/dynamic_search/models.py index 1a257b8817..f45d1bd9e4 100644 --- a/mayan/apps/dynamic_search/models.py +++ b/mayan/apps/dynamic_search/models.py @@ -34,8 +34,9 @@ class RecentSearch(models.Model): # Advanced search advanced_string = [] for key, value in query_dict.items(): - search_field = document_search.get_search_field(key) - advanced_string.append(u'%s: %s' % (search_field.label, smart_unicode(' '.join(value)))) + if key != 'page': + search_field = document_search.get_search_field(key) + advanced_string.append(u'%s: %s' % (search_field.label, smart_unicode(' '.join(value)))) display_string = u', '.join(advanced_string) else: From 07dd6a87efa0cb11df411ded1ab342c6ac274504 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 30 Sep 2014 14:45:22 -0400 Subject: [PATCH 4/4] Add test to make sure the page issue is fixed, issue #46 --- mayan/apps/documents/tests.py | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/mayan/apps/documents/tests.py b/mayan/apps/documents/tests.py index 57830075aa..9ffd68bdac 100644 --- a/mayan/apps/documents/tests.py +++ b/mayan/apps/documents/tests.py @@ -21,6 +21,7 @@ TEST_ADMIN_USERNAME = 'test_admin' TEST_ADMIN_EMAIL = 'admin@admin.com' TEST_DOCUMENT_PATH = os.path.join(settings.BASE_DIR, 'contrib', 'sample_documents', 'mayan_11_1.pdf') TEST_SIGNED_DOCUMENT_PATH = os.path.join(settings.BASE_DIR, 'contrib', 'sample_documents', 'mayan_11_1.pdf.gpg') +TEST_SMALL_DOCUMENT_PATH = os.path.join(settings.BASE_DIR, 'contrib', 'sample_documents', 'title_page.png') TEST_DOCUMENT_DESCRIPTION = 'test description' TEST_DOCUMENT_TYPE = 'test_document_type' @@ -358,3 +359,43 @@ class DocumentsViewsFunctionalTestCase(TestCase): response = self.client.get(reverse('document_type_list')) self.assertEqual(response.status_code, 200) self.assertTrue('List of document types (0)' in response.content) + + +class Issue46TestCase(TestCase): + """ + Functional tests to make sure issue 46 is fixed + """ + + def setUp(self): + self.admin_user = User.objects.create_superuser(username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD) + self.client = Client() + # Login the admin user + logged_in = self.client.login(username=TEST_ADMIN_USERNAME, password=TEST_ADMIN_PASSWORD) + self.assertTrue(logged_in) + self.assertTrue(self.admin_user.is_authenticated()) + + self.document_count = 30 + + # Upload 30 instances of the same test document + for i in range(self.document_count): + document = Document( + ) + document.save() + + with open(TEST_SMALL_DOCUMENT_PATH) as file_object: + document.new_version(file=File(file_object)) + + def test_advanced_search_past_first_page(self): + from . import document_search + + # Make sure all documents are returned by the search + model_list, flat_list, shown_result_count, result_count, elapsed_time = document_search.advanced_search({'versions__filename': 'png'}) + self.assertEqual(result_count, self.document_count) + + # Funcitonal test for the first page of advanced results + response = self.client.get(reverse('results'), {'versions__filename': 'png'}) + self.assertTrue('List of results (1 - 20 out of 30) (Page 1 of 2)' in response.content) + + # Functional test for the second page of advanced results + response = self.client.get(reverse('results'), {'versions__filename': 'png', 'page': 2}) + self.assertTrue('List of results (21 - 30 out of 30) (Page 2 of 2)' in response.content)