diff --git a/analysis/templates/analysis/text_token.html b/analysis/templates/analysis/text_token.html new file mode 100644 index 0000000..6696fbb --- /dev/null +++ b/analysis/templates/analysis/text_token.html @@ -0,0 +1,51 @@ +{% extends "base.html" %} +{% block main %} +{% with object as text %} + + + + + + + + + + + + + + + + + +
NameValue
+ Text + + {{text.text}} +
+ Language + + {{text.language}} +
+ Remove Stop Words + + {{text.remove_stopwords}} +
+{% endwith %} +{% endblock %} +{% block results %} + +{% with object.token_set.all as items %} + + + + + {% for item in items %} + + + + {% endfor %} +
text
{{item.value}}
+ +{% endwith %} +{% endblock %} diff --git a/analysis/templates/analysis/text_token_list.html b/analysis/templates/analysis/text_token_list.html new file mode 100644 index 0000000..d4887d1 --- /dev/null +++ b/analysis/templates/analysis/text_token_list.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} +{% block main %} +

Text token list

+{% endblock %} +{% block results %} + + + + + + + + + + {% for text in object_list %} + + + + + + + + + {% endfor %} +
TextLanguageRemove Stop WordsCreatedHas TokensDetail
+ + {{text.text}} + + {{text.language}}{{text.remove_stopwords}} + {{text.create}} + + {{text.has_tokens}} + + + Detail + +
+{% endblock %} diff --git a/analysis/tests/test_urls.py b/analysis/tests/test_urls.py index 9e94d34..10bbe5f 100644 --- a/analysis/tests/test_urls.py +++ b/analysis/tests/test_urls.py @@ -3,7 +3,7 @@ """ from django.test import SimpleTestCase, TestCase from django.urls import reverse -from django_find_similar.models import CheckResult +from django_find_similar.models import CheckResult, TextToken from mixer.backend.django import mixer from analysis.tests.data import get_2x2_training_data @@ -44,6 +44,10 @@ def test_reverse(self): 'url': 'result_list', 'reverse': 'result-list/', }, + { + 'url': 'text_token_list', + 'reverse': 'text-token-list/', + }, ] for url in urls: app_url = f'{app_name}:{url["url"]}' @@ -65,6 +69,7 @@ def test_reverse(self): training_data = get_2x2_training_data() check_result = mixer.blend(CheckResult) + text_token = mixer.blend(TextToken) app_name = 'analysis' urls = [ @@ -96,6 +101,13 @@ def test_reverse(self): }, 'reverse': f'result/{check_result.pk}/', }, + { + 'url': 'text_token', + 'kwargs': { + 'pk': text_token.pk + }, + 'reverse': f'text-token/{text_token.pk}/', + }, ] for url in urls: app_url = f'{app_name}:{url["url"]}' diff --git a/analysis/tests/tests_views.py b/analysis/tests/tests_views.py index c07f13d..ffb2c34 100644 --- a/analysis/tests/tests_views.py +++ b/analysis/tests/tests_views.py @@ -3,7 +3,7 @@ """ from django.core.files.uploadedfile import SimpleUploadedFile from django.urls import reverse -from django_find_similar.models import CheckResult +from django_find_similar.models import CheckResult, TextToken from dry_tests import ( TestCase, SimpleTestCase, @@ -566,3 +566,49 @@ def test_get(self): current_response = request.get_response(self.client) self.assertTrueResponse(current_response, true_response) + + +class TestTextTokenListView(TestCase): + + def setUp(self): + self.url = reverse('analysis:text_token_list') + + def test_get(self): + request = Request( + url=self.url, + ) + + true_response = TrueResponse( + status_code=200, + context=Context( + keys=['object_list'] + ) + ) + + current_response = request.get_response(self.client) + + self.assertTrueResponse(current_response, true_response) + + +class TestTextTokenDetailView(TestCase): + + def setUp(self): + self.text_token = mixer.blend(TextToken) + self.url = reverse('analysis:text_token', kwargs={'pk': self.text_token.pk}) + + def test_get(self): + request = Request( + url=self.url, + ) + + true_response = TrueResponse( + status_code=200, + context=Context( + items={ + 'object': self.text_token, + } + ) + ) + + current_response = request.get_response(self.client) + self.assertTrueResponse(current_response, true_response) \ No newline at end of file diff --git a/analysis/urls.py b/analysis/urls.py index d6f4c42..b04691d 100644 --- a/analysis/urls.py +++ b/analysis/urls.py @@ -17,4 +17,6 @@ path('training-data-list/', views.TrainingDataListView.as_view(), name="training_data_list"), path('result-list/', views.ResultListView.as_view(), name="result_list"), path('result//', views.ResultDetailView.as_view(), name="result"), + path('text-token-list/', views.TextTokenListView.as_view(), name="text_token_list"), + path('text-token//', views.TextTokenDetailView.as_view(), name="text_token"), ] diff --git a/analysis/views.py b/analysis/views.py index 8910d3b..2ffc220 100644 --- a/analysis/views.py +++ b/analysis/views.py @@ -237,3 +237,14 @@ class ResultListView(ListView): class ResultDetailView(DetailView): model = CheckResult template_name = 'analysis/result.html' + + +class TextTokenListView(ListView): + model = TextToken + template_name = 'analysis/text_token_list.html' + ordering = ['-create'] + + +class TextTokenDetailView(DetailView): + model = TextToken + template_name = 'analysis/text_token.html' diff --git a/checklistexample.png b/checklistexample.png deleted file mode 100644 index c816dc8..0000000 Binary files a/checklistexample.png and /dev/null differ diff --git a/templates/base.html b/templates/base.html index 8445a33..0a6ffb0 100644 --- a/templates/base.html +++ b/templates/base.html @@ -50,12 +50,12 @@