From 005cf3fdedd0a4338ff85a30c0c5472a6edcf1f1 Mon Sep 17 00:00:00 2001 From: George Hickman <george@ghickman.co.uk> Date: Thu, 18 Jul 2019 12:14:02 +0100 Subject: [PATCH] Apply isort --- addressfield/fields.py | 1 - addressfield/widgets.py | 1 - fabfile.py | 3 +- opentech/apply/activity/admin.py | 1 + opentech/apply/activity/forms.py | 3 +- .../management/commands/migrate_comments.py | 1 - opentech/apply/activity/messaging.py | 5 +- opentech/apply/activity/models.py | 3 +- opentech/apply/activity/tasks.py | 1 - opentech/apply/activity/tests/factories.py | 9 +++- .../apply/activity/tests/test_messaging.py | 13 +++-- opentech/apply/activity/tests/test_models.py | 2 +- opentech/apply/activity/tests/test_tasks.py | 1 - opentech/apply/activity/urls.py | 1 - opentech/apply/activity/views.py | 7 ++- opentech/apply/categories/admin_helpers.py | 1 - opentech/apply/categories/admin_views.py | 1 - opentech/apply/categories/blocks.py | 3 +- .../management/commands/seed_categories.py | 2 +- opentech/apply/categories/models.py | 9 +--- opentech/apply/dashboard/tests/test_views.py | 8 ++- opentech/apply/dashboard/urls.py | 1 - opentech/apply/dashboard/views.py | 2 +- opentech/apply/dashboard/wagtail_hooks.py | 3 +- opentech/apply/determinations/forms.py | 8 +-- .../migrate_concept_determinations.py | 1 - .../migrate_proposal_determinations.py | 1 - opentech/apply/determinations/models.py | 3 +- .../apply/determinations/tests/factories.py | 2 +- .../apply/determinations/tests/test_views.py | 2 +- opentech/apply/determinations/views.py | 14 +++-- opentech/apply/funds/admin.py | 12 ++++- opentech/apply/funds/admin_helpers.py | 1 - opentech/apply/funds/admin_views.py | 1 - opentech/apply/funds/api_views.py | 23 ++++----- opentech/apply/funds/blocks.py | 1 - opentech/apply/funds/differ.py | 4 +- opentech/apply/funds/edit_handlers.py | 5 +- opentech/apply/funds/forms.py | 2 +- .../management/commands/migration_base.py | 9 ++-- .../seed_community_lab_application.py | 3 +- .../management/commands/seed_concept_note.py | 9 ++-- .../management/commands/seed_fellowship.py | 9 ++-- .../commands/seed_rapid_response.py | 9 ++-- opentech/apply/funds/models/__init__.py | 5 +- opentech/apply/funds/models/applications.py | 17 ++++--- opentech/apply/funds/models/forms.py | 7 +-- opentech/apply/funds/models/mixins.py | 14 ++--- opentech/apply/funds/models/submissions.py | 44 ++++++++-------- opentech/apply/funds/models/utils.py | 11 ++-- opentech/apply/funds/serializers.py | 3 +- opentech/apply/funds/tables.py | 6 +-- .../apply/funds/templatetags/markdown_tags.py | 1 - .../apply/funds/tests/factories/__init__.py | 5 +- .../apply/funds/tests/factories/blocks.py | 3 +- .../apply/funds/tests/factories/models.py | 9 ++-- .../funds/tests/models/test_roundsandlabs.py | 1 - opentech/apply/funds/tests/test_admin_form.py | 5 +- .../apply/funds/tests/test_admin_views.py | 2 +- opentech/apply/funds/tests/test_api_views.py | 3 +- opentech/apply/funds/tests/test_forms.py | 12 ++--- opentech/apply/funds/tests/test_models.py | 10 ++-- opentech/apply/funds/tests/test_tags.py | 2 +- opentech/apply/funds/tests/test_views.py | 8 +-- .../funds/tests/views/test_batch_progress.py | 5 +- .../funds/tests/views/test_batch_reviewers.py | 5 +- .../apply/funds/tests/views/test_rounds.py | 6 +-- opentech/apply/funds/urls.py | 29 +++++------ opentech/apply/funds/views.py | 51 ++++++++++++------- opentech/apply/funds/wagtail_hooks.py | 4 +- opentech/apply/funds/widgets.py | 1 - opentech/apply/funds/workflow.py | 3 +- opentech/apply/home/models.py | 4 +- opentech/apply/review/admin.py | 1 - opentech/apply/review/blocks.py | 20 ++++++-- opentech/apply/review/fields.py | 5 +- .../commands/migrate_community_lab_reviews.py | 4 +- .../commands/migrate_concept_reviews.py | 4 +- .../migrate_fellowship_application_reviews.py | 4 +- .../migrate_fellowship_proposal_reviews.py | 4 +- .../commands/migrate_proposal_reviews.py | 4 +- .../management/commands/migrate_rr_reviews.py | 4 +- .../commands/migration_review_base.py | 5 +- opentech/apply/review/models.py | 21 ++++++-- .../apply/review/tests/factories/__init__.py | 5 +- .../apply/review/tests/factories/blocks.py | 10 ++-- .../apply/review/tests/factories/models.py | 8 +-- opentech/apply/review/tests/test_admin.py | 1 + opentech/apply/review/tests/test_models.py | 3 +- opentech/apply/review/tests/test_views.py | 15 ++++-- opentech/apply/review/urls.py | 7 ++- opentech/apply/review/views.py | 12 +++-- opentech/apply/review/wagtail_hooks.py | 1 - opentech/apply/stream_forms/blocks.py | 17 +++++-- opentech/apply/stream_forms/fields.py | 2 +- opentech/apply/stream_forms/forms.py | 1 - .../apply/stream_forms/testing/factories.py | 7 ++- opentech/apply/stream_forms/tests.py | 3 +- opentech/apply/urls.py | 8 ++- opentech/apply/users/admin_views.py | 1 - opentech/apply/users/decorators.py | 2 +- opentech/apply/users/forms.py | 4 +- opentech/apply/users/middleware.py | 4 +- opentech/apply/users/models.py | 11 ++-- opentech/apply/users/tests/factories.py | 3 +- .../apply/users/tests/test_oauth_access.py | 2 +- opentech/apply/users/tests/test_views.py | 3 +- opentech/apply/users/urls.py | 13 +++-- opentech/apply/users/utils.py | 2 +- opentech/apply/users/views.py | 3 -- opentech/apply/users/wagtail_hooks.py | 1 - opentech/apply/utils/blocks.py | 14 ++--- opentech/apply/utils/notifications.py | 1 - opentech/apply/utils/testing/__init__.py | 2 +- opentech/apply/utils/testing/tests.py | 5 +- opentech/images/models.py | 6 +-- opentech/public/forms/models.py | 17 ++++--- opentech/public/forms/wagtail_hooks.py | 1 - opentech/public/funds/models.py | 9 +--- opentech/public/home/blocks.py | 1 - opentech/public/home/models.py | 14 +++-- .../public/home/templatetags/home_tags.py | 1 - opentech/public/mailchimp/tests.py | 10 ++-- opentech/public/mailchimp/urls.py | 1 - opentech/public/mailchimp/views.py | 2 - opentech/public/navigation/models.py | 2 +- .../templatetags/navigation_tags.py | 1 - opentech/public/news/feeds.py | 3 +- .../news/management/commands/migrate_news.py | 10 ++-- opentech/public/news/models.py | 12 ++--- .../management/commands/migrate_people.py | 16 +++--- opentech/public/people/models.py | 19 ++++--- opentech/public/people/wagtail_hooks.py | 1 - .../management/commands/migrate_projects.py | 12 ++--- opentech/public/projects/models.py | 5 +- opentech/public/standardpages/models.py | 15 ++---- opentech/public/urls.py | 2 +- opentech/public/utils/context_processors.py | 1 - opentech/public/utils/models.py | 10 ++-- .../public/utils/templatetags/util_tags.py | 2 - opentech/public/utils/wagtail_hooks.py | 8 +-- opentech/settings/base.py | 1 - opentech/settings/test.py | 3 +- opentech/urls.py | 9 ++-- 144 files changed, 463 insertions(+), 455 deletions(-) diff --git a/addressfield/fields.py b/addressfield/fields.py index 7692b9eb4..ee18e7ed9 100644 --- a/addressfield/fields.py +++ b/addressfield/fields.py @@ -6,7 +6,6 @@ from django.core.exceptions import ValidationError from .widgets import AddressWidget - basepath = path.dirname(__file__) filepath = path.abspath(path.join(basepath, "static", "addressfield.min.json")) with open(filepath, encoding='utf8') as address_data: diff --git a/addressfield/widgets.py b/addressfield/widgets.py index 3b85a1f5a..e8561b09e 100644 --- a/addressfield/widgets.py +++ b/addressfield/widgets.py @@ -1,5 +1,4 @@ from django import forms - from django_countries import countries from django_select2.forms import Select2Widget diff --git a/fabfile.py b/fabfile.py index d3f51979c..1acf1b685 100644 --- a/fabfile.py +++ b/fabfile.py @@ -1,7 +1,6 @@ from datetime import datetime -from fabric.api import lcd, roles, runs_once, run, local, env, prompt, get - +from fabric.api import env, get, lcd, local, prompt, roles, run, runs_once env.roledefs = { 'production': [], diff --git a/opentech/apply/activity/admin.py b/opentech/apply/activity/admin.py index eacc4bfbd..0cde3d666 100644 --- a/opentech/apply/activity/admin.py +++ b/opentech/apply/activity/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Event, Message diff --git a/opentech/apply/activity/forms.py b/opentech/apply/activity/forms.py index 720706827..54f87191f 100644 --- a/opentech/apply/activity/forms.py +++ b/opentech/apply/activity/forms.py @@ -1,10 +1,9 @@ from django import forms from django.core.exceptions import ValidationError from django.utils.safestring import mark_safe - from pagedown.widgets import PagedownWidget -from .models import Activity, VISIBILILTY_HELP_TEXT, VISIBILITY +from .models import VISIBILILTY_HELP_TEXT, VISIBILITY, Activity class CommentForm(forms.ModelForm): diff --git a/opentech/apply/activity/management/commands/migrate_comments.py b/opentech/apply/activity/management/commands/migrate_comments.py index d03da81e7..320020400 100644 --- a/opentech/apply/activity/management/commands/migrate_comments.py +++ b/opentech/apply/activity/management/commands/migrate_comments.py @@ -1,6 +1,5 @@ import argparse import json - from datetime import datetime, timezone from django.contrib.auth import get_user_model diff --git a/opentech/apply/activity/messaging.py b/opentech/apply/activity/messaging.py index faaa386f3..c072f0009 100644 --- a/opentech/apply/activity/messaging.py +++ b/opentech/apply/activity/messaging.py @@ -1,11 +1,11 @@ import json -import requests from collections import defaultdict -from django.db import models +import requests from django.conf import settings from django.contrib import messages from django.contrib.auth import get_user_model +from django.db import models from django.template.loader import render_to_string from django.utils import timezone @@ -15,7 +15,6 @@ from .models import INTERNAL, PUBLIC from .options import MESSAGES from .tasks import send_mail - User = get_user_model() diff --git a/opentech/apply/activity/models.py b/opentech/apply/activity/models.py index 089686efe..083981a83 100644 --- a/opentech/apply/activity/models.py +++ b/opentech/apply/activity/models.py @@ -2,12 +2,11 @@ from django.conf import settings from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models -from django.db.models import Case, When, Value +from django.db.models import Case, Value, When from django.db.models.functions import Concat from .options import MESSAGES - COMMENT = 'comment' ACTION = 'action' diff --git a/opentech/apply/activity/tasks.py b/opentech/apply/activity/tasks.py index 569c27753..247c8ceda 100644 --- a/opentech/apply/activity/tasks.py +++ b/opentech/apply/activity/tasks.py @@ -1,5 +1,4 @@ from celery import Celery - from django.conf import settings from django.core.mail import EmailMessage diff --git a/opentech/apply/activity/tests/factories.py b/opentech/apply/activity/tests/factories.py index fb312efc0..90a3efa03 100644 --- a/opentech/apply/activity/tests/factories.py +++ b/opentech/apply/activity/tests/factories.py @@ -3,7 +3,14 @@ import uuid import factory from django.utils import timezone -from opentech.apply.activity.models import Activity, Event, INTERNAL, Message, MESSAGES, REVIEWER +from opentech.apply.activity.models import ( + INTERNAL, + MESSAGES, + REVIEWER, + Activity, + Event, + Message, +) from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory from opentech.apply.users.tests.factories import UserFactory diff --git a/opentech/apply/activity/tests/test_messaging.py b/opentech/apply/activity/tests/test_messaging.py index 78c1d19b6..6ffc5a8ba 100644 --- a/opentech/apply/activity/tests/test_messaging.py +++ b/opentech/apply/activity/tests/test_messaging.py @@ -4,12 +4,10 @@ import json from unittest.mock import Mock, patch import responses - +from django.contrib.messages import get_messages from django.core import mail from django.test import TestCase, override_settings -from django.contrib.messages import get_messages -from opentech.apply.utils.testing import make_request from opentech.apply.funds.tests.factories import ( ApplicationSubmissionFactory, AssignedReviewersFactory, @@ -17,17 +15,18 @@ from opentech.apply.funds.tests.factories import ( ) from opentech.apply.review.tests.factories import ReviewFactory from opentech.apply.users.tests.factories import ReviewerFactory, UserFactory +from opentech.apply.utils.testing import make_request -from ..models import Activity, Event, Message, INTERNAL, PUBLIC from ..messaging import ( - AdapterBase, + MESSAGES, ActivityAdapter, + AdapterBase, EmailAdapter, MessengerBackend, - neat_related, - MESSAGES, SlackAdapter, + neat_related, ) +from ..models import INTERNAL, PUBLIC, Activity, Event, Message from .factories import CommentFactory, EventFactory, MessageFactory diff --git a/opentech/apply/activity/tests/test_models.py b/opentech/apply/activity/tests/test_models.py index 2230036f3..4331229a1 100644 --- a/opentech/apply/activity/tests/test_models.py +++ b/opentech/apply/activity/tests/test_models.py @@ -1,7 +1,7 @@ from django.test import TestCase -from .factories import CommentFactory from ..models import Activity +from .factories import CommentFactory class TestActivityOnlyIncludesCurrent(TestCase): diff --git a/opentech/apply/activity/tests/test_tasks.py b/opentech/apply/activity/tests/test_tasks.py index f468f396c..3efd91b03 100644 --- a/opentech/apply/activity/tests/test_tasks.py +++ b/opentech/apply/activity/tests/test_tasks.py @@ -3,7 +3,6 @@ from unittest.mock import patch from django.test import TestCase from ..tasks import send_mail - from .factories import MessageFactory diff --git a/opentech/apply/activity/urls.py b/opentech/apply/activity/urls.py index cdad5c3af..19c085527 100644 --- a/opentech/apply/activity/urls.py +++ b/opentech/apply/activity/urls.py @@ -1,6 +1,5 @@ from django.urls import include, path - app_name = 'activity' diff --git a/opentech/apply/activity/views.py b/opentech/apply/activity/views.py index 25b216107..ed6998dfd 100644 --- a/opentech/apply/activity/views.py +++ b/opentech/apply/activity/views.py @@ -1,12 +1,11 @@ -from django.views.generic import CreateView from django.utils import timezone +from django.views.generic import CreateView from opentech.apply.utils.views import DelegatedViewMixin from .forms import CommentForm -from .messaging import messenger, MESSAGES -from .models import Activity, COMMENT - +from .messaging import MESSAGES, messenger +from .models import COMMENT, Activity ACTIVITY_LIMIT = 50 diff --git a/opentech/apply/categories/admin_helpers.py b/opentech/apply/categories/admin_helpers.py index 9f786fced..c43d785ea 100644 --- a/opentech/apply/categories/admin_helpers.py +++ b/opentech/apply/categories/admin_helpers.py @@ -1,5 +1,4 @@ from django.contrib.admin.utils import quote - from wagtail.contrib.modeladmin.helpers import ButtonHelper diff --git a/opentech/apply/categories/admin_views.py b/opentech/apply/categories/admin_views.py index 890bccbe4..4c115e319 100644 --- a/opentech/apply/categories/admin_views.py +++ b/opentech/apply/categories/admin_views.py @@ -1,6 +1,5 @@ from django.contrib.admin.utils import unquote from django.shortcuts import get_object_or_404 - from wagtail.contrib.modeladmin.views import CreateView diff --git a/opentech/apply/categories/blocks.py b/opentech/apply/categories/blocks.py index b8bf9a67c..26ef81979 100644 --- a/opentech/apply/categories/blocks.py +++ b/opentech/apply/categories/blocks.py @@ -1,12 +1,11 @@ from django import forms from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ - +from django_select2.forms import Select2MultipleWidget from wagtail.core.blocks import BooleanBlock, CharBlock, ChooserBlock, TextBlock from wagtail.core.utils import resolve_model_string from opentech.apply.stream_forms.blocks import OptionalFormFieldBlock -from django_select2.forms import Select2MultipleWidget class ModelChooserBlock(ChooserBlock): diff --git a/opentech/apply/categories/management/commands/seed_categories.py b/opentech/apply/categories/management/commands/seed_categories.py index 86354570d..1317cf625 100644 --- a/opentech/apply/categories/management/commands/seed_categories.py +++ b/opentech/apply/categories/management/commands/seed_categories.py @@ -1,8 +1,8 @@ from django.core.management.base import BaseCommand from django.db import transaction -from opentech.apply.categories.models import Category, Option from opentech.apply.categories.categories_seed import CATEGORIES +from opentech.apply.categories.models import Category, Option class Command(BaseCommand): diff --git a/opentech/apply/categories/models.py b/opentech/apply/categories/models.py index 81ce64591..eb3eab506 100644 --- a/opentech/apply/categories/models.py +++ b/opentech/apply/categories/models.py @@ -2,19 +2,14 @@ from django import forms from django.core.exceptions import PermissionDenied from django.db import models from django.template.loader import render_to_string - from modelcluster.fields import ParentalKey from modelcluster.models import ClusterableModel -from wagtail.admin.edit_handlers import ( - FieldPanel, - InlinePanel, -) +from treebeard.mp_tree import MP_Node +from wagtail.admin.edit_handlers import FieldPanel, InlinePanel from wagtail.admin.forms import WagtailAdminModelForm from wagtail.core.models import Orderable from wagtail.search import index -from treebeard.mp_tree import MP_Node - class Option(Orderable): value = models.CharField(max_length=255) diff --git a/opentech/apply/dashboard/tests/test_views.py b/opentech/apply/dashboard/tests/test_views.py index 54aba6a63..448fef5af 100644 --- a/opentech/apply/dashboard/tests/test_views.py +++ b/opentech/apply/dashboard/tests/test_views.py @@ -1,10 +1,14 @@ from opentech.apply.funds.tests.factories import ( - ApplicationSubmissionFactory, ApplicationRevisionFactory, + ApplicationSubmissionFactory, InvitedToProposalFactory, ) from opentech.apply.review.tests.factories import ReviewFactory, ReviewOpinionFactory -from opentech.apply.users.tests.factories import UserFactory, ReviewerFactory, StaffFactory +from opentech.apply.users.tests.factories import ( + ReviewerFactory, + StaffFactory, + UserFactory, +) from opentech.apply.utils.testing.tests import BaseViewTestCase diff --git a/opentech/apply/dashboard/urls.py b/opentech/apply/dashboard/urls.py index d8710de3c..1c906f43b 100644 --- a/opentech/apply/dashboard/urls.py +++ b/opentech/apply/dashboard/urls.py @@ -2,7 +2,6 @@ from django.urls import path from .views import DashboardView - app_name = 'dashboard' urlpatterns = [ diff --git a/opentech/apply/dashboard/views.py b/opentech/apply/dashboard/views.py index 0056650ff..a9670feaf 100644 --- a/opentech/apply/dashboard/views.py +++ b/opentech/apply/dashboard/views.py @@ -1,7 +1,7 @@ from django.http import HttpResponseRedirect from django.shortcuts import render -from django.views.generic import TemplateView from django.urls import reverse_lazy +from django.views.generic import TemplateView from django_tables2.views import SingleTableView from opentech.apply.funds.models import ApplicationSubmission, RoundsAndLabs diff --git a/opentech/apply/dashboard/wagtail_hooks.py b/opentech/apply/dashboard/wagtail_hooks.py index 89843e82e..aac0da2be 100644 --- a/opentech/apply/dashboard/wagtail_hooks.py +++ b/opentech/apply/dashboard/wagtail_hooks.py @@ -1,9 +1,8 @@ from urllib.parse import urljoin from django.urls import reverse - -from wagtail.core import hooks from wagtail.admin.menu import MenuItem +from wagtail.core import hooks from opentech.apply.home.models import ApplyHomePage diff --git a/opentech/apply/determinations/forms.py b/opentech/apply/determinations/forms.py index b6d2559b5..678043386 100644 --- a/opentech/apply/determinations/forms.py +++ b/opentech/apply/determinations/forms.py @@ -2,14 +2,10 @@ from django import forms from django.contrib.auth import get_user_model from django.core.exceptions import NON_FIELD_ERRORS -from opentech.apply.utils.options import RICH_TEXT_WIDGET from opentech.apply.funds.models import ApplicationSubmission +from opentech.apply.utils.options import RICH_TEXT_WIDGET -from .models import ( - Determination, - DETERMINATION_CHOICES, - TRANSITION_DETERMINATION, -) +from .models import DETERMINATION_CHOICES, TRANSITION_DETERMINATION, Determination from .utils import determination_actions User = get_user_model() diff --git a/opentech/apply/determinations/management/commands/migrate_concept_determinations.py b/opentech/apply/determinations/management/commands/migrate_concept_determinations.py index ce73c9362..3c3243b7e 100644 --- a/opentech/apply/determinations/management/commands/migrate_concept_determinations.py +++ b/opentech/apply/determinations/management/commands/migrate_concept_determinations.py @@ -1,6 +1,5 @@ import argparse import json - from datetime import datetime, timezone from django.contrib.auth import get_user_model diff --git a/opentech/apply/determinations/management/commands/migrate_proposal_determinations.py b/opentech/apply/determinations/management/commands/migrate_proposal_determinations.py index a43b335ec..344ba3ce7 100644 --- a/opentech/apply/determinations/management/commands/migrate_proposal_determinations.py +++ b/opentech/apply/determinations/management/commands/migrate_proposal_determinations.py @@ -1,6 +1,5 @@ import argparse import json - from datetime import datetime, timezone from django.contrib.auth import get_user_model diff --git a/opentech/apply/determinations/models.py b/opentech/apply/determinations/models.py index 2d985f2d6..dd289f889 100644 --- a/opentech/apply/determinations/models.py +++ b/opentech/apply/determinations/models.py @@ -4,14 +4,13 @@ from django.contrib.postgres.fields import JSONField from django.db import models from django.urls import reverse from django.utils.translation import ugettext_lazy as _ -from wagtail.admin.edit_handlers import TabbedInterface, ObjectList, FieldPanel +from wagtail.admin.edit_handlers import FieldPanel, ObjectList, TabbedInterface from wagtail.contrib.settings.models import BaseSetting from wagtail.contrib.settings.registry import register_setting from wagtail.core.fields import RichTextField from opentech.apply.funds.workflow import DETERMINATION_OUTCOMES - REJECTED = 0 NEEDS_MORE_INFO = 1 ACCEPTED = 2 diff --git a/opentech/apply/determinations/tests/factories.py b/opentech/apply/determinations/tests/factories.py index 1862a1474..9c88ba4f1 100644 --- a/opentech/apply/determinations/tests/factories.py +++ b/opentech/apply/determinations/tests/factories.py @@ -2,7 +2,7 @@ import factory from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory -from ..models import Determination, ACCEPTED, NEEDS_MORE_INFO, REJECTED +from ..models import ACCEPTED, NEEDS_MORE_INFO, REJECTED, Determination from ..views import get_form_for_stage diff --git a/opentech/apply/determinations/tests/test_views.py b/opentech/apply/determinations/tests/test_views.py index f3e71f999..489a5a09c 100644 --- a/opentech/apply/determinations/tests/test_views.py +++ b/opentech/apply/determinations/tests/test_views.py @@ -8,9 +8,9 @@ from django.urls import reverse_lazy from opentech.apply.activity.models import Activity from opentech.apply.determinations.models import ACCEPTED, REJECTED from opentech.apply.determinations.views import BatchDeterminationCreateView -from opentech.apply.users.tests.factories import StaffFactory, UserFactory from opentech.apply.funds.models import ApplicationSubmission from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory +from opentech.apply.users.tests.factories import StaffFactory, UserFactory from opentech.apply.utils.testing import BaseViewTestCase from .factories import DeterminationFactory diff --git a/opentech/apply/determinations/views.py b/opentech/apply/determinations/views.py index a5e65f32d..baf5e7f4c 100644 --- a/opentech/apply/determinations/views.py +++ b/opentech/apply/determinations/views.py @@ -9,14 +9,14 @@ from django.urls import reverse_lazy from django.utils import timezone from django.utils.decorators import method_decorator from django.utils.translation import ugettext_lazy as _ -from django.views.generic import DetailView, CreateView +from django.views.generic import CreateView, DetailView +from opentech.apply.activity.messaging import MESSAGES, messenger from opentech.apply.activity.models import Activity -from opentech.apply.activity.messaging import messenger, MESSAGES from opentech.apply.funds.models import ApplicationSubmission from opentech.apply.funds.workflow import DETERMINATION_OUTCOMES -from opentech.apply.utils.views import CreateOrUpdateView, ViewDispatcher from opentech.apply.users.decorators import staff_required +from opentech.apply.utils.views import CreateOrUpdateView, ViewDispatcher from .forms import ( BatchConceptDeterminationForm, @@ -24,8 +24,12 @@ from .forms import ( ConceptDeterminationForm, ProposalDeterminationForm, ) -from .models import Determination, DeterminationMessageSettings, NEEDS_MORE_INFO, TRANSITION_DETERMINATION - +from .models import ( + NEEDS_MORE_INFO, + TRANSITION_DETERMINATION, + Determination, + DeterminationMessageSettings, +) from .utils import ( can_create_determination, can_edit_determination, diff --git a/opentech/apply/funds/admin.py b/opentech/apply/funds/admin.py index b3da7925f..a12c1c0fe 100644 --- a/opentech/apply/funds/admin.py +++ b/opentech/apply/funds/admin.py @@ -1,16 +1,24 @@ from wagtail.contrib.modeladmin.helpers import PermissionHelper from wagtail.contrib.modeladmin.options import ModelAdmin, ModelAdminGroup +from opentech.apply.categories.admin import CategoryAdmin, MetaCategoryAdmin from opentech.apply.funds.models import ReviewerRole, ScreeningStatus from opentech.apply.review.admin import ReviewFormAdmin from opentech.apply.utils.admin import ListRelatedMixin + from .admin_helpers import ( ButtonsWithPreview, FormsFundRoundListFilter, RoundFundChooserView, ) -from .models import ApplicationForm, FundType, LabType, RequestForPartners, Round, SealedRound -from opentech.apply.categories.admin import CategoryAdmin, MetaCategoryAdmin +from .models import ( + ApplicationForm, + FundType, + LabType, + RequestForPartners, + Round, + SealedRound, +) class BaseRoundAdmin(ModelAdmin): diff --git a/opentech/apply/funds/admin_helpers.py b/opentech/apply/funds/admin_helpers.py index 75ce474fb..d879c7b1a 100644 --- a/opentech/apply/funds/admin_helpers.py +++ b/opentech/apply/funds/admin_helpers.py @@ -2,7 +2,6 @@ from django import forms from django.contrib import admin from django.urls import reverse from django.utils.translation import ugettext as _ - from wagtail.contrib.modeladmin.forms import ParentChooserForm from wagtail.contrib.modeladmin.helpers import PageButtonHelper from wagtail.contrib.modeladmin.views import ChooseParentView diff --git a/opentech/apply/funds/admin_views.py b/opentech/apply/funds/admin_views.py index d0a0cf181..9610cbbb4 100644 --- a/opentech/apply/funds/admin_views.py +++ b/opentech/apply/funds/admin_views.py @@ -1,7 +1,6 @@ from django.core.exceptions import PermissionDenied from django.shortcuts import redirect from django.utils.translation import ugettext as _ - from wagtail.admin import messages from wagtail.admin.forms import CopyForm from wagtail.admin.views.pages import get_valid_next_url_from_request diff --git a/opentech/apply/funds/api_views.py b/opentech/apply/funds/api_views.py index 1c2c1f3dd..a768bf447 100644 --- a/opentech/apply/funds/api_views.py +++ b/opentech/apply/funds/api_views.py @@ -1,35 +1,32 @@ from django.core.exceptions import PermissionDenied as DjangoPermissionDenied from django.db import transaction -from django.db.models import Q, Prefetch +from django.db.models import Prefetch, Q from django.utils import timezone - -from wagtail.core.models import Page - +from django_filters import rest_framework as filters from rest_framework import generics, mixins, permissions +from rest_framework.exceptions import NotFound, PermissionDenied, ValidationError from rest_framework.response import Response -from rest_framework.exceptions import (NotFound, PermissionDenied, - ValidationError) -from django_filters import rest_framework as filters +from wagtail.core.models import Page from opentech.api.pagination import StandardResultsSetPagination -from opentech.apply.activity.models import Activity, COMMENT -from opentech.apply.activity.messaging import messenger, MESSAGES +from opentech.apply.activity.messaging import MESSAGES, messenger +from opentech.apply.activity.models import COMMENT, Activity from opentech.apply.determinations.views import DeterminationCreateOrUpdateView -from opentech.apply.review.models import Review from opentech.apply.funds.models import FundType, LabType +from opentech.apply.review.models import Review from .models import ApplicationSubmission, RoundsAndLabs +from .permissions import IsApplyStaffUser, IsAuthor from .serializers import ( - CommentSerializer, CommentCreateSerializer, CommentEditSerializer, + CommentSerializer, RoundLabDetailSerializer, RoundLabSerializer, SubmissionActionSerializer, - SubmissionListSerializer, SubmissionDetailSerializer, + SubmissionListSerializer, ) -from .permissions import IsApplyStaffUser, IsAuthor from .workflow import PHASES diff --git a/opentech/apply/funds/blocks.py b/opentech/apply/funds/blocks.py index bec9b723d..f94447f78 100644 --- a/opentech/apply/funds/blocks.py +++ b/opentech/apply/funds/blocks.py @@ -2,7 +2,6 @@ import json from django import forms from django.utils.translation import ugettext_lazy as _ - from wagtail.core import blocks from addressfield.fields import AddressField diff --git a/opentech/apply/funds/differ.py b/opentech/apply/funds/differ.py index 7573d9a83..67d172778 100644 --- a/opentech/apply/funds/differ.py +++ b/opentech/apply/funds/differ.py @@ -1,7 +1,7 @@ -from bleach.sanitizer import Cleaner -from bs4 import BeautifulSoup from difflib import SequenceMatcher +from bleach.sanitizer import Cleaner +from bs4 import BeautifulSoup from django.utils.html import format_html from django.utils.text import mark_safe diff --git a/opentech/apply/funds/edit_handlers.py b/opentech/apply/funds/edit_handlers.py index d7f7b7825..643ba8c20 100644 --- a/opentech/apply/funds/edit_handlers.py +++ b/opentech/apply/funds/edit_handlers.py @@ -1,10 +1,9 @@ from django.forms import Field, Widget from django.forms.utils import pretty_name -from django.urls import reverse from django.template.loader import render_to_string - -from wagtail.core.models import Page +from django.urls import reverse from wagtail.admin.edit_handlers import EditHandler, FieldPanel +from wagtail.core.models import Page def reverse_edit(obj): diff --git a/opentech/apply/funds/forms.py b/opentech/apply/funds/forms.py index 4057a2906..7f6899684 100644 --- a/opentech/apply/funds/forms.py +++ b/opentech/apply/funds/forms.py @@ -5,7 +5,7 @@ from django_select2.forms import Select2Widget from opentech.apply.users.models import User -from .models import AssignedReviewers, ApplicationSubmission, ReviewerRole +from .models import ApplicationSubmission, AssignedReviewers, ReviewerRole from .utils import render_icon from .widgets import Select2MultiCheckboxesWidget from .workflow import get_action_mapping diff --git a/opentech/apply/funds/management/commands/migration_base.py b/opentech/apply/funds/management/commands/migration_base.py index 310140dbc..ea6dfb09b 100644 --- a/opentech/apply/funds/management/commands/migration_base.py +++ b/opentech/apply/funds/management/commands/migration_base.py @@ -1,9 +1,8 @@ import argparse import json import os -from urllib.parse import urlsplit - from datetime import datetime, timezone +from urllib.parse import urlsplit from django.conf import settings from django.contrib.auth import get_user_model @@ -13,10 +12,10 @@ from django.db.utils import IntegrityError from django_fsm import FSMField from storages.backends.s3boto3 import S3Boto3Storage -from opentech.apply.categories.models import Category, Option from opentech.apply.categories.categories_seed import CATEGORIES -from opentech.apply.funds.models import ApplicationSubmission, FundType, Round, LabType -from opentech.apply.funds.models.forms import RoundBaseForm, LabBaseForm +from opentech.apply.categories.models import Category, Option +from opentech.apply.funds.models import ApplicationSubmission, FundType, LabType, Round +from opentech.apply.funds.models.forms import LabBaseForm, RoundBaseForm from opentech.apply.funds.workflow import INITIAL_STATE diff --git a/opentech/apply/funds/management/commands/seed_community_lab_application.py b/opentech/apply/funds/management/commands/seed_community_lab_application.py index 732d98b32..8714a7c5c 100644 --- a/opentech/apply/funds/management/commands/seed_community_lab_application.py +++ b/opentech/apply/funds/management/commands/seed_community_lab_application.py @@ -6,9 +6,8 @@ from django.db import transaction from opentech.apply.funds.models import ApplicationForm, LabType from opentech.apply.funds.models.forms import LabBaseForm, LabBaseReviewForm -from opentech.apply.review.models import ReviewForm - from opentech.apply.home.models import ApplyHomePage +from opentech.apply.review.models import ReviewForm from opentech.apply.users.groups import STAFF_GROUP_NAME CL_FUND_TITLE = 'Community lab (archive fund)' diff --git a/opentech/apply/funds/management/commands/seed_concept_note.py b/opentech/apply/funds/management/commands/seed_concept_note.py index 9cb879687..c923e9acf 100644 --- a/opentech/apply/funds/management/commands/seed_concept_note.py +++ b/opentech/apply/funds/management/commands/seed_concept_note.py @@ -1,5 +1,4 @@ import json - from datetime import date from django.contrib.auth import get_user_model @@ -8,10 +7,12 @@ from django.db import transaction from opentech.apply.categories.models import Category from opentech.apply.funds.models import ApplicationForm, FundType, Round -from opentech.apply.funds.models.forms import ApplicationBaseForm, ApplicationBaseReviewForm -from opentech.apply.review.models import ReviewForm - +from opentech.apply.funds.models.forms import ( + ApplicationBaseForm, + ApplicationBaseReviewForm, +) from opentech.apply.home.models import ApplyHomePage +from opentech.apply.review.models import ReviewForm from opentech.apply.users.groups import STAFF_GROUP_NAME CN_ROUND_TITLE = 'Internet Freedom Fund (archive round)' diff --git a/opentech/apply/funds/management/commands/seed_fellowship.py b/opentech/apply/funds/management/commands/seed_fellowship.py index 1a233415b..f263d0146 100644 --- a/opentech/apply/funds/management/commands/seed_fellowship.py +++ b/opentech/apply/funds/management/commands/seed_fellowship.py @@ -1,5 +1,4 @@ import json - from datetime import date from django.contrib.auth import get_user_model @@ -8,10 +7,12 @@ from django.db import transaction from opentech.apply.categories.models import Category from opentech.apply.funds.models import ApplicationForm, FundType, Round -from opentech.apply.funds.models.forms import ApplicationBaseForm, ApplicationBaseReviewForm -from opentech.apply.review.models import ReviewForm - +from opentech.apply.funds.models.forms import ( + ApplicationBaseForm, + ApplicationBaseReviewForm, +) from opentech.apply.home.models import ApplyHomePage +from opentech.apply.review.models import ReviewForm from opentech.apply.users.groups import STAFF_GROUP_NAME FS_ROUND_TITLE = 'Fellowship (archive round)' diff --git a/opentech/apply/funds/management/commands/seed_rapid_response.py b/opentech/apply/funds/management/commands/seed_rapid_response.py index 7cf40a700..3aa8045c9 100644 --- a/opentech/apply/funds/management/commands/seed_rapid_response.py +++ b/opentech/apply/funds/management/commands/seed_rapid_response.py @@ -1,5 +1,4 @@ import json - from datetime import date from django.contrib.auth import get_user_model @@ -8,10 +7,12 @@ from django.db import transaction from opentech.apply.categories.models import Category from opentech.apply.funds.models import ApplicationForm, FundType, Round -from opentech.apply.funds.models.forms import ApplicationBaseForm, ApplicationBaseReviewForm -from opentech.apply.review.models import ReviewForm - +from opentech.apply.funds.models.forms import ( + ApplicationBaseForm, + ApplicationBaseReviewForm, +) from opentech.apply.home.models import ApplyHomePage +from opentech.apply.review.models import ReviewForm from opentech.apply.users.groups import STAFF_GROUP_NAME RR_ROUND_TITLE = 'Rapid Response (archive round)' diff --git a/opentech/apply/funds/models/__init__.py b/opentech/apply/funds/models/__init__.py index 4730a3a44..9b9fb053c 100644 --- a/opentech/apply/funds/models/__init__.py +++ b/opentech/apply/funds/models/__init__.py @@ -1,11 +1,10 @@ from django.utils.translation import ugettext_lazy as _ -from .applications import ApplicationBase, RoundBase, LabBase, RoundsAndLabs # NOQA +from .applications import ApplicationBase, LabBase, RoundBase, RoundsAndLabs # NOQA from .forms import ApplicationForm from .reviewer_role import ReviewerRole from .screening import ScreeningStatus -from .submissions import ApplicationSubmission, AssignedReviewers, ApplicationRevision - +from .submissions import ApplicationRevision, ApplicationSubmission, AssignedReviewers __all__ = ['ApplicationSubmission', 'AssignedReviewers', 'ApplicationRevision', 'ApplicationForm', 'ScreeningStatus', 'ReviewerRole'] diff --git a/opentech/apply/funds/models/applications.py b/opentech/apply/funds/models/applications.py index 0fad33145..b2097d043 100644 --- a/opentech/apply/funds/models/applications.py +++ b/opentech/apply/funds/models/applications.py @@ -17,15 +17,12 @@ from django.db.models import ( When, ) from django.db.models.functions import Coalesce, Length -from django.shortcuts import render - from django.http import Http404 +from django.shortcuts import render from django.utils.functional import cached_property from django.utils.text import mark_safe from django.utils.translation import ugettext_lazy as _ - from modelcluster.fields import ParentalManyToManyField - from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -36,11 +33,17 @@ from wagtail.admin.edit_handlers import ( from wagtail.core.models import Page, PageManager, PageQuerySet from ..admin_forms import RoundBasePageAdminForm, WorkflowFormAdminForm -from ..edit_handlers import ReadOnlyPanel, ReadOnlyInlinePanel +from ..edit_handlers import ReadOnlyInlinePanel, ReadOnlyPanel from ..workflow import OPEN_CALL_PHASES - from .submissions import ApplicationSubmission -from .utils import admin_url, EmailForm, SubmittableStreamForm, WorkflowStreamForm, LIMIT_TO_REVIEWERS, LIMIT_TO_STAFF +from .utils import ( + LIMIT_TO_REVIEWERS, + LIMIT_TO_STAFF, + EmailForm, + SubmittableStreamForm, + WorkflowStreamForm, + admin_url, +) class ApplicationBaseManager(PageQuerySet): diff --git a/opentech/apply/funds/models/forms.py b/opentech/apply/funds/models/forms.py index 40bf70d73..856124eee 100644 --- a/opentech/apply/funds/models/forms.py +++ b/opentech/apply/funds/models/forms.py @@ -1,11 +1,6 @@ from django.db import models - from modelcluster.fields import ParentalKey - -from wagtail.admin.edit_handlers import ( - FieldPanel, - StreamFieldPanel, -) +from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel from wagtail.core.fields import StreamField from wagtail.core.models import Orderable diff --git a/opentech/apply/funds/models/mixins.py b/opentech/apply/funds/models/mixins.py index 388e23849..cf6fd3228 100644 --- a/opentech/apply/funds/models/mixins.py +++ b/opentech/apply/funds/models/mixins.py @@ -1,16 +1,18 @@ from django.conf import settings -from django.utils.text import mark_safe from django.core.files import File from django.core.files.storage import get_storage_class +from django.utils.text import mark_safe from opentech.apply.stream_forms.blocks import ( - FileFieldBlock, FormFieldBlock, GroupToggleBlock, ImageFieldBlock, MultiFileFieldBlock + FileFieldBlock, + FormFieldBlock, + GroupToggleBlock, + ImageFieldBlock, + MultiFileFieldBlock, + UploadableMediaBlock, ) -from opentech.apply.utils.blocks import SingleIncludeMixin - -from opentech.apply.stream_forms.blocks import UploadableMediaBlock from opentech.apply.stream_forms.files import StreamFieldFile - +from opentech.apply.utils.blocks import SingleIncludeMixin __all__ = ['AccessFormData'] diff --git a/opentech/apply/funds/models/submissions.py b/opentech/apply/funds/models/submissions.py index cd1c41523..5e09d3938 100644 --- a/opentech/apply/funds/models/submissions.py +++ b/opentech/apply/funds/models/submissions.py @@ -10,8 +10,8 @@ from django.db import models from django.db.models import ( Case, Count, - IntegerField, F, + IntegerField, OuterRef, Prefetch, Q, @@ -19,51 +19,49 @@ from django.db.models import ( Sum, When, ) -from django.db.models.expressions import RawSQL, OrderBy +from django.db.models.expressions import OrderBy, RawSQL from django.db.models.functions import Coalesce from django.dispatch import receiver from django.urls import reverse from django.utils.text import slugify - -from django_fsm import can_proceed, FSMField, transition, RETURN_VALUE +from django_fsm import RETURN_VALUE, FSMField, can_proceed, transition from django_fsm.signals import post_transition - -from wagtail.core.fields import StreamField from wagtail.contrib.forms.models import AbstractFormSubmission +from wagtail.core.fields import StreamField -from opentech.apply.activity.messaging import messenger, MESSAGES +from opentech.apply.activity.messaging import MESSAGES, messenger from opentech.apply.determinations.models import Determination from opentech.apply.review.models import ReviewOpinion -from opentech.apply.review.options import MAYBE, AGREE, DISAGREE +from opentech.apply.review.options import AGREE, DISAGREE, MAYBE from opentech.apply.stream_forms.blocks import UploadableMediaBlock from opentech.apply.stream_forms.files import StreamFieldDataEncoder from opentech.apply.stream_forms.models import BaseStreamForm +from ..blocks import NAMED_BLOCKS, ApplicationCustomFormFieldsBlock +from ..workflow import ( + COMMUNITY_REVIEW_PHASES, + DETERMINATION_RESPONSE_PHASES, + INITIAL_STATE, + PHASES, + STAGE_CHANGE_ACTIONS, + WORKFLOWS, + UserPermissions, + active_statuses, + get_review_active_statuses, + review_statuses, +) from .mixins import AccessFormData from .utils import ( COMMUNITY_REVIEWER_GROUP_NAME, - LIMIT_TO_STAFF, - LIMIT_TO_REVIEWER_GROUPS, LIMIT_TO_PARTNERS, + LIMIT_TO_REVIEWER_GROUPS, + LIMIT_TO_STAFF, PARTNER_GROUP_NAME, REVIEW_GROUPS, REVIEWER_GROUP_NAME, STAFF_GROUP_NAME, WorkflowHelpers, ) -from ..blocks import ApplicationCustomFormFieldsBlock, NAMED_BLOCKS -from ..workflow import ( - active_statuses, - DETERMINATION_RESPONSE_PHASES, - get_review_active_statuses, - INITIAL_STATE, - PHASES, - review_statuses, - STAGE_CHANGE_ACTIONS, - UserPermissions, - WORKFLOWS, - COMMUNITY_REVIEW_PHASES, -) class JSONOrderable(models.QuerySet): diff --git a/opentech/apply/funds/models/utils.py b/opentech/apply/funds/models/utils.py index f6661614f..6f3e10bbe 100644 --- a/opentech/apply/funds/models/utils.py +++ b/opentech/apply/funds/models/utils.py @@ -1,6 +1,5 @@ from django.db import models from django.urls import reverse - from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -10,13 +9,17 @@ from wagtail.admin.edit_handlers import ( ) from wagtail.contrib.forms.models import AbstractEmailForm -from opentech.apply.activity.messaging import messenger, MESSAGES +from opentech.apply.activity.messaging import MESSAGES, messenger from opentech.apply.stream_forms.models import AbstractStreamForm -from opentech.apply.users.groups import REVIEWER_GROUP_NAME, STAFF_GROUP_NAME, PARTNER_GROUP_NAME, COMMUNITY_REVIEWER_GROUP_NAME +from opentech.apply.users.groups import ( + COMMUNITY_REVIEWER_GROUP_NAME, + PARTNER_GROUP_NAME, + REVIEWER_GROUP_NAME, + STAFF_GROUP_NAME, +) from ..workflow import WORKFLOWS - REVIEW_GROUPS = [ STAFF_GROUP_NAME, REVIEWER_GROUP_NAME, diff --git a/opentech/apply/funds/serializers.py b/opentech/apply/funds/serializers.py index 54478823b..6ad4c2132 100644 --- a/opentech/apply/funds/serializers.py +++ b/opentech/apply/funds/serializers.py @@ -1,7 +1,5 @@ import mistune - from django.contrib.auth import get_user_model - from django_bleach.templatetags.bleach_tags import bleach_value from rest_framework import serializers @@ -10,6 +8,7 @@ from opentech.apply.determinations.views import DeterminationCreateOrUpdateView from opentech.apply.review.models import Review, ReviewOpinion from opentech.apply.review.options import RECOMMENDATION_CHOICES from opentech.apply.users.groups import PARTNER_GROUP_NAME, STAFF_GROUP_NAME + from .models import ApplicationSubmission, RoundsAndLabs User = get_user_model() diff --git a/opentech/apply/funds/tables.py b/opentech/apply/funds/tables.py index f4a5c8a1f..e403067e2 100644 --- a/opentech/apply/funds/tables.py +++ b/opentech/apply/funds/tables.py @@ -1,17 +1,15 @@ import json import textwrap +import django_filters as filters +import django_tables2 as tables from django import forms from django.contrib.auth import get_user_model from django.db.models import F, Q from django.utils.html import format_html from django.utils.text import mark_safe, slugify from django.utils.translation import ugettext_lazy as _ - -import django_filters as filters -import django_tables2 as tables from django_tables2.utils import A - from wagtail.core.models import Page from opentech.apply.funds.models import ApplicationSubmission, Round, ScreeningStatus diff --git a/opentech/apply/funds/templatetags/markdown_tags.py b/opentech/apply/funds/templatetags/markdown_tags.py index bddae4d8a..e0f31f7b2 100644 --- a/opentech/apply/funds/templatetags/markdown_tags.py +++ b/opentech/apply/funds/templatetags/markdown_tags.py @@ -1,6 +1,5 @@ import mistune import tomd - from django import template register = template.Library() diff --git a/opentech/apply/funds/tests/factories/__init__.py b/opentech/apply/funds/tests/factories/__init__.py index c9d2b8eba..609b423ab 100644 --- a/opentech/apply/funds/tests/factories/__init__.py +++ b/opentech/apply/funds/tests/factories/__init__.py @@ -1,7 +1,6 @@ -from . import models -from .models import * # noqa -from . import blocks +from . import blocks, models from .blocks import * # noqa +from .models import * # noqa __all__ = [] diff --git a/opentech/apply/funds/tests/factories/blocks.py b/opentech/apply/funds/tests/factories/blocks.py index 7d05c2fdc..2e5782978 100644 --- a/opentech/apply/funds/tests/factories/blocks.py +++ b/opentech/apply/funds/tests/factories/blocks.py @@ -1,5 +1,6 @@ import json import random + import factory from opentech.apply.funds import blocks @@ -10,8 +11,8 @@ from opentech.apply.stream_forms.testing.factories import ( ImageFieldBlockFactory, MultiFileFieldBlockFactory, NumberFieldBlockFactory, - RadioFieldBlockFactory, ParagraphBlockFactory, + RadioFieldBlockFactory, StreamFieldUUIDFactory, ) from opentech.apply.utils.testing.factories import RichTextFieldBlockFactory diff --git a/opentech/apply/funds/tests/factories/models.py b/opentech/apply/funds/tests/factories/models.py index 5aca57fa6..6cf678297 100644 --- a/opentech/apply/funds/tests/factories/models.py +++ b/opentech/apply/funds/tests/factories/models.py @@ -4,8 +4,8 @@ import factory import wagtail_factories from opentech.apply.funds.models import ( - ApplicationSubmission, ApplicationRevision, + ApplicationSubmission, AssignedReviewers, FundType, LabType, @@ -16,9 +16,9 @@ from opentech.apply.funds.models import ( SealedRound, ) from opentech.apply.funds.models.forms import ( - ApplicationForm, ApplicationBaseForm, ApplicationBaseReviewForm, + ApplicationForm, LabBaseForm, LabBaseReviewForm, RoundBaseForm, @@ -27,12 +27,11 @@ from opentech.apply.funds.models.forms import ( from opentech.apply.funds.workflow import ConceptProposal, Request from opentech.apply.home.factories import ApplyHomePageFactory from opentech.apply.stream_forms.testing.factories import FormDataFactory -from opentech.apply.users.groups import STAFF_GROUP_NAME, REVIEWER_GROUP_NAME -from opentech.apply.users.tests.factories import StaffFactory, UserFactory, GroupFactory +from opentech.apply.users.groups import REVIEWER_GROUP_NAME, STAFF_GROUP_NAME +from opentech.apply.users.tests.factories import GroupFactory, StaffFactory, UserFactory from . import blocks - __all__ = [ 'FundTypeFactory', 'ApplicationBaseFormFactory', diff --git a/opentech/apply/funds/tests/models/test_roundsandlabs.py b/opentech/apply/funds/tests/models/test_roundsandlabs.py index a41aa0456..97045543d 100644 --- a/opentech/apply/funds/tests/models/test_roundsandlabs.py +++ b/opentech/apply/funds/tests/models/test_roundsandlabs.py @@ -1,7 +1,6 @@ from django.test import TestCase from opentech.apply.funds.models import RoundsAndLabs - from opentech.apply.funds.tests.factories import ( ApplicationSubmissionFactory, FundTypeFactory, diff --git a/opentech/apply/funds/tests/test_admin_form.py b/opentech/apply/funds/tests/test_admin_form.py index 93413519a..dad6c651d 100644 --- a/opentech/apply/funds/tests/test_admin_form.py +++ b/opentech/apply/funds/tests/test_admin_form.py @@ -1,11 +1,10 @@ -from django.test import TestCase - import factory +from django.test import TestCase from opentech.apply.funds.models import FundType +from opentech.apply.review.tests.factories import ReviewFormFactory from .factories import ApplicationFormFactory, FundTypeFactory, workflow_for_stages -from opentech.apply.review.tests.factories import ReviewFormFactory def formset_base(field, total, delete, factory, same=False): diff --git a/opentech/apply/funds/tests/test_admin_views.py b/opentech/apply/funds/tests/test_admin_views.py index 3469b0448..5d893f14a 100644 --- a/opentech/apply/funds/tests/test_admin_views.py +++ b/opentech/apply/funds/tests/test_admin_views.py @@ -1,8 +1,8 @@ from django.test import TestCase from django.urls import reverse -from opentech.apply.users.tests.factories import SuperUserFactory from opentech.apply.home.factories import ApplyHomePageFactory +from opentech.apply.users.tests.factories import SuperUserFactory from .test_admin_form import form_data diff --git a/opentech/apply/funds/tests/test_api_views.py b/opentech/apply/funds/tests/test_api_views.py index 4ef221274..ca93759e3 100644 --- a/opentech/apply/funds/tests/test_api_views.py +++ b/opentech/apply/funds/tests/test_api_views.py @@ -1,9 +1,8 @@ from django.test import TestCase, override_settings from django.urls import reverse_lazy -from opentech.apply.activity.models import Activity, PUBLIC, PRIVATE +from opentech.apply.activity.models import PRIVATE, PUBLIC, Activity from opentech.apply.activity.tests.factories import CommentFactory - from opentech.apply.users.tests.factories import UserFactory diff --git a/opentech/apply/funds/tests/test_forms.py b/opentech/apply/funds/tests/test_forms.py index 3525d19eb..02493a212 100644 --- a/opentech/apply/funds/tests/test_forms.py +++ b/opentech/apply/funds/tests/test_forms.py @@ -1,19 +1,15 @@ from django.test import TestCase + +from opentech.apply.funds.forms import UpdateReviewersForm from opentech.apply.funds.tests.factories import ( ApplicationSubmissionFactory, - AssignedWithRoleReviewersFactory, AssignedReviewersFactory, + AssignedWithRoleReviewersFactory, InvitedToProposalFactory, ReviewerRoleFactory, ) from opentech.apply.review.tests.factories import ReviewFactory -from opentech.apply.users.tests.factories import ( - ReviewerFactory, - StaffFactory, -) - - -from opentech.apply.funds.forms import UpdateReviewersForm +from opentech.apply.users.tests.factories import ReviewerFactory, StaffFactory class TestReviewerFormQueries(TestCase): diff --git a/opentech/apply/funds/tests/test_models.py b/opentech/apply/funds/tests/test_models.py index eaa22338c..d0df4a602 100644 --- a/opentech/apply/funds/tests/test_models.py +++ b/opentech/apply/funds/tests/test_models.py @@ -1,21 +1,21 @@ -from datetime import date, timedelta import itertools import os +from datetime import date, timedelta +from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import AnonymousUser -from django.conf import settings from django.core import mail from django.core.exceptions import ValidationError from django.test import TestCase, override_settings -from opentech.apply.funds.models import ApplicationSubmission from opentech.apply.funds.blocks import EmailBlock, FullNameBlock +from opentech.apply.funds.models import ApplicationSubmission from opentech.apply.funds.workflow import Request +from opentech.apply.review.options import MAYBE, NO from opentech.apply.review.tests.factories import ReviewFactory, ReviewOpinionFactory -from opentech.apply.review.options import NO, MAYBE -from opentech.apply.utils.testing import make_request from opentech.apply.users.tests.factories import StaffFactory +from opentech.apply.utils.testing import make_request from .factories import ( ApplicationSubmissionFactory, diff --git a/opentech/apply/funds/tests/test_tags.py b/opentech/apply/funds/tests/test_tags.py index ccbd84b93..cfc662c52 100644 --- a/opentech/apply/funds/tests/test_tags.py +++ b/opentech/apply/funds/tests/test_tags.py @@ -1,5 +1,5 @@ from django.template import Context, Template -from django.test import override_settings, TestCase +from django.test import TestCase, override_settings from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory diff --git a/opentech/apply/funds/tests/test_views.py b/opentech/apply/funds/tests/test_views.py index 3bd595dd2..ec583dad7 100644 --- a/opentech/apply/funds/tests/test_views.py +++ b/opentech/apply/funds/tests/test_views.py @@ -1,16 +1,16 @@ -from datetime import timedelta import json +from datetime import timedelta from django.utils import timezone from django.utils.text import slugify -from opentech.apply.activity.models import Activity, INTERNAL +from opentech.apply.activity.models import INTERNAL, Activity from opentech.apply.determinations.tests.factories import DeterminationFactory from opentech.apply.funds.tests.factories import ( - ApplicationSubmissionFactory, ApplicationRevisionFactory, - AssignedWithRoleReviewersFactory, + ApplicationSubmissionFactory, AssignedReviewersFactory, + AssignedWithRoleReviewersFactory, InvitedToProposalFactory, LabSubmissionFactory, ReviewerRoleFactory, diff --git a/opentech/apply/funds/tests/views/test_batch_progress.py b/opentech/apply/funds/tests/views/test_batch_progress.py index b7784f49f..54bd3b661 100644 --- a/opentech/apply/funds/tests/views/test_batch_progress.py +++ b/opentech/apply/funds/tests/views/test_batch_progress.py @@ -1,10 +1,7 @@ from unittest import mock +from opentech.apply.determinations.tests.factories import DeterminationFactory from opentech.apply.funds.models import ApplicationSubmission - -from opentech.apply.determinations.tests.factories import ( - DeterminationFactory -) from opentech.apply.funds.tests.factories import ( ApplicationSubmissionFactory, InvitedToProposalFactory, diff --git a/opentech/apply/funds/tests/views/test_batch_reviewers.py b/opentech/apply/funds/tests/views/test_batch_reviewers.py index f3d35b6a9..a87c68023 100644 --- a/opentech/apply/funds/tests/views/test_batch_reviewers.py +++ b/opentech/apply/funds/tests/views/test_batch_reviewers.py @@ -5,11 +5,8 @@ from opentech.apply.funds.tests.factories import ( AssignedWithRoleReviewersFactory, ReviewerRoleFactory, ) -from opentech.apply.users.tests.factories import ( - ReviewerFactory, - StaffFactory, -) from opentech.apply.review.tests.factories import ReviewFactory +from opentech.apply.users.tests.factories import ReviewerFactory, StaffFactory from opentech.apply.utils.testing.tests import BaseViewTestCase diff --git a/opentech/apply/funds/tests/views/test_rounds.py b/opentech/apply/funds/tests/views/test_rounds.py index 93b3bd710..ff0a37aea 100644 --- a/opentech/apply/funds/tests/views/test_rounds.py +++ b/opentech/apply/funds/tests/views/test_rounds.py @@ -1,8 +1,4 @@ -from opentech.apply.funds.tests.factories import ( - LabFactory, - RoundFactory, -) - +from opentech.apply.funds.tests.factories import LabFactory, RoundFactory from opentech.apply.users.tests.factories import ( ReviewerFactory, StaffFactory, diff --git a/opentech/apply/funds/urls.py b/opentech/apply/funds/urls.py index 386993422..84b9a3699 100644 --- a/opentech/apply/funds/urls.py +++ b/opentech/apply/funds/urls.py @@ -1,30 +1,29 @@ from django.urls import include, path +from .api_views import ( + CommentEdit, + CommentList, + CommentListCreate, + RoundLabDetail, + RoundLabList, + SubmissionAction, + SubmissionDetail, + SubmissionList, +) from .views import ( RevisionCompareView, RevisionListView, RoundListView, - SubmissionsByRound, - SubmissionsByStatus, + SubmissionDeleteView, SubmissionDetailView, SubmissionEditView, SubmissionListView, SubmissionOverviewView, - SubmissionSealedView, - SubmissionDeleteView, SubmissionPrivateMediaView, + SubmissionsByRound, + SubmissionsByStatus, + SubmissionSealedView, ) -from .api_views import ( - CommentEdit, - CommentList, - CommentListCreate, - RoundLabDetail, - RoundLabList, - SubmissionAction, - SubmissionList, - SubmissionDetail, -) - revision_urls = ([ path('', RevisionListView.as_view(), name='list'), diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 0b05d7548..1711a5ca1 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -3,66 +3,83 @@ from copy import copy from wsgiref.util import FileWrapper from django.conf import settings +from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.mixins import UserPassesTestMixin from django.contrib.auth.views import redirect_to_login -from django.contrib import messages from django.core.exceptions import PermissionDenied from django.core.files.storage import get_storage_class from django.db.models import Count, F, Q -from django.http import HttpResponseRedirect, Http404, StreamingHttpResponse +from django.http import Http404, HttpResponseRedirect, StreamingHttpResponse from django.shortcuts import get_object_or_404 from django.urls import reverse_lazy from django.utils.decorators import method_decorator from django.utils.text import mark_safe from django.utils.translation import ugettext_lazy as _ -from django.views.generic import DetailView, FormView, ListView, UpdateView, DeleteView, View - +from django.views.generic import ( + DeleteView, + DetailView, + FormView, + ListView, + UpdateView, + View, +) from django_filters.views import FilterView from django_tables2.views import SingleTableMixin - from wagtail.core.models import Page +from opentech.apply.activity.messaging import MESSAGES, messenger from opentech.apply.activity.views import ( - AllActivityContextMixin, ActivityContextMixin, + AllActivityContextMixin, CommentFormView, DelegatedViewMixin, ) -from opentech.apply.activity.messaging import messenger, MESSAGES -from opentech.apply.determinations.views import BatchDeterminationCreateView, DeterminationCreateOrUpdateView +from opentech.apply.determinations.views import ( + BatchDeterminationCreateView, + DeterminationCreateOrUpdateView, +) from opentech.apply.review.views import ReviewContextMixin from opentech.apply.users.decorators import staff_required -from opentech.apply.utils.views import DelegateableListView, DelegateableView, ViewDispatcher +from opentech.apply.utils.views import ( + DelegateableListView, + DelegateableView, + ViewDispatcher, +) from .differ import compare from .forms import ( - BatchUpdateReviewersForm, BatchProgressSubmissionForm, + BatchUpdateReviewersForm, ProgressSubmissionForm, ScreeningSubmissionForm, + UpdatePartnersForm, UpdateReviewersForm, UpdateSubmissionLeadForm, - UpdatePartnersForm, ) from .models import ( - ApplicationSubmission, ApplicationRevision, - RoundsAndLabs, + ApplicationSubmission, + LabBase, RoundBase, - LabBase + RoundsAndLabs, ) +from .permissions import is_user_has_access_to_view_submission from .tables import ( AdminSubmissionsTable, ReviewerSubmissionsTable, - RoundsTable, RoundsFilter, + RoundsTable, SubmissionFilterAndSearch, SubmissionReviewerFilterAndSearch, SummarySubmissionsTable, ) -from .workflow import INITIAL_STATE, STAGE_CHANGE_ACTIONS, PHASES_MAPPING, review_statuses -from .permissions import is_user_has_access_to_view_submission +from .workflow import ( + INITIAL_STATE, + PHASES_MAPPING, + STAGE_CHANGE_ACTIONS, + review_statuses, +) submission_storage = get_storage_class(getattr(settings, 'PRIVATE_FILE_STORAGE', None))() diff --git a/opentech/apply/funds/wagtail_hooks.py b/opentech/apply/funds/wagtail_hooks.py index c1e302ee6..3ccbcdea6 100644 --- a/opentech/apply/funds/wagtail_hooks.py +++ b/opentech/apply/funds/wagtail_hooks.py @@ -1,13 +1,11 @@ from django.contrib.auth.models import Permission - -from wagtail.core import hooks from wagtail.contrib.modeladmin.options import modeladmin_register +from wagtail.core import hooks from .admin import ApplyAdminGroup from .admin_views import custom_admin_round_copy_view from .models import RoundBase - modeladmin_register(ApplyAdminGroup) diff --git a/opentech/apply/funds/widgets.py b/opentech/apply/funds/widgets.py index d7ac9d879..236beaa6c 100644 --- a/opentech/apply/funds/widgets.py +++ b/opentech/apply/funds/widgets.py @@ -1,5 +1,4 @@ from django.contrib.staticfiles.templatetags.staticfiles import static - from django_select2.forms import Select2MultipleWidget diff --git a/opentech/apply/funds/workflow.py b/opentech/apply/funds/workflow.py index 883549229..0928477ef 100644 --- a/opentech/apply/funds/workflow.py +++ b/opentech/apply/funds/workflow.py @@ -1,9 +1,10 @@ +import itertools from collections import defaultdict from enum import Enum -import itertools from django.utils.text import slugify + """ This file defines classes which allow you to compose workflows based on the following structure: diff --git a/opentech/apply/home/models.py b/opentech/apply/home/models.py index 014137821..fc4338b62 100644 --- a/opentech/apply/home/models.py +++ b/opentech/apply/home/models.py @@ -1,12 +1,10 @@ from django.conf import settings from django.db import models from django.utils.decorators import method_decorator - from wagtail.admin.edit_handlers import FieldPanel from wagtail.core.models import Page from wagtail.search import index - -from wagtailcache.cache import cache_page, WagtailCacheMixin +from wagtailcache.cache import WagtailCacheMixin, cache_page from opentech.apply.funds.models import ApplicationBase, LabBase diff --git a/opentech/apply/review/admin.py b/opentech/apply/review/admin.py index 8986ee3df..ae6145abc 100644 --- a/opentech/apply/review/admin.py +++ b/opentech/apply/review/admin.py @@ -1,5 +1,4 @@ from django.conf.urls import url - from wagtail.contrib.modeladmin.options import ModelAdmin from wagtail.contrib.modeladmin.views import CreateView, InstanceSpecificView diff --git a/opentech/apply/review/blocks.py b/opentech/apply/review/blocks.py index 8bebb3711..c87f23df2 100644 --- a/opentech/apply/review/blocks.py +++ b/opentech/apply/review/blocks.py @@ -1,15 +1,27 @@ import json from django import forms - from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ - from wagtail.core.blocks import RichTextBlock from opentech.apply.review.fields import ScoredAnswerField -from opentech.apply.review.options import RECOMMENDATION_CHOICES, RATE_CHOICES_DICT, RATE_CHOICE_NA, NA, VISIBILITY, VISIBILILTY_HELP_TEXT, PRIVATE -from opentech.apply.stream_forms.blocks import OptionalFormFieldBlock, CharFieldBlock, TextFieldBlock, CheckboxFieldBlock, DropdownFieldBlock +from opentech.apply.review.options import ( + NA, + PRIVATE, + RATE_CHOICE_NA, + RATE_CHOICES_DICT, + RECOMMENDATION_CHOICES, + VISIBILILTY_HELP_TEXT, + VISIBILITY, +) +from opentech.apply.stream_forms.blocks import ( + CharFieldBlock, + CheckboxFieldBlock, + DropdownFieldBlock, + OptionalFormFieldBlock, + TextFieldBlock, +) from opentech.apply.utils.blocks import CustomFormFieldsBlock, MustIncludeFieldBlock from opentech.apply.utils.options import RICH_TEXT_WIDGET_SHORT diff --git a/opentech/apply/review/fields.py b/opentech/apply/review/fields.py index 169ca4bd9..1c3516073 100644 --- a/opentech/apply/review/fields.py +++ b/opentech/apply/review/fields.py @@ -1,10 +1,9 @@ from django import forms -from tinymce import TinyMCE - from django.forms import widgets from django.utils.safestring import mark_safe +from tinymce import TinyMCE -from opentech.apply.review.options import RATE_CHOICES, NA +from opentech.apply.review.options import NA, RATE_CHOICES from opentech.apply.utils.options import MCE_ATTRIBUTES_SHORT diff --git a/opentech/apply/review/management/commands/migrate_community_lab_reviews.py b/opentech/apply/review/management/commands/migrate_community_lab_reviews.py index b74793094..28272792f 100644 --- a/opentech/apply/review/management/commands/migrate_community_lab_reviews.py +++ b/opentech/apply/review/management/commands/migrate_community_lab_reviews.py @@ -1,4 +1,6 @@ -from opentech.apply.review.management.commands.migration_review_base import MigrateCommand +from opentech.apply.review.management.commands.migration_review_base import ( + MigrateCommand, +) class Command(MigrateCommand): diff --git a/opentech/apply/review/management/commands/migrate_concept_reviews.py b/opentech/apply/review/management/commands/migrate_concept_reviews.py index 8507acb75..e364c01d8 100644 --- a/opentech/apply/review/management/commands/migrate_concept_reviews.py +++ b/opentech/apply/review/management/commands/migrate_concept_reviews.py @@ -1,4 +1,6 @@ -from opentech.apply.review.management.commands.migration_review_base import MigrateCommand +from opentech.apply.review.management.commands.migration_review_base import ( + MigrateCommand, +) class Command(MigrateCommand): diff --git a/opentech/apply/review/management/commands/migrate_fellowship_application_reviews.py b/opentech/apply/review/management/commands/migrate_fellowship_application_reviews.py index e8c6716ee..6b5cb30a8 100644 --- a/opentech/apply/review/management/commands/migrate_fellowship_application_reviews.py +++ b/opentech/apply/review/management/commands/migrate_fellowship_application_reviews.py @@ -1,4 +1,6 @@ -from opentech.apply.review.management.commands.migration_review_base import MigrateCommand +from opentech.apply.review.management.commands.migration_review_base import ( + MigrateCommand, +) class Command(MigrateCommand): diff --git a/opentech/apply/review/management/commands/migrate_fellowship_proposal_reviews.py b/opentech/apply/review/management/commands/migrate_fellowship_proposal_reviews.py index d831822c5..4e52604a3 100644 --- a/opentech/apply/review/management/commands/migrate_fellowship_proposal_reviews.py +++ b/opentech/apply/review/management/commands/migrate_fellowship_proposal_reviews.py @@ -1,4 +1,6 @@ -from opentech.apply.review.management.commands.migration_review_base import MigrateCommand +from opentech.apply.review.management.commands.migration_review_base import ( + MigrateCommand, +) class Command(MigrateCommand): diff --git a/opentech/apply/review/management/commands/migrate_proposal_reviews.py b/opentech/apply/review/management/commands/migrate_proposal_reviews.py index e679c6856..6559fe706 100644 --- a/opentech/apply/review/management/commands/migrate_proposal_reviews.py +++ b/opentech/apply/review/management/commands/migrate_proposal_reviews.py @@ -1,4 +1,6 @@ -from opentech.apply.review.management.commands.migration_review_base import MigrateCommand +from opentech.apply.review.management.commands.migration_review_base import ( + MigrateCommand, +) class Command(MigrateCommand): diff --git a/opentech/apply/review/management/commands/migrate_rr_reviews.py b/opentech/apply/review/management/commands/migrate_rr_reviews.py index 6d9c3d3bb..8217be7b2 100644 --- a/opentech/apply/review/management/commands/migrate_rr_reviews.py +++ b/opentech/apply/review/management/commands/migrate_rr_reviews.py @@ -1,4 +1,6 @@ -from opentech.apply.review.management.commands.migration_review_base import MigrateCommand +from opentech.apply.review.management.commands.migration_review_base import ( + MigrateCommand, +) class Command(MigrateCommand): diff --git a/opentech/apply/review/management/commands/migration_review_base.py b/opentech/apply/review/management/commands/migration_review_base.py index 8cd7c9891..eb9065bb9 100644 --- a/opentech/apply/review/management/commands/migration_review_base.py +++ b/opentech/apply/review/management/commands/migration_review_base.py @@ -1,6 +1,5 @@ import argparse import json - from datetime import datetime, timezone from django.contrib.auth import get_user_model @@ -8,8 +7,8 @@ from django.core.management.base import BaseCommand from django.db import transaction from django.db.utils import IntegrityError -from opentech.apply.funds.models import ApplicationSubmission, Round, LabType -from opentech.apply.funds.models.forms import RoundBaseReviewForm, LabBaseReviewForm +from opentech.apply.funds.models import ApplicationSubmission, LabType, Round +from opentech.apply.funds.models.forms import LabBaseReviewForm, RoundBaseReviewForm from opentech.apply.review.models import Review from opentech.apply.review.options import NA diff --git a/opentech/apply/review/models.py b/opentech/apply/review/models.py index 740f9d847..a32d41d7d 100644 --- a/opentech/apply/review/models.py +++ b/opentech/apply/review/models.py @@ -9,16 +9,31 @@ from wagtail.core.fields import StreamField from opentech.apply.funds.models.mixins import AccessFormData from opentech.apply.stream_forms.models import BaseStreamForm -from opentech.apply.users.groups import STAFF_GROUP_NAME, REVIEWER_GROUP_NAME, PARTNER_GROUP_NAME +from opentech.apply.users.groups import ( + PARTNER_GROUP_NAME, + REVIEWER_GROUP_NAME, + STAFF_GROUP_NAME, +) from .blocks import ( - ReviewCustomFormFieldsBlock, RecommendationBlock, RecommendationCommentsBlock, + ReviewCustomFormFieldsBlock, ScoreFieldBlock, VisibilityBlock, ) -from .options import NA, YES, NO, MAYBE, RECOMMENDATION_CHOICES, DISAGREE, OPINION_CHOICES, VISIBILITY, PRIVATE, REVIEWER +from .options import ( + DISAGREE, + MAYBE, + NA, + NO, + OPINION_CHOICES, + PRIVATE, + RECOMMENDATION_CHOICES, + REVIEWER, + VISIBILITY, + YES, +) class ReviewFormFieldsMixin(models.Model): diff --git a/opentech/apply/review/tests/factories/__init__.py b/opentech/apply/review/tests/factories/__init__.py index c9d2b8eba..609b423ab 100644 --- a/opentech/apply/review/tests/factories/__init__.py +++ b/opentech/apply/review/tests/factories/__init__.py @@ -1,7 +1,6 @@ -from . import models -from .models import * # noqa -from . import blocks +from . import blocks, models from .blocks import * # noqa +from .models import * # noqa __all__ = [] diff --git a/opentech/apply/review/tests/factories/blocks.py b/opentech/apply/review/tests/factories/blocks.py index 23ce783dc..517d74b1b 100644 --- a/opentech/apply/review/tests/factories/blocks.py +++ b/opentech/apply/review/tests/factories/blocks.py @@ -1,11 +1,15 @@ import json import random + import factory from opentech.apply.review import blocks -from opentech.apply.review.options import YES, MAYBE, NO, PRIVATE, REVIEWER -from opentech.apply.stream_forms.testing.factories import FormFieldBlockFactory, CharFieldBlockFactory, \ - StreamFieldUUIDFactory +from opentech.apply.review.options import MAYBE, NO, PRIVATE, REVIEWER, YES +from opentech.apply.stream_forms.testing.factories import ( + CharFieldBlockFactory, + FormFieldBlockFactory, + StreamFieldUUIDFactory, +) from opentech.apply.utils.testing.factories import RichTextFieldBlockFactory __all__ = ['ReviewFormFieldsFactory', 'RecommendationBlockFactory', 'ScoreFieldBlockFactory'] diff --git a/opentech/apply/review/tests/factories/models.py b/opentech/apply/review/tests/factories/models.py index ee7077e60..5c1efb19a 100644 --- a/opentech/apply/review/tests/factories/models.py +++ b/opentech/apply/review/tests/factories/models.py @@ -1,11 +1,13 @@ import factory -from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory, AssignedReviewersFactory +from opentech.apply.funds.tests.factories import ( + ApplicationSubmissionFactory, + AssignedReviewersFactory, +) from opentech.apply.stream_forms.testing.factories import FormDataFactory -from ...options import YES, NO, MAYBE, AGREE, DISAGREE, PRIVATE, REVIEWER from ...models import Review, ReviewForm, ReviewOpinion - +from ...options import AGREE, DISAGREE, MAYBE, NO, PRIVATE, REVIEWER, YES from . import blocks __all__ = ['ReviewFactory', 'ReviewFormFactory', 'ReviewOpinionFactory'] diff --git a/opentech/apply/review/tests/test_admin.py b/opentech/apply/review/tests/test_admin.py index 3d4e56e0e..d053b4039 100644 --- a/opentech/apply/review/tests/test_admin.py +++ b/opentech/apply/review/tests/test_admin.py @@ -1,6 +1,7 @@ from unittest import TestCase from opentech.apply.review.models import ReviewForm + from .factories import ReviewFormFactory diff --git a/opentech/apply/review/tests/test_models.py b/opentech/apply/review/tests/test_models.py index 9f986ec10..3daa9a4eb 100644 --- a/opentech/apply/review/tests/test_models.py +++ b/opentech/apply/review/tests/test_models.py @@ -1,8 +1,9 @@ from django.test import TestCase from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory -from .factories import ReviewFactory, ReviewOpinionFactory + from ..options import MAYBE, NO, YES +from .factories import ReviewFactory, ReviewOpinionFactory class TestReviewQueryset(TestCase): diff --git a/opentech/apply/review/tests/test_views.py b/opentech/apply/review/tests/test_views.py index 7f4614e62..0d7aba292 100644 --- a/opentech/apply/review/tests/test_views.py +++ b/opentech/apply/review/tests/test_views.py @@ -2,12 +2,21 @@ from django.urls import reverse from opentech.apply.activity.models import Activity from opentech.apply.funds.tests.factories.models import ApplicationSubmissionFactory -from opentech.apply.users.tests.factories import ReviewerFactory, StaffFactory, UserFactory +from opentech.apply.users.tests.factories import ( + ReviewerFactory, + StaffFactory, + UserFactory, +) from opentech.apply.utils.testing.tests import BaseViewTestCase -from .factories import ReviewFactory, ReviewFormFieldsFactory, ReviewFormFactory, ReviewOpinionFactory from ..models import Review, ReviewOpinion -from ..options import NA, AGREE, DISAGREE +from ..options import AGREE, DISAGREE, NA +from .factories import ( + ReviewFactory, + ReviewFormFactory, + ReviewFormFieldsFactory, + ReviewOpinionFactory, +) class StaffReviewsTestCase(BaseViewTestCase): diff --git a/opentech/apply/review/urls.py b/opentech/apply/review/urls.py index 2d632fb1c..8a53ddadc 100644 --- a/opentech/apply/review/urls.py +++ b/opentech/apply/review/urls.py @@ -1,6 +1,11 @@ from django.urls import path -from .views import ReviewDetailView, ReviewListView, ReviewCreateOrUpdateView, ReviewDeleteView +from .views import ( + ReviewCreateOrUpdateView, + ReviewDeleteView, + ReviewDetailView, + ReviewListView, +) app_name = 'reviews' diff --git a/opentech/apply/review/views.py b/opentech/apply/review/views.py index 7b22550b1..9d800cf68 100644 --- a/opentech/apply/review/views.py +++ b/opentech/apply/review/views.py @@ -6,20 +6,22 @@ from django.shortcuts import get_object_or_404 from django.template.loader import get_template from django.urls import reverse_lazy from django.utils.decorators import method_decorator -from django.views.generic import CreateView, ListView, DetailView, DeleteView - +from django.views.generic import CreateView, DeleteView, DetailView, ListView from wagtail.core.blocks import RichTextBlock -from opentech.apply.activity.messaging import messenger, MESSAGES +from opentech.apply.activity.messaging import MESSAGES, messenger from opentech.apply.funds.models import ApplicationSubmission, AssignedReviewers from opentech.apply.funds.workflow import INITIAL_STATE -from opentech.apply.review.blocks import RecommendationBlock, RecommendationCommentsBlock +from opentech.apply.review.blocks import ( + RecommendationBlock, + RecommendationCommentsBlock, +) from opentech.apply.review.forms import ReviewModelForm, ReviewOpinionForm from opentech.apply.stream_forms.models import BaseStreamForm from opentech.apply.users.decorators import staff_required from opentech.apply.users.groups import REVIEWER_GROUP_NAME -from opentech.apply.utils.views import CreateOrUpdateView from opentech.apply.utils.image import generate_image_tag +from opentech.apply.utils.views import CreateOrUpdateView from .models import Review from .options import DISAGREE diff --git a/opentech/apply/review/wagtail_hooks.py b/opentech/apply/review/wagtail_hooks.py index 71f122fb7..64cad0a7f 100644 --- a/opentech/apply/review/wagtail_hooks.py +++ b/opentech/apply/review/wagtail_hooks.py @@ -1,5 +1,4 @@ from django.contrib.auth.models import Permission - from wagtail.core import hooks diff --git a/opentech/apply/stream_forms/blocks.py b/opentech/apply/stream_forms/blocks.py index 5a85ab8d8..a42565bfc 100644 --- a/opentech/apply/stream_forms/blocks.py +++ b/opentech/apply/stream_forms/blocks.py @@ -1,7 +1,5 @@ # Credit to https://github.com/BertrandBordage for initial implementation import bleach -from django_bleach.templatetags.bleach_tags import bleach_value - from django import forms from django.conf import settings from django.core.validators import FileExtensionValidator @@ -11,10 +9,21 @@ from django.utils.dateparse import parse_datetime from django.utils.encoding import force_text from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ +from django_bleach.templatetags.bleach_tags import bleach_value from unidecode import unidecode from wagtail.core.blocks import ( - StructBlock, TextBlock, CharBlock, BooleanBlock, ListBlock, StreamBlock, - DateBlock, TimeBlock, DateTimeBlock, ChoiceBlock, RichTextBlock, StaticBlock + BooleanBlock, + CharBlock, + ChoiceBlock, + DateBlock, + DateTimeBlock, + ListBlock, + RichTextBlock, + StaticBlock, + StreamBlock, + StructBlock, + TextBlock, + TimeBlock, ) from .fields import MultiFileField diff --git a/opentech/apply/stream_forms/fields.py b/opentech/apply/stream_forms/fields.py index c7a8deed5..607f77108 100644 --- a/opentech/apply/stream_forms/fields.py +++ b/opentech/apply/stream_forms/fields.py @@ -1,6 +1,6 @@ from django.conf import settings from django.core.validators import FileExtensionValidator -from django.forms import ClearableFileInput, FileField, CheckboxInput +from django.forms import CheckboxInput, ClearableFileInput, FileField class MultiFileInput(ClearableFileInput): diff --git a/opentech/apply/stream_forms/forms.py b/opentech/apply/stream_forms/forms.py index d4de59b9d..d503b3d70 100644 --- a/opentech/apply/stream_forms/forms.py +++ b/opentech/apply/stream_forms/forms.py @@ -1,6 +1,5 @@ from django import forms from django.forms.forms import DeclarativeFieldsMetaclass - from wagtail.contrib.forms.forms import BaseForm diff --git a/opentech/apply/stream_forms/testing/factories.py b/opentech/apply/stream_forms/testing/factories.py index f34216706..90eae4120 100644 --- a/opentech/apply/stream_forms/testing/factories.py +++ b/opentech/apply/stream_forms/testing/factories.py @@ -1,13 +1,12 @@ -from collections import defaultdict import json import uuid - -from django.core.files.uploadedfile import SimpleUploadedFile +from collections import defaultdict import factory +import wagtail_factories +from django.core.files.uploadedfile import SimpleUploadedFile from wagtail.core.blocks import RichTextBlock from wagtail.core.rich_text import RichText -import wagtail_factories from opentech.apply.stream_forms import blocks as stream_blocks diff --git a/opentech/apply/stream_forms/tests.py b/opentech/apply/stream_forms/tests.py index a8d37d02d..e1ed4ef6f 100644 --- a/opentech/apply/stream_forms/tests.py +++ b/opentech/apply/stream_forms/tests.py @@ -1,10 +1,9 @@ from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase - from faker import Faker -from .files import StreamFieldFile from .fields import MultiFileField, MultiFileInput +from .files import StreamFieldFile fake = Faker() diff --git a/opentech/apply/urls.py b/opentech/apply/urls.py index 6138117fa..044776c24 100644 --- a/opentech/apply/urls.py +++ b/opentech/apply/urls.py @@ -1,14 +1,12 @@ from django.conf import settings from django.urls import include, path - from two_factor.urls import urlpatterns as tf_urls -from .utils import views -from .users import urls as users_urls -from .dashboard import urls as dashboard_urls - from opentech.urls import base_urlpatterns +from .dashboard import urls as dashboard_urls +from .users import urls as users_urls +from .utils import views urlpatterns = [ path('apply/', include('opentech.apply.funds.urls', 'apply')), diff --git a/opentech/apply/users/admin_views.py b/opentech/apply/users/admin_views.py index b5a82dd75..b5f5fe8fd 100644 --- a/opentech/apply/users/admin_views.py +++ b/opentech/apply/users/admin_views.py @@ -3,7 +3,6 @@ from django.db.models import Q from django.shortcuts import render from django.utils.translation import ugettext as _ from django.views.decorators.vary import vary_on_headers - from wagtail.admin.forms import SearchForm from wagtail.admin.utils import any_permission_required from wagtail.core.compat import AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME diff --git a/opentech/apply/users/decorators.py b/opentech/apply/users/decorators.py index 26d4016f5..812c3d439 100644 --- a/opentech/apply/users/decorators.py +++ b/opentech/apply/users/decorators.py @@ -1,5 +1,5 @@ -from django.core.exceptions import PermissionDenied from django.contrib.auth.decorators import login_required, user_passes_test +from django.core.exceptions import PermissionDenied from .utils import can_use_oauth_check diff --git a/opentech/apply/users/forms.py b/opentech/apply/users/forms.py index d89f45a9c..7b74060d9 100644 --- a/opentech/apply/users/forms.py +++ b/opentech/apply/users/forms.py @@ -1,10 +1,8 @@ from django import forms from django.contrib.auth import get_user_model from django.utils.translation import gettext_lazy as _ - -from wagtail.users.forms import UserEditForm, UserCreationForm - from django_select2.forms import Select2Widget +from wagtail.users.forms import UserCreationForm, UserEditForm User = get_user_model() diff --git a/opentech/apply/users/middleware.py b/opentech/apply/users/middleware.py index 8affe31bc..4ebdf2d0e 100644 --- a/opentech/apply/users/middleware.py +++ b/opentech/apply/users/middleware.py @@ -1,5 +1,7 @@ from social_core.exceptions import AuthForbidden -from social_django.middleware import SocialAuthExceptionMiddleware as _SocialAuthExceptionMiddleware +from social_django.middleware import ( + SocialAuthExceptionMiddleware as _SocialAuthExceptionMiddleware, +) class SocialAuthExceptionMiddleware(_SocialAuthExceptionMiddleware): diff --git a/opentech/apply/users/models.py b/opentech/apply/users/models.py index 458f803ea..4953c3fcd 100644 --- a/opentech/apply/users/models.py +++ b/opentech/apply/users/models.py @@ -1,12 +1,17 @@ -from django.db import models -from django.db.models import Q from django.contrib.auth.hashers import make_password from django.contrib.auth.models import AbstractUser, BaseUserManager +from django.db import models +from django.db.models import Q from django.urls import reverse from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ -from .groups import REVIEWER_GROUP_NAME, STAFF_GROUP_NAME, PARTNER_GROUP_NAME, COMMUNITY_REVIEWER_GROUP_NAME +from .groups import ( + COMMUNITY_REVIEWER_GROUP_NAME, + PARTNER_GROUP_NAME, + REVIEWER_GROUP_NAME, + STAFF_GROUP_NAME, +) from .utils import send_activation_email diff --git a/opentech/apply/users/tests/factories.py b/opentech/apply/users/tests/factories.py index b111108c8..9f88fab96 100644 --- a/opentech/apply/users/tests/factories.py +++ b/opentech/apply/users/tests/factories.py @@ -1,8 +1,7 @@ +import factory from django.contrib.auth import get_user_model from django.contrib.auth.models import Group -import factory - from ..groups import REVIEWER_GROUP_NAME, STAFF_GROUP_NAME diff --git a/opentech/apply/users/tests/test_oauth_access.py b/opentech/apply/users/tests/test_oauth_access.py index 1cc2f13ab..62104cea8 100644 --- a/opentech/apply/users/tests/test_oauth_access.py +++ b/opentech/apply/users/tests/test_oauth_access.py @@ -1,5 +1,5 @@ -from django.contrib.auth import get_user_model from django.conf import settings +from django.contrib.auth import get_user_model from django.test import TestCase, override_settings from django.urls import reverse diff --git a/opentech/apply/users/tests/test_views.py b/opentech/apply/users/tests/test_views.py index 044a9566d..50fa3a82c 100644 --- a/opentech/apply/users/tests/test_views.py +++ b/opentech/apply/users/tests/test_views.py @@ -1,8 +1,9 @@ from django.core import mail -from django.test import override_settings, TestCase +from django.test import TestCase, override_settings from django.urls import reverse from opentech.apply.utils.testing.tests import BaseViewTestCase + from .factories import OAuthUserFactory, StaffFactory, UserFactory diff --git a/opentech/apply/users/urls.py b/opentech/apply/users/urls.py index 1d8d6f831..99073cf6c 100644 --- a/opentech/apply/users/urls.py +++ b/opentech/apply/users/urls.py @@ -1,9 +1,14 @@ -from django.urls import path, include from django.contrib.auth import views as auth_views -from django.urls import reverse_lazy - -from opentech.apply.users.views import LoginView, AccountView, become, oauth, ActivationView, create_password +from django.urls import include, path, reverse_lazy +from opentech.apply.users.views import ( + AccountView, + ActivationView, + LoginView, + become, + create_password, + oauth, +) app_name = 'users' diff --git a/opentech/apply/users/utils.py b/opentech/apply/users/utils.py index 74142ec71..38e2f6754 100644 --- a/opentech/apply/users/utils.py +++ b/opentech/apply/users/utils.py @@ -1,9 +1,9 @@ from django.conf import settings from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.template.loader import render_to_string +from django.urls import reverse from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode -from django.urls import reverse def can_use_oauth_check(user): diff --git a/opentech/apply/users/views.py b/opentech/apply/users/views.py index 86b54c1bd..7704f9269 100644 --- a/opentech/apply/users/views.py +++ b/opentech/apply/users/views.py @@ -17,16 +17,13 @@ from django.views.decorators.csrf import csrf_protect from django.views.decorators.debug import sensitive_post_parameters from django.views.generic import UpdateView from django.views.generic.base import TemplateView - from hijack.views import login_with_id from two_factor.views import LoginView as TwoFactorLoginView - from wagtail.admin.views.account import password_management_enabled from .decorators import require_oauth_whitelist from .forms import BecomeUserForm, ProfileForm - User = get_user_model() diff --git a/opentech/apply/users/wagtail_hooks.py b/opentech/apply/users/wagtail_hooks.py index dcd5276f5..b1e73a75d 100644 --- a/opentech/apply/users/wagtail_hooks.py +++ b/opentech/apply/users/wagtail_hooks.py @@ -1,5 +1,4 @@ from django.conf.urls import url - from wagtail.core import hooks from opentech.apply.utils.notifications import slack_notify diff --git a/opentech/apply/utils/blocks.py b/opentech/apply/utils/blocks.py index a4f9efb4d..f32a2835d 100644 --- a/opentech/apply/utils/blocks.py +++ b/opentech/apply/utils/blocks.py @@ -1,16 +1,18 @@ from collections import Counter -from pagedown.widgets import PagedownWidget import bleach - from django.core.exceptions import ValidationError from django.forms.utils import ErrorList -from django.utils.translation import ugettext_lazy as _ from django.utils.text import mark_safe +from django.utils.translation import ugettext_lazy as _ +from pagedown.widgets import PagedownWidget +from wagtail.core.blocks import StaticBlock, StreamBlock, StreamValue -from wagtail.core.blocks import StaticBlock, StreamValue, StreamBlock - -from opentech.apply.stream_forms.blocks import FormFieldBlock, OptionalFormFieldBlock, TextFieldBlock +from opentech.apply.stream_forms.blocks import ( + FormFieldBlock, + OptionalFormFieldBlock, + TextFieldBlock, +) from opentech.apply.utils.options import RICH_TEXT_WIDGET diff --git a/opentech/apply/utils/notifications.py b/opentech/apply/utils/notifications.py index bed3683da..11677be15 100644 --- a/opentech/apply/utils/notifications.py +++ b/opentech/apply/utils/notifications.py @@ -1,5 +1,4 @@ import requests - from django.conf import settings diff --git a/opentech/apply/utils/testing/__init__.py b/opentech/apply/utils/testing/__init__.py index 51bee7cf5..543930639 100644 --- a/opentech/apply/utils/testing/__init__.py +++ b/opentech/apply/utils/testing/__init__.py @@ -1 +1 @@ -from .tests import make_request, BaseViewTestCase # NOQA +from .tests import BaseViewTestCase, make_request # NOQA diff --git a/opentech/apply/utils/testing/tests.py b/opentech/apply/utils/testing/tests.py index bba277b3d..524bcaa25 100644 --- a/opentech/apply/utils/testing/tests.py +++ b/opentech/apply/utils/testing/tests.py @@ -1,9 +1,8 @@ -from django.contrib.messages.storage.fallback import FallbackStorage from django.contrib.auth.models import AnonymousUser -from django.test import override_settings, TestCase, RequestFactory +from django.contrib.messages.storage.fallback import FallbackStorage +from django.test import RequestFactory, TestCase, override_settings from django.urls import reverse - request_factory = RequestFactory() diff --git a/opentech/images/models.py b/opentech/images/models.py index dbc5e50c8..6ae7525cc 100644 --- a/opentech/images/models.py +++ b/opentech/images/models.py @@ -1,9 +1,5 @@ from django.db import models -from wagtail.images.models import ( - AbstractImage, - AbstractRendition, - Image, -) +from wagtail.images.models import AbstractImage, AbstractRendition, Image # We define our own custom image class to replace wagtailimages.Image, diff --git a/opentech/public/forms/models.py b/opentech/public/forms/models.py index bee7352c4..69c333b18 100644 --- a/opentech/public/forms/models.py +++ b/opentech/public/forms/models.py @@ -1,25 +1,28 @@ -import os import json +import os +from django.conf import settings from django.core.files.storage import get_storage_class from django.core.serializers.json import DjangoJSONEncoder -from django.conf import settings from django.db import models from django.forms import FileField from django.utils.decorators import method_decorator from django.utils.translation import ugettext_lazy as _ from django.views.decorators.cache import never_cache - from modelcluster.fields import ParentalKey - -from wagtail.core.fields import RichTextField from wagtail.admin.edit_handlers import ( - FieldPanel, FieldRowPanel, MultiFieldPanel, InlinePanel + FieldPanel, + FieldRowPanel, + InlinePanel, + MultiFieldPanel, ) from wagtail.contrib.forms.forms import FormBuilder from wagtail.contrib.forms.models import ( - AbstractEmailForm, AbstractFormField, FORM_FIELD_CHOICES + FORM_FIELD_CHOICES, + AbstractEmailForm, + AbstractFormField, ) +from wagtail.core.fields import RichTextField from wagtail.search import index from opentech.public.utils.models import BasePage diff --git a/opentech/public/forms/wagtail_hooks.py b/opentech/public/forms/wagtail_hooks.py index 7bb7907ed..6a6385235 100644 --- a/opentech/public/forms/wagtail_hooks.py +++ b/opentech/public/forms/wagtail_hooks.py @@ -1,5 +1,4 @@ from django.contrib.contenttypes.models import ContentType - from wagtail.core import hooks from opentech.public.forms.models import FormPage diff --git a/opentech/public/funds/models.py b/opentech/public/funds/models.py index ae23e2f48..c2d59ee81 100644 --- a/opentech/public/funds/models.py +++ b/opentech/public/funds/models.py @@ -1,13 +1,11 @@ from django.conf import settings +from django.core import validators from django.core.exceptions import ValidationError from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator -from django.core import validators from django.db import models from django.utils.deconstruct import deconstructible - from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -22,10 +20,7 @@ from wagtail.search import index from opentech.apply.funds.models import ApplicationSubmission from opentech.apply.funds.workflow import OPEN_CALL_PHASES -from opentech.public.utils.models import ( - BasePage, - RelatedPage, -) +from opentech.public.utils.models import BasePage, RelatedPage from .blocks import FundBlock, LabBlock diff --git a/opentech/public/home/blocks.py b/opentech/public/home/blocks.py index c7e9dddc9..50da83dcc 100644 --- a/opentech/public/home/blocks.py +++ b/opentech/public/home/blocks.py @@ -1,5 +1,4 @@ from wagtail.core import blocks - from wagtail.images.blocks import ImageChooserBlock diff --git a/opentech/public/home/models.py b/opentech/public/home/models.py index 25b5b404d..90be5e128 100644 --- a/opentech/public/home/models.py +++ b/opentech/public/home/models.py @@ -1,15 +1,19 @@ import datetime -from django.db import models +from django.db import models from modelcluster.fields import ParentalKey - -from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, PageChooserPanel, MultiFieldPanel, StreamFieldPanel +from wagtail.admin.edit_handlers import ( + FieldPanel, + InlinePanel, + MultiFieldPanel, + PageChooserPanel, + StreamFieldPanel, +) from wagtail.core.fields import StreamField from wagtail.search import index -from opentech.public.utils.models import BasePage, RelatedPage - from opentech.public.funds.models import FundPage, LabPage, RFPPage +from opentech.public.utils.models import BasePage, RelatedPage from .blocks import OurWorkBlock diff --git a/opentech/public/home/templatetags/home_tags.py b/opentech/public/home/templatetags/home_tags.py index 48902fb87..5e4e43869 100644 --- a/opentech/public/home/templatetags/home_tags.py +++ b/opentech/public/home/templatetags/home_tags.py @@ -1,7 +1,6 @@ from django import template from django.utils.safestring import mark_safe - register = template.Library() diff --git a/opentech/public/mailchimp/tests.py b/opentech/public/mailchimp/tests.py index 5dd089387..b70556922 100644 --- a/opentech/public/mailchimp/tests.py +++ b/opentech/public/mailchimp/tests.py @@ -1,12 +1,10 @@ -from urllib import parse -from unittest import mock import re - -from django.test import override_settings, TestCase -from django.urls import reverse +from unittest import mock +from urllib import parse import responses - +from django.test import TestCase, override_settings +from django.urls import reverse any_url = re.compile(".") diff --git a/opentech/public/mailchimp/urls.py b/opentech/public/mailchimp/urls.py index 4fe8fd700..f6500f540 100644 --- a/opentech/public/mailchimp/urls.py +++ b/opentech/public/mailchimp/urls.py @@ -2,7 +2,6 @@ from django.urls import path from .views import MailchimpSubscribeView - app_name = 'newsletter' diff --git a/opentech/public/mailchimp/views.py b/opentech/public/mailchimp/views.py index 0c1bdf805..596261a7a 100644 --- a/opentech/public/mailchimp/views.py +++ b/opentech/public/mailchimp/views.py @@ -1,5 +1,4 @@ import logging - import uuid from django.conf import settings @@ -10,7 +9,6 @@ from django.utils.translation import ugettext_lazy as _ from django.views.decorators.csrf import csrf_exempt from django.views.generic import RedirectView from django.views.generic.edit import FormMixin - from mailchimp3 import MailChimp from .forms import NewsletterForm diff --git a/opentech/public/navigation/models.py b/opentech/public/navigation/models.py index adce6c8af..8bdde4a92 100644 --- a/opentech/public/navigation/models.py +++ b/opentech/public/navigation/models.py @@ -1,6 +1,6 @@ from modelcluster.models import ClusterableModel -from wagtail.contrib.settings.models import BaseSetting, register_setting from wagtail.admin.edit_handlers import StreamFieldPanel +from wagtail.contrib.settings.models import BaseSetting, register_setting from wagtail.core import blocks from wagtail.core.fields import StreamField diff --git a/opentech/public/navigation/templatetags/navigation_tags.py b/opentech/public/navigation/templatetags/navigation_tags.py index 84ac38edd..089ae36f9 100644 --- a/opentech/public/navigation/templatetags/navigation_tags.py +++ b/opentech/public/navigation/templatetags/navigation_tags.py @@ -2,7 +2,6 @@ from django import template from opentech.public.navigation.models import NavigationSettings - register = template.Library() diff --git a/opentech/public/news/feeds.py b/opentech/public/news/feeds.py index b8cb442c8..e0d6bd378 100644 --- a/opentech/public/news/feeds.py +++ b/opentech/public/news/feeds.py @@ -3,10 +3,9 @@ from django.contrib.syndication.views import Feed from django.core.cache import cache from django.db.models.functions import Coalesce from django.http import Http404 - from wagtail.core.models import Site -from opentech.public.news.models import NewsPage, NewsType, NewsIndex, NewsFeedSettings +from opentech.public.news.models import NewsFeedSettings, NewsIndex, NewsPage, NewsType class NewsFeed(Feed): diff --git a/opentech/public/news/management/commands/migrate_news.py b/opentech/public/news/management/commands/migrate_news.py index c1d6357b7..fae187f68 100644 --- a/opentech/public/news/management/commands/migrate_news.py +++ b/opentech/public/news/management/commands/migrate_news.py @@ -1,28 +1,26 @@ import argparse import json - from datetime import datetime, timezone from django.core.management.base import BaseCommand from django.db import transaction from django.db.utils import IntegrityError - from wagtail.admin.rich_text.converters.editor_html import EditorHTMLConverter from wagtail.core.rich_text import RichText -from opentech.apply.categories.models import Category, Option from opentech.apply.categories.categories_seed import CATEGORIES +from opentech.apply.categories.models import Category, Option from opentech.apply.users.models import User -from opentech.public.people.models import PersonPage -from opentech.public.projects.models import ProjectPage from opentech.public.news.models import ( NewsIndex, NewsPage, NewsPageAuthor, - NewsType, NewsPageNewsType, NewsProjectRelatedPage, + NewsType, ) +from opentech.public.people.models import PersonPage +from opentech.public.projects.models import ProjectPage class Command(BaseCommand): diff --git a/opentech/public/news/models.py b/opentech/public/news/models.py index d25b7081a..72bab3f14 100644 --- a/opentech/public/news/models.py +++ b/opentech/public/news/models.py @@ -1,20 +1,18 @@ -from django.db import models -from django.db.models.functions import Coalesce from django.conf import settings from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator - +from django.db import models +from django.db.models.functions import Coalesce from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - -from wagtail.core.models import Orderable -from wagtail.core.fields import StreamField from wagtail.admin.edit_handlers import ( - InlinePanel, FieldPanel, + InlinePanel, PageChooserPanel, StreamFieldPanel, ) from wagtail.contrib.settings.models import BaseSetting, register_setting +from wagtail.core.fields import StreamField +from wagtail.core.models import Orderable from wagtail.search import index from opentech.public.utils.models import BasePage, RelatedPage diff --git a/opentech/public/people/management/commands/migrate_people.py b/opentech/public/people/management/commands/migrate_people.py index 105d37cb2..ae985771c 100644 --- a/opentech/public/people/management/commands/migrate_people.py +++ b/opentech/public/people/management/commands/migrate_people.py @@ -2,39 +2,35 @@ import argparse import itertools import json import mimetypes - from datetime import datetime, timezone -from urllib.parse import urlsplit from io import BytesIO - -import requests -from PIL import Image +from urllib.parse import urlsplit import bleach +import requests from django.core.files.images import ImageFile from django.core.management.base import BaseCommand from django.db import transaction from django.db.utils import IntegrityError - +from PIL import Image from wagtail.admin.rich_text.converters.editor_html import EditorHTMLConverter from wagtail.core.models import Page from wagtail.core.rich_text import RichText from wagtail.images import get_image_model -from opentech.apply.categories.models import Category, Option from opentech.apply.categories.categories_seed import CATEGORIES +from opentech.apply.categories.models import Category, Option from opentech.public.people.models import ( Funding, FundReviewers, PersonContactInfomation, - PersonPage, PersonIndexPage, - PersonType, + PersonPage, PersonPagePersonType, + PersonType, SocialMediaProfile, ) - WagtailImage = get_image_model() VALID_IMAGE_EXTENSIONS = [ diff --git a/opentech/public/people/models.py b/opentech/public/people/models.py index bb92bf204..f539405a4 100644 --- a/opentech/public/people/models.py +++ b/opentech/public/people/models.py @@ -1,26 +1,29 @@ -from django.db import models +from django.conf import settings from django.core.exceptions import ValidationError from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator -from django.conf import settings - +from django.db import models from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - -from wagtail.core.models import Orderable, PageManager, PageQuerySet -from wagtail.core.fields import StreamField from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel, PageChooserPanel, - StreamFieldPanel + StreamFieldPanel, ) +from wagtail.core.fields import StreamField +from wagtail.core.models import Orderable, PageManager, PageQuerySet from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.search import index from opentech.public.utils.blocks import StoryBlock -from opentech.public.utils.models import BasePage, BaseFunding, FundingMixin, RelatedPage +from opentech.public.utils.models import ( + BaseFunding, + BasePage, + FundingMixin, + RelatedPage, +) class SocialMediaProfile(models.Model): diff --git a/opentech/public/people/wagtail_hooks.py b/opentech/public/people/wagtail_hooks.py index ed2a0fce2..25fd275c3 100644 --- a/opentech/public/people/wagtail_hooks.py +++ b/opentech/public/people/wagtail_hooks.py @@ -1,6 +1,5 @@ from django.contrib.staticfiles.templatetags.staticfiles import static from django.utils.safestring import mark_safe - from wagtail.core import hooks diff --git a/opentech/public/projects/management/commands/migrate_projects.py b/opentech/public/projects/management/commands/migrate_projects.py index 3c91730ca..2ff5eaa32 100644 --- a/opentech/public/projects/management/commands/migrate_projects.py +++ b/opentech/public/projects/management/commands/migrate_projects.py @@ -2,27 +2,24 @@ import argparse import itertools import json import mimetypes - from datetime import datetime, timezone -from urllib.parse import urlsplit from io import BytesIO - -import requests -from PIL import Image +from urllib.parse import urlsplit import bleach +import requests from django.core.files.images import ImageFile from django.core.management.base import BaseCommand from django.db import transaction from django.db.utils import IntegrityError - +from PIL import Image from wagtail.admin.rich_text.converters.editor_html import EditorHTMLConverter from wagtail.core.models import Page from wagtail.core.rich_text import RichText from wagtail.images import get_image_model -from opentech.apply.categories.models import Category, Option from opentech.apply.categories.categories_seed import CATEGORIES +from opentech.apply.categories.models import Category, Option from opentech.public.projects.models import ( ProjectContactDetails, ProjectFunding, @@ -30,7 +27,6 @@ from opentech.public.projects.models import ( ProjectPage, ) - WagtailImage = get_image_model() VALID_IMAGE_EXTENSIONS = [ diff --git a/opentech/public/projects/models.py b/opentech/public/projects/models.py index 38e8828d7..6673f2d7a 100644 --- a/opentech/public/projects/models.py +++ b/opentech/public/projects/models.py @@ -1,14 +1,12 @@ import json -from django.db import models from django.conf import settings from django.core.exceptions import ValidationError from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.core.validators import URLValidator - +from django.db import models from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - from wagtail.admin.edit_handlers import ( FieldPanel, InlinePanel, @@ -16,7 +14,6 @@ from wagtail.admin.edit_handlers import ( PageChooserPanel, StreamFieldPanel, ) - from wagtail.core.fields import StreamField from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.search import index diff --git a/opentech/public/standardpages/models.py b/opentech/public/standardpages/models.py index 75fa8abf5..c7dec98db 100644 --- a/opentech/public/standardpages/models.py +++ b/opentech/public/standardpages/models.py @@ -1,23 +1,14 @@ -from django.db import models from django.conf import settings from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator - +from django.db import models from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - -from wagtail.admin.edit_handlers import ( - FieldPanel, StreamFieldPanel, - InlinePanel -) - +from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, StreamFieldPanel from wagtail.core.fields import StreamField from wagtail.search import index from opentech.public.utils.blocks import StoryBlock -from opentech.public.utils.models import ( - BasePage, - RelatedPage, -) +from opentech.public.utils.models import BasePage, RelatedPage class InformationPageRelatedPage(RelatedPage): diff --git a/opentech/public/urls.py b/opentech/public/urls.py index 7d27061f5..a1868e486 100644 --- a/opentech/public/urls.py +++ b/opentech/public/urls.py @@ -1,8 +1,8 @@ from django.urls import include, path -from .search import views as search_views from .mailchimp import urls as newsletter_urls from .news import feeds as news_feeds +from .search import views as search_views urlpatterns = [ path('search/', search_views.search, name='search'), diff --git a/opentech/public/utils/context_processors.py b/opentech/public/utils/context_processors.py index 149a40181..986525559 100644 --- a/opentech/public/utils/context_processors.py +++ b/opentech/public/utils/context_processors.py @@ -1,6 +1,5 @@ from opentech.apply.home.models import ApplyHomePage from opentech.public.home.models import HomePage - from opentech.public.mailchimp.forms import NewsletterForm diff --git a/opentech/public/utils/models.py b/opentech/public/utils/models.py index f78f7017c..b19c007a9 100644 --- a/opentech/public/utils/models.py +++ b/opentech/public/utils/models.py @@ -1,8 +1,7 @@ -from django.core.exceptions import ValidationError from django.conf import settings +from django.core.exceptions import ValidationError from django.db import models from django.utils.decorators import method_decorator - from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -11,14 +10,13 @@ from wagtail.admin.edit_handlers import ( PageChooserPanel, StreamFieldPanel, ) +from wagtail.contrib.settings.models import BaseSetting, register_setting from wagtail.core import blocks -from wagtail.core.fields import StreamField, RichTextField +from wagtail.core.fields import RichTextField, StreamField from wagtail.core.models import Orderable, Page from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.snippets.models import register_snippet -from wagtail.contrib.settings.models import BaseSetting, register_setting - -from wagtailcache.cache import cache_page, WagtailCacheMixin +from wagtailcache.cache import WagtailCacheMixin, cache_page class LinkFields(models.Model): diff --git a/opentech/public/utils/templatetags/util_tags.py b/opentech/public/utils/templatetags/util_tags.py index 8b419b5f4..e9923f6e4 100644 --- a/opentech/public/utils/templatetags/util_tags.py +++ b/opentech/public/utils/templatetags/util_tags.py @@ -1,10 +1,8 @@ from django import template - from wagtail.core.utils import camelcase_to_underscore from opentech.public.utils.models import SocialMediaSettings - register = template.Library() diff --git a/opentech/public/utils/wagtail_hooks.py b/opentech/public/utils/wagtail_hooks.py index 0efa847d6..a7041fe3f 100644 --- a/opentech/public/utils/wagtail_hooks.py +++ b/opentech/public/utils/wagtail_hooks.py @@ -1,8 +1,10 @@ from django.contrib.staticfiles.templatetags.staticfiles import static - -from wagtail.contrib.modeladmin.options import ModelAdminGroup, ModelAdmin, modeladmin_register +from wagtail.contrib.modeladmin.options import ( + ModelAdmin, + ModelAdminGroup, + modeladmin_register, +) from wagtail.core import hooks - from wagtailcache.cache import clear_cache from opentech.public.news.models import NewsType diff --git a/opentech/settings/base.py b/opentech/settings/base.py index edf98f4fb..1e74e1d3a 100644 --- a/opentech/settings/base.py +++ b/opentech/settings/base.py @@ -10,7 +10,6 @@ import dj_database_url import raven from raven.exceptions import InvalidGitRepository - env = os.environ.copy() PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/opentech/settings/test.py b/opentech/settings/test.py index 11a71f78e..c32b24e03 100644 --- a/opentech/settings/test.py +++ b/opentech/settings/test.py @@ -1,8 +1,9 @@ import logging +from .base import * # noqa + logging.disable(logging.CRITICAL) -from .base import * # noqa # Should only include explicit testing settings diff --git a/opentech/urls.py b/opentech/urls.py index 2aa4a198c..6d7124a6f 100644 --- a/opentech/urls.py +++ b/opentech/urls.py @@ -1,18 +1,17 @@ from django.conf import settings -from django.urls import include, path +from django.conf.urls import url from django.contrib import admin +from django.urls import include, path from django.views.generic import TemplateView -from django.conf.urls import url - -from wagtail.contrib.sitemaps.views import sitemap from wagtail.admin import urls as wagtailadmin_urls +from wagtail.contrib.sitemaps.views import sitemap from wagtail.core import urls as wagtail_urls from wagtail.documents import urls as wagtaildocs_urls from wagtail.images.views.serve import ServeView -from opentech.public import urls as public_urls from opentech.apply.users.urls import public_urlpatterns as user_urls from opentech.apply.users.views import LoginView +from opentech.public import urls as public_urls urlpatterns = [ path('django-admin/', admin.site.urls), -- GitLab