diff --git a/Dockerfile b/Dockerfile index 503523703..747564358 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,10 @@ RUN npm install --quiet -g grunt-cli COPY ["manage.py", "package.json", "example-config.json", "setup.py", "frontendbuild.sh", "Gruntfile.js", ".babelrc", ".eslintignore", ".eslintrc", "/app/src/"] COPY ["regulations", "/app/src/regulations"] COPY ["fr_notices", "/app/src/fr_notices"] +COPY ["notice_comment", "/app/src/notice_comment"] WORKDIR /app/src/ RUN ./frontendbuild.sh -RUN $PIP_CMD install --no-cache-dir -e . \ +RUN $PIP_CMD install --no-cache-dir -e .[notice_comment] \ && $PYTHON_CMD manage.py migrate ENV PYTHONUNBUFFERED="1" diff --git a/docs/notice_comment.management.commands.rst b/docs/notice_comment.management.commands.rst new file mode 100644 index 000000000..a89baf2c4 --- /dev/null +++ b/docs/notice_comment.management.commands.rst @@ -0,0 +1,22 @@ +notice\_comment\.management\.commands package +============================================= + +Submodules +---------- + +notice\_comment\.management\.commands\.setup\_cors module +--------------------------------------------------------- + +.. automodule:: notice_comment.management.commands.setup_cors + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: notice_comment.management.commands + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/notice_comment.management.rst b/docs/notice_comment.management.rst new file mode 100644 index 000000000..fa10069a4 --- /dev/null +++ b/docs/notice_comment.management.rst @@ -0,0 +1,17 @@ +notice\_comment\.management package +=================================== + +Subpackages +----------- + +.. toctree:: + + notice_comment.management.commands + +Module contents +--------------- + +.. automodule:: notice_comment.management + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/notice_comment.migrations.rst b/docs/notice_comment.migrations.rst new file mode 100644 index 000000000..432c842b7 --- /dev/null +++ b/docs/notice_comment.migrations.rst @@ -0,0 +1,22 @@ +notice\_comment\.migrations package +=================================== + +Submodules +---------- + +notice\_comment\.migrations\.0001\_initial module +------------------------------------------------- + +.. automodule:: notice_comment.migrations.0001_initial + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: notice_comment.migrations + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/notice_comment.rst b/docs/notice_comment.rst new file mode 100644 index 000000000..20f738aea --- /dev/null +++ b/docs/notice_comment.rst @@ -0,0 +1,63 @@ +notice\_comment package +======================= + +Subpackages +----------- + +.. toctree:: + + notice_comment.management + notice_comment.migrations + notice_comment.tests + +Submodules +---------- + +notice\_comment\.docket module +------------------------------ + +.. automodule:: notice_comment.docket + :members: + :undoc-members: + :show-inheritance: + +notice\_comment\.models module +------------------------------ + +.. automodule:: notice_comment.models + :members: + :undoc-members: + :show-inheritance: + +notice\_comment\.tasks module +----------------------------- + +.. automodule:: notice_comment.tasks + :members: + :undoc-members: + :show-inheritance: + +notice\_comment\.urls module +---------------------------- + +.. automodule:: notice_comment.urls + :members: + :undoc-members: + :show-inheritance: + +notice\_comment\.views module +----------------------------- + +.. automodule:: notice_comment.views + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: notice_comment + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/notice_comment.tests.rst b/docs/notice_comment.tests.rst new file mode 100644 index 000000000..e0fe79cc1 --- /dev/null +++ b/docs/notice_comment.tests.rst @@ -0,0 +1,38 @@ +notice\_comment\.tests package +============================== + +Submodules +---------- + +notice\_comment\.tests\.docket\_tests module +-------------------------------------------- + +.. automodule:: notice_comment.tests.docket_tests + :members: + :undoc-members: + :show-inheritance: + +notice\_comment\.tests\.tasks\_tests module +------------------------------------------- + +.. automodule:: notice_comment.tests.tasks_tests + :members: + :undoc-members: + :show-inheritance: + +notice\_comment\.tests\.views\_tests module +------------------------------------------- + +.. automodule:: notice_comment.tests.views_tests + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: notice_comment.tests + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/regulations.management.commands.rst b/docs/regulations.management.commands.rst index b7d0ec1c8..0c6aff955 100644 --- a/docs/regulations.management.commands.rst +++ b/docs/regulations.management.commands.rst @@ -36,14 +36,6 @@ regulations\.management\.commands\.fetch\_wkhtmltox module :undoc-members: :show-inheritance: -regulations\.management\.commands\.setup\_cors module ------------------------------------------------------ - -.. automodule:: regulations.management.commands.setup_cors - :members: - :undoc-members: - :show-inheritance: - Module contents --------------- diff --git a/docs/regulations.migrations.rst b/docs/regulations.migrations.rst index adc3b0371..d3c02042d 100644 --- a/docs/regulations.migrations.rst +++ b/docs/regulations.migrations.rst @@ -20,6 +20,14 @@ regulations\.migrations\.0002\_remove\_failedcommentsubmission\_files module :undoc-members: :show-inheritance: +regulations\.migrations\.0003\_delete\_failedcommentsubmission module +--------------------------------------------------------------------- + +.. automodule:: regulations.migrations.0003_delete_failedcommentsubmission + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- diff --git a/docs/regulations.rst b/docs/regulations.rst index a865f32e2..6115c66c3 100644 --- a/docs/regulations.rst +++ b/docs/regulations.rst @@ -34,30 +34,6 @@ regulations\.context module :undoc-members: :show-inheritance: -regulations\.docket module --------------------------- - -.. automodule:: regulations.docket - :members: - :undoc-members: - :show-inheritance: - -regulations\.models module --------------------------- - -.. automodule:: regulations.models - :members: - :undoc-members: - :show-inheritance: - -regulations\.tasks module -------------------------- - -.. automodule:: regulations.tasks - :members: - :undoc-members: - :show-inheritance: - regulations\.url\_caches module ------------------------------- diff --git a/docs/regulations.tests.rst b/docs/regulations.tests.rst index 2f2c274b9..6e581e02d 100644 --- a/docs/regulations.tests.rst +++ b/docs/regulations.tests.rst @@ -204,14 +204,6 @@ regulations\.tests\.partial\_view\_tests module :undoc-members: :show-inheritance: -regulations\.tests\.sanitize\_fields\_tests module --------------------------------------------------- - -.. automodule:: regulations.tests.sanitize_fields_tests - :members: - :undoc-members: - :show-inheritance: - regulations\.tests\.sidebar\_analyses\_tests module --------------------------------------------------- @@ -228,14 +220,6 @@ regulations\.tests\.sidebar\_help\_tests module :undoc-members: :show-inheritance: -regulations\.tests\.tasks\_tests module ---------------------------------------- - -.. automodule:: regulations.tests.tasks_tests - :members: - :undoc-members: - :show-inheritance: - regulations\.tests\.templatetags\_macros\_tests module ------------------------------------------------------ @@ -292,14 +276,6 @@ regulations\.tests\.views\_chrome\_tests module :undoc-members: :show-inheritance: -regulations\.tests\.views\_comment\_tests module ------------------------------------------------- - -.. automodule:: regulations.tests.views_comment_tests - :members: - :undoc-members: - :show-inheritance: - regulations\.tests\.views\_diff\_tests module --------------------------------------------- diff --git a/docs/regulations.views.rst b/docs/regulations.views.rst index 73ea4ccc2..61be9a8ce 100644 --- a/docs/regulations.views.rst +++ b/docs/regulations.views.rst @@ -28,14 +28,6 @@ regulations\.views\.chrome\_breakaway module :undoc-members: :show-inheritance: -regulations\.views\.comment module ----------------------------------- - -.. automodule:: regulations.views.comment - :members: - :undoc-members: - :show-inheritance: - regulations\.views\.diff module ------------------------------- diff --git a/regulations/templates/regulations/comment-additional-info.html b/notice_comment/__init__.py similarity index 100% rename from regulations/templates/regulations/comment-additional-info.html rename to notice_comment/__init__.py diff --git a/regulations/docket.py b/notice_comment/docket.py similarity index 100% rename from regulations/docket.py rename to notice_comment/docket.py diff --git a/regulations/templates/regulations/comment-disclaimer.html b/notice_comment/management/__init__.py similarity index 100% rename from regulations/templates/regulations/comment-disclaimer.html rename to notice_comment/management/__init__.py diff --git a/notice_comment/management/commands/__init__.py b/notice_comment/management/commands/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/regulations/management/commands/setup_cors.py b/notice_comment/management/commands/setup_cors.py similarity index 100% rename from regulations/management/commands/setup_cors.py rename to notice_comment/management/commands/setup_cors.py diff --git a/notice_comment/migrations/0001_initial.py b/notice_comment/migrations/0001_initial.py new file mode 100644 index 000000000..f826c7481 --- /dev/null +++ b/notice_comment/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.3 on 2017-07-18 15:47 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='FailedCommentSubmission', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, + serialize=False, verbose_name='ID')), + ('body', models.TextField()), + ], + ), + ] diff --git a/notice_comment/migrations/__init__.py b/notice_comment/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/regulations/models.py b/notice_comment/models.py similarity index 100% rename from regulations/models.py rename to notice_comment/models.py diff --git a/regulations/tasks.py b/notice_comment/tasks.py similarity index 98% rename from regulations/tasks.py rename to notice_comment/tasks.py index 285aa31ba..8e47161e3 100644 --- a/regulations/tasks.py +++ b/notice_comment/tasks.py @@ -24,7 +24,7 @@ from django.template import loader from django.utils.crypto import get_random_string -from regulations.models import FailedCommentSubmission +from notice_comment.models import FailedCommentSubmission logger = get_task_logger(__name__) @@ -102,7 +102,7 @@ def json_to_html(sections, mark_as_draft=False): :param mark_as_draft: Indicates if the HTML is to be marked as DRAFT """ return loader.render_to_string( - 'regulations/comment.html', + 'notice_comment/comment.html', {'sections': sections, 'mark_as_draft': mark_as_draft} ) diff --git a/notice_comment/templates/notice_comment/additional-info.html b/notice_comment/templates/notice_comment/additional-info.html new file mode 100644 index 000000000..e69de29bb diff --git a/regulations/templates/regulations/comment.html b/notice_comment/templates/notice_comment/comment.html similarity index 100% rename from regulations/templates/regulations/comment.html rename to notice_comment/templates/notice_comment/comment.html diff --git a/regulations/templates/regulations/comment-confirm-chrome.html b/notice_comment/templates/notice_comment/confirm-chrome.html similarity index 71% rename from regulations/templates/regulations/comment-confirm-chrome.html rename to notice_comment/templates/notice_comment/confirm-chrome.html index 031edeba6..8ee325e80 100644 --- a/regulations/templates/regulations/comment-confirm-chrome.html +++ b/notice_comment/templates/notice_comment/confirm-chrome.html @@ -9,11 +9,11 @@ data-metadata-url="{{metadata_url}}" data-doc-id="{{doc_number}}"> {% if message %} - {% include 'regulations/comment-confirm-invalid.html' %} + {% include 'notice_comment/confirm-invalid.html' %} {% elif not metadata_url %} - {% include 'regulations/comment-confirm-fail.html' %} + {% include 'notice_comment/confirm-fail.html' %} {% else %} - {% include 'regulations/comment-confirm-success.html' %} + {% include 'notice_comment/confirm-success.html' %} {% endif %} diff --git a/regulations/templates/regulations/comment-confirm-fail.html b/notice_comment/templates/notice_comment/confirm-fail.html similarity index 100% rename from regulations/templates/regulations/comment-confirm-fail.html rename to notice_comment/templates/notice_comment/confirm-fail.html diff --git a/regulations/templates/regulations/comment-confirm-invalid.html b/notice_comment/templates/notice_comment/confirm-invalid.html similarity index 75% rename from regulations/templates/regulations/comment-confirm-invalid.html rename to notice_comment/templates/notice_comment/confirm-invalid.html index 610d63871..aef70cbfc 100644 --- a/regulations/templates/regulations/comment-confirm-invalid.html +++ b/notice_comment/templates/notice_comment/confirm-invalid.html @@ -1,4 +1,4 @@ -{% extends "regulations/comment-confirm-fail.html" %} +{% extends "notice_comment/confirm-fail.html" %} {% block alert-text %}
diff --git a/regulations/templates/regulations/comment-confirm-success.html b/notice_comment/templates/notice_comment/confirm-success.html similarity index 100% rename from regulations/templates/regulations/comment-confirm-success.html rename to notice_comment/templates/notice_comment/confirm-success.html diff --git a/notice_comment/templates/notice_comment/disclaimer.html b/notice_comment/templates/notice_comment/disclaimer.html new file mode 100644 index 000000000..e69de29bb diff --git a/regulations/templates/regulations/comment-review-chrome.html b/notice_comment/templates/notice_comment/review-chrome.html similarity index 96% rename from regulations/templates/regulations/comment-review-chrome.html rename to notice_comment/templates/notice_comment/review-chrome.html index 267c1d3d4..c0e5eb5be 100644 --- a/regulations/templates/regulations/comment-review-chrome.html +++ b/notice_comment/templates/notice_comment/review-chrome.html @@ -67,10 +67,10 @@

Building your PDF...

- {% include 'regulations/comment-additional-info.html' %} + {% include 'notice_comment/additional-info.html' %}
- {% include 'regulations/comment-disclaimer.html' %} + {% include 'notice_comment/disclaimer.html' %}
diff --git a/notice_comment/tests/__init__.py b/notice_comment/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/regulations/tests/sanitize_fields_tests.py b/notice_comment/tests/docket_tests.py similarity index 94% rename from regulations/tests/sanitize_fields_tests.py rename to notice_comment/tests/docket_tests.py index b873905d8..7de3a55d2 100644 --- a/regulations/tests/sanitize_fields_tests.py +++ b/notice_comment/tests/docket_tests.py @@ -4,13 +4,13 @@ import httpretty import requests -from regulations.docket import sanitize_fields +from notice_comment.docket import sanitize_fields class SanitizeFieldsTest(TestCase): def setUp(self): self.patch_document_fields = patch( - 'regulations.docket.get_document_fields') + 'notice_comment.docket.get_document_fields') mock_object = self.patch_document_fields.start() mock_object.return_value = { 'required_field': {'maxLength': 10, 'required': True}, @@ -82,7 +82,7 @@ def test_503(self): valid, message = sanitize_fields({'something': 'else'}) self.assertTrue(valid) - @patch('regulations.docket.requests.get') + @patch('notice_comment.docket.requests.get') def test_timeout(self, get): get.side_effect = requests.Timeout with self.settings(REGS_GOV_API_URL='http://example.com'): diff --git a/regulations/tests/tasks_tests.py b/notice_comment/tests/tasks_tests.py similarity index 90% rename from regulations/tests/tasks_tests.py rename to notice_comment/tests/tasks_tests.py index b22d27b49..3cee41010 100644 --- a/regulations/tests/tasks_tests.py +++ b/notice_comment/tests/tasks_tests.py @@ -8,14 +8,14 @@ from django.test import TestCase, override_settings from requests.exceptions import RequestException -from regulations.tasks import submit_comment, cache_pdf, SignedUrl -from regulations.models import FailedCommentSubmission +from notice_comment.models import FailedCommentSubmission +from notice_comment.tasks import submit_comment, cache_pdf, SignedUrl -@mock.patch('regulations.tasks.submit_comment.retry') -@mock.patch('regulations.tasks.post_submission') -@mock.patch('regulations.tasks.html_to_pdf') -@mock.patch('regulations.tasks.cache_pdf') +@mock.patch('notice_comment.tasks.submit_comment.retry') +@mock.patch('notice_comment.tasks.post_submission') +@mock.patch('notice_comment.tasks.html_to_pdf') +@mock.patch('notice_comment.tasks.cache_pdf') @override_settings( ATTACHMENT_BUCKET='test-bucket', ATTACHMENT_ACCESS_KEY_ID='test-access-key', @@ -102,7 +102,7 @@ def test_error_fetching_from_s3_saves(self, cached_pdf, html_to_pdf, self.comments[1]['files'].append( {"name": "file_name.png", "key": "someKey"}) retry.return_value = MaxRetriesExceededError() - with mock.patch('regulations.tasks.boto3') as boto3: + with mock.patch('notice_comment.tasks.boto3') as boto3: client = boto3.Session.return_value.client.return_value client.download_file.side_effect = botocore.exceptions.ClientError submit_comment(self.comments, self.form, self.meta) @@ -118,8 +118,8 @@ def test_error_fetching_from_s3_saves(self, cached_pdf, html_to_pdf, class TestHelpers(TestCase): - @mock.patch('regulations.tasks.SignedUrl.generate') - @mock.patch('regulations.tasks.s3_client') + @mock.patch('notice_comment.tasks.SignedUrl.generate') + @mock.patch('notice_comment.tasks.s3_client') def test_cache_pdf(self, s3_client, url_generate): meta = SignedUrl('meta', 'https://s3.amazonaws.com/bucket/meta') url_generate.return_value = SignedUrl( diff --git a/regulations/tests/views_comment_tests.py b/notice_comment/tests/views_tests.py similarity index 80% rename from regulations/tests/views_comment_tests.py rename to notice_comment/tests/views_tests.py index da9e1328a..5e7fc9b3d 100644 --- a/regulations/tests/views_comment_tests.py +++ b/notice_comment/tests/views_tests.py @@ -3,7 +3,7 @@ from django.test import SimpleTestCase, override_settings -from regulations.views import comment +from notice_comment import views @override_settings( @@ -11,18 +11,19 @@ ATTACHMENT_ACCESS_KEY_ID='test-access-key', ATTACHMENT_SECRET_ACCESS_KEY='test-secret-key', ATTACHMENT_MAX_SIZE=42, + ROOT_URLCONF='notice_comment.urls', ) class TestUploadProxy(SimpleTestCase): @mock.patch('time.time') - @mock.patch('regulations.tasks.s3_client') - @mock.patch('regulations.tasks.get_random_string') + @mock.patch('notice_comment.tasks.s3_client') + @mock.patch('notice_comment.tasks.get_random_string') def test_get_url(self, get_random, mock_client, mock_time): generate_presigned = mock_client.generate_presigned_url generate_presigned.side_effect = ['first-url', 'second-url'] get_random.return_value = 'not-so-random' mock_time.return_value = 123 - resp = self.client.get('/comments/attachment?size=42&name=foo.pdf') + resp = self.client.get('/attachment?size=42&name=foo.pdf') self.assertEqual(resp.status_code, 200) body = json.loads(resp.content.decode()) generate_presigned.assert_any_call( @@ -38,7 +39,7 @@ def test_get_url(self, get_random, mock_client, mock_time): generate_presigned.assert_any_call( ClientMethod='get_object', Params={ - 'ResponseExpires': 123 + comment.PREVIEW_EXPIRATION_SECONDS, + 'ResponseExpires': 123 + views.PREVIEW_EXPIRATION_SECONDS, 'ResponseContentDisposition': 'attachment; filename="foo.pdf"', 'Bucket': 'test-bucket', 'Key': get_random.return_value, @@ -49,19 +50,19 @@ def test_get_url(self, get_random, mock_client, mock_time): self.assertEqual(body['urls']['get'], 'second-url') def test_get_url_empty(self): - resp = self.client.get('/comments/attachment?size=0&name=foo.pdf') + resp = self.client.get('/attachment?size=0&name=foo.pdf') self.assertEqual(resp.status_code, 400) body = json.loads(resp.content.decode()) self.assertEqual(body['message'], 'Invalid attachment size') def test_get_url_over_limit(self): - resp = self.client.get('/comments/attachment?size=43&name=foo.pdf') + resp = self.client.get('/attachment?size=43&name=foo.pdf') self.assertEqual(resp.status_code, 400) body = json.loads(resp.content.decode()) self.assertEqual(body['message'], 'Invalid attachment size') def test_get_url_invalid_extension(self): - resp = self.client.get('/comments/attachment?size=42&name=foo.exe') + resp = self.client.get('/attachment?size=42&name=foo.exe') self.assertEqual(resp.status_code, 400) body = json.loads(resp.content.decode()) self.assertEqual(body['message'], 'Invalid attachment type') diff --git a/notice_comment/urls.py b/notice_comment/urls.py new file mode 100644 index 000000000..c4bd0b8a9 --- /dev/null +++ b/notice_comment/urls.py @@ -0,0 +1,16 @@ +from django.conf.urls import url + +from notice_comment.views import (PrepareCommentView, SubmitCommentView, + get_federal_agencies, get_gov_agency_types, + preview_comment, upload_proxy) + +urlpatterns = [ + url(r'^attachment$', upload_proxy), + url(r'^review/(?P[\w-]+)$', PrepareCommentView.as_view(), + name='comment_review'), + url(r'^preview$', preview_comment), + url(r'^(?P[\w-]+)$', SubmitCommentView.as_view(), + name='comment_submit'), + url(r'^federal_agencies$', get_federal_agencies), + url(r'^gov_agency_types$', get_gov_agency_types), +] diff --git a/regulations/views/comment.py b/notice_comment/views.py similarity index 89% rename from regulations/views/comment.py rename to notice_comment/views.py index 40809d65b..4ebe2256b 100644 --- a/regulations/views/comment.py +++ b/notice_comment/views.py @@ -15,8 +15,7 @@ from django.views.generic.base import View import requests -from regulations import tasks -from regulations import docket +from notice_comment import docket, tasks from regulations.views.preamble import ( common_context, CommentState, generate_html_tree, first_preamble_section, notice_data) @@ -126,7 +125,7 @@ def post(self, request, doc_number): except Exception as exc: logger.exception(exc) - template = 'regulations/comment-confirm-chrome.html' + template = 'notice_comment/confirm-chrome.html' return TemplateResponse(request=request, template=template, context=context) @@ -203,3 +202,21 @@ def make_cache_key(*args, **kwargs): Sort the keys to ensure repeatability """ return ":".join((key + ":" + str(kwargs[key]) for key in sorted(kwargs))) + + +class PrepareCommentView(View): + def get(self, request, doc_number): + context = common_context(doc_number) + + if context['meta']['comment_state'] != CommentState.OPEN: + raise Http404("Cannot comment on {}".format(doc_number)) + + context.update(generate_html_tree(context['preamble'], request, + id_prefix=[doc_number, 'preamble'])) + context['comment_mode'] = 'write' + context['comment_fields'] = docket.safe_get_document_fields( + settings.COMMENT_DOCUMENT_ID) + template = 'notice_comment/review-chrome.html' + + return TemplateResponse(request=request, template=template, + context=context) diff --git a/regulations/all_urls.py b/regulations/all_urls.py new file mode 100644 index 000000000..79da060c9 --- /dev/null +++ b/regulations/all_urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import include, url + +from regulations.urls import urlpatterns + +urlpatterns = [ + url(r'^comments/', include('notice_comment.urls')), +] + urlpatterns diff --git a/regulations/migrations/0003_delete_failedcommentsubmission.py b/regulations/migrations/0003_delete_failedcommentsubmission.py new file mode 100644 index 000000000..f58b32fd9 --- /dev/null +++ b/regulations/migrations/0003_delete_failedcommentsubmission.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.3 on 2017-07-18 15:49 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('regulations', '0002_remove_failedcommentsubmission_files'), + ] + + operations = [ + migrations.DeleteModel( + name='FailedCommentSubmission', + ), + ] diff --git a/regulations/settings/dev.py b/regulations/settings/dev.py index bcb68cd7e..b41a9d8af 100644 --- a/regulations/settings/dev.py +++ b/regulations/settings/dev.py @@ -6,6 +6,9 @@ CACHES['eregs_longterm_cache']['BACKEND'] = 'django.core.cache.backends.dummy.DummyCache' CACHES['api_cache']['TIMEOUT'] = 5 # roughly per request +ROOT_URLCONF = 'regulations.all_urls' +INSTALLED_APPS = INSTALLED_APPS + ('notice_comment',) + try: from local_settings import * except ImportError: diff --git a/regulations/urls.py b/regulations/urls.py index b2ac44c23..c66d546be 100644 --- a/regulations/urls.py +++ b/regulations/urls.py @@ -16,8 +16,8 @@ from regulations.views.partial_search import PartialSearch from regulations.views.partial_sxs import ParagraphSXSView from regulations.views.preamble import ( - CFRChangesView, PreambleView, PrepareCommentView, - ChromePreambleSearchView) + CFRChangesView, PreambleView, ChromePreambleSearchView +) from regulations.views.redirect import ( diff_redirect, redirect_by_current_date, @@ -26,7 +26,6 @@ ) from regulations.views.sidebar import SideBarView from regulations.views.universal_landing import universal -from regulations.views import comment # Re-usable URL patterns. meta_version = r'(?P<%s>[-\d\w_]+)' @@ -46,15 +45,6 @@ url(r'^$', universal, name='universal_landing'), # about page url(r'^about$', about, name='about'), - url(r'^comments/attachment$', comment.upload_proxy), - url(r'^comments/review/(?P[\w-]+)$', - PrepareCommentView.as_view(), name='comment_review'), - url(r'^comments/preview$', comment.preview_comment), - url(r'^comments/comment/(?P[\w-]+)$', - comment.SubmitCommentView.as_view(), - name='comment_submit'), - url(r'^comments/federal_agencies$', comment.get_federal_agencies), - url(r'^comments/gov_agency_types$', comment.get_gov_agency_types), # Redirect to version by date (by GET) # Example http://.../regulation_redirect/201-3-v url(r'^regulation_redirect/%s$' % paragraph_pattern, redirect_by_date_get, diff --git a/regulations/views/preamble.py b/regulations/views/preamble.py index 533fb8d67..fc7acdf4c 100644 --- a/regulations/views/preamble.py +++ b/regulations/views/preamble.py @@ -17,7 +17,6 @@ from django.views.generic.base import View from fr_notices import navigation -from regulations import docket from regulations.generator import generator from regulations.generator.api_reader import ApiReader from regulations.generator.html_builder import ( @@ -241,24 +240,6 @@ def get_context_data(self, **kwargs): return context -class PrepareCommentView(View): - def get(self, request, doc_number): - context = common_context(doc_number) - - if context['meta']['comment_state'] != CommentState.OPEN: - raise Http404("Cannot comment on {}".format(doc_number)) - - context.update(generate_html_tree(context['preamble'], request, - id_prefix=[doc_number, 'preamble'])) - context['comment_mode'] = 'write' - context['comment_fields'] = docket.safe_get_document_fields( - settings.COMMENT_DOCUMENT_ID) - template = 'regulations/comment-review-chrome.html' - - return TemplateResponse(request=request, template=template, - context=context) - - SubpartInfo = namedtuple('SubpartInfo', ['letter', 'title', 'urls', 'idx']) diff --git a/setup.py b/setup.py index ab587d7e2..613d8c08e 100644 --- a/setup.py +++ b/setup.py @@ -3,20 +3,20 @@ setup( name="regulations", - version="7.1.0", + version="8.0.0", packages=find_packages(), include_package_data=True, install_requires=[ - 'boto3', 'cached-property', - 'celery', 'django>=1.8,<1.12', 'enum34', 'futures', 'requests', 'six', - 'requests-toolbelt', ], + extras_require={ + 'notice_comment': ['boto3', 'celery', 'requests-toolbelt'], + }, classifiers=[ 'License :: Public Domain', 'License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication' diff --git a/tox.ini b/tox.ini index 5674bdb2b..5b09781a9 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,7 @@ deps = pytest~=3.0 pytest_cov~=2.4 pytest_django~=3.1 +extras = notice_comment commands = pytest --cov @@ -24,15 +25,16 @@ deps = bandit==1.4.0 flake8==2.5.4 commands = - flake8 fr_notices regulations - bandit -r --ini tox.ini fr_notices regulations manage.py setup.py + flake8 fr_notices notice_comment regulations + bandit -r --ini tox.ini fr_notices notice_comment regulations manage.py setup.py [testenv:docs] deps = sphinx commands = # Tox won't do wildcard expansion, so run in a shell - sh -c "rm -f docs/regulations*.rst docs/fr_notices*.rst" + sh -c "rm -f docs/regulations*.rst docs/fr_notices*.rst docs/notice_comment*.rst" sphinx-apidoc -F -o docs fr_notices + sphinx-apidoc -F -o docs notice_comment sphinx-apidoc -F -o docs regulations sphinx-build -b dirhtml -d docs/_build/doctrees/ docs/ docs/_build/dirhtml/ whitelist_externals = sh @@ -55,11 +57,11 @@ passenv = commands = py.test regulations/uitests -s [bandit] -exclude = fr_notices/tests,regulations/tests,regulations/uitests +exclude = fr_notices/tests,notice_comment/tests,regulations/tests,regulations/uitests [coverage:run] -source = regulations,fr_notices -omit = regulations/uitests/*,regulations/tests/*,fr_notices/tests/* +source = regulations,fr_notices,notice_comment +omit = regulations/uitests/*,regulations/tests/*,fr_notices/tests/*,notice_comment/tests/* [flake8] exclude = regulations/settings/*.py @@ -67,7 +69,7 @@ exclude = regulations/settings/*.py [isort] [pytest] -testpaths = regulations/tests fr_notices/tests +testpaths = regulations/tests fr_notices/tests notice_comment/tests python_files = tests_*.py *_test.py *_tests.py DJANGO_SETTINGS_MODULE = regulations.settings.dev