From c7003ba04f7797a29d2cb0ff6f6b40a94e5ba692 Mon Sep 17 00:00:00 2001 From: sks444 <krishnasingh.ss30@gmail.com> Date: Thu, 29 Oct 2020 11:36:14 +0530 Subject: [PATCH] Fix linting issues --- hypha/apply/api/v1/screening/views.py | 16 ++++----- hypha/apply/api/v1/serializers.py | 2 +- hypha/apply/api/v1/urls.py | 5 ++- hypha/apply/funds/admin_views.py | 2 +- hypha/apply/funds/forms.py | 10 ++++-- hypha/apply/funds/models/screening.py | 1 + hypha/apply/funds/models/submissions.py | 7 ++-- .../src/javascript/apply/screening-status.js | 34 ++++++++++--------- 8 files changed, 43 insertions(+), 34 deletions(-) diff --git a/hypha/apply/api/v1/screening/views.py b/hypha/apply/api/v1/screening/views.py index 6b4505886..2bc96a0ef 100644 --- a/hypha/apply/api/v1/screening/views.py +++ b/hypha/apply/api/v1/screening/views.py @@ -1,25 +1,21 @@ from django.shortcuts import get_object_or_404 - -from rest_framework import viewsets, permissions, mixins, status -from rest_framework.response import Response -from rest_framework.exceptions import ValidationError -from rest_framework.decorators import action - from django_filters import rest_framework as filters - +from rest_framework import mixins, permissions, status, viewsets +from rest_framework.decorators import action +from rest_framework.exceptions import ValidationError +from rest_framework.response import Response from rest_framework_api_key.permissions import HasAPIKey from hypha.apply.funds.models import ScreeningStatus +from ..mixin import SubmissionNestedMixin from ..pagination import StandardResultsSetPagination from ..permissions import IsApplyStaffUser -from ..mixin import SubmissionNestedMixin - from .filters import ScreeningStatusFilter from .serializers import ( + ScreeningStatusDefaultSerializer, ScreeningStatusListSerializer, ScreeningStatusSerializer, - ScreeningStatusDefaultSerializer ) diff --git a/hypha/apply/api/v1/serializers.py b/hypha/apply/api/v1/serializers.py index bb7fee566..fd9102ebd 100644 --- a/hypha/apply/api/v1/serializers.py +++ b/hypha/apply/api/v1/serializers.py @@ -8,12 +8,12 @@ from hypha.apply.determinations.models import Determination from hypha.apply.determinations.templatetags.determination_tags import ( show_determination_button, ) +from hypha.apply.api.v1.screening.serializers import ScreeningStatusSerializer from hypha.apply.determinations.views import DeterminationCreateOrUpdateView from hypha.apply.funds.models import ApplicationSubmission, RoundsAndLabs from hypha.apply.review.models import Review, ReviewOpinion from hypha.apply.review.options import RECOMMENDATION_CHOICES from hypha.apply.users.groups import PARTNER_GROUP_NAME, STAFF_GROUP_NAME -from hypha.apply.api.v1.screening.serializers import ScreeningStatusSerializer User = get_user_model() diff --git a/hypha/apply/api/v1/urls.py b/hypha/apply/api/v1/urls.py index e1529d339..523a9444d 100644 --- a/hypha/apply/api/v1/urls.py +++ b/hypha/apply/api/v1/urls.py @@ -3,7 +3,10 @@ from rest_framework_nested import routers from hypha.apply.api.v1.determination.views import SubmissionDeterminationViewSet from hypha.apply.api.v1.review.views import SubmissionReviewViewSet -from hypha.apply.api.v1.screening.views import ScreeningStatusViewSet, SubmissionScreeningStatusViewSet +from hypha.apply.api.v1.screening.views import ( + ScreeningStatusViewSet, + SubmissionScreeningStatusViewSet, +) from .views import ( CommentViewSet, diff --git a/hypha/apply/funds/admin_views.py b/hypha/apply/funds/admin_views.py index 8c2371495..1991566d6 100644 --- a/hypha/apply/funds/admin_views.py +++ b/hypha/apply/funds/admin_views.py @@ -5,7 +5,7 @@ from django.utils.translation import gettext_lazy as _ 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, EditView +from wagtail.contrib.modeladmin.views import CreateView from wagtail.core import hooks from wagtail.core.models import Page diff --git a/hypha/apply/funds/forms.py b/hypha/apply/funds/forms.py index 63cc032dd..3714761dc 100644 --- a/hypha/apply/funds/forms.py +++ b/hypha/apply/funds/forms.py @@ -11,7 +11,13 @@ from django_select2.forms import Select2Widget from hypha.apply.categories.models import MetaTerm from hypha.apply.users.models import User -from .models import ApplicationSubmission, AssignedReviewers, Reminder, ReviewerRole, ScreeningStatus +from .models import ( + ApplicationSubmission, + AssignedReviewers, + Reminder, + ReviewerRole, + ScreeningStatus, +) from .utils import render_icon from .widgets import MetaTermSelect2Widget, Select2MultiCheckboxesWidget from .workflow import get_action_mapping @@ -109,7 +115,7 @@ class ScreeningSubmissionForm(ApplicationSubmissionModelForm): self.should_show = False if self.user.is_apply_staff: self.should_show = True - + def clean(self): cleaned_data = super().clean() instance = self.instance diff --git a/hypha/apply/funds/models/screening.py b/hypha/apply/funds/models/screening.py index f60be6017..3c0084f55 100644 --- a/hypha/apply/funds/models/screening.py +++ b/hypha/apply/funds/models/screening.py @@ -1,4 +1,5 @@ from django.db import models + from ..admin_forms import ScreeningStatusAdminForm diff --git a/hypha/apply/funds/models/submissions.py b/hypha/apply/funds/models/submissions.py index 397fd5e75..9d5c02a2a 100644 --- a/hypha/apply/funds/models/submissions.py +++ b/hypha/apply/funds/models/submissions.py @@ -1,7 +1,8 @@ -from functools import partialmethod import json -from django.conf import settings +from functools import partialmethod + from django.apps import apps +from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import Group from django.contrib.contenttypes.fields import GenericRelation @@ -816,7 +817,7 @@ class ApplicationSubmission( @property def has_no_default_screening_status_set(self): return self.screening_statuses.filter(default=True, yes=False).exists() - + @property def can_not_edit_default(self): return self.screening_statuses.all().count() > 1 diff --git a/hypha/static_src/src/javascript/apply/screening-status.js b/hypha/static_src/src/javascript/apply/screening-status.js index 3ad2ccb9c..6d98162b4 100644 --- a/hypha/static_src/src/javascript/apply/screening-status.js +++ b/hypha/static_src/src/javascript/apply/screening-status.js @@ -31,7 +31,7 @@ }); }); - $('.show-screening-options').on('click', '#screening-options-ajax', function(){ + $('.show-screening-options').on('click', '#screening-options-ajax', function () { var $screeningOptions = $(this); var currentStatus = $screeningOptions.data('yes'); @@ -44,32 +44,34 @@ $screeningStatuses = $screeningStatuses.empty(); if (currentStatus === true) { $('#current-status').text('Current statuses: ' + defaultYes); - $.each(yesStatuses, function(key,value) { - if(key === defaultYes) { + $.each(yesStatuses, function (key, value) { + if (key === defaultYes) { $screeningStatuses.append($('<option></option>') - .attr('value', value) - .attr('selected', 'selected').text(key)); + .attr('value', value) + .attr('selected', 'selected').text(key)); } else { $screeningStatuses.append($('<option></option>') - .attr('value', value).text(key)); + .attr('value', value).text(key) + ); } - }); + }); } else { $('#current-status').text('Current statuses: ' + defaultNo); - $.each(noStatuses, function(key,value) { - if(key === defaultNo) { - $screeningStatuses.append($("<option></option>") - .attr("value", value) - .attr("selected","selected").text(key)); + $.each(noStatuses, function (key, value) { + if (key === defaultNo) { + $screeningStatuses.append($('<option></option>') + .attr('value', value) + .attr('selected', 'selected').text(key)); } else { - $screeningStatuses.append($("<option></option>") - .attr("value", value).text(key)); + $screeningStatuses.append($('<option></option>') + .attr('value', value).text(key) + ); } - }); + }); } }); - + })(jQuery); -- GitLab