diff --git a/addressfield/fields.py b/addressfield/fields.py index 7692b9eb466616fc1bf94e1ee1ee077f6f4b8f1e..ee18e7ed906868502b58ef7b6e6fefb4c75c6f55 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 3b85a1f5ac725a5b86820a572fd787a6dedaa8d5..e8561b09e9f0c12ae9bed310e6a7db0fdbba8273 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 d3f51979c90c3759abb5faee72cc5063b4cdce4c..1acf1b685a17a4e154212b6bd3a5766c7b9cf48d 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 eacc4bfbde9664469434699c67ef262ac8762e47..0cde3d66617ec35c7a06aaadc1a2c12d13370fa2 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 7207068278ddd6893a3418d54dc87475f5318775..54f87191f6e7714c7e0dacc2529d74bf6053b286 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 d03da81e7c6619e060663d15fb97066784b05907..320020400e02f576c2de3f0c829f622fdcfaaee3 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 faaa386f36438b4c9f97e6975a153fb65f46c644..c072f00095ba4314fbd1d5d4c97b1575bf38fcff 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 089686efeeb4264c43c9e802eae6d69e720e480e..083981a839a917da4c57ba4f36159990469aeece 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 569c2775323dcce3630b021ab52e3d5280f62e8b..247c8ceda95de33fc5cd4d347528d1a1181f45fc 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 fb312efc0b9cd7bb634709535b9b320b45b09adb..90a3efa03a44b84f5df40e6d6148bed2b32137f1 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 78c1d19b6ba54a7c730f1b64b1b0a6f1e9ada01a..6ffc5a8ba970705f5dc58701dd083a0ebb303301 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 2230036f34e6a4796565d09f05f6e7cc52515d80..4331229a1ec12a185cb07b19af98590e4078334d 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 f468f396c0e0e2f0415359a9a912beecc5097b31..3efd91b032f6cc3cd26958f84886e52711426b80 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 cdad5c3af33c762c1c1758d709d10609ac7b4078..19c0855275d45f3e4ee2837471121ea044a2d764 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 25b216107e5528f0eaa36aaaad3f95c950b97b93..ed6998dfd5046a45dde90730a0883520fe89d487 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 9f786fced1de4030624668a1e96c39297d414ba2..c43d785eacabe11b36754c3cfb4d6ba1afeb8f7b 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 890bccbe451363c024e42286f885067a66515838..4c115e319414b4c9e4a34c26eb395d780e375fae 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 b8bf9a67c1180cd53a62490fae49aa46930fe6e9..26ef819791407fd2a48db841e26b8fce06048faf 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 86354570dffe2fa60c0c20338f593815f202ec8c..1317cf625fca95130ff977939395b52abd45f7b9 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 81ce64591b3e827bfe49197c62e2d7cb18f07824..eb3eab5062904abc50aa83b67e67a0818befe4f4 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 54aba6a63a4a97204163699093cb308ddfde4440..448fef5afbaecb0fb369fd8faf745df1c6064101 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 d8710de3c1d3730bf0ac5960335a8e549ba8e85f..1c906f43b08660fb471cab4ddb5ead6a499067ec 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 0056650ffb2f0e73f79aa623383f572b17d396ee..a9670feaf0ed3dbb996930ae3dad6bb35c367d62 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 89843e82ecd19e03272655582f5599b014b02753..aac0da2be79a212f8e43d3ad7648b9849a05d911 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 b6d2559b5ab956869eb18ba7bb29e43dcca7a22e..67804338665dba1044dd3f224841adeecf7ba0d6 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 ce73c9362be0977d6b0de20f4ddddf2f7163c41a..3c3243b7e1cad62ee8967da9ddc7a640606584ed 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 a43b335ec2e6e55d93eed052c9fa573d0f2af51f..344ba3ce7fb006b55ba91d613745f85431f0d500 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 2d985f2d6fd43b053289e394b17339c5ded16902..dd289f8896c24f448ef06c00482cbc5e61c97043 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 1862a147482ef8b25c1aed5d27afa23155ee0ba3..9c88ba4f12cbc9954dc084aa598b5707a226f3ea 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 f3e71f9993958c43c092ae6c0cf592eea53411fd..489a5a09c389c5b8c28c9bad13e73dba50e265a6 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 a5e65f32d0d16335708f4c0cd52d278dfaf6280a..baf5e7f4c8fd0e2c3ec0951005354521d24285ec 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 b3da7925fbff5995afb963a9ea316c7d95549922..a12c1c0fe58a61e5f016a2ed4d32d4f68c9230a9 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 75ce474fbf28c8f37df7de768e2654e78619aee8..d879c7b1a3640056f2c4d516f53bb2bc43898b48 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 d0a0cf1812ab5d1ac22cc674e2c489ffb4f6e1d9..9610cbbb4a6e0e01dfd32d3d6ac3948e75ddf8c1 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 1c2c1f3dd7eb81dfbcf9811c90ec006f1da7fb15..a768bf447f2fab31f326f9a401fc0dabeb8edbf9 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 bec9b723dbd973e0a47b979aa320d28387084fe9..f94447f783c35af69e20f9f4af2b28817a31bc8c 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 7573d9a830fc078c3de01dd5cc1cae62710d5391..67d172778c63b755aa6116aa18d071d79da53452 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 d7f7b78257aea95e0fc58673e7fec9ee9c601535..643ba8c203895600f6cd11d0c48049014fa01446 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 4057a2906143566e572b6e1acb8497137eb6d51b..7f68996840f890152cea392170aad35e82d10252 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 310140dbc180e0cd0864b11e819c2c72483e5a4c..ea6dfb09bc74bf4b8e3618a0cc9d78df32a37e59 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 732d98b32a6212fbba8dac74e3f19a70d8b4114d..8714a7c5cf65adfb8109fa904549eb385ba617e3 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 9cb8796873a50ffc17d3e7e0c6b332ee91a1c9ac..c923e9acf8aeab5e5b6144a6d46d240ebfac6a69 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 1a233415b89044e3fc4820e4cb5feecfc13cb82f..f263d01467a332a03c9e002bbb8ddf8eb329e64c 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 7cf40a7008248c48dcbd7f33c4b67777ed0abc85..3aa8045c998068914ebf676348bb4a71f201893e 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 4730a3a44167279ff536202439cdaa88cd6c12c0..9b9fb053cb7716418b4f0218e3f506e21bf46bb3 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 0fad33145e7f0a50ec9da415caf34dc325b20c18..b2097d043ca869033fab82c9add020bae394dd48 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 40bf70d7308353816a2ba3b97bde955f0a31ba99..856124eee2b4e9e664c134ac7f7b0ed45dccbb81 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 388e238497eb6676d2de8544ecb30afc65446590..cf6fd322841ef574a5f54661aacbced237a19ea2 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 cd1c4152330e07aa3e251b2500d0a6639e1feaf2..5e09d39383bd0bca2040f54f0242e114c3bb3520 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 f6661614fc08fdb6d955ab9bb6a1121f62c714ef..6f3e10bbe0df2066b9a034e4ba86e2b251863a4d 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 54478823b417cab8b1a3c054b7fac2f6a3d0a0a7..6ad4c2132940b18e6a04d30e351a61eb0351caaa 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 f4a5c8a1f9d1bf486b0441e3cbf4fe9c90fcb7a9..e403067e2a5e356195e0165e04d52938bcbb8cec 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 bddae4d8a14e7e8c522967c64fd4eafa261e78a7..e0f31f7b2b3c6c6352959a631cc1a9f8f87e35b2 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 c9d2b8ebadf12898359444c6059e84c4383a94cc..609b423ab4a0373180921e113b60b8a76aea4ed5 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 7d05c2fdc3e63f85e7e8c59187d7fc444038169a..2e57829784d28f391f83c13fdc09e8b6a5ac281f 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 5aca57fa69bc98e232e65ac850f3368579c60f1e..6cf678297ddf5a4165d71a47ca90e0b1a05fb300 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 a41aa04568fc2445992316eaaa4772f3220df3b8..97045543dc67af75582d768a481e3a6b6dbce6d2 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 93413519a472dc54e3a217bad6d76e9588e9c533..dad6c651dcde1e5f9a224f3fd204056caa5da5f7 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 3469b0448bbab7eb7bdf37c197628fa22d2ee2d4..5d893f14a1828d7cb455c9696a7f9706d86ffbdf 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 4ef221274adda7686e582b076aa72fea6eb686f8..ca93759e3c86668c3dd21fe07be956a94fed6b67 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 3525d19eb32abbf235846eb4e0033f4b2f2775cf..02493a2124e8938d3eaf9ab843cc12f4f28cd7bb 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 eaa22338c1c81d12aabff0d25395dc18916a5c1f..d0df4a602abbceee8a71687199ef461df0fd2215 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 ccbd84b93e06e44c3ea854da2fdad49ef6ff074e..cfc662c521267e8157372a69c0ffc91a1f3f7953 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 3bd595dd277c5deca0bf7e5dc896af7f54172f6e..ec583dad777d56e7c98bb039d5e3dca8dbd79b7e 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 b7784f49feb9729fbaacdd2a451184521f8d5005..54bd3b6612421922bca2fdab2c2c42b76544c449 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 f3d35b6a92cc0704dc9564a7c15e7504fe2338c9..a87c6802389c0794483f1d5a9d75e875f3c0d3ad 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 93b3bd7107be9653543ac74446b761de78d9bd14..ff0a37aeaa6435ecff0333f0a958760141be76be 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 386993422d70d095bd1c10dc336fd9c0616fdc74..84b9a3699e3498d0290bf3e872f08dc562ba418d 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 0b05d75483ffeb19edfad866c72088a80c657f07..1711a5ca143ca11b1655a1387db8835bae192964 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 c1e302ee6ee1937c11de18b2770d023cf8e4d7a1..3ccbcdea67ceb860603341527f7fb8f5da4d6dfc 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 d7ac9d879f2ea91801d78b718bd2e9874071f787..236beaa6c346126e856e36723cd0c1686ca3cf5b 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 8835492298d1a91258b437fb362612e77c1cfee8..0928477ef3953357f5197029b5e2efa02f385b66 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 014137821098120601481efcdf8f9b231803b63b..fc4338b622c8e87f74b9dfc2029c720b86479ccd 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 8986ee3dfee19e57b00136895c9aebcf49c68e10..ae6145abc7aec77380db0b7a074dcb0916cd472c 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 8bebb3711ade8b32c00bee6c2819cfbdd2418d0a..c87f23df2f1a7a9079a768fc2bb6e7db812ea953 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 169ca4bd95ea2a416d72f222c259194bb9e69022..1c3516073a01197a4657e957ecee7fab50002993 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 b74793094ca9e966e5f8d33aba847e9cac9869a6..28272792fc7a24d32244930dda8f6b07d3ccb4e8 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 8507acb751b5a0f16116d765370f7f2964e87aec..e364c01d8b799fef27ca7761c8985891bb08d04c 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 e8c6716ee57c47e3c1927f39f1023f70ea725abb..6b5cb30a83c2f9b31245ee7e7e18c0b9d8acc958 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 d831822c5c29bac069e1c212558ad05e3ef5a8ec..4e52604a383ac9768e64eaa9dee400f2bab2da5d 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 e679c68563b01eaf0fdeb28f1d071754d9eb86b5..6559fe70648b43e6297c641ec330d10fee6ec6fb 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 6d9c3d3bb36efb1aa3bd41279e1595e0afd11f33..8217be7b2137bdf61d9031af001c52865e29738b 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 8cd7c989108b0dce2f5aea76dc70cc62af69f62b..eb9065bb9462eb31edbc228d7b5bb1f2c1341392 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 740f9d847f5e36709d68d12f60966a41e9457376..a32d41d7dc3efa5bb0c66975e705ed1edf2e6a93 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 c9d2b8ebadf12898359444c6059e84c4383a94cc..609b423ab4a0373180921e113b60b8a76aea4ed5 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 23ce783dc3b683457666799745928082e7828dad..517d74b1b66697eaf95006fadd44d06caf597dd5 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 ee7077e60528ea187680fe3c8abcb475a64d9232..5c1efb19a247aaf634a64af2740aa498575b85eb 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 3d4e56e0e6e8d833561b8dd5d4fc86f63f18466c..d053b40391940ed43d0a03cdc56c2f6addbc1eb5 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 9f986ec10f3e78183b662ab2929af55d8a60b9a2..3daa9a4eb5babb1b2aeed6c937e7f806b8e0b8b9 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 7f4614e629916420299604df7885813e6a302073..0d7aba29250c93b0acdbb9f8f58a0abc56bff9ac 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 2d632fb1cddd25f1ee42b697acba11c72ffe2d67..8a53ddadcf227cf9ff7a2f2c70bd36eccfc23092 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 7b22550b16c81f0a9901b5f265bae3bfeb5ac861..9d800cf6870bd6ef58de084298f3a3040d5922f3 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 71f122fb74e779aa73c878ed427d79d88480aa36..64cad0a7fb44ac9ca409ed133b3a7b2d29707143 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 5a85ab8d8d0d30e03059c3a934de9298849333b2..a42565bfcb159de2865739754c23b18e6ce6b6d9 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 c7a8deed5921ec957558420f721f73f737fdcbef..607f77108b4d19f4cefdcbe83532aa45c4eb3cbc 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 d4de59b9d7284da9da2f4250531b2af8fc65dbbf..d503b3d70c2583a40aa70771fc5ea975d1aa89af 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 f3421670610081f668ae6adeb5b2929cb521468d..90eae4120e6ec069e77f913cd8cb19c0ae31376b 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 a8d37d02de09a7a503431f897d4c7299db54e86a..e1ed4ef6fba8638c18fe0a540db0b2bd1cfceffe 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 6138117fab04d25e24a59884ba270f81a3b7f2ec..044776c248698d237715d01ae1abb7cce8d96d53 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 b5a82dd75253da3efe067baf1649b2802779258c..b5f5fe8fd4c8e152895de101488d5db32ce59bd6 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 26d4016f57356e56ce077dfa4c40d012ee2ccef1..812c3d4391fd19f01ba067c421fe5f440368e288 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 d89f45a9c45d41e81acc16958517f0fa6354a88a..7b74060d9c68e0548d956dcbeedc0ce5c212b94a 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 8affe31bc4e52aaf652fc0901730d67a27d2c97e..4ebdf2d0e55453a10ffbe6b5069c04ec03f1d53a 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 458f803ea4cc510d50274daf45c33a7a85863e05..4953c3fcd41371310f48b721e6872492d3c330cb 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 b111108c871b44f89780a9472a3c68b3c3d2dedd..9f88fab964de364de9f94615a3df7f6876fe56ef 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 1cc2f13ab373fe94f72bb9e3b4d09a753bba97e8..62104cea816a8789ad6c57286172506aeaf21f8a 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 044a9566de15344b6d99487cfd18c2c462ac36d8..50fa3a82c9c4342bc86eef63a97ee9ed698c9324 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 1d8d6f8317a337e638b4337cb320fd392e4d251e..99073cf6ca54de19a0bfcf86d43df12dba26bdc8 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 74142ec7131ce70e93f66c2310e65259d3e43d7e..38e2f6754d5b1ecc73939cd6309e5c9d9ad0a533 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 86b54c1bd48823b171b537486f88b7ebbe5a4fe9..7704f92690054848018513baba6a4f640c5f734d 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 dcd5276f5f356dea951f5dfba794fb96dda19954..b1e73a75df11f287e46655da7044fcfdc1f06b57 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 a4f9efb4d179d27568c7467342c24eb7d0b43025..f32a2835d7dd97f436e6aefbe763dabaefaff324 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 bed3683da90108043926563a59f6c05e7d8f3178..11677be1520263cd1755e08bf8915d5b4e0fe790 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 51bee7cf554f86ae3460ee4e30dfa08ff549188c..543930639558bca50676ca3cd739729ff86f2e0a 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 bba277b3d117141767a458d942b252b9a2cd63b6..524bcaa256fc858e7b902d86a8b329d3441996b1 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 dbc5e50c8e9ccd64513b2a8190fd5a4a3554fdf9..6ae7525cc31db60d8da87d69d63b9453b59ddebf 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 bee7352c4805565b82b2193cdf43987aa87c8c69..69c333b1877e80a7059861d3aec492ef4ebf0fed 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 7bb7907eda7c3bbd5ff7c56afb3c2718ef5fc0b7..6a6385235af17fdc323d8962080122590c84dd76 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 ae23e2f4813a39fdd2c35a311d4853bcbf4e398d..c2d59ee81d62a274338a069ab98aa4352742dacf 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 c7e9dddc92acc55b013e2295a2ab4e9f29b24bb7..50da83dcc9ba616a7f7545bd84d5c46778cb5d6a 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 25b5b404d2f01c509b2d285a1638328845ca07b8..90be5e1286005e7237251892782756a6409dc9fb 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 48902fb8703286def7d60e618394e8f9f1d7af24..5e4e438690e9e520271d0c17e216cfb798d61880 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 5dd089387611991a1f8642eb17883523614e799f..b7055692269b1a9c6f38c38d49415135c9c3af0a 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 4fe8fd700905dce757a61635859439915c5eb90f..f6500f54045cc9e2c3b338a28f60c79d1f369f79 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 0c1bdf80585333d81864c7e9ae10b4a5f28f7678..596261a7ac2a7a8aa3cdbf03eef9c180712e2527 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 adce6c8af60137134d9b0072d09a82a1c68004e3..8bdde4a92c384cced4832806b993a6c84fb1c4a6 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 84ac38eddfe2816b4808fd7602d0449130d05d79..089ae36f909ede5109c804fc39ecdf1395165492 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 b8cb442c8123fec60dcce7e872ed48662211fd31..e0d6bd37807e68e226dea30bc59eec8bf07d64c2 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 c1d6357b77f0619f4636d48797776b5d113f0761..fae187f68208eaf3672f9b9c4826ae5a0769055f 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 d25b7081aa73cad19232191d4c6be8aa87e4f9b2..72bab3f145918f8f506ed2775042465222d04fd1 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 105d37cb220fd068c949c4802c29c9e27bcaa85d..ae985771c67b01ce932550b19c9e3b94ba4f6289 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 bb92bf204bfcb173d7521ec32a92b0ed25a8e4b5..f539405a45423d319be0c01dcf6f7e5a3109e061 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 ed2a0fce2c6dd8432105e3337c051a0d28635533..25fd275c3eab6bf9bcce3c8a2dbc8a703740e831 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 3c91730ca7acd3d86042620ccca29cde270c0f00..2ff5eaa320cf92e48b9a3b64010d5f3d8b66e532 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 38e8828d7994c281928663f6032bda8183524f7e..6673f2d7a5f0702b785422313397f94985bca56d 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 75fa8abf5aeab58a6640becb9f638d176e7d2b00..c7dec98db17555b59c423694d3b35d19d60cc425 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 7d27061f5c0ebd716c7eaeb69a0377029c62e9f3..a1868e486fe4e5b2079e4c954b1589e7f77da439 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 149a40181ae1a97390338f32baa92c4c174ed096..986525559778e649fd2815309076058f5ad4ac1c 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 f78f7017c8e9e939a3aa8cb33acd31f7d1e05b14..b19c007a9793ac6f4cf7d9ad463c41d20f546d91 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 8b419b5f4d5fd440432b1b48bc0a59c4bfb23650..e9923f6e4197f371b31ec75df806321b49924ba9 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 0efa847d6ceabae61810a0538d81d6e707e644f1..a7041fe3f9d64a732e259acfe886ad9c7410363f 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 edf98f4fbc862bef0c067a60687a080146707255..1e74e1d3adec14ec85808ca52d7fd84925283113 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 11a71f78e5248d8568b15eaf0f8d0ca00ff70acd..c32b24e03fd81a0adc803ff6698bc526717fc753 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 2aa4a198c885865d2e0d283fcb36893c4410586c..6d7124a6fbddbf9f15d1275b46571eae0c45aa3f 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),