diff --git a/.circleci/config.yml b/.circleci/config.yml index 84b52c1570cc427f47f2fa085238b33f6165c69b..5d1ba29917f4ab96e42e18e0a1bb8b3e8bcf83cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -75,7 +75,6 @@ jobs: command: | . venv/bin/activate flake8 ./opentech - make sort python manage.py collectstatic --noinput --verbosity=0 python manage.py check python manage.py makemigrations --check --noinput --verbosity=1 diff --git a/.isort.cfg b/.isort.cfg index e894dedfa057d1e49a10b8cc3aa835b38575b3f8..fb797cbc35eaa99307f786244258d8b05d891108 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,9 +1,3 @@ [settings] -default_section=FIRSTPARTY -force_grid_wrap=0 -include_trailing_comma=True known_first_party=esi, home, images, navigation, search, settings, standardpages, urls, utils, wsgi -line_length=88 -multi_line_output=3 -skip_glob = .direnv,node_modules,venv,**/migrations/** -use_parentheses=True +default_section=FIRSTPARTY diff --git a/.travis.yml b/.travis.yml index 1f81e3d394d4d1eae5273275ac9d84390aea37ae..3a9983e245c3b1b21cb284eeedf40771ddd90916 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,9 +50,6 @@ script: # Run python code style checks - flake8 ./opentech - # Check import sort order of Python files - - make sort - # Collect static - python manage.py collectstatic --noinput --verbosity=0 diff --git a/Makefile b/Makefile deleted file mode 100644 index c20c39c8bcc01e10fb48fb9c0a322b9258b9fca3..0000000000000000000000000000000000000000 --- a/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.PHONY: -help: - @echo "Usage:" - @echo " make help prints this help." - @echo " make fix fix import sort order." - @echo " make sort run the linter." - -.PHONY: fix -fix: - isort -y - -.PHONY: sort -sort: - @echo "Running Isort" && isort --check-only --diff || exit 1 diff --git a/addressfield/fields.py b/addressfield/fields.py index ee18e7ed906868502b58ef7b6e6fefb4c75c6f55..7692b9eb466616fc1bf94e1ee1ee077f6f4b8f1e 100644 --- a/addressfield/fields.py +++ b/addressfield/fields.py @@ -6,6 +6,7 @@ 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 e8561b09e9f0c12ae9bed310e6a7db0fdbba8273..3b85a1f5ac725a5b86820a572fd787a6dedaa8d5 100644 --- a/addressfield/widgets.py +++ b/addressfield/widgets.py @@ -1,4 +1,5 @@ from django import forms + from django_countries import countries from django_select2.forms import Select2Widget diff --git a/fabfile.py b/fabfile.py index 1acf1b685a17a4e154212b6bd3a5766c7b9cf48d..d3f51979c90c3759abb5faee72cc5063b4cdce4c 100644 --- a/fabfile.py +++ b/fabfile.py @@ -1,6 +1,7 @@ from datetime import datetime -from fabric.api import env, get, lcd, local, prompt, roles, run, runs_once +from fabric.api import lcd, roles, runs_once, run, local, env, prompt, get + env.roledefs = { 'production': [], diff --git a/opentech/apply/activity/admin.py b/opentech/apply/activity/admin.py index 0cde3d66617ec35c7a06aaadc1a2c12d13370fa2..eacc4bfbde9664469434699c67ef262ac8762e47 100644 --- a/opentech/apply/activity/admin.py +++ b/opentech/apply/activity/admin.py @@ -1,5 +1,4 @@ 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 54f87191f6e7714c7e0dacc2529d74bf6053b286..7207068278ddd6893a3418d54dc87475f5318775 100644 --- a/opentech/apply/activity/forms.py +++ b/opentech/apply/activity/forms.py @@ -1,9 +1,10 @@ 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 VISIBILILTY_HELP_TEXT, VISIBILITY, Activity +from .models import Activity, VISIBILILTY_HELP_TEXT, VISIBILITY 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 320020400e02f576c2de3f0c829f622fdcfaaee3..d03da81e7c6619e060663d15fb97066784b05907 100644 --- a/opentech/apply/activity/management/commands/migrate_comments.py +++ b/opentech/apply/activity/management/commands/migrate_comments.py @@ -1,5 +1,6 @@ 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 c072f00095ba4314fbd1d5d4c97b1575bf38fcff..faaa386f36438b4c9f97e6975a153fb65f46c644 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 -import requests +from django.db import models 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,6 +15,7 @@ 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 083981a839a917da4c57ba4f36159990469aeece..089686efeeb4264c43c9e802eae6d69e720e480e 100644 --- a/opentech/apply/activity/models.py +++ b/opentech/apply/activity/models.py @@ -2,11 +2,12 @@ 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, Value, When +from django.db.models import Case, When, Value 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 247c8ceda95de33fc5cd4d347528d1a1181f45fc..569c2775323dcce3630b021ab52e3d5280f62e8b 100644 --- a/opentech/apply/activity/tasks.py +++ b/opentech/apply/activity/tasks.py @@ -1,4 +1,5 @@ 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 90a3efa03a44b84f5df40e6d6148bed2b32137f1..fb312efc0b9cd7bb634709535b9b320b45b09adb 100644 --- a/opentech/apply/activity/tests/factories.py +++ b/opentech/apply/activity/tests/factories.py @@ -3,14 +3,7 @@ import uuid import factory from django.utils import timezone -from opentech.apply.activity.models import ( - INTERNAL, - MESSAGES, - REVIEWER, - Activity, - Event, - Message, -) +from opentech.apply.activity.models import Activity, Event, INTERNAL, Message, MESSAGES, REVIEWER 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 6ffc5a8ba970705f5dc58701dd083a0ebb303301..78c1d19b6ba54a7c730f1b64b1b0a6f1e9ada01a 100644 --- a/opentech/apply/activity/tests/test_messaging.py +++ b/opentech/apply/activity/tests/test_messaging.py @@ -4,10 +4,12 @@ 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, @@ -15,18 +17,17 @@ 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 ( - MESSAGES, - ActivityAdapter, AdapterBase, + ActivityAdapter, EmailAdapter, MessengerBackend, - SlackAdapter, neat_related, + MESSAGES, + SlackAdapter, ) -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 4331229a1ec12a185cb07b19af98590e4078334d..2230036f34e6a4796565d09f05f6e7cc52515d80 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 ..models import Activity from .factories import CommentFactory +from ..models import Activity class TestActivityOnlyIncludesCurrent(TestCase): diff --git a/opentech/apply/activity/tests/test_tasks.py b/opentech/apply/activity/tests/test_tasks.py index 3efd91b032f6cc3cd26958f84886e52711426b80..f468f396c0e0e2f0415359a9a912beecc5097b31 100644 --- a/opentech/apply/activity/tests/test_tasks.py +++ b/opentech/apply/activity/tests/test_tasks.py @@ -3,6 +3,7 @@ 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 19c0855275d45f3e4ee2837471121ea044a2d764..cdad5c3af33c762c1c1758d709d10609ac7b4078 100644 --- a/opentech/apply/activity/urls.py +++ b/opentech/apply/activity/urls.py @@ -1,5 +1,6 @@ from django.urls import include, path + app_name = 'activity' diff --git a/opentech/apply/activity/views.py b/opentech/apply/activity/views.py index ed6998dfd5046a45dde90730a0883520fe89d487..25b216107e5528f0eaa36aaaad3f95c950b97b93 100644 --- a/opentech/apply/activity/views.py +++ b/opentech/apply/activity/views.py @@ -1,11 +1,12 @@ -from django.utils import timezone from django.views.generic import CreateView +from django.utils import timezone from opentech.apply.utils.views import DelegatedViewMixin from .forms import CommentForm -from .messaging import MESSAGES, messenger -from .models import COMMENT, Activity +from .messaging import messenger, MESSAGES +from .models import Activity, COMMENT + ACTIVITY_LIMIT = 50 diff --git a/opentech/apply/categories/admin_helpers.py b/opentech/apply/categories/admin_helpers.py index c43d785eacabe11b36754c3cfb4d6ba1afeb8f7b..9f786fced1de4030624668a1e96c39297d414ba2 100644 --- a/opentech/apply/categories/admin_helpers.py +++ b/opentech/apply/categories/admin_helpers.py @@ -1,4 +1,5 @@ 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 4c115e319414b4c9e4a34c26eb395d780e375fae..890bccbe451363c024e42286f885067a66515838 100644 --- a/opentech/apply/categories/admin_views.py +++ b/opentech/apply/categories/admin_views.py @@ -1,5 +1,6 @@ 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 26ef819791407fd2a48db841e26b8fce06048faf..b8bf9a67c1180cd53a62490fae49aa46930fe6e9 100644 --- a/opentech/apply/categories/blocks.py +++ b/opentech/apply/categories/blocks.py @@ -1,11 +1,12 @@ 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 1317cf625fca95130ff977939395b52abd45f7b9..86354570dffe2fa60c0c20338f593815f202ec8c 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.categories_seed import CATEGORIES from opentech.apply.categories.models import Category, Option +from opentech.apply.categories.categories_seed import CATEGORIES class Command(BaseCommand): diff --git a/opentech/apply/categories/models.py b/opentech/apply/categories/models.py index eb3eab5062904abc50aa83b67e67a0818befe4f4..81ce64591b3e827bfe49197c62e2d7cb18f07824 100644 --- a/opentech/apply/categories/models.py +++ b/opentech/apply/categories/models.py @@ -2,14 +2,19 @@ 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 treebeard.mp_tree import MP_Node -from wagtail.admin.edit_handlers import FieldPanel, InlinePanel +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 448fef5afbaecb0fb369fd8faf745df1c6064101..54aba6a63a4a97204163699093cb308ddfde4440 100644 --- a/opentech/apply/dashboard/tests/test_views.py +++ b/opentech/apply/dashboard/tests/test_views.py @@ -1,14 +1,10 @@ from opentech.apply.funds.tests.factories import ( - ApplicationRevisionFactory, ApplicationSubmissionFactory, + ApplicationRevisionFactory, InvitedToProposalFactory, ) from opentech.apply.review.tests.factories import ReviewFactory, ReviewOpinionFactory -from opentech.apply.users.tests.factories import ( - ReviewerFactory, - StaffFactory, - UserFactory, -) +from opentech.apply.users.tests.factories import UserFactory, ReviewerFactory, StaffFactory from opentech.apply.utils.testing.tests import BaseViewTestCase diff --git a/opentech/apply/dashboard/urls.py b/opentech/apply/dashboard/urls.py index 1c906f43b08660fb471cab4ddb5ead6a499067ec..d8710de3c1d3730bf0ac5960335a8e549ba8e85f 100644 --- a/opentech/apply/dashboard/urls.py +++ b/opentech/apply/dashboard/urls.py @@ -2,6 +2,7 @@ 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 a9670feaf0ed3dbb996930ae3dad6bb35c367d62..0056650ffb2f0e73f79aa623383f572b17d396ee 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.urls import reverse_lazy from django.views.generic import TemplateView +from django.urls import reverse_lazy 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 aac0da2be79a212f8e43d3ad7648b9849a05d911..89843e82ecd19e03272655582f5599b014b02753 100644 --- a/opentech/apply/dashboard/wagtail_hooks.py +++ b/opentech/apply/dashboard/wagtail_hooks.py @@ -1,8 +1,9 @@ from urllib.parse import urljoin from django.urls import reverse -from wagtail.admin.menu import MenuItem + from wagtail.core import hooks +from wagtail.admin.menu import MenuItem from opentech.apply.home.models import ApplyHomePage diff --git a/opentech/apply/determinations/forms.py b/opentech/apply/determinations/forms.py index 67804338665dba1044dd3f224841adeecf7ba0d6..b6d2559b5ab956869eb18ba7bb29e43dcca7a22e 100644 --- a/opentech/apply/determinations/forms.py +++ b/opentech/apply/determinations/forms.py @@ -2,10 +2,14 @@ from django import forms from django.contrib.auth import get_user_model from django.core.exceptions import NON_FIELD_ERRORS -from opentech.apply.funds.models import ApplicationSubmission from opentech.apply.utils.options import RICH_TEXT_WIDGET +from opentech.apply.funds.models import ApplicationSubmission -from .models import DETERMINATION_CHOICES, TRANSITION_DETERMINATION, Determination +from .models import ( + Determination, + DETERMINATION_CHOICES, + TRANSITION_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 3c3243b7e1cad62ee8967da9ddc7a640606584ed..ce73c9362be0977d6b0de20f4ddddf2f7163c41a 100644 --- a/opentech/apply/determinations/management/commands/migrate_concept_determinations.py +++ b/opentech/apply/determinations/management/commands/migrate_concept_determinations.py @@ -1,5 +1,6 @@ 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 344ba3ce7fb006b55ba91d613745f85431f0d500..a43b335ec2e6e55d93eed052c9fa573d0f2af51f 100644 --- a/opentech/apply/determinations/management/commands/migrate_proposal_determinations.py +++ b/opentech/apply/determinations/management/commands/migrate_proposal_determinations.py @@ -1,5 +1,6 @@ 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 dd289f8896c24f448ef06c00482cbc5e61c97043..2d985f2d6fd43b053289e394b17339c5ded16902 100644 --- a/opentech/apply/determinations/models.py +++ b/opentech/apply/determinations/models.py @@ -4,13 +4,14 @@ 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 FieldPanel, ObjectList, TabbedInterface +from wagtail.admin.edit_handlers import TabbedInterface, ObjectList, FieldPanel 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 9c88ba4f12cbc9954dc084aa598b5707a226f3ea..1862a147482ef8b25c1aed5d27afa23155ee0ba3 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 ACCEPTED, NEEDS_MORE_INFO, REJECTED, Determination +from ..models import Determination, ACCEPTED, NEEDS_MORE_INFO, REJECTED 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 489a5a09c389c5b8c28c9bad13e73dba50e265a6..f3e71f9993958c43c092ae6c0cf592eea53411fd 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 baf5e7f4c8fd0e2c3ec0951005354521d24285ec..a5e65f32d0d16335708f4c0cd52d278dfaf6280a 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 CreateView, DetailView +from django.views.generic import DetailView, CreateView -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.users.decorators import staff_required from opentech.apply.utils.views import CreateOrUpdateView, ViewDispatcher +from opentech.apply.users.decorators import staff_required from .forms import ( BatchConceptDeterminationForm, @@ -24,12 +24,8 @@ from .forms import ( ConceptDeterminationForm, ProposalDeterminationForm, ) -from .models import ( - NEEDS_MORE_INFO, - TRANSITION_DETERMINATION, - Determination, - DeterminationMessageSettings, -) +from .models import Determination, DeterminationMessageSettings, NEEDS_MORE_INFO, TRANSITION_DETERMINATION + from .utils import ( can_create_determination, can_edit_determination, diff --git a/opentech/apply/funds/admin.py b/opentech/apply/funds/admin.py index a12c1c0fe58a61e5f016a2ed4d32d4f68c9230a9..b3da7925fbff5995afb963a9ea316c7d95549922 100644 --- a/opentech/apply/funds/admin.py +++ b/opentech/apply/funds/admin.py @@ -1,24 +1,16 @@ 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 .models import ApplicationForm, FundType, LabType, RequestForPartners, Round, SealedRound +from opentech.apply.categories.admin import CategoryAdmin, MetaCategoryAdmin class BaseRoundAdmin(ModelAdmin): diff --git a/opentech/apply/funds/admin_helpers.py b/opentech/apply/funds/admin_helpers.py index d879c7b1a3640056f2c4d516f53bb2bc43898b48..75ce474fbf28c8f37df7de768e2654e78619aee8 100644 --- a/opentech/apply/funds/admin_helpers.py +++ b/opentech/apply/funds/admin_helpers.py @@ -2,6 +2,7 @@ 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 9610cbbb4a6e0e01dfd32d3d6ac3948e75ddf8c1..d0a0cf1812ab5d1ac22cc674e2c489ffb4f6e1d9 100644 --- a/opentech/apply/funds/admin_views.py +++ b/opentech/apply/funds/admin_views.py @@ -1,6 +1,7 @@ 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 a768bf447f2fab31f326f9a401fc0dabeb8edbf9..1c2c1f3dd7eb81dfbcf9811c90ec006f1da7fb15 100644 --- a/opentech/apply/funds/api_views.py +++ b/opentech/apply/funds/api_views.py @@ -1,32 +1,35 @@ from django.core.exceptions import PermissionDenied as DjangoPermissionDenied from django.db import transaction -from django.db.models import Prefetch, Q +from django.db.models import Q, Prefetch from django.utils import timezone -from django_filters import rest_framework as filters + +from wagtail.core.models import Page + from rest_framework import generics, mixins, permissions -from rest_framework.exceptions import NotFound, PermissionDenied, ValidationError from rest_framework.response import Response -from wagtail.core.models import Page +from rest_framework.exceptions import (NotFound, PermissionDenied, + ValidationError) +from django_filters import rest_framework as filters from opentech.api.pagination import StandardResultsSetPagination -from opentech.apply.activity.messaging import MESSAGES, messenger -from opentech.apply.activity.models import COMMENT, Activity +from opentech.apply.activity.models import Activity, COMMENT +from opentech.apply.activity.messaging import messenger, MESSAGES from opentech.apply.determinations.views import DeterminationCreateOrUpdateView -from opentech.apply.funds.models import FundType, LabType from opentech.apply.review.models import Review +from opentech.apply.funds.models import FundType, LabType from .models import ApplicationSubmission, RoundsAndLabs -from .permissions import IsApplyStaffUser, IsAuthor from .serializers import ( + CommentSerializer, CommentCreateSerializer, CommentEditSerializer, - CommentSerializer, RoundLabDetailSerializer, RoundLabSerializer, SubmissionActionSerializer, - SubmissionDetailSerializer, SubmissionListSerializer, + SubmissionDetailSerializer, ) +from .permissions import IsApplyStaffUser, IsAuthor from .workflow import PHASES diff --git a/opentech/apply/funds/blocks.py b/opentech/apply/funds/blocks.py index f94447f783c35af69e20f9f4af2b28817a31bc8c..bec9b723dbd973e0a47b979aa320d28387084fe9 100644 --- a/opentech/apply/funds/blocks.py +++ b/opentech/apply/funds/blocks.py @@ -2,6 +2,7 @@ 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 67d172778c63b755aa6116aa18d071d79da53452..7573d9a830fc078c3de01dd5cc1cae62710d5391 100644 --- a/opentech/apply/funds/differ.py +++ b/opentech/apply/funds/differ.py @@ -1,7 +1,7 @@ -from difflib import SequenceMatcher - from bleach.sanitizer import Cleaner from bs4 import BeautifulSoup +from difflib import SequenceMatcher + 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 643ba8c203895600f6cd11d0c48049014fa01446..d7f7b78257aea95e0fc58673e7fec9ee9c601535 100644 --- a/opentech/apply/funds/edit_handlers.py +++ b/opentech/apply/funds/edit_handlers.py @@ -1,9 +1,10 @@ from django.forms import Field, Widget from django.forms.utils import pretty_name -from django.template.loader import render_to_string from django.urls import reverse -from wagtail.admin.edit_handlers import EditHandler, FieldPanel +from django.template.loader import render_to_string + from wagtail.core.models import Page +from wagtail.admin.edit_handlers import EditHandler, FieldPanel def reverse_edit(obj): diff --git a/opentech/apply/funds/forms.py b/opentech/apply/funds/forms.py index 7f68996840f890152cea392170aad35e82d10252..4057a2906143566e572b6e1acb8497137eb6d51b 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 ApplicationSubmission, AssignedReviewers, ReviewerRole +from .models import AssignedReviewers, ApplicationSubmission, 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 ea6dfb09bc74bf4b8e3618a0cc9d78df32a37e59..310140dbc180e0cd0864b11e819c2c72483e5a4c 100644 --- a/opentech/apply/funds/management/commands/migration_base.py +++ b/opentech/apply/funds/management/commands/migration_base.py @@ -1,9 +1,10 @@ import argparse import json import os -from datetime import datetime, timezone from urllib.parse import urlsplit +from datetime import datetime, timezone + from django.conf import settings from django.contrib.auth import get_user_model from django.core.management.base import BaseCommand @@ -12,10 +13,10 @@ from django.db.utils import IntegrityError from django_fsm import FSMField from storages.backends.s3boto3 import S3Boto3Storage -from opentech.apply.categories.categories_seed import CATEGORIES 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.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.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 8714a7c5cf65adfb8109fa904549eb385ba617e3..732d98b32a6212fbba8dac74e3f19a70d8b4114d 100644 --- a/opentech/apply/funds/management/commands/seed_community_lab_application.py +++ b/opentech/apply/funds/management/commands/seed_community_lab_application.py @@ -6,8 +6,9 @@ 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.home.models import ApplyHomePage from opentech.apply.review.models import ReviewForm + +from opentech.apply.home.models import ApplyHomePage 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 c923e9acf8aeab5e5b6144a6d46d240ebfac6a69..9cb8796873a50ffc17d3e7e0c6b332ee91a1c9ac 100644 --- a/opentech/apply/funds/management/commands/seed_concept_note.py +++ b/opentech/apply/funds/management/commands/seed_concept_note.py @@ -1,4 +1,5 @@ import json + from datetime import date from django.contrib.auth import get_user_model @@ -7,12 +8,10 @@ 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.home.models import ApplyHomePage +from opentech.apply.funds.models.forms import ApplicationBaseForm, ApplicationBaseReviewForm from opentech.apply.review.models import ReviewForm + +from opentech.apply.home.models import ApplyHomePage 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 f263d01467a332a03c9e002bbb8ddf8eb329e64c..1a233415b89044e3fc4820e4cb5feecfc13cb82f 100644 --- a/opentech/apply/funds/management/commands/seed_fellowship.py +++ b/opentech/apply/funds/management/commands/seed_fellowship.py @@ -1,4 +1,5 @@ import json + from datetime import date from django.contrib.auth import get_user_model @@ -7,12 +8,10 @@ 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.home.models import ApplyHomePage +from opentech.apply.funds.models.forms import ApplicationBaseForm, ApplicationBaseReviewForm from opentech.apply.review.models import ReviewForm + +from opentech.apply.home.models import ApplyHomePage 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 3aa8045c998068914ebf676348bb4a71f201893e..7cf40a7008248c48dcbd7f33c4b67777ed0abc85 100644 --- a/opentech/apply/funds/management/commands/seed_rapid_response.py +++ b/opentech/apply/funds/management/commands/seed_rapid_response.py @@ -1,4 +1,5 @@ import json + from datetime import date from django.contrib.auth import get_user_model @@ -7,12 +8,10 @@ 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.home.models import ApplyHomePage +from opentech.apply.funds.models.forms import ApplicationBaseForm, ApplicationBaseReviewForm from opentech.apply.review.models import ReviewForm + +from opentech.apply.home.models import ApplyHomePage 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 9b9fb053cb7716418b4f0218e3f506e21bf46bb3..4730a3a44167279ff536202439cdaa88cd6c12c0 100644 --- a/opentech/apply/funds/models/__init__.py +++ b/opentech/apply/funds/models/__init__.py @@ -1,10 +1,11 @@ from django.utils.translation import ugettext_lazy as _ -from .applications import ApplicationBase, LabBase, RoundBase, RoundsAndLabs # NOQA +from .applications import ApplicationBase, RoundBase, LabBase, RoundsAndLabs # NOQA from .forms import ApplicationForm from .reviewer_role import ReviewerRole from .screening import ScreeningStatus -from .submissions import ApplicationRevision, ApplicationSubmission, AssignedReviewers +from .submissions import ApplicationSubmission, AssignedReviewers, ApplicationRevision + __all__ = ['ApplicationSubmission', 'AssignedReviewers', 'ApplicationRevision', 'ApplicationForm', 'ScreeningStatus', 'ReviewerRole'] diff --git a/opentech/apply/funds/models/applications.py b/opentech/apply/funds/models/applications.py index b2097d043ca869033fab82c9add020bae394dd48..0fad33145e7f0a50ec9da415caf34dc325b20c18 100644 --- a/opentech/apply/funds/models/applications.py +++ b/opentech/apply/funds/models/applications.py @@ -17,12 +17,15 @@ from django.db.models import ( When, ) from django.db.models.functions import Coalesce, Length -from django.http import Http404 from django.shortcuts import render + +from django.http import Http404 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, @@ -33,17 +36,11 @@ from wagtail.admin.edit_handlers import ( from wagtail.core.models import Page, PageManager, PageQuerySet from ..admin_forms import RoundBasePageAdminForm, WorkflowFormAdminForm -from ..edit_handlers import ReadOnlyInlinePanel, ReadOnlyPanel +from ..edit_handlers import ReadOnlyPanel, ReadOnlyInlinePanel from ..workflow import OPEN_CALL_PHASES + from .submissions import ApplicationSubmission -from .utils import ( - LIMIT_TO_REVIEWERS, - LIMIT_TO_STAFF, - EmailForm, - SubmittableStreamForm, - WorkflowStreamForm, - admin_url, -) +from .utils import admin_url, EmailForm, SubmittableStreamForm, WorkflowStreamForm, LIMIT_TO_REVIEWERS, LIMIT_TO_STAFF class ApplicationBaseManager(PageQuerySet): diff --git a/opentech/apply/funds/models/forms.py b/opentech/apply/funds/models/forms.py index 856124eee2b4e9e664c134ac7f7b0ed45dccbb81..40bf70d7308353816a2ba3b97bde955f0a31ba99 100644 --- a/opentech/apply/funds/models/forms.py +++ b/opentech/apply/funds/models/forms.py @@ -1,6 +1,11 @@ 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 cf6fd322841ef574a5f54661aacbced237a19ea2..388e238497eb6676d2de8544ecb30afc65446590 100644 --- a/opentech/apply/funds/models/mixins.py +++ b/opentech/apply/funds/models/mixins.py @@ -1,19 +1,17 @@ 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, - UploadableMediaBlock, + FileFieldBlock, FormFieldBlock, GroupToggleBlock, ImageFieldBlock, MultiFileFieldBlock ) -from opentech.apply.stream_forms.files import StreamFieldFile from opentech.apply.utils.blocks import SingleIncludeMixin +from opentech.apply.stream_forms.blocks import UploadableMediaBlock +from opentech.apply.stream_forms.files import StreamFieldFile + + __all__ = ['AccessFormData'] diff --git a/opentech/apply/funds/models/submissions.py b/opentech/apply/funds/models/submissions.py index 5e09d39383bd0bca2040f54f0242e114c3bb3520..cd1c4152330e07aa3e251b2500d0a6639e1feaf2 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, - F, IntegerField, + F, OuterRef, Prefetch, Q, @@ -19,49 +19,51 @@ from django.db.models import ( Sum, When, ) -from django.db.models.expressions import OrderBy, RawSQL +from django.db.models.expressions import RawSQL, OrderBy 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 RETURN_VALUE, FSMField, can_proceed, transition + +from django_fsm import can_proceed, FSMField, transition, RETURN_VALUE from django_fsm.signals import post_transition -from wagtail.contrib.forms.models import AbstractFormSubmission + from wagtail.core.fields import StreamField +from wagtail.contrib.forms.models import AbstractFormSubmission -from opentech.apply.activity.messaging import MESSAGES, messenger +from opentech.apply.activity.messaging import messenger, MESSAGES from opentech.apply.determinations.models import Determination from opentech.apply.review.models import ReviewOpinion -from opentech.apply.review.options import AGREE, DISAGREE, MAYBE +from opentech.apply.review.options import MAYBE, AGREE, DISAGREE 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_PARTNERS, - LIMIT_TO_REVIEWER_GROUPS, LIMIT_TO_STAFF, + LIMIT_TO_REVIEWER_GROUPS, + LIMIT_TO_PARTNERS, 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 6f3e10bbe0df2066b9a034e4ba86e2b251863a4d..f6661614fc08fdb6d955ab9bb6a1121f62c714ef 100644 --- a/opentech/apply/funds/models/utils.py +++ b/opentech/apply/funds/models/utils.py @@ -1,5 +1,6 @@ from django.db import models from django.urls import reverse + from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -9,17 +10,13 @@ from wagtail.admin.edit_handlers import ( ) from wagtail.contrib.forms.models import AbstractEmailForm -from opentech.apply.activity.messaging import MESSAGES, messenger +from opentech.apply.activity.messaging import messenger, MESSAGES from opentech.apply.stream_forms.models import AbstractStreamForm -from opentech.apply.users.groups import ( - COMMUNITY_REVIEWER_GROUP_NAME, - PARTNER_GROUP_NAME, - REVIEWER_GROUP_NAME, - STAFF_GROUP_NAME, -) +from opentech.apply.users.groups import REVIEWER_GROUP_NAME, STAFF_GROUP_NAME, PARTNER_GROUP_NAME, COMMUNITY_REVIEWER_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 6ad4c2132940b18e6a04d30e351a61eb0351caaa..54478823b417cab8b1a3c054b7fac2f6a3d0a0a7 100644 --- a/opentech/apply/funds/serializers.py +++ b/opentech/apply/funds/serializers.py @@ -1,5 +1,7 @@ import mistune + from django.contrib.auth import get_user_model + from django_bleach.templatetags.bleach_tags import bleach_value from rest_framework import serializers @@ -8,7 +10,6 @@ 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 e403067e2a5e356195e0165e04d52938bcbb8cec..f4a5c8a1f9d1bf486b0441e3cbf4fe9c90fcb7a9 100644 --- a/opentech/apply/funds/tables.py +++ b/opentech/apply/funds/tables.py @@ -1,15 +1,17 @@ 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 e0f31f7b2b3c6c6352959a631cc1a9f8f87e35b2..bddae4d8a14e7e8c522967c64fd4eafa261e78a7 100644 --- a/opentech/apply/funds/templatetags/markdown_tags.py +++ b/opentech/apply/funds/templatetags/markdown_tags.py @@ -1,5 +1,6 @@ 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 609b423ab4a0373180921e113b60b8a76aea4ed5..c9d2b8ebadf12898359444c6059e84c4383a94cc 100644 --- a/opentech/apply/funds/tests/factories/__init__.py +++ b/opentech/apply/funds/tests/factories/__init__.py @@ -1,6 +1,7 @@ -from . import blocks, models +from . import models +from .models import * # noqa +from . import blocks 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 2e57829784d28f391f83c13fdc09e8b6a5ac281f..7d05c2fdc3e63f85e7e8c59187d7fc444038169a 100644 --- a/opentech/apply/funds/tests/factories/blocks.py +++ b/opentech/apply/funds/tests/factories/blocks.py @@ -1,6 +1,5 @@ import json import random - import factory from opentech.apply.funds import blocks @@ -11,8 +10,8 @@ from opentech.apply.stream_forms.testing.factories import ( ImageFieldBlockFactory, MultiFileFieldBlockFactory, NumberFieldBlockFactory, - ParagraphBlockFactory, RadioFieldBlockFactory, + ParagraphBlockFactory, 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 6cf678297ddf5a4165d71a47ca90e0b1a05fb300..5aca57fa69bc98e232e65ac850f3368579c60f1e 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 ( - ApplicationRevision, ApplicationSubmission, + ApplicationRevision, 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,11 +27,12 @@ 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 REVIEWER_GROUP_NAME, STAFF_GROUP_NAME -from opentech.apply.users.tests.factories import GroupFactory, StaffFactory, UserFactory +from opentech.apply.users.groups import STAFF_GROUP_NAME, REVIEWER_GROUP_NAME +from opentech.apply.users.tests.factories import StaffFactory, UserFactory, GroupFactory 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 97045543dc67af75582d768a481e3a6b6dbce6d2..a41aa04568fc2445992316eaaa4772f3220df3b8 100644 --- a/opentech/apply/funds/tests/models/test_roundsandlabs.py +++ b/opentech/apply/funds/tests/models/test_roundsandlabs.py @@ -1,6 +1,7 @@ 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 dad6c651dcde1e5f9a224f3fd204056caa5da5f7..93413519a472dc54e3a217bad6d76e9588e9c533 100644 --- a/opentech/apply/funds/tests/test_admin_form.py +++ b/opentech/apply/funds/tests/test_admin_form.py @@ -1,10 +1,11 @@ -import factory from django.test import TestCase +import factory + 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 5d893f14a1828d7cb455c9696a7f9706d86ffbdf..3469b0448bbab7eb7bdf37c197628fa22d2ee2d4 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.home.factories import ApplyHomePageFactory from opentech.apply.users.tests.factories import SuperUserFactory +from opentech.apply.home.factories import ApplyHomePageFactory 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 ca93759e3c86668c3dd21fe07be956a94fed6b67..4ef221274adda7686e582b076aa72fea6eb686f8 100644 --- a/opentech/apply/funds/tests/test_api_views.py +++ b/opentech/apply/funds/tests/test_api_views.py @@ -1,8 +1,9 @@ from django.test import TestCase, override_settings from django.urls import reverse_lazy -from opentech.apply.activity.models import PRIVATE, PUBLIC, Activity +from opentech.apply.activity.models import Activity, PUBLIC, PRIVATE 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 02493a2124e8938d3eaf9ab843cc12f4f28cd7bb..3525d19eb32abbf235846eb4e0033f4b2f2775cf 100644 --- a/opentech/apply/funds/tests/test_forms.py +++ b/opentech/apply/funds/tests/test_forms.py @@ -1,15 +1,19 @@ from django.test import TestCase - -from opentech.apply.funds.forms import UpdateReviewersForm from opentech.apply.funds.tests.factories import ( ApplicationSubmissionFactory, - AssignedReviewersFactory, AssignedWithRoleReviewersFactory, + AssignedReviewersFactory, InvitedToProposalFactory, ReviewerRoleFactory, ) from opentech.apply.review.tests.factories import ReviewFactory -from opentech.apply.users.tests.factories import ReviewerFactory, StaffFactory +from opentech.apply.users.tests.factories import ( + ReviewerFactory, + StaffFactory, +) + + +from opentech.apply.funds.forms import UpdateReviewersForm class TestReviewerFormQueries(TestCase): diff --git a/opentech/apply/funds/tests/test_models.py b/opentech/apply/funds/tests/test_models.py index d0df4a602abbceee8a71687199ef461df0fd2215..eaa22338c1c81d12aabff0d25395dc18916a5c1f 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.blocks import EmailBlock, FullNameBlock from opentech.apply.funds.models import ApplicationSubmission +from opentech.apply.funds.blocks import EmailBlock, FullNameBlock 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.users.tests.factories import StaffFactory +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 .factories import ( ApplicationSubmissionFactory, diff --git a/opentech/apply/funds/tests/test_tags.py b/opentech/apply/funds/tests/test_tags.py index cfc662c521267e8157372a69c0ffc91a1f3f7953..ccbd84b93e06e44c3ea854da2fdad49ef6ff074e 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 TestCase, override_settings +from django.test import override_settings, TestCase 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 ec583dad777d56e7c98bb039d5e3dca8dbd79b7e..3bd595dd277c5deca0bf7e5dc896af7f54172f6e 100644 --- a/opentech/apply/funds/tests/test_views.py +++ b/opentech/apply/funds/tests/test_views.py @@ -1,16 +1,16 @@ -import json from datetime import timedelta +import json from django.utils import timezone from django.utils.text import slugify -from opentech.apply.activity.models import INTERNAL, Activity +from opentech.apply.activity.models import Activity, INTERNAL from opentech.apply.determinations.tests.factories import DeterminationFactory from opentech.apply.funds.tests.factories import ( - ApplicationRevisionFactory, ApplicationSubmissionFactory, - AssignedReviewersFactory, + ApplicationRevisionFactory, AssignedWithRoleReviewersFactory, + AssignedReviewersFactory, 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 54bd3b6612421922bca2fdab2c2c42b76544c449..b7784f49feb9729fbaacdd2a451184521f8d5005 100644 --- a/opentech/apply/funds/tests/views/test_batch_progress.py +++ b/opentech/apply/funds/tests/views/test_batch_progress.py @@ -1,7 +1,10 @@ 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 a87c6802389c0794483f1d5a9d75e875f3c0d3ad..f3d35b6a92cc0704dc9564a7c15e7504fe2338c9 100644 --- a/opentech/apply/funds/tests/views/test_batch_reviewers.py +++ b/opentech/apply/funds/tests/views/test_batch_reviewers.py @@ -5,8 +5,11 @@ 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 ff0a37aeaa6435ecff0333f0a958760141be76be..93b3bd7107be9653543ac74446b761de78d9bd14 100644 --- a/opentech/apply/funds/tests/views/test_rounds.py +++ b/opentech/apply/funds/tests/views/test_rounds.py @@ -1,4 +1,8 @@ -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 84b9a3699e3498d0290bf3e872f08dc562ba418d..386993422d70d095bd1c10dc336fd9c0616fdc74 100644 --- a/opentech/apply/funds/urls.py +++ b/opentech/apply/funds/urls.py @@ -1,30 +1,31 @@ from django.urls import include, path -from .api_views import ( - CommentEdit, - CommentList, - CommentListCreate, - RoundLabDetail, - RoundLabList, - SubmissionAction, - SubmissionDetail, - SubmissionList, -) from .views import ( RevisionCompareView, RevisionListView, RoundListView, - SubmissionDeleteView, + SubmissionsByRound, + SubmissionsByStatus, SubmissionDetailView, SubmissionEditView, SubmissionListView, SubmissionOverviewView, - SubmissionPrivateMediaView, - SubmissionsByRound, - SubmissionsByStatus, SubmissionSealedView, + SubmissionDeleteView, + SubmissionPrivateMediaView, +) +from .api_views import ( + CommentEdit, + CommentList, + CommentListCreate, + RoundLabDetail, + RoundLabList, + SubmissionAction, + SubmissionList, + SubmissionDetail, ) + revision_urls = ([ path('', RevisionListView.as_view(), name='list'), path('compare/<int:to>/<int:from>/', RevisionCompareView.as_view(), name='compare'), diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 1711a5ca143ca11b1655a1387db8835bae192964..0b05d75483ffeb19edfad866c72088a80c657f07 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -3,83 +3,66 @@ 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 Http404, HttpResponseRedirect, StreamingHttpResponse +from django.http import HttpResponseRedirect, Http404, 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 ( - DeleteView, - DetailView, - FormView, - ListView, - UpdateView, - View, -) +from django.views.generic import DetailView, FormView, ListView, UpdateView, DeleteView, 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 ( - ActivityContextMixin, AllActivityContextMixin, + ActivityContextMixin, CommentFormView, DelegatedViewMixin, ) -from opentech.apply.determinations.views import ( - BatchDeterminationCreateView, - DeterminationCreateOrUpdateView, -) +from opentech.apply.activity.messaging import messenger, MESSAGES +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 ( - BatchProgressSubmissionForm, BatchUpdateReviewersForm, + BatchProgressSubmissionForm, ProgressSubmissionForm, ScreeningSubmissionForm, - UpdatePartnersForm, UpdateReviewersForm, UpdateSubmissionLeadForm, + UpdatePartnersForm, ) from .models import ( - ApplicationRevision, ApplicationSubmission, - LabBase, - RoundBase, + ApplicationRevision, RoundsAndLabs, + RoundBase, + LabBase ) -from .permissions import is_user_has_access_to_view_submission from .tables import ( AdminSubmissionsTable, ReviewerSubmissionsTable, - RoundsFilter, RoundsTable, + RoundsFilter, SubmissionFilterAndSearch, SubmissionReviewerFilterAndSearch, SummarySubmissionsTable, ) -from .workflow import ( - INITIAL_STATE, - PHASES_MAPPING, - STAGE_CHANGE_ACTIONS, - review_statuses, -) +from .workflow import INITIAL_STATE, STAGE_CHANGE_ACTIONS, PHASES_MAPPING, review_statuses +from .permissions import is_user_has_access_to_view_submission 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 3ccbcdea67ceb860603341527f7fb8f5da4d6dfc..c1e302ee6ee1937c11de18b2770d023cf8e4d7a1 100644 --- a/opentech/apply/funds/wagtail_hooks.py +++ b/opentech/apply/funds/wagtail_hooks.py @@ -1,11 +1,13 @@ from django.contrib.auth.models import Permission -from wagtail.contrib.modeladmin.options import modeladmin_register + from wagtail.core import hooks +from wagtail.contrib.modeladmin.options import modeladmin_register 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 236beaa6c346126e856e36723cd0c1686ca3cf5b..d7ac9d879f2ea91801d78b718bd2e9874071f787 100644 --- a/opentech/apply/funds/widgets.py +++ b/opentech/apply/funds/widgets.py @@ -1,4 +1,5 @@ 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 0928477ef3953357f5197029b5e2efa02f385b66..8835492298d1a91258b437fb362612e77c1cfee8 100644 --- a/opentech/apply/funds/workflow.py +++ b/opentech/apply/funds/workflow.py @@ -1,10 +1,9 @@ -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 fc4338b622c8e87f74b9dfc2029c720b86479ccd..014137821098120601481efcdf8f9b231803b63b 100644 --- a/opentech/apply/home/models.py +++ b/opentech/apply/home/models.py @@ -1,10 +1,12 @@ 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 WagtailCacheMixin, cache_page + +from wagtailcache.cache import cache_page, WagtailCacheMixin from opentech.apply.funds.models import ApplicationBase, LabBase diff --git a/opentech/apply/review/admin.py b/opentech/apply/review/admin.py index ae6145abc7aec77380db0b7a074dcb0916cd472c..8986ee3dfee19e57b00136895c9aebcf49c68e10 100644 --- a/opentech/apply/review/admin.py +++ b/opentech/apply/review/admin.py @@ -1,4 +1,5 @@ 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 c87f23df2f1a7a9079a768fc2bb6e7db812ea953..8bebb3711ade8b32c00bee6c2819cfbdd2418d0a 100644 --- a/opentech/apply/review/blocks.py +++ b/opentech/apply/review/blocks.py @@ -1,27 +1,15 @@ 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 ( - 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.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.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 1c3516073a01197a4657e957ecee7fab50002993..169ca4bd95ea2a416d72f222c259194bb9e69022 100644 --- a/opentech/apply/review/fields.py +++ b/opentech/apply/review/fields.py @@ -1,9 +1,10 @@ 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 NA, RATE_CHOICES +from opentech.apply.review.options import RATE_CHOICES, NA 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 28272792fc7a24d32244930dda8f6b07d3ccb4e8..b74793094ca9e966e5f8d33aba847e9cac9869a6 100644 --- a/opentech/apply/review/management/commands/migrate_community_lab_reviews.py +++ b/opentech/apply/review/management/commands/migrate_community_lab_reviews.py @@ -1,6 +1,4 @@ -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 e364c01d8b799fef27ca7761c8985891bb08d04c..8507acb751b5a0f16116d765370f7f2964e87aec 100644 --- a/opentech/apply/review/management/commands/migrate_concept_reviews.py +++ b/opentech/apply/review/management/commands/migrate_concept_reviews.py @@ -1,6 +1,4 @@ -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 6b5cb30a83c2f9b31245ee7e7e18c0b9d8acc958..e8c6716ee57c47e3c1927f39f1023f70ea725abb 100644 --- a/opentech/apply/review/management/commands/migrate_fellowship_application_reviews.py +++ b/opentech/apply/review/management/commands/migrate_fellowship_application_reviews.py @@ -1,6 +1,4 @@ -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 4e52604a383ac9768e64eaa9dee400f2bab2da5d..d831822c5c29bac069e1c212558ad05e3ef5a8ec 100644 --- a/opentech/apply/review/management/commands/migrate_fellowship_proposal_reviews.py +++ b/opentech/apply/review/management/commands/migrate_fellowship_proposal_reviews.py @@ -1,6 +1,4 @@ -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 6559fe70648b43e6297c641ec330d10fee6ec6fb..e679c68563b01eaf0fdeb28f1d071754d9eb86b5 100644 --- a/opentech/apply/review/management/commands/migrate_proposal_reviews.py +++ b/opentech/apply/review/management/commands/migrate_proposal_reviews.py @@ -1,6 +1,4 @@ -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 8217be7b2137bdf61d9031af001c52865e29738b..6d9c3d3bb36efb1aa3bd41279e1595e0afd11f33 100644 --- a/opentech/apply/review/management/commands/migrate_rr_reviews.py +++ b/opentech/apply/review/management/commands/migrate_rr_reviews.py @@ -1,6 +1,4 @@ -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 eb9065bb9462eb31edbc228d7b5bb1f2c1341392..8cd7c989108b0dce2f5aea76dc70cc62af69f62b 100644 --- a/opentech/apply/review/management/commands/migration_review_base.py +++ b/opentech/apply/review/management/commands/migration_review_base.py @@ -1,5 +1,6 @@ import argparse import json + from datetime import datetime, timezone from django.contrib.auth import get_user_model @@ -7,8 +8,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, LabType, Round -from opentech.apply.funds.models.forms import LabBaseReviewForm, RoundBaseReviewForm +from opentech.apply.funds.models import ApplicationSubmission, Round, LabType +from opentech.apply.funds.models.forms import RoundBaseReviewForm, LabBaseReviewForm 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 a32d41d7dc3efa5bb0c66975e705ed1edf2e6a93..740f9d847f5e36709d68d12f60966a41e9457376 100644 --- a/opentech/apply/review/models.py +++ b/opentech/apply/review/models.py @@ -9,31 +9,16 @@ 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 ( - PARTNER_GROUP_NAME, - REVIEWER_GROUP_NAME, - STAFF_GROUP_NAME, -) +from opentech.apply.users.groups import STAFF_GROUP_NAME, REVIEWER_GROUP_NAME, PARTNER_GROUP_NAME from .blocks import ( + ReviewCustomFormFieldsBlock, RecommendationBlock, RecommendationCommentsBlock, - ReviewCustomFormFieldsBlock, ScoreFieldBlock, VisibilityBlock, ) -from .options import ( - DISAGREE, - MAYBE, - NA, - NO, - OPINION_CHOICES, - PRIVATE, - RECOMMENDATION_CHOICES, - REVIEWER, - VISIBILITY, - YES, -) +from .options import NA, YES, NO, MAYBE, RECOMMENDATION_CHOICES, DISAGREE, OPINION_CHOICES, VISIBILITY, PRIVATE, REVIEWER class ReviewFormFieldsMixin(models.Model): diff --git a/opentech/apply/review/tests/factories/__init__.py b/opentech/apply/review/tests/factories/__init__.py index 609b423ab4a0373180921e113b60b8a76aea4ed5..c9d2b8ebadf12898359444c6059e84c4383a94cc 100644 --- a/opentech/apply/review/tests/factories/__init__.py +++ b/opentech/apply/review/tests/factories/__init__.py @@ -1,6 +1,7 @@ -from . import blocks, models +from . import models +from .models import * # noqa +from . import blocks 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 517d74b1b66697eaf95006fadd44d06caf597dd5..23ce783dc3b683457666799745928082e7828dad 100644 --- a/opentech/apply/review/tests/factories/blocks.py +++ b/opentech/apply/review/tests/factories/blocks.py @@ -1,15 +1,11 @@ import json import random - import factory from opentech.apply.review import blocks -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.review.options import YES, MAYBE, NO, PRIVATE, REVIEWER +from opentech.apply.stream_forms.testing.factories import FormFieldBlockFactory, CharFieldBlockFactory, \ + 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 5c1efb19a247aaf634a64af2740aa498575b85eb..ee7077e60528ea187680fe3c8abcb475a64d9232 100644 --- a/opentech/apply/review/tests/factories/models.py +++ b/opentech/apply/review/tests/factories/models.py @@ -1,13 +1,11 @@ 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 d053b40391940ed43d0a03cdc56c2f6addbc1eb5..3d4e56e0e6e8d833561b8dd5d4fc86f63f18466c 100644 --- a/opentech/apply/review/tests/test_admin.py +++ b/opentech/apply/review/tests/test_admin.py @@ -1,7 +1,6 @@ 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 3daa9a4eb5babb1b2aeed6c937e7f806b8e0b8b9..9f986ec10f3e78183b662ab2929af55d8a60b9a2 100644 --- a/opentech/apply/review/tests/test_models.py +++ b/opentech/apply/review/tests/test_models.py @@ -1,9 +1,8 @@ from django.test import TestCase from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory - -from ..options import MAYBE, NO, YES from .factories import ReviewFactory, ReviewOpinionFactory +from ..options import MAYBE, NO, YES class TestReviewQueryset(TestCase): diff --git a/opentech/apply/review/tests/test_views.py b/opentech/apply/review/tests/test_views.py index 0d7aba29250c93b0acdbb9f8f58a0abc56bff9ac..7f4614e629916420299604df7885813e6a302073 100644 --- a/opentech/apply/review/tests/test_views.py +++ b/opentech/apply/review/tests/test_views.py @@ -2,21 +2,12 @@ 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 AGREE, DISAGREE, NA -from .factories import ( - ReviewFactory, - ReviewFormFactory, - ReviewFormFieldsFactory, - ReviewOpinionFactory, -) +from ..options import NA, AGREE, DISAGREE class StaffReviewsTestCase(BaseViewTestCase): diff --git a/opentech/apply/review/urls.py b/opentech/apply/review/urls.py index 8a53ddadcf227cf9ff7a2f2c70bd36eccfc23092..2d632fb1cddd25f1ee42b697acba11c72ffe2d67 100644 --- a/opentech/apply/review/urls.py +++ b/opentech/apply/review/urls.py @@ -1,11 +1,6 @@ from django.urls import path -from .views import ( - ReviewCreateOrUpdateView, - ReviewDeleteView, - ReviewDetailView, - ReviewListView, -) +from .views import ReviewDetailView, ReviewListView, ReviewCreateOrUpdateView, ReviewDeleteView app_name = 'reviews' diff --git a/opentech/apply/review/views.py b/opentech/apply/review/views.py index 9d800cf6870bd6ef58de084298f3a3040d5922f3..7b22550b16c81f0a9901b5f265bae3bfeb5ac861 100644 --- a/opentech/apply/review/views.py +++ b/opentech/apply/review/views.py @@ -6,22 +6,20 @@ 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, DeleteView, DetailView, ListView +from django.views.generic import CreateView, ListView, DetailView, DeleteView + from wagtail.core.blocks import RichTextBlock -from opentech.apply.activity.messaging import MESSAGES, messenger +from opentech.apply.activity.messaging import messenger, MESSAGES 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.image import generate_image_tag from opentech.apply.utils.views import CreateOrUpdateView +from opentech.apply.utils.image import generate_image_tag 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 64cad0a7fb44ac9ca409ed133b3a7b2d29707143..71f122fb74e779aa73c878ed427d79d88480aa36 100644 --- a/opentech/apply/review/wagtail_hooks.py +++ b/opentech/apply/review/wagtail_hooks.py @@ -1,4 +1,5 @@ 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 a42565bfcb159de2865739754c23b18e6ce6b6d9..5a85ab8d8d0d30e03059c3a934de9298849333b2 100644 --- a/opentech/apply/stream_forms/blocks.py +++ b/opentech/apply/stream_forms/blocks.py @@ -1,5 +1,7 @@ # 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 @@ -9,21 +11,10 @@ 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 ( - BooleanBlock, - CharBlock, - ChoiceBlock, - DateBlock, - DateTimeBlock, - ListBlock, - RichTextBlock, - StaticBlock, - StreamBlock, - StructBlock, - TextBlock, - TimeBlock, + StructBlock, TextBlock, CharBlock, BooleanBlock, ListBlock, StreamBlock, + DateBlock, TimeBlock, DateTimeBlock, ChoiceBlock, RichTextBlock, StaticBlock ) from .fields import MultiFileField diff --git a/opentech/apply/stream_forms/fields.py b/opentech/apply/stream_forms/fields.py index 607f77108b4d19f4cefdcbe83532aa45c4eb3cbc..c7a8deed5921ec957558420f721f73f737fdcbef 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 CheckboxInput, ClearableFileInput, FileField +from django.forms import ClearableFileInput, FileField, CheckboxInput class MultiFileInput(ClearableFileInput): diff --git a/opentech/apply/stream_forms/forms.py b/opentech/apply/stream_forms/forms.py index d503b3d70c2583a40aa70771fc5ea975d1aa89af..d4de59b9d7284da9da2f4250531b2af8fc65dbbf 100644 --- a/opentech/apply/stream_forms/forms.py +++ b/opentech/apply/stream_forms/forms.py @@ -1,5 +1,6 @@ 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 90eae4120e6ec069e77f913cd8cb19c0ae31376b..f3421670610081f668ae6adeb5b2929cb521468d 100644 --- a/opentech/apply/stream_forms/testing/factories.py +++ b/opentech/apply/stream_forms/testing/factories.py @@ -1,12 +1,13 @@ +from collections import defaultdict import json import uuid -from collections import defaultdict -import factory -import wagtail_factories from django.core.files.uploadedfile import SimpleUploadedFile + +import factory 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 e1ed4ef6fba8638c18fe0a540db0b2bd1cfceffe..a8d37d02de09a7a503431f897d4c7299db54e86a 100644 --- a/opentech/apply/stream_forms/tests.py +++ b/opentech/apply/stream_forms/tests.py @@ -1,9 +1,10 @@ from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase + from faker import Faker -from .fields import MultiFileField, MultiFileInput from .files import StreamFieldFile +from .fields import MultiFileField, MultiFileInput fake = Faker() diff --git a/opentech/apply/urls.py b/opentech/apply/urls.py index 044776c248698d237715d01ae1abb7cce8d96d53..6138117fab04d25e24a59884ba270f81a3b7f2ec 100644 --- a/opentech/apply/urls.py +++ b/opentech/apply/urls.py @@ -1,12 +1,14 @@ 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 b5f5fe8fd4c8e152895de101488d5db32ce59bd6..b5a82dd75253da3efe067baf1649b2802779258c 100644 --- a/opentech/apply/users/admin_views.py +++ b/opentech/apply/users/admin_views.py @@ -3,6 +3,7 @@ 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 812c3d4391fd19f01ba067c421fe5f440368e288..26d4016f57356e56ce077dfa4c40d012ee2ccef1 100644 --- a/opentech/apply/users/decorators.py +++ b/opentech/apply/users/decorators.py @@ -1,5 +1,5 @@ -from django.contrib.auth.decorators import login_required, user_passes_test from django.core.exceptions import PermissionDenied +from django.contrib.auth.decorators import login_required, user_passes_test from .utils import can_use_oauth_check diff --git a/opentech/apply/users/forms.py b/opentech/apply/users/forms.py index 7b74060d9c68e0548d956dcbeedc0ce5c212b94a..d89f45a9c45d41e81acc16958517f0fa6354a88a 100644 --- a/opentech/apply/users/forms.py +++ b/opentech/apply/users/forms.py @@ -1,8 +1,10 @@ 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 4ebdf2d0e55453a10ffbe6b5069c04ec03f1d53a..8affe31bc4e52aaf652fc0901730d67a27d2c97e 100644 --- a/opentech/apply/users/middleware.py +++ b/opentech/apply/users/middleware.py @@ -1,7 +1,5 @@ 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 4953c3fcd41371310f48b721e6872492d3c330cb..458f803ea4cc510d50274daf45c33a7a85863e05 100644 --- a/opentech/apply/users/models.py +++ b/opentech/apply/users/models.py @@ -1,17 +1,12 @@ -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.contrib.auth.hashers import make_password +from django.contrib.auth.models import AbstractUser, BaseUserManager from django.urls import reverse from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ -from .groups import ( - COMMUNITY_REVIEWER_GROUP_NAME, - PARTNER_GROUP_NAME, - REVIEWER_GROUP_NAME, - STAFF_GROUP_NAME, -) +from .groups import REVIEWER_GROUP_NAME, STAFF_GROUP_NAME, PARTNER_GROUP_NAME, COMMUNITY_REVIEWER_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 9f88fab964de364de9f94615a3df7f6876fe56ef..b111108c871b44f89780a9472a3c68b3c3d2dedd 100644 --- a/opentech/apply/users/tests/factories.py +++ b/opentech/apply/users/tests/factories.py @@ -1,7 +1,8 @@ -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 62104cea816a8789ad6c57286172506aeaf21f8a..1cc2f13ab373fe94f72bb9e3b4d09a753bba97e8 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.conf import settings from django.contrib.auth import get_user_model +from django.conf import settings 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 50fa3a82c9c4342bc86eef63a97ee9ed698c9324..044a9566de15344b6d99487cfd18c2c462ac36d8 100644 --- a/opentech/apply/users/tests/test_views.py +++ b/opentech/apply/users/tests/test_views.py @@ -1,9 +1,8 @@ from django.core import mail -from django.test import TestCase, override_settings +from django.test import override_settings, TestCase 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 99073cf6ca54de19a0bfcf86d43df12dba26bdc8..1d8d6f8317a337e638b4337cb320fd392e4d251e 100644 --- a/opentech/apply/users/urls.py +++ b/opentech/apply/users/urls.py @@ -1,14 +1,9 @@ +from django.urls import path, include from django.contrib.auth import views as auth_views -from django.urls import include, path, reverse_lazy +from django.urls import reverse_lazy + +from opentech.apply.users.views import LoginView, AccountView, become, oauth, ActivationView, create_password -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 38e2f6754d5b1ecc73939cd6309e5c9d9ad0a533..74142ec7131ce70e93f66c2310e65259d3e43d7e 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 7704f92690054848018513baba6a4f640c5f734d..86b54c1bd48823b171b537486f88b7ebbe5a4fe9 100644 --- a/opentech/apply/users/views.py +++ b/opentech/apply/users/views.py @@ -17,13 +17,16 @@ 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 b1e73a75df11f287e46655da7044fcfdc1f06b57..dcd5276f5f356dea951f5dfba794fb96dda19954 100644 --- a/opentech/apply/users/wagtail_hooks.py +++ b/opentech/apply/users/wagtail_hooks.py @@ -1,4 +1,5 @@ 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 f32a2835d7dd97f436e6aefbe763dabaefaff324..a4f9efb4d179d27568c7467342c24eb7d0b43025 100644 --- a/opentech/apply/utils/blocks.py +++ b/opentech/apply/utils/blocks.py @@ -1,18 +1,16 @@ 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.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 django.utils.text import mark_safe + +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 11677be1520263cd1755e08bf8915d5b4e0fe790..bed3683da90108043926563a59f6c05e7d8f3178 100644 --- a/opentech/apply/utils/notifications.py +++ b/opentech/apply/utils/notifications.py @@ -1,4 +1,5 @@ import requests + from django.conf import settings diff --git a/opentech/apply/utils/testing/__init__.py b/opentech/apply/utils/testing/__init__.py index 543930639558bca50676ca3cd739729ff86f2e0a..51bee7cf554f86ae3460ee4e30dfa08ff549188c 100644 --- a/opentech/apply/utils/testing/__init__.py +++ b/opentech/apply/utils/testing/__init__.py @@ -1 +1 @@ -from .tests import BaseViewTestCase, make_request # NOQA +from .tests import make_request, BaseViewTestCase # NOQA diff --git a/opentech/apply/utils/testing/tests.py b/opentech/apply/utils/testing/tests.py index 524bcaa256fc858e7b902d86a8b329d3441996b1..bba277b3d117141767a458d942b252b9a2cd63b6 100644 --- a/opentech/apply/utils/testing/tests.py +++ b/opentech/apply/utils/testing/tests.py @@ -1,8 +1,9 @@ -from django.contrib.auth.models import AnonymousUser from django.contrib.messages.storage.fallback import FallbackStorage -from django.test import RequestFactory, TestCase, override_settings +from django.contrib.auth.models import AnonymousUser +from django.test import override_settings, TestCase, RequestFactory from django.urls import reverse + request_factory = RequestFactory() diff --git a/opentech/images/models.py b/opentech/images/models.py index 6ae7525cc31db60d8da87d69d63b9453b59ddebf..dbc5e50c8e9ccd64513b2a8190fd5a4a3554fdf9 100644 --- a/opentech/images/models.py +++ b/opentech/images/models.py @@ -1,5 +1,9 @@ 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 69c333b1877e80a7059861d3aec492ef4ebf0fed..bee7352c4805565b82b2193cdf43987aa87c8c69 100644 --- a/opentech/public/forms/models.py +++ b/opentech/public/forms/models.py @@ -1,28 +1,25 @@ -import json import os +import json -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, - InlinePanel, - MultiFieldPanel, + FieldPanel, FieldRowPanel, MultiFieldPanel, InlinePanel ) from wagtail.contrib.forms.forms import FormBuilder from wagtail.contrib.forms.models import ( - FORM_FIELD_CHOICES, - AbstractEmailForm, - AbstractFormField, + AbstractEmailForm, AbstractFormField, FORM_FIELD_CHOICES ) -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 6a6385235af17fdc323d8962080122590c84dd76..7bb7907eda7c3bbd5ff7c56afb3c2718ef5fc0b7 100644 --- a/opentech/public/forms/wagtail_hooks.py +++ b/opentech/public/forms/wagtail_hooks.py @@ -1,4 +1,5 @@ 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 c2d59ee81d62a274338a069ab98aa4352742dacf..ae23e2f4813a39fdd2c35a311d4853bcbf4e398d 100644 --- a/opentech/public/funds/models.py +++ b/opentech/public/funds/models.py @@ -1,11 +1,13 @@ 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, @@ -20,7 +22,10 @@ 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 50da83dcc9ba616a7f7545bd84d5c46778cb5d6a..c7e9dddc92acc55b013e2295a2ab4e9f29b24bb7 100644 --- a/opentech/public/home/blocks.py +++ b/opentech/public/home/blocks.py @@ -1,4 +1,5 @@ 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 90be5e1286005e7237251892782756a6409dc9fb..25b5b404d2f01c509b2d285a1638328845ca07b8 100644 --- a/opentech/public/home/models.py +++ b/opentech/public/home/models.py @@ -1,20 +1,16 @@ import datetime - from django.db import models + from modelcluster.fields import ParentalKey -from wagtail.admin.edit_handlers import ( - FieldPanel, - InlinePanel, - MultiFieldPanel, - PageChooserPanel, - StreamFieldPanel, -) + +from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, PageChooserPanel, MultiFieldPanel, StreamFieldPanel from wagtail.core.fields import StreamField from wagtail.search import index -from opentech.public.funds.models import FundPage, LabPage, RFPPage from opentech.public.utils.models import BasePage, RelatedPage +from opentech.public.funds.models import FundPage, LabPage, RFPPage + from .blocks import OurWorkBlock diff --git a/opentech/public/home/templatetags/home_tags.py b/opentech/public/home/templatetags/home_tags.py index 5e4e438690e9e520271d0c17e216cfb798d61880..48902fb8703286def7d60e618394e8f9f1d7af24 100644 --- a/opentech/public/home/templatetags/home_tags.py +++ b/opentech/public/home/templatetags/home_tags.py @@ -1,6 +1,7 @@ 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 b7055692269b1a9c6f38c38d49415135c9c3af0a..5dd089387611991a1f8642eb17883523614e799f 100644 --- a/opentech/public/mailchimp/tests.py +++ b/opentech/public/mailchimp/tests.py @@ -1,11 +1,13 @@ -import re -from unittest import mock from urllib import parse +from unittest import mock +import re -import responses -from django.test import TestCase, override_settings +from django.test import override_settings, TestCase from django.urls import reverse +import responses + + any_url = re.compile(".") diff --git a/opentech/public/mailchimp/urls.py b/opentech/public/mailchimp/urls.py index f6500f54045cc9e2c3b338a28f60c79d1f369f79..4fe8fd700905dce757a61635859439915c5eb90f 100644 --- a/opentech/public/mailchimp/urls.py +++ b/opentech/public/mailchimp/urls.py @@ -2,6 +2,7 @@ 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 596261a7ac2a7a8aa3cdbf03eef9c180712e2527..0c1bdf80585333d81864c7e9ae10b4a5f28f7678 100644 --- a/opentech/public/mailchimp/views.py +++ b/opentech/public/mailchimp/views.py @@ -1,4 +1,5 @@ import logging + import uuid from django.conf import settings @@ -9,6 +10,7 @@ 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 8bdde4a92c384cced4832806b993a6c84fb1c4a6..adce6c8af60137134d9b0072d09a82a1c68004e3 100644 --- a/opentech/public/navigation/models.py +++ b/opentech/public/navigation/models.py @@ -1,6 +1,6 @@ from modelcluster.models import ClusterableModel -from wagtail.admin.edit_handlers import StreamFieldPanel from wagtail.contrib.settings.models import BaseSetting, register_setting +from wagtail.admin.edit_handlers import StreamFieldPanel 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 089ae36f909ede5109c804fc39ecdf1395165492..84ac38eddfe2816b4808fd7602d0449130d05d79 100644 --- a/opentech/public/navigation/templatetags/navigation_tags.py +++ b/opentech/public/navigation/templatetags/navigation_tags.py @@ -2,6 +2,7 @@ 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 e0d6bd37807e68e226dea30bc59eec8bf07d64c2..b8cb442c8123fec60dcce7e872ed48662211fd31 100644 --- a/opentech/public/news/feeds.py +++ b/opentech/public/news/feeds.py @@ -3,9 +3,10 @@ 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 NewsFeedSettings, NewsIndex, NewsPage, NewsType +from opentech.public.news.models import NewsPage, NewsType, NewsIndex, NewsFeedSettings class NewsFeed(Feed): diff --git a/opentech/public/news/management/commands/migrate_news.py b/opentech/public/news/management/commands/migrate_news.py index fae187f68208eaf3672f9b9c4826ae5a0769055f..c1d6357b77f0619f4636d48797776b5d113f0761 100644 --- a/opentech/public/news/management/commands/migrate_news.py +++ b/opentech/public/news/management/commands/migrate_news.py @@ -1,26 +1,28 @@ 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.categories_seed import CATEGORIES from opentech.apply.categories.models import Category, Option +from opentech.apply.categories.categories_seed import CATEGORIES 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 72bab3f145918f8f506ed2775042465222d04fd1..d25b7081aa73cad19232191d4c6be8aa87e4f9b2 100644 --- a/opentech/public/news/models.py +++ b/opentech/public/news/models.py @@ -1,18 +1,20 @@ -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 django.conf import settings +from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator + 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 ( - FieldPanel, InlinePanel, + FieldPanel, 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 ae985771c67b01ce932550b19c9e3b94ba4f6289..105d37cb220fd068c949c4802c29c9e27bcaa85d 100644 --- a/opentech/public/people/management/commands/migrate_people.py +++ b/opentech/public/people/management/commands/migrate_people.py @@ -2,35 +2,39 @@ import argparse import itertools import json import mimetypes + from datetime import datetime, timezone -from io import BytesIO from urllib.parse import urlsplit +from io import BytesIO -import bleach import requests +from PIL import Image + +import bleach 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.categories_seed import CATEGORIES from opentech.apply.categories.models import Category, Option +from opentech.apply.categories.categories_seed import CATEGORIES from opentech.public.people.models import ( Funding, FundReviewers, PersonContactInfomation, - PersonIndexPage, PersonPage, - PersonPagePersonType, + PersonIndexPage, PersonType, + PersonPagePersonType, SocialMediaProfile, ) + WagtailImage = get_image_model() VALID_IMAGE_EXTENSIONS = [ diff --git a/opentech/public/people/models.py b/opentech/public/people/models.py index f539405a45423d319be0c01dcf6f7e5a3109e061..bb92bf204bfcb173d7521ec32a92b0ed25a8e4b5 100644 --- a/opentech/public/people/models.py +++ b/opentech/public/people/models.py @@ -1,29 +1,26 @@ -from django.conf import settings +from django.db import models from django.core.exceptions import ValidationError from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator -from django.db import models +from django.conf import settings + 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 ( - BaseFunding, - BasePage, - FundingMixin, - RelatedPage, -) +from opentech.public.utils.models import BasePage, BaseFunding, FundingMixin, RelatedPage class SocialMediaProfile(models.Model): diff --git a/opentech/public/people/wagtail_hooks.py b/opentech/public/people/wagtail_hooks.py index 25fd275c3eab6bf9bcce3c8a2dbc8a703740e831..ed2a0fce2c6dd8432105e3337c051a0d28635533 100644 --- a/opentech/public/people/wagtail_hooks.py +++ b/opentech/public/people/wagtail_hooks.py @@ -1,5 +1,6 @@ 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 2ff5eaa320cf92e48b9a3b64010d5f3d8b66e532..3c91730ca7acd3d86042620ccca29cde270c0f00 100644 --- a/opentech/public/projects/management/commands/migrate_projects.py +++ b/opentech/public/projects/management/commands/migrate_projects.py @@ -2,24 +2,27 @@ import argparse import itertools import json import mimetypes + from datetime import datetime, timezone -from io import BytesIO from urllib.parse import urlsplit +from io import BytesIO -import bleach import requests +from PIL import Image + +import bleach 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.categories_seed import CATEGORIES from opentech.apply.categories.models import Category, Option +from opentech.apply.categories.categories_seed import CATEGORIES from opentech.public.projects.models import ( ProjectContactDetails, ProjectFunding, @@ -27,6 +30,7 @@ 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 6673f2d7a5f0702b785422313397f94985bca56d..38e8828d7994c281928663f6032bda8183524f7e 100644 --- a/opentech/public/projects/models.py +++ b/opentech/public/projects/models.py @@ -1,12 +1,14 @@ 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, @@ -14,6 +16,7 @@ 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 c7dec98db17555b59c423694d3b35d19d60cc425..75fa8abf5aeab58a6640becb9f638d176e7d2b00 100644 --- a/opentech/public/standardpages/models.py +++ b/opentech/public/standardpages/models.py @@ -1,14 +1,23 @@ +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, InlinePanel, StreamFieldPanel + +from wagtail.admin.edit_handlers import ( + FieldPanel, StreamFieldPanel, + InlinePanel +) + 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 a1868e486fe4e5b2079e4c954b1589e7f77da439..7d27061f5c0ebd716c7eaeb69a0377029c62e9f3 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 986525559778e649fd2815309076058f5ad4ac1c..149a40181ae1a97390338f32baa92c4c174ed096 100644 --- a/opentech/public/utils/context_processors.py +++ b/opentech/public/utils/context_processors.py @@ -1,5 +1,6 @@ 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 b19c007a9793ac6f4cf7d9ad463c41d20f546d91..f78f7017c8e9e939a3aa8cb33acd31f7d1e05b14 100644 --- a/opentech/public/utils/models.py +++ b/opentech/public/utils/models.py @@ -1,7 +1,8 @@ -from django.conf import settings from django.core.exceptions import ValidationError +from django.conf import settings from django.db import models from django.utils.decorators import method_decorator + from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -10,13 +11,14 @@ 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 RichTextField, StreamField +from wagtail.core.fields import StreamField, RichTextField from wagtail.core.models import Orderable, Page from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.snippets.models import register_snippet -from wagtailcache.cache import WagtailCacheMixin, cache_page +from wagtail.contrib.settings.models import BaseSetting, register_setting + +from wagtailcache.cache import cache_page, WagtailCacheMixin class LinkFields(models.Model): diff --git a/opentech/public/utils/templatetags/util_tags.py b/opentech/public/utils/templatetags/util_tags.py index e9923f6e4197f371b31ec75df806321b49924ba9..8b419b5f4d5fd440432b1b48bc0a59c4bfb23650 100644 --- a/opentech/public/utils/templatetags/util_tags.py +++ b/opentech/public/utils/templatetags/util_tags.py @@ -1,8 +1,10 @@ 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 a7041fe3f9d64a732e259acfe886ad9c7410363f..0efa847d6ceabae61810a0538d81d6e707e644f1 100644 --- a/opentech/public/utils/wagtail_hooks.py +++ b/opentech/public/utils/wagtail_hooks.py @@ -1,10 +1,8 @@ from django.contrib.staticfiles.templatetags.staticfiles import static -from wagtail.contrib.modeladmin.options import ( - ModelAdmin, - ModelAdminGroup, - modeladmin_register, -) + +from wagtail.contrib.modeladmin.options import ModelAdminGroup, ModelAdmin, 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 1e74e1d3adec14ec85808ca52d7fd84925283113..edf98f4fbc862bef0c067a60687a080146707255 100644 --- a/opentech/settings/base.py +++ b/opentech/settings/base.py @@ -10,6 +10,7 @@ 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 c32b24e03fd81a0adc803ff6698bc526717fc753..11a71f78e5248d8568b15eaf0f8d0ca00ff70acd 100644 --- a/opentech/settings/test.py +++ b/opentech/settings/test.py @@ -1,9 +1,8 @@ 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 6d7124a6fbddbf9f15d1275b46571eae0c45aa3f..2aa4a198c885865d2e0d283fcb36893c4410586c 100644 --- a/opentech/urls.py +++ b/opentech/urls.py @@ -1,17 +1,18 @@ from django.conf import settings -from django.conf.urls import url -from django.contrib import admin from django.urls import include, path +from django.contrib import admin from django.views.generic import TemplateView -from wagtail.admin import urls as wagtailadmin_urls +from django.conf.urls import url + from wagtail.contrib.sitemaps.views import sitemap +from wagtail.admin import urls as wagtailadmin_urls 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), diff --git a/requirements.txt b/requirements.txt index 0478500e49e4642089b8c6497d4f4ee36c0e96d3..fd62eb82244b7b99d7ec8eb99da9fcf18f6ab455 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ # Test dependencies flake8 factory_boy==2.9.2 -isort==4.3.21 wagtail-factories==1.1.0 responses==0.10.4