diff --git a/addressfield/fields.py b/addressfield/fields.py index 8a733823..ad0887b4 100644 --- a/addressfield/fields.py +++ b/addressfield/fields.py @@ -6,7 +6,6 @@ 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 3b85a1f5..e8561b09 100644 --- a/addressfield/widgets.py +++ b/addressfield/widgets.py @@ -1,5 +1,4 @@ from django import forms - from django_countries import countries from django_select2.forms import Select2Widget diff --git a/hypha/apply/activity/admin.py b/hypha/apply/activity/admin.py index 11d7238c..ba4883b4 100644 --- a/hypha/apply/activity/admin.py +++ b/hypha/apply/activity/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Event, Message diff --git a/hypha/apply/activity/forms.py b/hypha/apply/activity/forms.py index af781fb6..13462fa8 100644 --- a/hypha/apply/activity/forms.py +++ b/hypha/apply/activity/forms.py @@ -1,10 +1,9 @@ from django import forms from django.core.exceptions import ValidationError from django.utils.safestring import mark_safe - from pagedown.widgets import PagedownWidget -from .models import Activity, VISIBILILTY_HELP_TEXT, VISIBILITY +from .models import VISIBILILTY_HELP_TEXT, VISIBILITY, Activity class CommentForm(forms.ModelForm): diff --git a/hypha/apply/activity/management/commands/migrate_comments.py b/hypha/apply/activity/management/commands/migrate_comments.py index 3b9e326f..728d7953 100644 --- a/hypha/apply/activity/management/commands/migrate_comments.py +++ b/hypha/apply/activity/management/commands/migrate_comments.py @@ -1,6 +1,5 @@ import argparse import json - from datetime import datetime, timezone from django.contrib.auth import get_user_model diff --git a/hypha/apply/activity/messaging.py b/hypha/apply/activity/messaging.py index 6ef6fe78..d3872bab 100644 --- a/hypha/apply/activity/messaging.py +++ b/hypha/apply/activity/messaging.py @@ -1,16 +1,16 @@ import json -import requests import logging from collections import defaultdict -from django.db import models +import requests from django.conf import settings from django.contrib import messages from django.contrib.auth import get_user_model +from django.db import models from django.template.loader import render_to_string from django.utils import timezone -from .models import TEAM, ALL +from .models import ALL, TEAM from .options import MESSAGES from .tasks import send_mail diff --git a/hypha/apply/activity/models.py b/hypha/apply/activity/models.py index 82b87a65..e8908e38 100644 --- a/hypha/apply/activity/models.py +++ b/hypha/apply/activity/models.py @@ -2,12 +2,11 @@ from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models -from django.db.models import Case, When, Value +from django.db.models import Case, Value, When from django.db.models.functions import Concat from .options import MESSAGES - COMMENT = 'comment' ACTION = 'action' diff --git a/hypha/apply/activity/tasks.py b/hypha/apply/activity/tasks.py index 569c2775..247c8ced 100644 --- a/hypha/apply/activity/tasks.py +++ b/hypha/apply/activity/tasks.py @@ -1,5 +1,4 @@ from celery import Celery - from django.conf import settings from django.core.mail import EmailMessage diff --git a/hypha/apply/activity/templatetags/activity_tags.py b/hypha/apply/activity/templatetags/activity_tags.py index 758210d5..0e6cb238 100644 --- a/hypha/apply/activity/templatetags/activity_tags.py +++ b/hypha/apply/activity/templatetags/activity_tags.py @@ -6,7 +6,7 @@ from hypha.apply.projects.models import Contract from hypha.apply.review.models import Review -from ..models import TEAM, ALL, REVIEWER +from ..models import ALL, REVIEWER, TEAM register = template.Library() diff --git a/hypha/apply/activity/tests/factories.py b/hypha/apply/activity/tests/factories.py index d26b0f03..da49d6f5 100644 --- a/hypha/apply/activity/tests/factories.py +++ b/hypha/apply/activity/tests/factories.py @@ -3,7 +3,14 @@ import factory from django.utils import timezone -from hypha.apply.activity.models import Activity, Event, TEAM, Message, MESSAGES, REVIEWER +from hypha.apply.activity.models import ( + MESSAGES, + REVIEWER, + TEAM, + Activity, + Event, + Message, +) from hypha.apply.funds.tests.factories import ApplicationSubmissionFactory from hypha.apply.users.tests.factories import UserFactory diff --git a/hypha/apply/activity/tests/test_messaging.py b/hypha/apply/activity/tests/test_messaging.py index 5c9620fc..73e9ab5a 100644 --- a/hypha/apply/activity/tests/test_messaging.py +++ b/hypha/apply/activity/tests/test_messaging.py @@ -4,39 +4,35 @@ 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 hypha.apply.utils.testing import make_request from hypha.apply.funds.tests.factories import ( ApplicationSubmissionFactory, AssignedReviewersFactory, AssignedWithRoleReviewersFactory, ) +from hypha.apply.projects.tests.factories import PaymentRequestFactory, ProjectFactory from hypha.apply.review.tests.factories import ReviewFactory from hypha.apply.users.tests.factories import ( ApplicantFactory, ReviewerFactory, StaffFactory, - UserFactory -) -from hypha.apply.projects.tests.factories import ( - ProjectFactory, - PaymentRequestFactory + UserFactory, ) +from hypha.apply.utils.testing import make_request -from ..models import Activity, Event, Message, TEAM, ALL from ..messaging import ( - AdapterBase, + MESSAGES, ActivityAdapter, + AdapterBase, EmailAdapter, MessengerBackend, - neat_related, - MESSAGES, SlackAdapter, + neat_related, ) +from ..models import ALL, TEAM, Activity, Event, Message from .factories import CommentFactory, EventFactory, MessageFactory diff --git a/hypha/apply/activity/tests/test_models.py b/hypha/apply/activity/tests/test_models.py index 2230036f..4331229a 100644 --- a/hypha/apply/activity/tests/test_models.py +++ b/hypha/apply/activity/tests/test_models.py @@ -1,7 +1,7 @@ from django.test import TestCase -from .factories import CommentFactory from ..models import Activity +from .factories import CommentFactory class TestActivityOnlyIncludesCurrent(TestCase): diff --git a/hypha/apply/activity/tests/test_tasks.py b/hypha/apply/activity/tests/test_tasks.py index 42e1482b..163ffcbb 100644 --- a/hypha/apply/activity/tests/test_tasks.py +++ b/hypha/apply/activity/tests/test_tasks.py @@ -3,7 +3,6 @@ from django.test import TestCase from ..tasks import send_mail - from .factories import MessageFactory diff --git a/hypha/apply/activity/urls.py b/hypha/apply/activity/urls.py index cdad5c3a..19c08552 100644 --- a/hypha/apply/activity/urls.py +++ b/hypha/apply/activity/urls.py @@ -1,6 +1,5 @@ from django.urls import include, path - app_name = 'activity' diff --git a/hypha/apply/activity/views.py b/hypha/apply/activity/views.py index bc0f58c8..7b75221f 100644 --- a/hypha/apply/activity/views.py +++ b/hypha/apply/activity/views.py @@ -1,11 +1,11 @@ -from django.views.generic import CreateView from django.utils import timezone +from django.views.generic import CreateView from hypha.apply.utils.views import DelegatedViewMixin from .forms import CommentForm -from .messaging import messenger, MESSAGES -from .models import Activity, COMMENT +from .messaging import MESSAGES, messenger +from .models import COMMENT, Activity class ActivityContextMixin: diff --git a/hypha/apply/api/v1/serializers.py b/hypha/apply/api/v1/serializers.py index 7efb05b1..ba8ccc45 100644 --- a/hypha/apply/api/v1/serializers.py +++ b/hypha/apply/api/v1/serializers.py @@ -1,7 +1,5 @@ import mistune - from django.contrib.auth import get_user_model - from django_bleach.templatetags.bleach_tags import bleach_value from rest_framework import serializers diff --git a/hypha/apply/api/v1/tests/test_serializers.py b/hypha/apply/api/v1/tests/test_serializers.py index f2905558..fb460f85 100644 --- a/hypha/apply/api/v1/tests/test_serializers.py +++ b/hypha/apply/api/v1/tests/test_serializers.py @@ -1,4 +1,4 @@ -from django.test import override_settings, TestCase +from django.test import TestCase, override_settings from hypha.apply.funds.tests.factories import ApplicationSubmissionFactory from hypha.apply.review.tests.factories import ReviewFactory diff --git a/hypha/apply/api/v1/tests/test_views.py b/hypha/apply/api/v1/tests/test_views.py index 10923edb..07e356ba 100644 --- a/hypha/apply/api/v1/tests/test_views.py +++ b/hypha/apply/api/v1/tests/test_views.py @@ -1,9 +1,8 @@ from django.test import TestCase, override_settings from django.urls import reverse_lazy -from hypha.apply.activity.models import Activity, APPLICANT, ALL +from hypha.apply.activity.models import ALL, APPLICANT, Activity from hypha.apply.activity.tests.factories import CommentFactory - from hypha.apply.users.tests.factories import UserFactory diff --git a/hypha/apply/api/v1/urls.py b/hypha/apply/api/v1/urls.py index df7f62c6..102a3592 100644 --- a/hypha/apply/api/v1/urls.py +++ b/hypha/apply/api/v1/urls.py @@ -7,8 +7,8 @@ RoundLabDetail, RoundLabList, SubmissionAction, - SubmissionList, SubmissionDetail, + SubmissionList, ) app_name = 'v1' diff --git a/hypha/apply/api/v1/views.py b/hypha/apply/api/v1/views.py index 8cefcbcd..668a6233 100644 --- a/hypha/apply/api/v1/views.py +++ b/hypha/apply/api/v1/views.py @@ -1,37 +1,37 @@ from django.core.exceptions import PermissionDenied as DjangoPermissionDenied from django.db import transaction -from django.db.models import Q, Prefetch +from django.db.models import Prefetch, Q from django.utils import timezone - -from wagtail.core.models import Page - +from django_filters import rest_framework as filters from rest_framework import generics, mixins, permissions +from rest_framework.exceptions import NotFound, PermissionDenied, ValidationError from rest_framework.response import Response -from rest_framework.exceptions import (NotFound, PermissionDenied, - ValidationError) from rest_framework_api_key.permissions import HasAPIKey -from django_filters import rest_framework as filters - -from hypha.apply.funds.models import ApplicationSubmission, RoundsAndLabs -from hypha.apply.funds.workflow import PHASES +from wagtail.core.models import Page -from hypha.apply.activity.models import Activity, COMMENT -from hypha.apply.activity.messaging import messenger, MESSAGES +from hypha.apply.activity.messaging import MESSAGES, messenger +from hypha.apply.activity.models import COMMENT, Activity from hypha.apply.determinations.views import DeterminationCreateOrUpdateView +from hypha.apply.funds.models import ( + ApplicationSubmission, + FundType, + LabType, + RoundsAndLabs, +) +from hypha.apply.funds.workflow import PHASES from hypha.apply.review.models import Review -from hypha.apply.funds.models import FundType, LabType from .pagination import StandardResultsSetPagination from .permissions import IsApplyStaffUser, IsAuthor from .serializers import ( - CommentSerializer, CommentCreateSerializer, CommentEditSerializer, + CommentSerializer, RoundLabDetailSerializer, RoundLabSerializer, SubmissionActionSerializer, - SubmissionListSerializer, SubmissionDetailSerializer, + SubmissionListSerializer, ) diff --git a/hypha/apply/categories/admin_helpers.py b/hypha/apply/categories/admin_helpers.py index 6937b6b3..f803d144 100644 --- a/hypha/apply/categories/admin_helpers.py +++ b/hypha/apply/categories/admin_helpers.py @@ -1,5 +1,4 @@ from django.contrib.admin.utils import quote - from wagtail.contrib.modeladmin.helpers import ButtonHelper diff --git a/hypha/apply/categories/admin_views.py b/hypha/apply/categories/admin_views.py index 98faa64a..96c6f969 100644 --- a/hypha/apply/categories/admin_views.py +++ b/hypha/apply/categories/admin_views.py @@ -1,6 +1,5 @@ from django.contrib.admin.utils import unquote from django.shortcuts import get_object_or_404 - from wagtail.contrib.modeladmin.views import CreateView diff --git a/hypha/apply/categories/blocks.py b/hypha/apply/categories/blocks.py index bb6b2cf9..13e0f75e 100644 --- a/hypha/apply/categories/blocks.py +++ b/hypha/apply/categories/blocks.py @@ -1,12 +1,11 @@ from django import forms -from django.utils.functional import cached_property, SimpleLazyObject +from django.utils.functional import SimpleLazyObject, 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 hypha.apply.stream_forms.blocks import OptionalFormFieldBlock -from django_select2.forms import Select2MultipleWidget class ModelChooserBlock(ChooserBlock): diff --git a/hypha/apply/categories/management/commands/seed_categories.py b/hypha/apply/categories/management/commands/seed_categories.py index 660e0033..e5b0526d 100644 --- a/hypha/apply/categories/management/commands/seed_categories.py +++ b/hypha/apply/categories/management/commands/seed_categories.py @@ -1,8 +1,8 @@ from django.core.management.base import BaseCommand from django.db import transaction -from hypha.apply.categories.models import Category, Option from hypha.apply.categories.categories_seed import CATEGORIES +from hypha.apply.categories.models import Category, Option class Command(BaseCommand): diff --git a/hypha/apply/categories/models.py b/hypha/apply/categories/models.py index a21ec1a1..e5d508b0 100644 --- a/hypha/apply/categories/models.py +++ b/hypha/apply/categories/models.py @@ -3,21 +3,15 @@ from django.db import models from django.template.loader import render_to_string from django.utils.translation import ugettext_lazy as _ - from modelcluster.fields import ParentalKey from modelcluster.models import ClusterableModel -from wagtail.admin.edit_handlers import ( - FieldPanel, - InlinePanel, - MultiFieldPanel, -) +from treebeard.mp_tree import MP_Node +from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel from wagtail.admin.forms import WagtailAdminModelForm from wagtail.core.fields import RichTextField 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/hypha/apply/dashboard/tests/test_views.py b/hypha/apply/dashboard/tests/test_views.py index eeee74dc..493c870c 100644 --- a/hypha/apply/dashboard/tests/test_views.py +++ b/hypha/apply/dashboard/tests/test_views.py @@ -1,6 +1,6 @@ from hypha.apply.funds.tests.factories import ( - ApplicationSubmissionFactory, ApplicationRevisionFactory, + ApplicationSubmissionFactory, InvitedToProposalFactory, ) from hypha.apply.projects.models import ( @@ -11,17 +11,14 @@ SUBMITTED, UNDER_REVIEW, ) -from hypha.apply.projects.tests.factories import ( - PaymentRequestFactory, - ProjectFactory -) +from hypha.apply.projects.tests.factories import PaymentRequestFactory, ProjectFactory from hypha.apply.review.tests.factories import ReviewFactory, ReviewOpinionFactory from hypha.apply.users.groups import APPROVER_GROUP_NAME from hypha.apply.users.tests.factories import ( ApplicantFactory, GroupFactory, ReviewerFactory, - StaffFactory + StaffFactory, ) from hypha.apply.utils.testing.tests import BaseViewTestCase diff --git a/hypha/apply/dashboard/urls.py b/hypha/apply/dashboard/urls.py index d8710de3..1c906f43 100644 --- a/hypha/apply/dashboard/urls.py +++ b/hypha/apply/dashboard/urls.py @@ -2,7 +2,6 @@ from .views import DashboardView - app_name = 'dashboard' urlpatterns = [ diff --git a/hypha/apply/dashboard/views.py b/hypha/apply/dashboard/views.py index 735b1c1f..9ed14ac5 100644 --- a/hypha/apply/dashboard/views.py +++ b/hypha/apply/dashboard/views.py @@ -12,16 +12,13 @@ SubmissionsTable, SummarySubmissionsTable, SummarySubmissionsTableWithRole, - review_filter_for_user + review_filter_for_user, ) from hypha.apply.projects.filters import ProjectListFilter -from hypha.apply.projects.models import ( - PaymentRequest, - Project -) +from hypha.apply.projects.models import PaymentRequest, Project from hypha.apply.projects.tables import ( PaymentRequestsDashboardTable, - ProjectsDashboardTable + ProjectsDashboardTable, ) from hypha.apply.utils.views import ViewDispatcher diff --git a/hypha/apply/dashboard/wagtail_hooks.py b/hypha/apply/dashboard/wagtail_hooks.py index 6c466b05..6d4cc3dd 100644 --- a/hypha/apply/dashboard/wagtail_hooks.py +++ b/hypha/apply/dashboard/wagtail_hooks.py @@ -1,9 +1,8 @@ from urllib.parse import urljoin from django.urls import reverse - -from wagtail.core import hooks from wagtail.admin.menu import MenuItem +from wagtail.core import hooks from hypha.apply.home.models import ApplyHomePage diff --git a/hypha/apply/determinations/forms.py b/hypha/apply/determinations/forms.py index 51604b43..1e3daf4e 100644 --- a/hypha/apply/determinations/forms.py +++ b/hypha/apply/determinations/forms.py @@ -2,14 +2,14 @@ from django.contrib.auth import get_user_model from django.core.exceptions import NON_FIELD_ERRORS -from hypha.apply.utils.fields import RichTextField from hypha.apply.funds.models import ApplicationSubmission +from hypha.apply.utils.fields import RichTextField from .models import ( - Determination, - DeterminationFormSettings, DETERMINATION_CHOICES, TRANSITION_DETERMINATION, + Determination, + DeterminationFormSettings, ) from .utils import determination_actions diff --git a/hypha/apply/determinations/management/commands/migrate_concept_determinations.py b/hypha/apply/determinations/management/commands/migrate_concept_determinations.py index aca56786..48078e6c 100644 --- a/hypha/apply/determinations/management/commands/migrate_concept_determinations.py +++ b/hypha/apply/determinations/management/commands/migrate_concept_determinations.py @@ -1,6 +1,5 @@ import argparse import json - from datetime import datetime, timezone from django.contrib.auth import get_user_model diff --git a/hypha/apply/determinations/management/commands/migrate_proposal_determinations.py b/hypha/apply/determinations/management/commands/migrate_proposal_determinations.py index 644f10da..4333565d 100644 --- a/hypha/apply/determinations/management/commands/migrate_proposal_determinations.py +++ b/hypha/apply/determinations/management/commands/migrate_proposal_determinations.py @@ -1,6 +1,5 @@ import argparse import json - from datetime import datetime, timezone from django.contrib.auth import get_user_model diff --git a/hypha/apply/determinations/models.py b/hypha/apply/determinations/models.py index 92695da3..34abe12b 100644 --- a/hypha/apply/determinations/models.py +++ b/hypha/apply/determinations/models.py @@ -4,13 +4,17 @@ from django.db import models from django.urls import reverse from django.utils.translation import ugettext_lazy as _ -from wagtail.admin.edit_handlers import TabbedInterface, ObjectList, FieldPanel, MultiFieldPanel +from wagtail.admin.edit_handlers import ( + FieldPanel, + MultiFieldPanel, + ObjectList, + TabbedInterface, +) from wagtail.contrib.settings.models import BaseSetting, register_setting from wagtail.core.fields import RichTextField from hypha.apply.funds.workflow import DETERMINATION_OUTCOMES - REJECTED = 0 NEEDS_MORE_INFO = 1 ACCEPTED = 2 diff --git a/hypha/apply/determinations/tests/factories.py b/hypha/apply/determinations/tests/factories.py index ab7bc799..53708005 100644 --- a/hypha/apply/determinations/tests/factories.py +++ b/hypha/apply/determinations/tests/factories.py @@ -2,7 +2,7 @@ from hypha.apply.funds.tests.factories import ApplicationSubmissionFactory -from ..models import Determination, ACCEPTED, NEEDS_MORE_INFO, REJECTED +from ..models import ACCEPTED, NEEDS_MORE_INFO, REJECTED, Determination from ..views import get_form_for_stage diff --git a/hypha/apply/determinations/tests/test_views.py b/hypha/apply/determinations/tests/test_views.py index fea56814..1171319d 100644 --- a/hypha/apply/determinations/tests/test_views.py +++ b/hypha/apply/determinations/tests/test_views.py @@ -2,15 +2,15 @@ from django.contrib.messages.storage.fallback import FallbackStorage from django.contrib.sessions.middleware import SessionMiddleware -from django.test import override_settings, RequestFactory +from django.test import RequestFactory, override_settings from django.urls import reverse_lazy from hypha.apply.activity.models import Activity -from hypha.apply.determinations.models import ACCEPTED, REJECTED, NEEDS_MORE_INFO +from hypha.apply.determinations.models import ACCEPTED, NEEDS_MORE_INFO, REJECTED from hypha.apply.determinations.views import BatchDeterminationCreateView -from hypha.apply.users.tests.factories import StaffFactory, UserFactory from hypha.apply.funds.models import ApplicationSubmission from hypha.apply.funds.tests.factories import ApplicationSubmissionFactory +from hypha.apply.users.tests.factories import StaffFactory, UserFactory from hypha.apply.utils.testing import BaseViewTestCase from .factories import DeterminationFactory diff --git a/hypha/apply/determinations/views.py b/hypha/apply/determinations/views.py index 37a3bf57..09f0f967 100644 --- a/hypha/apply/determinations/views.py +++ b/hypha/apply/determinations/views.py @@ -11,15 +11,15 @@ from django.utils import timezone from django.utils.decorators import method_decorator from django.utils.translation import ugettext_lazy as _ -from django.views.generic import DetailView, CreateView +from django.views.generic import CreateView, DetailView +from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.activity.models import Activity -from hypha.apply.activity.messaging import messenger, MESSAGES from hypha.apply.funds.models import ApplicationSubmission from hypha.apply.funds.workflow import DETERMINATION_OUTCOMES from hypha.apply.projects.models import Project -from hypha.apply.utils.views import CreateOrUpdateView, ViewDispatcher from hypha.apply.users.decorators import staff_required +from hypha.apply.utils.views import CreateOrUpdateView, ViewDispatcher from .forms import ( BatchConceptDeterminationForm, @@ -27,8 +27,12 @@ ConceptDeterminationForm, ProposalDeterminationForm, ) -from .models import Determination, DeterminationMessageSettings, NEEDS_MORE_INFO, TRANSITION_DETERMINATION - +from .models import ( + NEEDS_MORE_INFO, + TRANSITION_DETERMINATION, + Determination, + DeterminationMessageSettings, +) from .utils import ( can_create_determination, can_edit_determination, diff --git a/hypha/apply/flags/models.py b/hypha/apply/flags/models.py index 726fd0be..d5fc7148 100644 --- a/hypha/apply/flags/models.py +++ b/hypha/apply/flags/models.py @@ -1,7 +1,7 @@ from django.conf import settings -from django.db import models from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType +from django.db import models class Flag(models.Model): diff --git a/hypha/apply/flags/views.py b/hypha/apply/flags/views.py index e806d450..9cff528b 100644 --- a/hypha/apply/flags/views.py +++ b/hypha/apply/flags/views.py @@ -1,6 +1,6 @@ from django.contrib.contenttypes.models import ContentType +from django.http import HttpResponseNotAllowed, JsonResponse from django.utils.decorators import method_decorator -from django.http import JsonResponse, HttpResponseNotAllowed from django.views import View from hypha.apply.funds.models import ApplicationSubmission diff --git a/hypha/apply/funds/admin.py b/hypha/apply/funds/admin.py index ed29bb65..53b97773 100644 --- a/hypha/apply/funds/admin.py +++ b/hypha/apply/funds/admin.py @@ -4,21 +4,28 @@ from wagtail.contrib.modeladmin.helpers import PermissionHelper from wagtail.contrib.modeladmin.options import ModelAdmin, ModelAdminGroup +from hypha.apply.categories.admin import CategoryAdmin, MetaTermAdmin from hypha.apply.funds.models import ReviewerRole, ScreeningStatus from hypha.apply.review.admin import ReviewFormAdmin from hypha.apply.utils.admin import ListRelatedMixin -from hypha.apply.categories.admin import CategoryAdmin, MetaTermAdmin from .admin_helpers import ( + ApplicationFormButtonHelper, ButtonsWithPreview, FormsFundRoundListFilter, - RoundStateListFilter, - RoundFundChooserView, RoundAdminURLHelper, - ApplicationFormButtonHelper, + RoundFundChooserView, + RoundStateListFilter, ) from .admin_views import CopyApplicationFormViewClass -from .models import ApplicationForm, FundType, LabType, RequestForPartners, Round, SealedRound +from .models import ( + ApplicationForm, + FundType, + LabType, + RequestForPartners, + Round, + SealedRound, +) class BaseRoundAdmin(ModelAdmin): diff --git a/hypha/apply/funds/admin_forms.py b/hypha/apply/funds/admin_forms.py index bfcf8ae8..4d6c7b0b 100644 --- a/hypha/apply/funds/admin_forms.py +++ b/hypha/apply/funds/admin_forms.py @@ -1,4 +1,5 @@ from collections import Counter + from wagtail.admin.forms import WagtailAdminPageForm from .workflow import WORKFLOWS diff --git a/hypha/apply/funds/admin_helpers.py b/hypha/apply/funds/admin_helpers.py index e0791f0c..8922875c 100644 --- a/hypha/apply/funds/admin_helpers.py +++ b/hypha/apply/funds/admin_helpers.py @@ -5,9 +5,12 @@ from django.urls import reverse from django.utils.functional import cached_property from django.utils.translation import ugettext as _ - from wagtail.contrib.modeladmin.forms import ParentChooserForm -from wagtail.contrib.modeladmin.helpers import PageAdminURLHelper, PageButtonHelper, ButtonHelper +from wagtail.contrib.modeladmin.helpers import ( + ButtonHelper, + PageAdminURLHelper, + PageButtonHelper, +) from wagtail.contrib.modeladmin.views import ChooseParentView from wagtail.core.models import Page diff --git a/hypha/apply/funds/admin_views.py b/hypha/apply/funds/admin_views.py index dcb6eb55..1b268853 100644 --- a/hypha/apply/funds/admin_views.py +++ b/hypha/apply/funds/admin_views.py @@ -1,14 +1,13 @@ +from django.contrib.admin.utils import unquote from django.core.exceptions import PermissionDenied -from django.shortcuts import redirect, get_object_or_404 +from django.shortcuts import get_object_or_404, redirect from django.utils.translation import ugettext as _ -from django.contrib.admin.utils import unquote - from wagtail.admin import messages from wagtail.admin.forms.pages import CopyForm from wagtail.admin.views.pages import get_valid_next_url_from_request +from wagtail.contrib.modeladmin.views import CreateView from wagtail.core import hooks from wagtail.core.models import Page -from wagtail.contrib.modeladmin.views import CreateView def custom_admin_round_copy_view(request, page): diff --git a/hypha/apply/funds/blocks.py b/hypha/apply/funds/blocks.py index 1253aee1..ca986923 100644 --- a/hypha/apply/funds/blocks.py +++ b/hypha/apply/funds/blocks.py @@ -2,10 +2,9 @@ from django import forms from django.utils.translation import ugettext_lazy as _ - from wagtail.core import blocks -from addressfield.fields import AddressField, ADDRESS_FIELDS_ORDER +from addressfield.fields import ADDRESS_FIELDS_ORDER, AddressField from hypha.apply.categories.blocks import CategoryQuestionBlock from hypha.apply.stream_forms.blocks import FormFieldsBlock from hypha.apply.utils.blocks import ( diff --git a/hypha/apply/funds/differ.py b/hypha/apply/funds/differ.py index 51d4e462..ea077c49 100644 --- a/hypha/apply/funds/differ.py +++ b/hypha/apply/funds/differ.py @@ -1,8 +1,7 @@ import re - -from bleach.sanitizer import Cleaner from difflib import SequenceMatcher +from bleach.sanitizer import Cleaner from django.utils.html import format_html from django.utils.safestring import mark_safe diff --git a/hypha/apply/funds/edit_handlers.py b/hypha/apply/funds/edit_handlers.py index 80d961ac..26ceb81f 100644 --- a/hypha/apply/funds/edit_handlers.py +++ b/hypha/apply/funds/edit_handlers.py @@ -1,10 +1,9 @@ from django.forms import Field, Widget from django.forms.utils import pretty_name -from django.urls import reverse from django.template.loader import render_to_string - -from wagtail.core.models import Page +from django.urls import reverse from wagtail.admin.edit_handlers import EditHandler, FieldPanel +from wagtail.core.models import Page def reverse_edit(obj): diff --git a/hypha/apply/funds/files.py b/hypha/apply/funds/files.py index fa9ddb5e..b5ee6c23 100644 --- a/hypha/apply/funds/files.py +++ b/hypha/apply/funds/files.py @@ -1,4 +1,5 @@ import os + from django.urls import reverse from hypha.apply.stream_forms.files import StreamFieldFile diff --git a/hypha/apply/funds/forms.py b/hypha/apply/funds/forms.py index 3cfa9d47..b8071e3d 100644 --- a/hypha/apply/funds/forms.py +++ b/hypha/apply/funds/forms.py @@ -3,16 +3,16 @@ from operator import methodcaller from django import forms +from django.utils.safestring import mark_safe from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ -from django.utils.safestring import mark_safe from hypha.apply.categories.models import MetaTerm from hypha.apply.users.models import User -from .models import AssignedReviewers, ApplicationSubmission, ReviewerRole +from .models import ApplicationSubmission, AssignedReviewers, ReviewerRole from .utils import render_icon -from .widgets import Select2MultiCheckboxesWidget, MetaTermSelect2Widget +from .widgets import MetaTermSelect2Widget, Select2MultiCheckboxesWidget from .workflow import get_action_mapping diff --git a/hypha/apply/funds/management/commands/migration_base.py b/hypha/apply/funds/management/commands/migration_base.py index d16b19b2..a23abaaa 100644 --- a/hypha/apply/funds/management/commands/migration_base.py +++ b/hypha/apply/funds/management/commands/migration_base.py @@ -1,9 +1,8 @@ import argparse import json import os -from urllib.parse import urlsplit - from datetime import datetime, timezone +from urllib.parse import urlsplit from django.conf import settings from django.contrib.auth import get_user_model @@ -13,10 +12,10 @@ from django_fsm import FSMField from storages.backends.s3boto3 import S3Boto3Storage -from hypha.apply.categories.models import Category, Option from hypha.apply.categories.categories_seed import CATEGORIES -from hypha.apply.funds.models import ApplicationSubmission, FundType, Round, LabType -from hypha.apply.funds.models.forms import RoundBaseForm, LabBaseForm +from hypha.apply.categories.models import Category, Option +from hypha.apply.funds.models import ApplicationSubmission, FundType, LabType, Round +from hypha.apply.funds.models.forms import LabBaseForm, RoundBaseForm from hypha.apply.funds.workflow import INITIAL_STATE diff --git a/hypha/apply/funds/management/commands/seed_community_lab_application.py b/hypha/apply/funds/management/commands/seed_community_lab_application.py index 94619bec..aee97942 100644 --- a/hypha/apply/funds/management/commands/seed_community_lab_application.py +++ b/hypha/apply/funds/management/commands/seed_community_lab_application.py @@ -6,9 +6,8 @@ from hypha.apply.funds.models import ApplicationForm, LabType from hypha.apply.funds.models.forms import LabBaseForm, LabBaseReviewForm -from hypha.apply.review.models import ReviewForm - from hypha.apply.home.models import ApplyHomePage +from hypha.apply.review.models import ReviewForm from hypha.apply.users.groups import STAFF_GROUP_NAME CL_FUND_TITLE = 'Community lab (archive fund)' diff --git a/hypha/apply/funds/management/commands/seed_concept_note.py b/hypha/apply/funds/management/commands/seed_concept_note.py index 6f53b547..28f3ee79 100644 --- a/hypha/apply/funds/management/commands/seed_concept_note.py +++ b/hypha/apply/funds/management/commands/seed_concept_note.py @@ -1,5 +1,4 @@ import json - from datetime import date from django.contrib.auth import get_user_model @@ -8,10 +7,12 @@ from hypha.apply.categories.models import Category from hypha.apply.funds.models import ApplicationForm, FundType, Round -from hypha.apply.funds.models.forms import ApplicationBaseForm, ApplicationBaseReviewForm -from hypha.apply.review.models import ReviewForm - +from hypha.apply.funds.models.forms import ( + ApplicationBaseForm, + ApplicationBaseReviewForm, +) from hypha.apply.home.models import ApplyHomePage +from hypha.apply.review.models import ReviewForm from hypha.apply.users.groups import STAFF_GROUP_NAME CN_ROUND_TITLE = 'Internet Freedom Fund (archive round)' diff --git a/hypha/apply/funds/management/commands/seed_fellowship.py b/hypha/apply/funds/management/commands/seed_fellowship.py index dc8bc069..42fc743d 100644 --- a/hypha/apply/funds/management/commands/seed_fellowship.py +++ b/hypha/apply/funds/management/commands/seed_fellowship.py @@ -1,5 +1,4 @@ import json - from datetime import date from django.contrib.auth import get_user_model @@ -8,10 +7,12 @@ from hypha.apply.categories.models import Category from hypha.apply.funds.models import ApplicationForm, FundType, Round -from hypha.apply.funds.models.forms import ApplicationBaseForm, ApplicationBaseReviewForm -from hypha.apply.review.models import ReviewForm - +from hypha.apply.funds.models.forms import ( + ApplicationBaseForm, + ApplicationBaseReviewForm, +) from hypha.apply.home.models import ApplyHomePage +from hypha.apply.review.models import ReviewForm from hypha.apply.users.groups import STAFF_GROUP_NAME FS_ROUND_TITLE = 'Fellowship (archive round)' diff --git a/hypha/apply/funds/management/commands/seed_rapid_response.py b/hypha/apply/funds/management/commands/seed_rapid_response.py index 8ea67e67..398a9510 100644 --- a/hypha/apply/funds/management/commands/seed_rapid_response.py +++ b/hypha/apply/funds/management/commands/seed_rapid_response.py @@ -1,5 +1,4 @@ import json - from datetime import date from django.contrib.auth import get_user_model @@ -8,10 +7,12 @@ from hypha.apply.categories.models import Category from hypha.apply.funds.models import ApplicationForm, FundType, Round -from hypha.apply.funds.models.forms import ApplicationBaseForm, ApplicationBaseReviewForm -from hypha.apply.review.models import ReviewForm - +from hypha.apply.funds.models.forms import ( + ApplicationBaseForm, + ApplicationBaseReviewForm, +) from hypha.apply.home.models import ApplyHomePage +from hypha.apply.review.models import ReviewForm from hypha.apply.users.groups import STAFF_GROUP_NAME RR_ROUND_TITLE = 'Rapid Response (archive round)' diff --git a/hypha/apply/funds/models/__init__.py b/hypha/apply/funds/models/__init__.py index 4730a3a4..9b9fb053 100644 --- a/hypha/apply/funds/models/__init__.py +++ b/hypha/apply/funds/models/__init__.py @@ -1,11 +1,10 @@ from django.utils.translation import ugettext_lazy as _ -from .applications import ApplicationBase, RoundBase, LabBase, RoundsAndLabs # NOQA +from .applications import ApplicationBase, LabBase, RoundBase, RoundsAndLabs # NOQA from .forms import ApplicationForm from .reviewer_role import ReviewerRole from .screening import ScreeningStatus -from .submissions import ApplicationSubmission, AssignedReviewers, ApplicationRevision - +from .submissions import ApplicationRevision, ApplicationSubmission, AssignedReviewers __all__ = ['ApplicationSubmission', 'AssignedReviewers', 'ApplicationRevision', 'ApplicationForm', 'ScreeningStatus', 'ReviewerRole'] diff --git a/hypha/apply/funds/models/applications.py b/hypha/apply/funds/models/applications.py index 2191bd0f..a27909d7 100644 --- a/hypha/apply/funds/models/applications.py +++ b/hypha/apply/funds/models/applications.py @@ -16,16 +16,13 @@ Subquery, When, ) -from django.db.models.functions import Coalesce, Length, Left -from django.shortcuts import render - +from django.db.models.functions import Coalesce, Left, Length from django.http import Http404 +from django.shortcuts import render from django.utils.functional import cached_property from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ - from modelcluster.fields import ParentalManyToManyField - from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -36,11 +33,17 @@ from wagtail.core.models import Page, PageManager, PageQuerySet from ..admin_forms import RoundBasePageAdminForm, WorkflowFormAdminForm -from ..edit_handlers import ReadOnlyPanel, ReadOnlyInlinePanel +from ..edit_handlers import ReadOnlyInlinePanel, ReadOnlyPanel from ..workflow import OPEN_CALL_PHASES - from .submissions import ApplicationSubmission -from .utils import admin_url, EmailForm, SubmittableStreamForm, WorkflowStreamForm, LIMIT_TO_REVIEWERS, LIMIT_TO_STAFF +from .utils import ( + LIMIT_TO_REVIEWERS, + LIMIT_TO_STAFF, + EmailForm, + SubmittableStreamForm, + WorkflowStreamForm, + admin_url, +) class ApplicationBaseManager(PageQuerySet): diff --git a/hypha/apply/funds/models/forms.py b/hypha/apply/funds/models/forms.py index 08884128..e1868c0b 100644 --- a/hypha/apply/funds/models/forms.py +++ b/hypha/apply/funds/models/forms.py @@ -1,11 +1,6 @@ from django.db import models - from modelcluster.fields import ParentalKey - -from wagtail.admin.edit_handlers import ( - FieldPanel, - StreamFieldPanel, -) +from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel from wagtail.core.fields import StreamField from wagtail.core.models import Orderable diff --git a/hypha/apply/funds/models/mixins.py b/hypha/apply/funds/models/mixins.py index 90147651..b686a3df 100644 --- a/hypha/apply/funds/models/mixins.py +++ b/hypha/apply/funds/models/mixins.py @@ -1,12 +1,15 @@ -from django.utils.safestring import mark_safe from django.core.files import File +from django.utils.safestring import mark_safe from hypha.apply.stream_forms.blocks import ( - FileFieldBlock, FormFieldBlock, GroupToggleBlock, ImageFieldBlock, MultiFileFieldBlock + FileFieldBlock, + FormFieldBlock, + GroupToggleBlock, + ImageFieldBlock, + MultiFileFieldBlock, + UploadableMediaBlock, ) from hypha.apply.utils.blocks import SingleIncludeMixin - -from hypha.apply.stream_forms.blocks import UploadableMediaBlock from hypha.apply.utils.storage import PrivateStorage from ..files import SubmissionStreamFieldFile diff --git a/hypha/apply/funds/models/submissions.py b/hypha/apply/funds/models/submissions.py index 0aa1f131..04c20c12 100644 --- a/hypha/apply/funds/models/submissions.py +++ b/hypha/apply/funds/models/submissions.py @@ -1,17 +1,17 @@ from functools import partialmethod from django.conf import settings -from django.contrib.contenttypes.fields import GenericRelation from django.contrib.auth import get_user_model from django.contrib.auth.models import Group +from django.contrib.contenttypes.fields import GenericRelation from django.contrib.postgres.fields import JSONField from django.core.exceptions import PermissionDenied from django.db import models from django.db.models import ( Case, Count, - IntegerField, F, + IntegerField, OuterRef, Prefetch, Q, @@ -19,52 +19,50 @@ Sum, When, ) -from django.db.models.expressions import RawSQL, OrderBy +from django.db.models.expressions import OrderBy, RawSQL from django.db.models.functions import Coalesce from django.dispatch import receiver from django.urls import reverse from django.utils.text import slugify - -from django_fsm import can_proceed, FSMField, transition, RETURN_VALUE +from django_fsm import RETURN_VALUE, FSMField, can_proceed, transition from django_fsm.signals import post_transition - -from wagtail.core.fields import StreamField from wagtail.contrib.forms.models import AbstractFormSubmission +from wagtail.core.fields import StreamField -from hypha.apply.activity.messaging import messenger, MESSAGES +from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.categories.models import MetaTerm from hypha.apply.determinations.models import Determination from hypha.apply.flags.models import Flag from hypha.apply.review.models import ReviewOpinion -from hypha.apply.review.options import MAYBE, AGREE, DISAGREE +from hypha.apply.review.options import AGREE, DISAGREE, MAYBE from hypha.apply.stream_forms.files import StreamFieldDataEncoder from hypha.apply.stream_forms.models import BaseStreamForm +from ..blocks import NAMED_BLOCKS, ApplicationCustomFormFieldsBlock +from ..workflow import ( + COMMUNITY_REVIEW_PHASES, + DETERMINATION_RESPONSE_PHASES, + INITIAL_STATE, + PHASES, + PHASES_MAPPING, + STAGE_CHANGE_ACTIONS, + WORKFLOWS, + UserPermissions, + active_statuses, + get_review_active_statuses, + review_statuses, +) from .mixins import AccessFormData from .utils import ( COMMUNITY_REVIEWER_GROUP_NAME, - LIMIT_TO_STAFF, - LIMIT_TO_REVIEWER_GROUPS, LIMIT_TO_PARTNERS, + LIMIT_TO_REVIEWER_GROUPS, + LIMIT_TO_STAFF, 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, - PHASES_MAPPING, - review_statuses, - STAGE_CHANGE_ACTIONS, - UserPermissions, - WORKFLOWS, - COMMUNITY_REVIEW_PHASES, -) class JSONOrderable(models.QuerySet): diff --git a/hypha/apply/funds/models/utils.py b/hypha/apply/funds/models/utils.py index 0d785dab..caa8194a 100644 --- a/hypha/apply/funds/models/utils.py +++ b/hypha/apply/funds/models/utils.py @@ -1,6 +1,5 @@ from django.db import models from django.urls import reverse - from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -10,13 +9,17 @@ ) from wagtail.contrib.forms.models import AbstractEmailForm -from hypha.apply.activity.messaging import messenger, MESSAGES +from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.stream_forms.models import AbstractStreamForm -from hypha.apply.users.groups import REVIEWER_GROUP_NAME, STAFF_GROUP_NAME, PARTNER_GROUP_NAME, COMMUNITY_REVIEWER_GROUP_NAME +from hypha.apply.users.groups import ( + COMMUNITY_REVIEWER_GROUP_NAME, + PARTNER_GROUP_NAME, + REVIEWER_GROUP_NAME, + STAFF_GROUP_NAME, +) from ..workflow import WORKFLOWS - REVIEW_GROUPS = [ STAFF_GROUP_NAME, REVIEWER_GROUP_NAME, diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py index 8192a8c1..cff5208c 100644 --- a/hypha/apply/funds/tables.py +++ b/hypha/apply/funds/tables.py @@ -1,18 +1,16 @@ 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.safestring import mark_safe from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ -from django.utils.safestring import mark_safe - -import django_filters as filters -import django_tables2 as tables from django_tables2.utils import A - from wagtail.core.models import Page from hypha.apply.funds.models import ApplicationSubmission, Round, ScreeningStatus diff --git a/hypha/apply/funds/templatetags/markdown_tags.py b/hypha/apply/funds/templatetags/markdown_tags.py index bddae4d8..e0f31f7b 100644 --- a/hypha/apply/funds/templatetags/markdown_tags.py +++ b/hypha/apply/funds/templatetags/markdown_tags.py @@ -1,6 +1,5 @@ import mistune import tomd - from django import template register = template.Library() diff --git a/hypha/apply/funds/tests/factories/__init__.py b/hypha/apply/funds/tests/factories/__init__.py index c9d2b8eb..609b423a 100644 --- a/hypha/apply/funds/tests/factories/__init__.py +++ b/hypha/apply/funds/tests/factories/__init__.py @@ -1,7 +1,6 @@ -from . import models -from .models import * # noqa -from . import blocks +from . import blocks, models from .blocks import * # noqa +from .models import * # noqa __all__ = [] diff --git a/hypha/apply/funds/tests/factories/blocks.py b/hypha/apply/funds/tests/factories/blocks.py index 3f2e6178..ea3d81d9 100644 --- a/hypha/apply/funds/tests/factories/blocks.py +++ b/hypha/apply/funds/tests/factories/blocks.py @@ -1,5 +1,6 @@ import json import random + import factory from hypha.apply.funds import blocks diff --git a/hypha/apply/funds/tests/factories/models.py b/hypha/apply/funds/tests/factories/models.py index 0d2b5f25..87f7647c 100644 --- a/hypha/apply/funds/tests/factories/models.py +++ b/hypha/apply/funds/tests/factories/models.py @@ -4,8 +4,8 @@ import wagtail_factories from hypha.apply.funds.models import ( - ApplicationSubmission, ApplicationRevision, + ApplicationSubmission, AssignedReviewers, FundType, LabType, @@ -16,9 +16,9 @@ SealedRound, ) from hypha.apply.funds.models.forms import ( - ApplicationForm, ApplicationBaseForm, ApplicationBaseReviewForm, + ApplicationForm, LabBaseForm, LabBaseReviewForm, RoundBaseForm, @@ -27,12 +27,15 @@ from hypha.apply.funds.workflow import ConceptProposal, Request from hypha.apply.home.factories import ApplyHomePageFactory from hypha.apply.stream_forms.testing.factories import FormDataFactory -from hypha.apply.users.groups import STAFF_GROUP_NAME, REVIEWER_GROUP_NAME -from hypha.apply.users.tests.factories import StaffFactory, ApplicantFactory, GroupFactory +from hypha.apply.users.groups import REVIEWER_GROUP_NAME, STAFF_GROUP_NAME +from hypha.apply.users.tests.factories import ( + ApplicantFactory, + GroupFactory, + StaffFactory, +) from . import blocks - __all__ = [ 'FundTypeFactory', 'ApplicationBaseFormFactory', diff --git a/hypha/apply/funds/tests/models/test_roundsandlabs.py b/hypha/apply/funds/tests/models/test_roundsandlabs.py index f35ca23d..f1c8c5a7 100644 --- a/hypha/apply/funds/tests/models/test_roundsandlabs.py +++ b/hypha/apply/funds/tests/models/test_roundsandlabs.py @@ -1,7 +1,6 @@ from django.test import TestCase from hypha.apply.funds.models import RoundsAndLabs - from hypha.apply.funds.tests.factories import ( ApplicationSubmissionFactory, FundTypeFactory, diff --git a/hypha/apply/funds/tests/test_admin_form.py b/hypha/apply/funds/tests/test_admin_form.py index ce7fc3cd..0975734e 100644 --- a/hypha/apply/funds/tests/test_admin_form.py +++ b/hypha/apply/funds/tests/test_admin_form.py @@ -1,11 +1,10 @@ -from django.test import TestCase - import factory +from django.test import TestCase from hypha.apply.funds.models import FundType +from hypha.apply.review.tests.factories import ReviewFormFactory from .factories import ApplicationFormFactory, FundTypeFactory, workflow_for_stages -from hypha.apply.review.tests.factories import ReviewFormFactory def formset_base(field, total, delete, factory, same=False, form_stage_info=None): diff --git a/hypha/apply/funds/tests/test_forms.py b/hypha/apply/funds/tests/test_forms.py index 05fb2251..6cc07a4c 100644 --- a/hypha/apply/funds/tests/test_forms.py +++ b/hypha/apply/funds/tests/test_forms.py @@ -1,19 +1,15 @@ from django.test import TestCase + +from hypha.apply.funds.forms import UpdateReviewersForm from hypha.apply.funds.tests.factories import ( ApplicationSubmissionFactory, - AssignedWithRoleReviewersFactory, AssignedReviewersFactory, + AssignedWithRoleReviewersFactory, InvitedToProposalFactory, ReviewerRoleFactory, ) from hypha.apply.review.tests.factories import ReviewFactory -from hypha.apply.users.tests.factories import ( - ReviewerFactory, - StaffFactory, -) - - -from hypha.apply.funds.forms import UpdateReviewersForm +from hypha.apply.users.tests.factories import ReviewerFactory, StaffFactory class TestReviewerFormQueries(TestCase): diff --git a/hypha/apply/funds/tests/test_models.py b/hypha/apply/funds/tests/test_models.py index 460792ee..9d903d7f 100644 --- a/hypha/apply/funds/tests/test_models.py +++ b/hypha/apply/funds/tests/test_models.py @@ -1,22 +1,22 @@ -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 django.urls import reverse -from hypha.apply.funds.models import ApplicationSubmission from hypha.apply.funds.blocks import EmailBlock, FullNameBlock +from hypha.apply.funds.models import ApplicationSubmission from hypha.apply.funds.workflow import Request +from hypha.apply.review.options import MAYBE, NO from hypha.apply.review.tests.factories import ReviewFactory, ReviewOpinionFactory -from hypha.apply.review.options import NO, MAYBE -from hypha.apply.utils.testing import make_request from hypha.apply.users.tests.factories import StaffFactory +from hypha.apply.utils.testing import make_request from .factories import ( ApplicationSubmissionFactory, diff --git a/hypha/apply/funds/tests/test_tags.py b/hypha/apply/funds/tests/test_tags.py index b0b68174..fc8630b8 100644 --- a/hypha/apply/funds/tests/test_tags.py +++ b/hypha/apply/funds/tests/test_tags.py @@ -1,5 +1,5 @@ from django.template import Context, Template -from django.test import override_settings, TestCase +from django.test import TestCase, override_settings from hypha.apply.funds.tests.factories import ApplicationSubmissionFactory diff --git a/hypha/apply/funds/tests/test_views.py b/hypha/apply/funds/tests/test_views.py index ba742995..3908abf8 100644 --- a/hypha/apply/funds/tests/test_views.py +++ b/hypha/apply/funds/tests/test_views.py @@ -8,15 +8,13 @@ from django.utils import timezone from django.utils.text import slugify -from hypha.apply.activity.models import Activity, TEAM -from hypha.apply.projects.models import Project -from hypha.apply.projects.tests.factories import ProjectFactory +from hypha.apply.activity.models import TEAM, Activity from hypha.apply.determinations.tests.factories import DeterminationFactory from hypha.apply.funds.tests.factories import ( - ApplicationSubmissionFactory, ApplicationRevisionFactory, - AssignedWithRoleReviewersFactory, + ApplicationSubmissionFactory, AssignedReviewersFactory, + AssignedWithRoleReviewersFactory, InvitedToProposalFactory, LabSubmissionFactory, ReviewerRoleFactory, @@ -24,12 +22,14 @@ SealedRoundFactory, SealedSubmissionFactory, ) +from hypha.apply.projects.models import Project +from hypha.apply.projects.tests.factories import ProjectFactory from hypha.apply.review.tests.factories import ReviewFactory from hypha.apply.users.tests.factories import ( + ApplicantFactory, ReviewerFactory, StaffFactory, SuperUserFactory, - ApplicantFactory, ) from hypha.apply.utils.testing import make_request from hypha.apply.utils.testing.tests import BaseViewTestCase diff --git a/hypha/apply/funds/tests/views/test_batch_progress.py b/hypha/apply/funds/tests/views/test_batch_progress.py index b9f92fb9..5326d0fb 100644 --- a/hypha/apply/funds/tests/views/test_batch_progress.py +++ b/hypha/apply/funds/tests/views/test_batch_progress.py @@ -1,19 +1,12 @@ from unittest import mock +from hypha.apply.determinations.tests.factories import DeterminationFactory from hypha.apply.funds.models import ApplicationSubmission - -from hypha.apply.determinations.tests.factories import ( - DeterminationFactory -) from hypha.apply.funds.tests.factories import ( ApplicationSubmissionFactory, InvitedToProposalFactory, ) -from hypha.apply.users.tests.factories import ( - ReviewerFactory, - StaffFactory, - UserFactory, -) +from hypha.apply.users.tests.factories import ReviewerFactory, StaffFactory, UserFactory from hypha.apply.utils.testing.tests import BaseViewTestCase diff --git a/hypha/apply/funds/tests/views/test_batch_reviewers.py b/hypha/apply/funds/tests/views/test_batch_reviewers.py index 9d0cbdc7..87cec469 100644 --- a/hypha/apply/funds/tests/views/test_batch_reviewers.py +++ b/hypha/apply/funds/tests/views/test_batch_reviewers.py @@ -5,11 +5,8 @@ AssignedWithRoleReviewersFactory, ReviewerRoleFactory, ) -from hypha.apply.users.tests.factories import ( - ReviewerFactory, - StaffFactory, -) from hypha.apply.review.tests.factories import ReviewFactory +from hypha.apply.users.tests.factories import ReviewerFactory, StaffFactory from hypha.apply.utils.testing.tests import BaseViewTestCase diff --git a/hypha/apply/funds/tests/views/test_rounds.py b/hypha/apply/funds/tests/views/test_rounds.py index c1056b2e..4607b78f 100644 --- a/hypha/apply/funds/tests/views/test_rounds.py +++ b/hypha/apply/funds/tests/views/test_rounds.py @@ -1,13 +1,5 @@ -from hypha.apply.funds.tests.factories import ( - LabFactory, - RoundFactory, -) - -from hypha.apply.users.tests.factories import ( - ReviewerFactory, - StaffFactory, - UserFactory, -) +from hypha.apply.funds.tests.factories import LabFactory, RoundFactory +from hypha.apply.users.tests.factories import ReviewerFactory, StaffFactory, UserFactory from hypha.apply.utils.testing.tests import BaseViewTestCase diff --git a/hypha/apply/funds/urls.py b/hypha/apply/funds/urls.py index 8be9868f..2a089d7a 100644 --- a/hypha/apply/funds/urls.py +++ b/hypha/apply/funds/urls.py @@ -6,22 +6,21 @@ RevisionCompareView, RevisionListView, RoundListView, - SubmissionsByRound, - SubmissionsByStatus, + SubmissionDeleteView, + SubmissionDetailPDFView, + SubmissionDetailSimplifiedView, SubmissionDetailView, SubmissionEditView, SubmissionListView, SubmissionOverviewView, - SubmissionSealedView, - SubmissionDeleteView, SubmissionPrivateMediaView, - SubmissionDetailPDFView, - SubmissionDetailSimplifiedView, - SubmissionUserFlaggedView, + SubmissionsByRound, + SubmissionsByStatus, + SubmissionSealedView, SubmissionStaffFlaggedView, + SubmissionUserFlaggedView, ) - revision_urls = ([ path('', RevisionListView.as_view(), name='list'), path('compare///', RevisionCompareView.as_view(), name='compare'), diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index dd8e7413..01192852 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -1,72 +1,89 @@ from copy import copy +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 import messages from django.core.exceptions import PermissionDenied from django.db.models import Count, F, Q -from django.http import FileResponse, HttpResponseRedirect, Http404 +from django.http import FileResponse, Http404, HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.urls import reverse_lazy from django.utils.decorators import method_decorator from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from django.views import View -from django.views.generic import CreateView, DetailView, FormView, ListView, UpdateView, DeleteView +from django.views.generic import ( + CreateView, + DeleteView, + DetailView, + FormView, + ListView, + UpdateView, +) from django.views.generic.detail import SingleObjectMixin - from django_filters.views import FilterView from django_tables2.views import SingleTableMixin - from wagtail.core.models import Page +from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.activity.views import ( ActivityContextMixin, CommentFormView, DelegatedViewMixin, ) -from hypha.apply.activity.messaging import messenger, MESSAGES -from hypha.apply.determinations.views import BatchDeterminationCreateView, DeterminationCreateOrUpdateView +from hypha.apply.determinations.views import ( + BatchDeterminationCreateView, + DeterminationCreateOrUpdateView, +) from hypha.apply.projects.forms import CreateProjectForm from hypha.apply.projects.models import Project from hypha.apply.review.views import ReviewContextMixin from hypha.apply.users.decorators import staff_required from hypha.apply.utils.pdfs import make_pdf from hypha.apply.utils.storage import PrivateMediaView -from hypha.apply.utils.views import DelegateableListView, DelegateableView, ViewDispatcher +from hypha.apply.utils.views import ( + DelegateableListView, + DelegateableView, + ViewDispatcher, +) from .differ import compare from .files import generate_submission_file_path from .forms import ( - BatchUpdateSubmissionLeadForm, - BatchUpdateReviewersForm, BatchProgressSubmissionForm, + BatchUpdateReviewersForm, + BatchUpdateSubmissionLeadForm, ProgressSubmissionForm, ScreeningSubmissionForm, + UpdateMetaTermsForm, + UpdatePartnersForm, UpdateReviewersForm, UpdateSubmissionLeadForm, - UpdatePartnersForm, - UpdateMetaTermsForm, ) from .models import ( - ApplicationSubmission, ApplicationRevision, - RoundsAndLabs, + ApplicationSubmission, + LabBase, RoundBase, - LabBase + RoundsAndLabs, ) from .paginators import LazyPaginator from .permissions import is_user_has_access_to_view_submission from .tables import ( AdminSubmissionsTable, ReviewerSubmissionsTable, - RoundsTable, RoundsFilter, + RoundsTable, SubmissionFilterAndSearch, SubmissionReviewerFilterAndSearch, SummarySubmissionsTable, ) -from .workflow import INITIAL_STATE, STAGE_CHANGE_ACTIONS, PHASES_MAPPING, review_statuses +from .workflow import ( + INITIAL_STATE, + PHASES_MAPPING, + STAGE_CHANGE_ACTIONS, + review_statuses, +) class BaseAdminSubmissionsTable(SingleTableMixin, FilterView): diff --git a/hypha/apply/funds/wagtail_hooks.py b/hypha/apply/funds/wagtail_hooks.py index c1e302ee..3ccbcdea 100644 --- a/hypha/apply/funds/wagtail_hooks.py +++ b/hypha/apply/funds/wagtail_hooks.py @@ -1,13 +1,11 @@ from django.contrib.auth.models import Permission - -from wagtail.core import hooks from wagtail.contrib.modeladmin.options import modeladmin_register +from wagtail.core import hooks from .admin import ApplyAdminGroup from .admin_views import custom_admin_round_copy_view from .models import RoundBase - modeladmin_register(ApplyAdminGroup) diff --git a/hypha/apply/funds/widgets.py b/hypha/apply/funds/widgets.py index 3c0b8101..dc0c5866 100644 --- a/hypha/apply/funds/widgets.py +++ b/hypha/apply/funds/widgets.py @@ -1,5 +1,4 @@ from django.contrib.staticfiles.templatetags.staticfiles import static - from django_select2.forms import Select2MultipleWidget diff --git a/hypha/apply/funds/workflow.py b/hypha/apply/funds/workflow.py index 5c2c7a42..b0c35390 100644 --- a/hypha/apply/funds/workflow.py +++ b/hypha/apply/funds/workflow.py @@ -1,10 +1,11 @@ +import itertools from collections import defaultdict from enum import Enum -import itertools from django.conf import settings from django.utils.text import slugify + """ This file defines classes which allow you to compose workflows based on the following structure: diff --git a/hypha/apply/home/models.py b/hypha/apply/home/models.py index 6857926f..f4940018 100644 --- a/hypha/apply/home/models.py +++ b/hypha/apply/home/models.py @@ -1,12 +1,10 @@ from django.conf import settings from django.db import models from django.utils.decorators import method_decorator - from wagtail.admin.edit_handlers import FieldPanel from wagtail.core.models import Page from wagtail.search import index - -from wagtailcache.cache import cache_page, WagtailCacheMixin +from wagtailcache.cache import WagtailCacheMixin, cache_page from hypha.apply.funds.models import ApplicationBase, LabBase diff --git a/hypha/apply/projects/filters.py b/hypha/apply/projects/filters.py index 9afde93f..4917e4c2 100644 --- a/hypha/apply/projects/filters.py +++ b/hypha/apply/projects/filters.py @@ -5,7 +5,7 @@ from hypha.apply.funds.tables import ( Select2ModelMultipleChoiceFilter, Select2MultipleChoiceFilter, - get_used_funds + get_used_funds, ) from .models import ( diff --git a/hypha/apply/projects/forms.py b/hypha/apply/projects/forms.py index f49c0d08..660a2d34 100644 --- a/hypha/apply/projects/forms.py +++ b/hypha/apply/projects/forms.py @@ -31,11 +31,10 @@ Project, Report, ReportConfig, - ReportVersion, ReportPrivateFiles, + ReportVersion, ) - User = get_user_model() diff --git a/hypha/apply/projects/management/commands/notify_report_due.py b/hypha/apply/projects/management/commands/notify_report_due.py index 298957e5..b02f05f3 100644 --- a/hypha/apply/projects/management/commands/notify_report_due.py +++ b/hypha/apply/projects/management/commands/notify_report_due.py @@ -1,11 +1,11 @@ from dateutil.relativedelta import relativedelta - from django.conf import settings from django.contrib.messages.storage.fallback import FallbackStorage from django.core.management.base import BaseCommand from django.http import HttpRequest -from django.utils import timezone from django.urls import set_urlconf +from django.utils import timezone + from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.home.models import ApplyHomePage from hypha.apply.projects.models import Project diff --git a/hypha/apply/projects/models.py b/hypha/apply/projects/models.py index 1a4b0446..bdea1de3 100644 --- a/hypha/apply/projects/models.py +++ b/hypha/apply/projects/models.py @@ -13,18 +13,9 @@ from django.core.exceptions import ValidationError from django.core.validators import MinValueValidator from django.db import models -from django.db.models import ( - Case, - F, - ExpressionWrapper, - Max, - OuterRef, - Q, - Subquery, - Sum, - Value as V, - When, -) +from django.db.models import Case, ExpressionWrapper, F, Max, OuterRef, Q, Subquery, Sum +from django.db.models import Value as V +from django.db.models import When from django.db.models.functions import Cast, Coalesce from django.db.models.signals import post_delete from django.dispatch.dispatcher import receiver @@ -32,20 +23,16 @@ from django.utils import timezone from django.utils.functional import cached_property from django.utils.translation import ugettext as _ +from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel from wagtail.contrib.settings.models import BaseSetting, register_setting -from wagtail.admin.edit_handlers import ( - FieldPanel, - StreamFieldPanel, -) from wagtail.core.fields import StreamField +from addressfield.fields import ADDRESS_FIELDS_ORDER +from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.funds.models.mixins import AccessFormData from hypha.apply.stream_forms.blocks import FormFieldsBlock from hypha.apply.stream_forms.files import StreamFieldDataEncoder from hypha.apply.stream_forms.models import BaseStreamForm - -from addressfield.fields import ADDRESS_FIELDS_ORDER -from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.utils.storage import PrivateStorage logger = logging.getLogger(__name__) diff --git a/hypha/apply/projects/tables.py b/hypha/apply/projects/tables.py index dc07414b..2c86e162 100644 --- a/hypha/apply/projects/tables.py +++ b/hypha/apply/projects/tables.py @@ -1,8 +1,8 @@ import textwrap import django_tables2 as tables -from django.db.models import F, Sum from django.contrib.humanize.templatetags.humanize import intcomma +from django.db.models import F, Sum from django.utils.safestring import mark_safe from .models import PaymentRequest, Project, Report diff --git a/hypha/apply/projects/tests/factories.py b/hypha/apply/projects/tests/factories.py index 2f5a3752..6a8251cf 100644 --- a/hypha/apply/projects/tests/factories.py +++ b/hypha/apply/projects/tests/factories.py @@ -9,9 +9,9 @@ from hypha.apply.funds.tests.factories import ApplicationSubmissionFactory from hypha.apply.projects.models import ( COMPLETE, + IN_PROGRESS, Contract, DocumentCategory, - IN_PROGRESS, PacketFile, PaymentReceipt, PaymentRequest, @@ -21,7 +21,10 @@ ReportConfig, ReportVersion, ) -from hypha.apply.stream_forms.testing.factories import FormDataFactory, FormFieldsBlockFactory +from hypha.apply.stream_forms.testing.factories import ( + FormDataFactory, + FormFieldsBlockFactory, +) from hypha.apply.users.tests.factories import StaffFactory, UserFactory ADDRESS = { diff --git a/hypha/apply/projects/tests/test_commands.py b/hypha/apply/projects/tests/test_commands.py index 41b4522c..685162fe 100644 --- a/hypha/apply/projects/tests/test_commands.py +++ b/hypha/apply/projects/tests/test_commands.py @@ -1,18 +1,13 @@ from io import StringIO from dateutil.relativedelta import relativedelta - from django.core.management import call_command -from django.test import override_settings, TestCase +from django.test import TestCase, override_settings from django.utils import timezone from hypha.apply.home.models import ApplyHomePage -from .factories import ( - ProjectFactory, - ReportConfigFactory, - ReportFactory, -) +from .factories import ProjectFactory, ReportConfigFactory, ReportFactory @override_settings(ROOT_URLCONF='hypha.apply.urls') diff --git a/hypha/apply/projects/tests/test_forms.py b/hypha/apply/projects/tests/test_forms.py index c00edf1a..77b5c459 100644 --- a/hypha/apply/projects/tests/test_forms.py +++ b/hypha/apply/projects/tests/test_forms.py @@ -4,9 +4,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase, override_settings -from hypha.apply.users.tests.factories import ( - UserFactory, -) +from hypha.apply.users.tests.factories import UserFactory from ..files import get_files from ..forms import ( @@ -17,20 +15,14 @@ StaffUploadContractForm, UploadContractForm, filter_choices, - filter_request_choices -) -from ..models import ( - CHANGES_REQUESTED, - DECLINED, - PAID, - SUBMITTED, - UNDER_REVIEW, + filter_request_choices, ) +from ..models import CHANGES_REQUESTED, DECLINED, PAID, SUBMITTED, UNDER_REVIEW from .factories import ( DocumentCategoryFactory, PaymentRequestFactory, ProjectFactory, - address_to_form_data + address_to_form_data, ) diff --git a/hypha/apply/projects/tests/test_models.py b/hypha/apply/projects/tests/test_models.py index acc86486..68e566ff 100644 --- a/hypha/apply/projects/tests/test_models.py +++ b/hypha/apply/projects/tests/test_models.py @@ -13,8 +13,8 @@ PAID, SUBMITTED, UNDER_REVIEW, - Project, PaymentRequest, + Project, Report, ReportConfig, ) @@ -23,8 +23,8 @@ PacketFileFactory, PaymentRequestFactory, ProjectFactory, - ReportFactory, ReportConfigFactory, + ReportFactory, ) diff --git a/hypha/apply/projects/tests/test_templatetags.py b/hypha/apply/projects/tests/test_templatetags.py index 30448e44..50cf3f09 100644 --- a/hypha/apply/projects/tests/test_templatetags.py +++ b/hypha/apply/projects/tests/test_templatetags.py @@ -12,14 +12,10 @@ IN_PROGRESS, PAID, SUBMITTED, - UNDER_REVIEW + UNDER_REVIEW, ) from ..templatetags.contract_tools import user_can_upload_contract -from ..templatetags.payment_request_tools import ( - can_change_status, - can_delete, - can_edit -) +from ..templatetags.payment_request_tools import can_change_status, can_delete, can_edit from .factories import ContractFactory, PaymentRequestFactory, ProjectFactory diff --git a/hypha/apply/projects/tests/test_views.py b/hypha/apply/projects/tests/test_views.py index ac82d4ca..7e5b1e8b 100644 --- a/hypha/apply/projects/tests/test_views.py +++ b/hypha/apply/projects/tests/test_views.py @@ -1,7 +1,7 @@ from decimal import Decimal from io import BytesIO -from dateutil.relativedelta import relativedelta +from dateutil.relativedelta import relativedelta from django.contrib.auth.models import AnonymousUser from django.core.exceptions import PermissionDenied from django.test import RequestFactory, TestCase, override_settings @@ -15,19 +15,13 @@ ReviewerFactory, StaffFactory, SuperUserFactory, - UserFactory + UserFactory, ) from hypha.apply.utils.testing.tests import BaseViewTestCase -from ..forms import SetPendingForm from ..files import get_files -from ..models import ( - CHANGES_REQUESTED, - COMMITTED, - CONTRACTING, - IN_PROGRESS, - SUBMITTED, -) +from ..forms import SetPendingForm +from ..models import CHANGES_REQUESTED, COMMITTED, CONTRACTING, IN_PROGRESS, SUBMITTED from ..views import ContractsMixin, ProjectDetailSimplifiedView from .factories import ( ContractFactory, diff --git a/hypha/apply/projects/views/payment.py b/hypha/apply/projects/views/payment.py index 1ae549ab..ca73b497 100644 --- a/hypha/apply/projects/views/payment.py +++ b/hypha/apply/projects/views/payment.py @@ -4,34 +4,22 @@ from django.db import transaction from django.shortcuts import get_object_or_404, redirect from django.utils.decorators import method_decorator -from django.views.generic import ( - CreateView, - DeleteView, - DetailView, - UpdateView -) +from django.views.generic import CreateView, DeleteView, DetailView, UpdateView from django_filters.views import FilterView from django_tables2 import SingleTableMixin from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.users.decorators import staff_required from hypha.apply.utils.storage import PrivateMediaView -from hypha.apply.utils.views import ( - DelegateableView, - DelegatedViewMixin, - ViewDispatcher, -) +from hypha.apply.utils.views import DelegateableView, DelegatedViewMixin, ViewDispatcher +from ..filters import PaymentRequestListFilter from ..forms import ( ChangePaymentRequestStatusForm, CreatePaymentRequestForm, EditPaymentRequestForm, ) -from ..filters import PaymentRequestListFilter -from ..models import ( - PaymentRequest, - Project -) +from ..models import PaymentRequest, Project from ..tables import PaymentRequestsListTable diff --git a/hypha/apply/projects/views/project.py b/hypha/apply/projects/views/project.py index 4a149cf0..f90774d2 100644 --- a/hypha/apply/projects/views/project.py +++ b/hypha/apply/projects/views/project.py @@ -19,7 +19,7 @@ DetailView, FormView, TemplateView, - UpdateView + UpdateView, ) from django_filters.views import FilterView from django_tables2 import SingleTableMixin @@ -28,18 +28,10 @@ from hypha.apply.activity.views import ActivityContextMixin, CommentFormView from hypha.apply.users.decorators import approver_required, staff_required from hypha.apply.utils.storage import PrivateMediaView -from hypha.apply.utils.views import ( - DelegateableView, - DelegatedViewMixin, - ViewDispatcher, -) +from hypha.apply.utils.views import DelegateableView, DelegatedViewMixin, ViewDispatcher from ..files import get_files -from ..filters import ( - PaymentRequestListFilter, - ProjectListFilter, - ReportListFilter, -) +from ..filters import PaymentRequestListFilter, ProjectListFilter, ReportListFilter from ..forms import ( ApproveContractForm, CreateApprovalForm, @@ -52,7 +44,7 @@ StaffUploadContractForm, UpdateProjectLeadForm, UploadContractForm, - UploadDocumentForm + UploadDocumentForm, ) from ..models import ( CONTRACTING, @@ -65,16 +57,9 @@ Project, Report, ) -from ..tables import ( - PaymentRequestsListTable, - ProjectsListTable, - ReportListTable, -) - -from .report import ReportingMixin, ReportFrequencyUpdate - +from ..tables import PaymentRequestsListTable, ProjectsListTable, ReportListTable +from .report import ReportFrequencyUpdate, ReportingMixin -# APPROVAL VIEWS @method_decorator(staff_required, name='dispatch') class SendForApprovalView(DelegatedViewMixin, UpdateView): diff --git a/hypha/apply/projects/views/report.py b/hypha/apply/projects/views/report.py index bb9c54bc..ae27c9f8 100644 --- a/hypha/apply/projects/views/report.py +++ b/hypha/apply/projects/views/report.py @@ -5,24 +5,18 @@ from django.shortcuts import get_object_or_404, redirect from django.utils.decorators import method_decorator from django.views import View -from django.views.generic import ( - DetailView, - UpdateView, -) +from django.views.generic import DetailView, UpdateView from django.views.generic.detail import SingleObjectMixin from django_filters.views import FilterView from django_tables2 import SingleTableMixin from hypha.apply.activity.messaging import MESSAGES, messenger +from hypha.apply.users.decorators import staff_required from hypha.apply.utils.storage import PrivateMediaView from hypha.apply.utils.views import DelegatedViewMixin -from hypha.apply.users.decorators import staff_required from ..filters import ReportListFilter -from ..forms import ( - ReportEditForm, - ReportFrequencyForm, -) +from ..forms import ReportEditForm, ReportFrequencyForm from ..models import Report, ReportConfig, ReportPrivateFiles from ..tables import ReportListTable diff --git a/hypha/apply/projects/wagtail_hooks.py b/hypha/apply/projects/wagtail_hooks.py index b33974ab..af6ea6f8 100644 --- a/hypha/apply/projects/wagtail_hooks.py +++ b/hypha/apply/projects/wagtail_hooks.py @@ -2,5 +2,4 @@ from .admin import ManageAdminGoup - modeladmin_register(ManageAdminGoup) diff --git a/hypha/apply/review/admin.py b/hypha/apply/review/admin.py index cb96ff94..1c771b2c 100644 --- a/hypha/apply/review/admin.py +++ b/hypha/apply/review/admin.py @@ -1,5 +1,4 @@ from django.conf.urls import url - from wagtail.contrib.modeladmin.options import ModelAdmin from wagtail.contrib.modeladmin.views import CreateView, InstanceSpecificView diff --git a/hypha/apply/review/blocks.py b/hypha/apply/review/blocks.py index 34b46d64..fd433080 100644 --- a/hypha/apply/review/blocks.py +++ b/hypha/apply/review/blocks.py @@ -1,15 +1,27 @@ import json from django import forms - from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ - from wagtail.core.blocks import RichTextBlock from hypha.apply.review.fields import ScoredAnswerField -from hypha.apply.review.options import RECOMMENDATION_CHOICES, RATE_CHOICES_DICT, RATE_CHOICE_NA, NA, VISIBILITY, VISIBILILTY_HELP_TEXT, PRIVATE -from hypha.apply.stream_forms.blocks import OptionalFormFieldBlock, CharFieldBlock, TextFieldBlock, CheckboxFieldBlock, DropdownFieldBlock +from hypha.apply.review.options import ( + NA, + PRIVATE, + RATE_CHOICE_NA, + RATE_CHOICES_DICT, + RECOMMENDATION_CHOICES, + VISIBILILTY_HELP_TEXT, + VISIBILITY, +) +from hypha.apply.stream_forms.blocks import ( + CharFieldBlock, + CheckboxFieldBlock, + DropdownFieldBlock, + OptionalFormFieldBlock, + TextFieldBlock, +) from hypha.apply.utils.blocks import CustomFormFieldsBlock, MustIncludeFieldBlock from hypha.apply.utils.options import RICH_TEXT_WIDGET_SHORT diff --git a/hypha/apply/review/fields.py b/hypha/apply/review/fields.py index ac2529a3..1750f265 100644 --- a/hypha/apply/review/fields.py +++ b/hypha/apply/review/fields.py @@ -1,10 +1,9 @@ from django import forms -from tinymce import TinyMCE - from django.forms import widgets from django.utils.safestring import mark_safe +from tinymce import TinyMCE -from hypha.apply.review.options import RATE_CHOICES, NA +from hypha.apply.review.options import NA, RATE_CHOICES from hypha.apply.utils.options import MCE_ATTRIBUTES_SHORT diff --git a/hypha/apply/review/management/commands/migration_review_base.py b/hypha/apply/review/management/commands/migration_review_base.py index 7a76fcef..7ef22d25 100644 --- a/hypha/apply/review/management/commands/migration_review_base.py +++ b/hypha/apply/review/management/commands/migration_review_base.py @@ -1,6 +1,5 @@ import argparse import json - from datetime import datetime, timezone from django.contrib.auth import get_user_model @@ -8,8 +7,8 @@ from django.db import transaction from django.db.utils import IntegrityError -from hypha.apply.funds.models import ApplicationSubmission, Round, LabType -from hypha.apply.funds.models.forms import RoundBaseReviewForm, LabBaseReviewForm +from hypha.apply.funds.models import ApplicationSubmission, LabType, Round +from hypha.apply.funds.models.forms import LabBaseReviewForm, RoundBaseReviewForm from hypha.apply.review.models import Review from hypha.apply.review.options import NA diff --git a/hypha/apply/review/models.py b/hypha/apply/review/models.py index 99f7822d..0f91ec9d 100644 --- a/hypha/apply/review/models.py +++ b/hypha/apply/review/models.py @@ -9,16 +9,31 @@ from hypha.apply.funds.models.mixins import AccessFormData from hypha.apply.stream_forms.models import BaseStreamForm -from hypha.apply.users.groups import STAFF_GROUP_NAME, REVIEWER_GROUP_NAME, PARTNER_GROUP_NAME +from hypha.apply.users.groups import ( + PARTNER_GROUP_NAME, + REVIEWER_GROUP_NAME, + STAFF_GROUP_NAME, +) from .blocks import ( - ReviewCustomFormFieldsBlock, RecommendationBlock, RecommendationCommentsBlock, + ReviewCustomFormFieldsBlock, ScoreFieldBlock, VisibilityBlock, ) -from .options import NA, YES, NO, MAYBE, RECOMMENDATION_CHOICES, DISAGREE, OPINION_CHOICES, VISIBILITY, PRIVATE, REVIEWER +from .options import ( + DISAGREE, + MAYBE, + NA, + NO, + OPINION_CHOICES, + PRIVATE, + RECOMMENDATION_CHOICES, + REVIEWER, + VISIBILITY, + YES, +) class ReviewFormFieldsMixin(models.Model): diff --git a/hypha/apply/review/tests/factories/__init__.py b/hypha/apply/review/tests/factories/__init__.py index c9d2b8eb..609b423a 100644 --- a/hypha/apply/review/tests/factories/__init__.py +++ b/hypha/apply/review/tests/factories/__init__.py @@ -1,7 +1,6 @@ -from . import models -from .models import * # noqa -from . import blocks +from . import blocks, models from .blocks import * # noqa +from .models import * # noqa __all__ = [] diff --git a/hypha/apply/review/tests/factories/blocks.py b/hypha/apply/review/tests/factories/blocks.py index 1a0e4732..a3b651dc 100644 --- a/hypha/apply/review/tests/factories/blocks.py +++ b/hypha/apply/review/tests/factories/blocks.py @@ -1,11 +1,15 @@ import json import random + import factory from hypha.apply.review import blocks -from hypha.apply.review.options import YES, MAYBE, NO, PRIVATE, REVIEWER -from hypha.apply.stream_forms.testing.factories import FormFieldBlockFactory, CharFieldBlockFactory, \ - StreamFieldUUIDFactory +from hypha.apply.review.options import MAYBE, NO, PRIVATE, REVIEWER, YES +from hypha.apply.stream_forms.testing.factories import ( + CharFieldBlockFactory, + FormFieldBlockFactory, + StreamFieldUUIDFactory, +) from hypha.apply.utils.testing.factories import RichTextFieldBlockFactory __all__ = ['ReviewFormFieldsFactory', 'RecommendationBlockFactory', 'ScoreFieldBlockFactory'] diff --git a/hypha/apply/review/tests/factories/models.py b/hypha/apply/review/tests/factories/models.py index 7c4a84ea..97c72de3 100644 --- a/hypha/apply/review/tests/factories/models.py +++ b/hypha/apply/review/tests/factories/models.py @@ -1,11 +1,13 @@ import factory -from hypha.apply.funds.tests.factories import ApplicationSubmissionFactory, AssignedReviewersFactory +from hypha.apply.funds.tests.factories import ( + ApplicationSubmissionFactory, + AssignedReviewersFactory, +) from hypha.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/hypha/apply/review/tests/test_admin.py b/hypha/apply/review/tests/test_admin.py index 544653d6..56b02b38 100644 --- a/hypha/apply/review/tests/test_admin.py +++ b/hypha/apply/review/tests/test_admin.py @@ -1,6 +1,7 @@ from unittest import TestCase from hypha.apply.review.models import ReviewForm + from .factories import ReviewFormFactory diff --git a/hypha/apply/review/tests/test_models.py b/hypha/apply/review/tests/test_models.py index 498de981..e5118599 100644 --- a/hypha/apply/review/tests/test_models.py +++ b/hypha/apply/review/tests/test_models.py @@ -1,8 +1,9 @@ from django.test import TestCase from hypha.apply.funds.tests.factories import ApplicationSubmissionFactory -from .factories import ReviewFactory, ReviewOpinionFactory + from ..options import MAYBE, NO, YES +from .factories import ReviewFactory, ReviewOpinionFactory class TestReviewQueryset(TestCase): diff --git a/hypha/apply/review/tests/test_views.py b/hypha/apply/review/tests/test_views.py index fb7608d6..f92f26f6 100644 --- a/hypha/apply/review/tests/test_views.py +++ b/hypha/apply/review/tests/test_views.py @@ -5,9 +5,14 @@ from hypha.apply.users.tests.factories import ReviewerFactory, StaffFactory, UserFactory from hypha.apply.utils.testing.tests import BaseViewTestCase -from .factories import ReviewFactory, ReviewFormFieldsFactory, ReviewFormFactory, ReviewOpinionFactory from ..models import Review, ReviewOpinion -from ..options import NA, AGREE, DISAGREE +from ..options import AGREE, DISAGREE, NA +from .factories import ( + ReviewFactory, + ReviewFormFactory, + ReviewFormFieldsFactory, + ReviewOpinionFactory, +) class StaffReviewsTestCase(BaseViewTestCase): diff --git a/hypha/apply/review/urls.py b/hypha/apply/review/urls.py index e7d575eb..0d389652 100644 --- a/hypha/apply/review/urls.py +++ b/hypha/apply/review/urls.py @@ -1,6 +1,12 @@ from django.urls import path -from .views import ReviewDetailView, ReviewListView, ReviewCreateOrUpdateView, ReviewDeleteView, ReviewEditView +from .views import ( + ReviewCreateOrUpdateView, + ReviewDeleteView, + ReviewDetailView, + ReviewEditView, + ReviewListView, +) app_name = 'reviews' diff --git a/hypha/apply/review/views.py b/hypha/apply/review/views.py index 135f13c1..a6e75b4e 100644 --- a/hypha/apply/review/views.py +++ b/hypha/apply/review/views.py @@ -6,11 +6,16 @@ from django.template.loader import get_template from django.urls import reverse_lazy from django.utils.decorators import method_decorator -from django.views.generic import CreateView, ListView, DetailView, DeleteView, UpdateView - +from django.views.generic import ( + CreateView, + DeleteView, + DetailView, + ListView, + UpdateView, +) from wagtail.core.blocks import RichTextBlock -from hypha.apply.activity.messaging import messenger, MESSAGES +from hypha.apply.activity.messaging import MESSAGES, messenger from hypha.apply.funds.models import ApplicationSubmission, AssignedReviewers from hypha.apply.funds.workflow import INITIAL_STATE from hypha.apply.review.blocks import RecommendationBlock, RecommendationCommentsBlock @@ -18,8 +23,8 @@ from hypha.apply.stream_forms.models import BaseStreamForm from hypha.apply.users.decorators import staff_required from hypha.apply.users.groups import REVIEWER_GROUP_NAME -from hypha.apply.utils.views import CreateOrUpdateView from hypha.apply.utils.image import generate_image_tag +from hypha.apply.utils.views import CreateOrUpdateView from .models import Review from .options import DISAGREE diff --git a/hypha/apply/review/wagtail_hooks.py b/hypha/apply/review/wagtail_hooks.py index 71f122fb..64cad0a7 100644 --- a/hypha/apply/review/wagtail_hooks.py +++ b/hypha/apply/review/wagtail_hooks.py @@ -1,5 +1,4 @@ from django.contrib.auth.models import Permission - from wagtail.core import hooks diff --git a/hypha/apply/stream_forms/blocks.py b/hypha/apply/stream_forms/blocks.py index 09b37619..7c454d3f 100644 --- a/hypha/apply/stream_forms/blocks.py +++ b/hypha/apply/stream_forms/blocks.py @@ -1,8 +1,6 @@ # Credit to https://github.com/BertrandBordage for initial implementation import bleach from dateutil.parser import isoparse, parse -from django_bleach.templatetags.bleach_tags import bleach_value - from django import forms from django.conf import settings from django.core.validators import FileExtensionValidator @@ -12,10 +10,22 @@ from django.utils.encoding import force_str from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ +from django_bleach.templatetags.bleach_tags import bleach_value from unidecode import unidecode from wagtail.core.blocks import ( - StructBlock, TextBlock, CharBlock, BooleanBlock, ListBlock, StreamBlock, - DateBlock, TimeBlock, DateTimeBlock, ChoiceBlock, RichTextBlock, StaticBlock, URLBlock + BooleanBlock, + CharBlock, + ChoiceBlock, + DateBlock, + DateTimeBlock, + ListBlock, + RichTextBlock, + StaticBlock, + StreamBlock, + StructBlock, + TextBlock, + TimeBlock, + URLBlock, ) from .fields import MultiFileField diff --git a/hypha/apply/stream_forms/fields.py b/hypha/apply/stream_forms/fields.py index e8ab5336..e2f630ae 100644 --- a/hypha/apply/stream_forms/fields.py +++ b/hypha/apply/stream_forms/fields.py @@ -1,6 +1,6 @@ from django.conf import settings from django.core.validators import FileExtensionValidator -from django.forms import ClearableFileInput, FileField, CheckboxInput +from django.forms import CheckboxInput, ClearableFileInput, FileField class MultiFileInput(ClearableFileInput): diff --git a/hypha/apply/stream_forms/forms.py b/hypha/apply/stream_forms/forms.py index d4de59b9..d503b3d7 100644 --- a/hypha/apply/stream_forms/forms.py +++ b/hypha/apply/stream_forms/forms.py @@ -1,6 +1,5 @@ from django import forms from django.forms.forms import DeclarativeFieldsMetaclass - from wagtail.contrib.forms.forms import BaseForm diff --git a/hypha/apply/stream_forms/testing/factories.py b/hypha/apply/stream_forms/testing/factories.py index 4520f19c..49d7c5bf 100644 --- a/hypha/apply/stream_forms/testing/factories.py +++ b/hypha/apply/stream_forms/testing/factories.py @@ -1,13 +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 from django.core.serializers.json import DjangoJSONEncoder -import factory from wagtail.core.blocks import RichTextBlock from wagtail.core.rich_text import RichText -import wagtail_factories from hypha.apply.stream_forms import blocks as stream_blocks diff --git a/hypha/apply/stream_forms/tests.py b/hypha/apply/stream_forms/tests.py index 52fe2970..3fa97e3c 100644 --- a/hypha/apply/stream_forms/tests.py +++ b/hypha/apply/stream_forms/tests.py @@ -1,11 +1,10 @@ from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase - from faker import Faker -from .files import StreamFieldFile -from .fields import MultiFileField, MultiFileInput from .blocks import FormFieldBlock, FormFieldsBlock +from .fields import MultiFileField, MultiFileInput +from .files import StreamFieldFile fake = Faker() diff --git a/hypha/apply/urls.py b/hypha/apply/urls.py index c290ceb9..080d7bcf 100644 --- a/hypha/apply/urls.py +++ b/hypha/apply/urls.py @@ -1,15 +1,13 @@ 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 .api import urls as api_urls - from hypha.urls import base_urlpatterns +from .api import urls as api_urls +from .dashboard import urls as dashboard_urls +from .users import urls as users_urls +from .utils import views urlpatterns = [ path('apply/', include('hypha.apply.funds.urls', 'apply')), diff --git a/hypha/apply/users/admin_views.py b/hypha/apply/users/admin_views.py index 77826bdc..643dfcf8 100644 --- a/hypha/apply/users/admin_views.py +++ b/hypha/apply/users/admin_views.py @@ -4,7 +4,6 @@ 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.search 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/hypha/apply/users/decorators.py b/hypha/apply/users/decorators.py index b41a4aae..726113b5 100644 --- a/hypha/apply/users/decorators.py +++ b/hypha/apply/users/decorators.py @@ -1,5 +1,5 @@ -from django.core.exceptions import PermissionDenied from django.contrib.auth.decorators import login_required, user_passes_test +from django.core.exceptions import PermissionDenied from .utils import can_use_oauth_check diff --git a/hypha/apply/users/forms.py b/hypha/apply/users/forms.py index d89f45a9..7b74060d 100644 --- a/hypha/apply/users/forms.py +++ b/hypha/apply/users/forms.py @@ -1,10 +1,8 @@ from django import forms from django.contrib.auth import get_user_model from django.utils.translation import gettext_lazy as _ - -from wagtail.users.forms import UserEditForm, UserCreationForm - from django_select2.forms import Select2Widget +from wagtail.users.forms import UserCreationForm, UserEditForm User = get_user_model() diff --git a/hypha/apply/users/middleware.py b/hypha/apply/users/middleware.py index 8affe31b..4ebdf2d0 100644 --- a/hypha/apply/users/middleware.py +++ b/hypha/apply/users/middleware.py @@ -1,5 +1,7 @@ from social_core.exceptions import AuthForbidden -from social_django.middleware import SocialAuthExceptionMiddleware as _SocialAuthExceptionMiddleware +from social_django.middleware import ( + SocialAuthExceptionMiddleware as _SocialAuthExceptionMiddleware, +) class SocialAuthExceptionMiddleware(_SocialAuthExceptionMiddleware): diff --git a/hypha/apply/users/models.py b/hypha/apply/users/models.py index 1c60d84b..a00f87cd 100644 --- a/hypha/apply/users/models.py +++ b/hypha/apply/users/models.py @@ -5,9 +5,14 @@ from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ -from .groups import (APPLICANT_GROUP_NAME, APPROVER_GROUP_NAME, - COMMUNITY_REVIEWER_GROUP_NAME, PARTNER_GROUP_NAME, - REVIEWER_GROUP_NAME, STAFF_GROUP_NAME) +from .groups import ( + APPLICANT_GROUP_NAME, + APPROVER_GROUP_NAME, + COMMUNITY_REVIEWER_GROUP_NAME, + PARTNER_GROUP_NAME, + REVIEWER_GROUP_NAME, + STAFF_GROUP_NAME, +) from .utils import send_activation_email diff --git a/hypha/apply/users/tests/factories.py b/hypha/apply/users/tests/factories.py index 0fb5bee1..f9b4b231 100644 --- a/hypha/apply/users/tests/factories.py +++ b/hypha/apply/users/tests/factories.py @@ -1,11 +1,10 @@ import uuid +import factory from django.contrib.auth import get_user_model from django.contrib.auth.models import Group from django.utils.text import slugify -import factory - from ..groups import ( APPLICANT_GROUP_NAME, APPROVER_GROUP_NAME, diff --git a/hypha/apply/users/tests/test_oauth_access.py b/hypha/apply/users/tests/test_oauth_access.py index 4fa5c4b4..8de97b56 100644 --- a/hypha/apply/users/tests/test_oauth_access.py +++ b/hypha/apply/users/tests/test_oauth_access.py @@ -1,5 +1,5 @@ -from django.contrib.auth import get_user_model from django.conf import settings +from django.contrib.auth import get_user_model from django.test import TestCase, override_settings from django.urls import reverse diff --git a/hypha/apply/users/tests/test_views.py b/hypha/apply/users/tests/test_views.py index 49fb30d8..1529f86f 100644 --- a/hypha/apply/users/tests/test_views.py +++ b/hypha/apply/users/tests/test_views.py @@ -1,14 +1,10 @@ from django.core import mail -from django.test import override_settings, TestCase +from django.test import TestCase, override_settings from django.urls import reverse from hypha.apply.utils.testing.tests import BaseViewTestCase -from .factories import ( - OAuthUserFactory, - StaffFactory, - SuperUserFactory, - UserFactory, -) + +from .factories import OAuthUserFactory, StaffFactory, SuperUserFactory, UserFactory @override_settings(ROOT_URLCONF='hypha.apply.urls') diff --git a/hypha/apply/users/urls.py b/hypha/apply/users/urls.py index 943ea9c9..ee0affa8 100644 --- a/hypha/apply/users/urls.py +++ b/hypha/apply/users/urls.py @@ -1,9 +1,14 @@ -from django.urls import path, include from django.contrib.auth import views as auth_views -from django.urls import reverse_lazy - -from hypha.apply.users.views import LoginView, AccountView, become, oauth, ActivationView, create_password +from django.urls import include, path, reverse_lazy +from hypha.apply.users.views import ( + AccountView, + ActivationView, + LoginView, + become, + create_password, + oauth, +) app_name = 'users' diff --git a/hypha/apply/users/utils.py b/hypha/apply/users/utils.py index d5560027..f044ec2f 100644 --- a/hypha/apply/users/utils.py +++ b/hypha/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/hypha/apply/users/views.py b/hypha/apply/users/views.py index 91cc1102..d7a1fd35 100644 --- a/hypha/apply/users/views.py +++ b/hypha/apply/users/views.py @@ -18,16 +18,13 @@ 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/hypha/apply/users/wagtail_hooks.py b/hypha/apply/users/wagtail_hooks.py index f0b7fbdd..7c33cead 100644 --- a/hypha/apply/users/wagtail_hooks.py +++ b/hypha/apply/users/wagtail_hooks.py @@ -1,6 +1,5 @@ from django.conf.urls import url from django.urls import reverse - from wagtail.core import hooks from hypha.apply.utils.notifications import slack_notify diff --git a/hypha/apply/utils/blocks.py b/hypha/apply/utils/blocks.py index 17193826..76c8ef55 100644 --- a/hypha/apply/utils/blocks.py +++ b/hypha/apply/utils/blocks.py @@ -1,16 +1,18 @@ from collections import Counter -from pagedown.widgets import PagedownWidget import bleach - from django.core.exceptions import ValidationError from django.forms.utils import ErrorList -from django.utils.translation import ugettext_lazy as _ from django.utils.safestring import mark_safe +from django.utils.translation import ugettext_lazy as _ +from pagedown.widgets import PagedownWidget +from wagtail.core.blocks import StaticBlock, StreamBlock, StreamValue -from wagtail.core.blocks import StaticBlock, StreamValue, StreamBlock - -from hypha.apply.stream_forms.blocks import FormFieldBlock, OptionalFormFieldBlock, TextFieldBlock +from hypha.apply.stream_forms.blocks import ( + FormFieldBlock, + OptionalFormFieldBlock, + TextFieldBlock, +) from hypha.apply.utils.options import RICH_TEXT_WIDGET diff --git a/hypha/apply/utils/notifications.py b/hypha/apply/utils/notifications.py index 037b23a3..13e403e4 100644 --- a/hypha/apply/utils/notifications.py +++ b/hypha/apply/utils/notifications.py @@ -1,5 +1,4 @@ import requests - from django.conf import settings diff --git a/hypha/apply/utils/pdfs.py b/hypha/apply/utils/pdfs.py index e44e6898..505b9c2d 100644 --- a/hypha/apply/utils/pdfs.py +++ b/hypha/apply/utils/pdfs.py @@ -1,6 +1,7 @@ -import os import io +import os +from bs4 import BeautifulSoup, NavigableString from reportlab.lib import pagesizes from reportlab.lib.colors import Color, white from reportlab.lib.styles import ParagraphStyle as PS @@ -18,9 +19,6 @@ TableStyle, ) - -from bs4 import BeautifulSoup, NavigableString - styles = { 'Question': PS(fontName='MontserratBold', fontSize=14, name='Question', spaceAfter=0, spaceBefore=18, leading=21), 'Normal': PS(fontName='NotoSans', name='Normal'), diff --git a/hypha/apply/utils/storage.py b/hypha/apply/utils/storage.py index f431b200..5e65e8be 100644 --- a/hypha/apply/utils/storage.py +++ b/hypha/apply/utils/storage.py @@ -3,7 +3,6 @@ from django.http import FileResponse from django.views.generic import View - private_file_storage = getattr(settings, 'PRIVATE_FILE_STORAGE', None) PrivateStorage = get_storage_class(private_file_storage) diff --git a/hypha/apply/utils/testing/__init__.py b/hypha/apply/utils/testing/__init__.py index 51bee7cf..54393063 100644 --- a/hypha/apply/utils/testing/__init__.py +++ b/hypha/apply/utils/testing/__init__.py @@ -1 +1 @@ -from .tests import make_request, BaseViewTestCase # NOQA +from .tests import BaseViewTestCase, make_request # NOQA diff --git a/hypha/apply/utils/testing/tests.py b/hypha/apply/utils/testing/tests.py index 3fec6e08..f3b2592c 100644 --- a/hypha/apply/utils/testing/tests.py +++ b/hypha/apply/utils/testing/tests.py @@ -1,9 +1,8 @@ -from django.contrib.messages.storage.fallback import FallbackStorage from django.contrib.auth.models import AnonymousUser -from django.test import override_settings, TestCase, RequestFactory +from django.contrib.messages.storage.fallback import FallbackStorage +from django.test import RequestFactory, TestCase, override_settings from django.urls import reverse - request_factory = RequestFactory() diff --git a/hypha/apply/utils/views.py b/hypha/apply/utils/views.py index 5f01b74d..0e7d6174 100644 --- a/hypha/apply/utils/views.py +++ b/hypha/apply/utils/views.py @@ -1,13 +1,13 @@ from django.contrib.auth.decorators import login_required from django.forms.models import ModelForm from django.http import HttpResponseForbidden +from django.shortcuts import redirect from django.utils.decorators import method_decorator from django.views import defaults from django.views.generic import View from django.views.generic.base import ContextMixin from django.views.generic.detail import SingleObjectTemplateResponseMixin from django.views.generic.edit import ModelFormMixin, ProcessFormView -from django.shortcuts import redirect def page_not_found(request, exception=None, template_name='apply/404.html'): diff --git a/hypha/images/models.py b/hypha/images/models.py index dbc5e50c..6ae7525c 100644 --- a/hypha/images/models.py +++ b/hypha/images/models.py @@ -1,9 +1,5 @@ from django.db import models -from wagtail.images.models import ( - AbstractImage, - AbstractRendition, - Image, -) +from wagtail.images.models import AbstractImage, AbstractRendition, Image # We define our own custom image class to replace wagtailimages.Image, diff --git a/hypha/public/forms/models.py b/hypha/public/forms/models.py index a0cb6b66..b5f4af0e 100644 --- a/hypha/public/forms/models.py +++ b/hypha/public/forms/models.py @@ -1,25 +1,28 @@ -import os import json +import os +from django.conf import settings from django.core.files.storage import get_storage_class from django.core.serializers.json import DjangoJSONEncoder -from django.conf import settings from django.db import models from django.forms import FileField from django.utils.decorators import method_decorator from django.utils.translation import ugettext_lazy as _ from django.views.decorators.cache import never_cache - from modelcluster.fields import ParentalKey - -from wagtail.core.fields import RichTextField from wagtail.admin.edit_handlers import ( - FieldPanel, FieldRowPanel, MultiFieldPanel, InlinePanel + FieldPanel, + FieldRowPanel, + InlinePanel, + MultiFieldPanel, ) from wagtail.contrib.forms.forms import FormBuilder from wagtail.contrib.forms.models import ( - AbstractEmailForm, AbstractFormField, FORM_FIELD_CHOICES + FORM_FIELD_CHOICES, + AbstractEmailForm, + AbstractFormField, ) +from wagtail.core.fields import RichTextField from wagtail.search import index from hypha.public.utils.models import BasePage diff --git a/hypha/public/forms/wagtail_hooks.py b/hypha/public/forms/wagtail_hooks.py index fc2f84a6..6bf68a1f 100644 --- a/hypha/public/forms/wagtail_hooks.py +++ b/hypha/public/forms/wagtail_hooks.py @@ -1,5 +1,4 @@ from django.contrib.contenttypes.models import ContentType - from wagtail.core import hooks from hypha.public.forms.models import FormPage diff --git a/hypha/public/funds/models.py b/hypha/public/funds/models.py index 3d848007..75511e17 100644 --- a/hypha/public/funds/models.py +++ b/hypha/public/funds/models.py @@ -1,13 +1,11 @@ from django.conf import settings +from django.core import validators from django.core.exceptions import ValidationError from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator -from django.core import validators from django.db import models from django.utils.deconstruct import deconstructible - from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -22,10 +20,7 @@ from hypha.apply.funds.models import ApplicationSubmission from hypha.apply.funds.workflow import OPEN_CALL_PHASES -from hypha.public.utils.models import ( - BasePage, - RelatedPage, -) +from hypha.public.utils.models import BasePage, RelatedPage from .blocks import FundBlock, LabBlock diff --git a/hypha/public/home/blocks.py b/hypha/public/home/blocks.py index c7e9dddc..50da83dc 100644 --- a/hypha/public/home/blocks.py +++ b/hypha/public/home/blocks.py @@ -1,5 +1,4 @@ from wagtail.core import blocks - from wagtail.images.blocks import ImageChooserBlock diff --git a/hypha/public/home/models.py b/hypha/public/home/models.py index 10d9bc99..d2598eb8 100644 --- a/hypha/public/home/models.py +++ b/hypha/public/home/models.py @@ -1,15 +1,19 @@ import datetime -from django.db import models +from django.db import models from modelcluster.fields import ParentalKey - -from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, PageChooserPanel, MultiFieldPanel, StreamFieldPanel +from wagtail.admin.edit_handlers import ( + FieldPanel, + InlinePanel, + MultiFieldPanel, + PageChooserPanel, + StreamFieldPanel, +) from wagtail.core.fields import StreamField from wagtail.search import index -from hypha.public.utils.models import BasePage, RelatedPage - from hypha.public.funds.models import FundPage, LabPage, RFPPage +from hypha.public.utils.models import BasePage, RelatedPage from .blocks import OurWorkBlock diff --git a/hypha/public/home/templatetags/home_tags.py b/hypha/public/home/templatetags/home_tags.py index 48902fb8..5e4e4386 100644 --- a/hypha/public/home/templatetags/home_tags.py +++ b/hypha/public/home/templatetags/home_tags.py @@ -1,7 +1,6 @@ from django import template from django.utils.safestring import mark_safe - register = template.Library() diff --git a/hypha/public/mailchimp/models.py b/hypha/public/mailchimp/models.py index b337a66a..300bd401 100644 --- a/hypha/public/mailchimp/models.py +++ b/hypha/public/mailchimp/models.py @@ -1,5 +1,4 @@ from django.db import models - from wagtail.admin.edit_handlers import FieldPanel from wagtail.contrib.settings.models import BaseSetting, register_setting diff --git a/hypha/public/mailchimp/tests.py b/hypha/public/mailchimp/tests.py index 1b91ba01..772cc990 100644 --- a/hypha/public/mailchimp/tests.py +++ b/hypha/public/mailchimp/tests.py @@ -1,12 +1,10 @@ -from urllib import parse -from unittest import mock import re - -from django.test import override_settings, TestCase -from django.urls import reverse +from unittest import mock +from urllib import parse import responses - +from django.test import TestCase, override_settings +from django.urls import reverse any_url = re.compile(".") diff --git a/hypha/public/mailchimp/urls.py b/hypha/public/mailchimp/urls.py index 4fe8fd70..f6500f54 100644 --- a/hypha/public/mailchimp/urls.py +++ b/hypha/public/mailchimp/urls.py @@ -2,7 +2,6 @@ from .views import MailchimpSubscribeView - app_name = 'newsletter' diff --git a/hypha/public/mailchimp/views.py b/hypha/public/mailchimp/views.py index 84b4b2ab..8efd3640 100644 --- a/hypha/public/mailchimp/views.py +++ b/hypha/public/mailchimp/views.py @@ -1,5 +1,4 @@ import logging - import uuid from django.conf import settings @@ -10,7 +9,6 @@ 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/hypha/public/navigation/models.py b/hypha/public/navigation/models.py index adce6c8a..8bdde4a9 100644 --- a/hypha/public/navigation/models.py +++ b/hypha/public/navigation/models.py @@ -1,6 +1,6 @@ from modelcluster.models import ClusterableModel -from wagtail.contrib.settings.models import BaseSetting, register_setting from wagtail.admin.edit_handlers import StreamFieldPanel +from wagtail.contrib.settings.models import BaseSetting, register_setting from wagtail.core import blocks from wagtail.core.fields import StreamField diff --git a/hypha/public/navigation/templatetags/navigation_tags.py b/hypha/public/navigation/templatetags/navigation_tags.py index 2b7f4bb7..e474fd01 100644 --- a/hypha/public/navigation/templatetags/navigation_tags.py +++ b/hypha/public/navigation/templatetags/navigation_tags.py @@ -2,7 +2,6 @@ from hypha.public.navigation.models import NavigationSettings - register = template.Library() diff --git a/hypha/public/news/feeds.py b/hypha/public/news/feeds.py index 54550250..cee735c3 100644 --- a/hypha/public/news/feeds.py +++ b/hypha/public/news/feeds.py @@ -3,10 +3,9 @@ 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 hypha.public.news.models import NewsPage, NewsType, NewsIndex, NewsFeedSettings +from hypha.public.news.models import NewsFeedSettings, NewsIndex, NewsPage, NewsType class NewsFeed(Feed): diff --git a/hypha/public/news/management/commands/migrate_news.py b/hypha/public/news/management/commands/migrate_news.py index bc518bfe..0c82a63c 100644 --- a/hypha/public/news/management/commands/migrate_news.py +++ b/hypha/public/news/management/commands/migrate_news.py @@ -1,28 +1,26 @@ import argparse import json - from datetime import datetime, timezone from django.core.management.base import BaseCommand from django.db import transaction from django.db.utils import IntegrityError - from wagtail.admin.rich_text.converters.editor_html import EditorHTMLConverter from wagtail.core.rich_text import RichText -from hypha.apply.categories.models import Category, Option from hypha.apply.categories.categories_seed import CATEGORIES +from hypha.apply.categories.models import Category, Option from hypha.apply.users.models import User -from hypha.public.people.models import PersonPage -from hypha.public.projects.models import ProjectPage from hypha.public.news.models import ( NewsIndex, NewsPage, NewsPageAuthor, - NewsType, NewsPageNewsType, NewsProjectRelatedPage, + NewsType, ) +from hypha.public.people.models import PersonPage +from hypha.public.projects.models import ProjectPage class Command(BaseCommand): diff --git a/hypha/public/news/models.py b/hypha/public/news/models.py index 8b1d43ab..c860f6bb 100644 --- a/hypha/public/news/models.py +++ b/hypha/public/news/models.py @@ -1,20 +1,18 @@ -from django.db import models -from django.db.models.functions import Coalesce from django.conf import settings from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator - +from django.db import models +from django.db.models.functions import Coalesce from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - -from wagtail.core.models import Orderable -from wagtail.core.fields import StreamField from wagtail.admin.edit_handlers import ( - InlinePanel, FieldPanel, + InlinePanel, PageChooserPanel, StreamFieldPanel, ) from wagtail.contrib.settings.models import BaseSetting, register_setting +from wagtail.core.fields import StreamField +from wagtail.core.models import Orderable from wagtail.search import index from hypha.public.utils.models import BasePage, RelatedPage diff --git a/hypha/public/people/management/commands/migrate_people.py b/hypha/public/people/management/commands/migrate_people.py index 770cc24e..6780ec45 100644 --- a/hypha/public/people/management/commands/migrate_people.py +++ b/hypha/public/people/management/commands/migrate_people.py @@ -2,39 +2,35 @@ import itertools import json import mimetypes - from datetime import datetime, timezone -from urllib.parse import urlsplit from io import BytesIO - -import requests -from PIL import Image +from urllib.parse import urlsplit import bleach +import requests from django.core.files.images import ImageFile from django.core.management.base import BaseCommand from django.db import transaction from django.db.utils import IntegrityError - +from PIL import Image from wagtail.admin.rich_text.converters.editor_html import EditorHTMLConverter from wagtail.core.models import Page from wagtail.core.rich_text import RichText from wagtail.images import get_image_model -from hypha.apply.categories.models import Category, Option from hypha.apply.categories.categories_seed import CATEGORIES +from hypha.apply.categories.models import Category, Option from hypha.public.people.models import ( Funding, FundReviewers, PersonContactInfomation, - PersonPage, PersonIndexPage, - PersonType, + PersonPage, PersonPagePersonType, + PersonType, SocialMediaProfile, ) - WagtailImage = get_image_model() VALID_IMAGE_EXTENSIONS = [ diff --git a/hypha/public/people/models.py b/hypha/public/people/models.py index 256314f9..dc2e6864 100644 --- a/hypha/public/people/models.py +++ b/hypha/public/people/models.py @@ -1,26 +1,24 @@ -from django.db import models +from django.conf import settings from django.core.exceptions import ValidationError from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator -from django.conf import settings - +from django.db import models from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - -from wagtail.core.models import Orderable, PageManager, PageQuerySet -from wagtail.core.fields import StreamField from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel, PageChooserPanel, - StreamFieldPanel + StreamFieldPanel, ) +from wagtail.core.fields import StreamField +from wagtail.core.models import Orderable, PageManager, PageQuerySet from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.search import index from hypha.public.utils.blocks import StoryBlock -from hypha.public.utils.models import BasePage, BaseFunding, FundingMixin, RelatedPage +from hypha.public.utils.models import BaseFunding, BasePage, FundingMixin, RelatedPage class SocialMediaProfile(models.Model): diff --git a/hypha/public/people/wagtail_hooks.py b/hypha/public/people/wagtail_hooks.py index ed2a0fce..25fd275c 100644 --- a/hypha/public/people/wagtail_hooks.py +++ b/hypha/public/people/wagtail_hooks.py @@ -1,6 +1,5 @@ from django.contrib.staticfiles.templatetags.staticfiles import static from django.utils.safestring import mark_safe - from wagtail.core import hooks diff --git a/hypha/public/projects/management/commands/migrate_projects.py b/hypha/public/projects/management/commands/migrate_projects.py index 4279079a..93d4aaf6 100644 --- a/hypha/public/projects/management/commands/migrate_projects.py +++ b/hypha/public/projects/management/commands/migrate_projects.py @@ -2,27 +2,24 @@ import itertools import json import mimetypes - from datetime import datetime, timezone -from urllib.parse import urlsplit from io import BytesIO - -import requests -from PIL import Image +from urllib.parse import urlsplit import bleach +import requests from django.core.files.images import ImageFile from django.core.management.base import BaseCommand from django.db import transaction from django.db.utils import IntegrityError - +from PIL import Image from wagtail.admin.rich_text.converters.editor_html import EditorHTMLConverter from wagtail.core.models import Page from wagtail.core.rich_text import RichText from wagtail.images import get_image_model -from hypha.apply.categories.models import Category, Option from hypha.apply.categories.categories_seed import CATEGORIES +from hypha.apply.categories.models import Category, Option from hypha.public.projects.models import ( ProjectContactDetails, ProjectFunding, @@ -30,7 +27,6 @@ ProjectPage, ) - WagtailImage = get_image_model() VALID_IMAGE_EXTENSIONS = [ diff --git a/hypha/public/projects/models.py b/hypha/public/projects/models.py index f3656df2..6cefcf7d 100644 --- a/hypha/public/projects/models.py +++ b/hypha/public/projects/models.py @@ -1,14 +1,12 @@ import json -from django.db import models from django.conf import settings from django.core.exceptions import ValidationError from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.core.validators import URLValidator - +from django.db import models from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - from wagtail.admin.edit_handlers import ( FieldPanel, InlinePanel, @@ -16,19 +14,13 @@ PageChooserPanel, StreamFieldPanel, ) - from wagtail.core.fields import StreamField from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.search import index from hypha.apply.categories.models import Option from hypha.public.utils.blocks import StoryBlock -from hypha.public.utils.models import ( - BaseFunding, - BasePage, - FundingMixin, - RelatedPage, -) +from hypha.public.utils.models import BaseFunding, BasePage, FundingMixin, RelatedPage from .widgets import CategoriesWidget diff --git a/hypha/public/standardpages/models.py b/hypha/public/standardpages/models.py index 01b93997..2de8b3a7 100644 --- a/hypha/public/standardpages/models.py +++ b/hypha/public/standardpages/models.py @@ -1,23 +1,14 @@ -from django.db import models from django.conf import settings from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator - +from django.db import models from modelcluster.fields import ParentalKey from pagedown.widgets import PagedownWidget - -from wagtail.admin.edit_handlers import ( - FieldPanel, StreamFieldPanel, - InlinePanel -) - +from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, StreamFieldPanel from wagtail.core.fields import StreamField from wagtail.search import index from hypha.public.utils.blocks import StoryBlock -from hypha.public.utils.models import ( - BasePage, - RelatedPage, -) +from hypha.public.utils.models import BasePage, RelatedPage class InformationPageRelatedPage(RelatedPage): diff --git a/hypha/public/urls.py b/hypha/public/urls.py index 7d27061f..a1868e48 100644 --- a/hypha/public/urls.py +++ b/hypha/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/hypha/public/utils/models.py b/hypha/public/utils/models.py index f5cf5403..f1e33523 100644 --- a/hypha/public/utils/models.py +++ b/hypha/public/utils/models.py @@ -1,8 +1,7 @@ -from django.core.exceptions import ValidationError from django.conf import settings +from django.core.exceptions import ValidationError from django.db import models from django.utils.decorators import method_decorator - from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, @@ -11,14 +10,13 @@ PageChooserPanel, StreamFieldPanel, ) +from wagtail.contrib.settings.models import BaseSetting, register_setting from wagtail.core import blocks -from wagtail.core.fields import StreamField, RichTextField +from wagtail.core.fields import RichTextField, StreamField from wagtail.core.models import Orderable, Page from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.snippets.models import register_snippet -from wagtail.contrib.settings.models import BaseSetting, register_setting - -from wagtailcache.cache import cache_page, WagtailCacheMixin +from wagtailcache.cache import WagtailCacheMixin, cache_page class LinkFields(models.Model): diff --git a/hypha/public/utils/templatetags/util_tags.py b/hypha/public/utils/templatetags/util_tags.py index d1be553d..270a4eb7 100644 --- a/hypha/public/utils/templatetags/util_tags.py +++ b/hypha/public/utils/templatetags/util_tags.py @@ -1,10 +1,8 @@ from django import template - from wagtail.core.utils import camelcase_to_underscore from hypha.public.utils.models import SocialMediaSettings - register = template.Library() diff --git a/hypha/public/utils/wagtail_hooks.py b/hypha/public/utils/wagtail_hooks.py index 914642e2..12448438 100644 --- a/hypha/public/utils/wagtail_hooks.py +++ b/hypha/public/utils/wagtail_hooks.py @@ -1,8 +1,10 @@ from django.contrib.staticfiles.templatetags.staticfiles import static - -from wagtail.contrib.modeladmin.options import ModelAdminGroup, ModelAdmin, modeladmin_register +from wagtail.contrib.modeladmin.options import ( + ModelAdmin, + ModelAdminGroup, + modeladmin_register, +) from wagtail.core import hooks - from wagtailcache.cache import clear_cache from hypha.public.news.models import NewsType diff --git a/hypha/settings/base.py b/hypha/settings/base.py index 2a3fa51d..f9cedc9c 100644 --- a/hypha/settings/base.py +++ b/hypha/settings/base.py @@ -4,6 +4,7 @@ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os + import dj_database_url env = os.environ.copy() diff --git a/hypha/settings/test.py b/hypha/settings/test.py index b5990e45..ebbfa77f 100644 --- a/hypha/settings/test.py +++ b/hypha/settings/test.py @@ -1,8 +1,9 @@ import logging +from .base import * # noqa + logging.disable(logging.CRITICAL) -from .base import * # noqa # Should only include explicit testing settings diff --git a/hypha/urls.py b/hypha/urls.py index 60db2bb4..d060adff 100644 --- a/hypha/urls.py +++ b/hypha/urls.py @@ -1,18 +1,17 @@ from django.conf import settings -from django.urls import include, path +from django.conf.urls import url from django.contrib import admin +from django.urls import include, path from django.views.generic import TemplateView -from django.conf.urls import url - -from wagtail.contrib.sitemaps.views import sitemap from wagtail.admin import urls as wagtailadmin_urls +from wagtail.contrib.sitemaps.views import sitemap from wagtail.core import urls as wagtail_urls from wagtail.documents import urls as wagtaildocs_urls from wagtail.images.views.serve import ServeView -from hypha.public import urls as public_urls from hypha.apply.users.urls import public_urlpatterns as user_urls from hypha.apply.users.views import LoginView +from hypha.public import urls as public_urls urlpatterns = [ path('django-admin/', admin.site.urls),