Skip to content

Commit

Permalink
optimize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Sispheor committed Sep 26, 2023
1 parent e8b14b9 commit 3f8ae1f
Show file tree
Hide file tree
Showing 43 changed files with 52 additions and 79 deletions.
3 changes: 1 addition & 2 deletions profiles/api/serializers/permission_serializers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from profiles.models.squest_permission import Permission
from rest_framework.serializers import ModelSerializer

from profiles.api.serializers import ContentTypeSerializer
from profiles.models.squest_permission import Permission


class PermissionSerializer(ModelSerializer):
Expand Down
3 changes: 1 addition & 2 deletions profiles/api/views/permission_api_views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from profiles.models.squest_permission import Permission

from Squest.utils.squest_api_views import SquestRetrieveUpdateDestroyAPIView, SquestListCreateAPIView
from profiles.api.serializers import PermissionSerializer
from profiles.filters import PermissionFilter
from profiles.models.squest_permission import Permission


class PermissionDetails(SquestRetrieveUpdateDestroyAPIView):
Expand Down
1 change: 0 additions & 1 deletion profiles/api/views/quota_api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from profiles.models import Quota



class SquestObjectPermissionsQuota(SquestObjectPermissions):
"""
Custom permission to only allow owners of an object to edit it.
Expand Down
2 changes: 0 additions & 2 deletions profiles/api/views/scope_api_views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from django.contrib.auth.models import User
from django.views.generic import RedirectView
from rest_framework.exceptions import MethodNotAllowed
from rest_framework.exceptions import NotFound
from rest_framework.generics import get_object_or_404
from rest_framework.permissions import IsAuthenticated
from rest_framework.reverse import reverse

from Squest.utils.squest_api_views import SquestCreateAPIView, SquestDestroyAPIView, SquestObjectPermissions
from profiles.api.serializers import AbstractScopeCreateRBACSerializer
Expand Down
1 change: 0 additions & 1 deletion profiles/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.apps import AppConfig
from django.db.models.signals import post_migrate


logger = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion profiles/filters/permission_filter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from Squest.utils.squest_filter import SquestFilter
from profiles.models.squest_permission import Permission

from Squest.utils.squest_filter import SquestFilter

class PermissionFilter(SquestFilter):
class Meta:
Expand Down
3 changes: 1 addition & 2 deletions profiles/forms/model_permission_form.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from profiles.models.squest_permission import Permission

from Squest.utils.squest_model_form import SquestModelForm
from profiles.models.squest_permission import Permission


class ModelPermissionForm(SquestModelForm):
Expand Down
3 changes: 1 addition & 2 deletions profiles/forms/permission_form.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from profiles.models.squest_permission import Permission

from Squest.utils.squest_model_form import SquestModelForm
from profiles.models.squest_permission import Permission


class PermissionForm(SquestModelForm):
Expand Down
1 change: 0 additions & 1 deletion profiles/models/quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.db.models import ForeignKey, Sum, Q
from django.db.models.signals import post_delete
from django.dispatch import receiver
from django.urls import reverse

from Squest.utils.squest_model import SquestModel

Expand Down
2 changes: 1 addition & 1 deletion profiles/models/role.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from profiles.models.squest_permission import Permission
from django.db.models import CharField, ManyToManyField

from Squest.utils.squest_model import SquestModel
from profiles.models.squest_permission import Permission


class AbstractRole(SquestModel):
Expand Down
1 change: 1 addition & 0 deletions profiles/models/team.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.exceptions import ValidationError
from django.db.models import ForeignKey, PROTECT, Q

from profiles.models import Organization
from profiles.models.scope import Scope

Expand Down
3 changes: 2 additions & 1 deletion profiles/tables/permission_table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from profiles.models.squest_permission import Permission
from django_tables2 import tables, TemplateColumn

from profiles.models.squest_permission import Permission


class PermissionTable(tables.Table):
actions = TemplateColumn(template_name='generics/custom_columns/generic_actions.html', orderable=False)
Expand Down
2 changes: 1 addition & 1 deletion profiles/tables/quota_table.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.utils.html import format_html
from django_tables2 import LinkColumn, Table, TemplateColumn
from django_tables2 import LinkColumn, TemplateColumn

from Squest.utils.squest_table import SquestTable
from profiles.models import Quota
Expand Down
2 changes: 0 additions & 2 deletions profiles/views/globalpermission.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from django.urls import reverse

from Squest.utils.squest_views import *
from profiles.forms import GlobalPermissionForm
from profiles.models import GlobalPermission
Expand Down
2 changes: 1 addition & 1 deletion profiles/views/permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from profiles.filters import PermissionFilter
from profiles.forms.model_permission_form import ModelPermissionForm
from profiles.forms.permission_form import PermissionForm
from profiles.tables import PermissionTable
from profiles.models import Permission
from profiles.tables import PermissionTable
from service_catalog.models import ApprovalStep


Expand Down
2 changes: 1 addition & 1 deletion profiles/views/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from Squest.utils.squest_views import SquestFormView, SquestDeleteView
from profiles.forms.scope_form import ScopeCreateRBACForm
from profiles.models import RBAC, Organization, GlobalPermission, AbstractScope, Team
from profiles.models import RBAC, GlobalPermission, AbstractScope, Team


def get_breadcrumbs_for_scope(scope):
Expand Down
2 changes: 1 addition & 1 deletion resource_tracker_v2/forms/transformer_form.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from django.forms import FloatField, ModelChoiceField
from django.forms import ModelChoiceField

from Squest.utils.squest_model_form import SquestModelForm
from resource_tracker_v2.models import AttributeDefinition, Transformer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import os.path

import yaml
from django.core.management import BaseCommand

from Squest import settings
from resource_tracker_v2.models import ResourceGroup, AttributeDefinition, Transformer, Resource
from django.core.management import BaseCommand

logger = logging.getLogger(__name__)

Expand Down
4 changes: 1 addition & 3 deletions resource_tracker_v2/tables/resource_table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from django_tables2 import CheckBoxColumn, TemplateColumn, Column, LinkColumn
from django_tables2.columns import BoundColumns
from django_tables2.utils import A
from django_tables2 import CheckBoxColumn, TemplateColumn, LinkColumn

from Squest.utils.squest_table import SquestTable
from resource_tracker_v2.models import Resource
Expand Down
1 change: 0 additions & 1 deletion resource_tracker_v2/views/attribute_definition_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from Squest.utils.squest_views import *
from profiles.models import Quota
from profiles.tables.quota_table import QuotaTable
from resource_tracker_v2.filters.attribute_definition_filter import AttributeDefinitionFilter
from resource_tracker_v2.forms.attribute_definition_form import AttributeDefinitionForm
Expand Down
1 change: 0 additions & 1 deletion resource_tracker_v2/views/resource_group_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from resource_tracker_v2.filters.resource_group_filter import ResourceGroupFilter
from resource_tracker_v2.forms.resource_group_form import ResourceGroupForm
from resource_tracker_v2.models import ResourceGroup, AttributeDefinition, Transformer
from resource_tracker_v2.tables.attribute_defintion_table import AttributeDefinitionTable
from resource_tracker_v2.tables.resource_group_table import ResourceGroupTable
from resource_tracker_v2.tables.resource_table import ResourceTable
from resource_tracker_v2.tables.transformer_table import TransformerTable
Expand Down
2 changes: 0 additions & 2 deletions service_catalog/api/serializers/approval_step_serializer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from copy import deepcopy

from rest_framework.exceptions import ValidationError
from rest_framework.relations import PrimaryKeyRelatedField
from rest_framework.serializers import ModelSerializer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from rest_framework.serializers import ModelSerializer, Field
from rest_framework.serializers import ModelSerializer

from service_catalog.models import ApprovalStepState

Expand Down
4 changes: 1 addition & 3 deletions service_catalog/api/views/approval_step_api_views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from rest_framework.generics import get_object_or_404

from Squest.utils.squest_api_views import SquestListCreateAPIView, SquestRetrieveUpdateDestroyAPIView
from service_catalog.api.serializers.approval_step_serializer import ApprovalStepSerializer
from service_catalog.filters.approval_step_filter import ApprovalStepFilter
from service_catalog.models import ApprovalStep, ApprovalWorkflow
from service_catalog.models import ApprovalStep


class ApprovalStepListCreate(SquestListCreateAPIView):
Expand Down
1 change: 0 additions & 1 deletion service_catalog/api/views/operation_api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from service_catalog.models.instance import Instance
from service_catalog.models.operation_type import OperationType
from service_catalog.models.operations import Operation
from service_catalog.models.services import Service


class OperationListCreate(SquestListCreateAPIView):
Expand Down
4 changes: 2 additions & 2 deletions service_catalog/api/views/operation_survey_api_views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from drf_yasg.utils import swagger_auto_schema
from rest_framework import status
from rest_framework.exceptions import NotFound, PermissionDenied
from rest_framework.exceptions import NotFound
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response

from Squest.utils.squest_api_views import SquestObjectPermissions, SquestGenericAPIView, SquestRetrieveUpdateAPIView
from Squest.utils.squest_api_views import SquestObjectPermissions, SquestRetrieveUpdateAPIView
from service_catalog.api.serializers.tower_survey_field_serializer import TowerSurveyFieldSerializer
from service_catalog.models import Operation
from service_catalog.models.tower_survey_field import TowerSurveyField
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from copy import deepcopy

from django_fsm import can_proceed
from drf_yasg.utils import swagger_auto_schema
from rest_framework import status
Expand Down
4 changes: 2 additions & 2 deletions service_catalog/filters/instance_filter.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.forms import HiddenInput, CheckboxInput
from django.forms import CheckboxInput
from django.utils.translation import gettext_lazy as _
from django_filters import MultipleChoiceFilter, BooleanFilter, BaseInFilter, CharFilter

from Squest.utils.squest_filter import SquestFilter
from profiles.models import Scope, AbstractScope, GlobalPermission
from profiles.models import Scope, AbstractScope
from service_catalog.models import Instance, Service
from service_catalog.models.instance import InstanceState

Expand Down
2 changes: 1 addition & 1 deletion service_catalog/forms/approval_step_form.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from profiles.models.squest_permission import Permission
from django.core.exceptions import ValidationError
from django.forms import ModelMultipleChoiceField, HiddenInput
from django.urls import reverse

from Squest.utils.squest_model_form import SquestModelForm
from profiles.models.squest_permission import Permission
from service_catalog.models import ApprovalStep, TowerSurveyField

EXCLUDED_PERMISSION = ["add_approvalstep", "change_approvalstep", "delete_approvalstep", "list_approvalstep",
Expand Down
1 change: 0 additions & 1 deletion service_catalog/forms/form_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
import logging

from service_catalog.models import ApprovalState
Expand Down
1 change: 1 addition & 0 deletions service_catalog/forms/tower_server_forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re

import requests
import towerlib
from django import forms
Expand Down
1 change: 0 additions & 1 deletion service_catalog/mail_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import base64
import logging

from os import linesep

from django.conf import settings
Expand Down
8 changes: 3 additions & 5 deletions service_catalog/models/approval_step.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from django.urls import reverse

from profiles.models.squest_permission import Permission
from django.db.models import ForeignKey, CharField, SET_NULL, CASCADE, IntegerField, ManyToManyField, PROTECT, Q, \
TextField
from django.db.models import ForeignKey, CharField, SET_NULL, CASCADE, IntegerField, ManyToManyField, PROTECT, TextField
from django.db.models.signals import post_save
from django.urls import reverse

from Squest.utils.squest_model import SquestModel
from profiles.models.squest_permission import Permission


class ApprovalStep(SquestModel):
Expand Down
3 changes: 1 addition & 2 deletions service_catalog/models/hooks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from django.core.exceptions import ValidationError
from django.db.models import ForeignKey, CASCADE, CharField, JSONField, SET_NULL, IntegerField, ManyToManyField
from django.db.models import ForeignKey, CASCADE, CharField, JSONField, IntegerField, ManyToManyField
from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _

Expand Down Expand Up @@ -60,7 +60,6 @@ def trigger_hook(cls, sender, instance, name, source, target, *args, **kwargs):
:return:
"""
from service_catalog.api.serializers import InstanceReadSerializer, AdminRequestSerializer
from service_catalog.models import Instance, Request
logger.debug(f"[HookManager] trigger_hook executed with "
f"sender model '{sender.__name__}', "
f"instance ID'{instance.id}', "
Expand Down
4 changes: 2 additions & 2 deletions service_catalog/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db.models import CharField, JSONField, ForeignKey, DateTimeField, ManyToManyField, PROTECT, Q, \
from django.db.models import CharField, JSONField, ForeignKey, DateTimeField, PROTECT, Q, \
CASCADE
from django.db.models.signals import post_save, pre_delete, pre_save
from django.dispatch import receiver
Expand All @@ -12,9 +12,9 @@
from Squest.utils.ansible_when import AnsibleWhen
from Squest.utils.squest_model import SquestModel
from profiles.models.scope import Scope
from service_catalog.models.hooks import HookManager
from service_catalog.models.instance_state import InstanceState
from service_catalog.models.services import Service
from service_catalog.models.hooks import HookManager

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion service_catalog/models/operations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.core.exceptions import ValidationError
from django.db.models import CharField, ForeignKey, BooleanField, IntegerField, CASCADE, SET_NULL, JSONField, PROTECT
from django.db.models import CharField, ForeignKey, BooleanField, IntegerField, CASCADE, SET_NULL, JSONField
from django.db.models.signals import post_save, pre_save, post_delete
from django.dispatch import receiver
from django.urls import reverse
Expand Down
3 changes: 1 addition & 2 deletions service_catalog/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
from Squest.utils.ansible_when import AnsibleWhen
from Squest.utils.squest_model import SquestModel
from service_catalog.models.exceptions import ExceptionServiceCatalog
from service_catalog.models.hooks import HookManager
from service_catalog.models.instance import Instance, InstanceState
from service_catalog.models.operations import Operation, OperationType
from service_catalog.models.request_state import RequestState
from service_catalog.models.hooks import HookManager

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -321,7 +321,6 @@ def _get_approval_workflow(self):
return None

def setup_approval_workflow(self):
from service_catalog.models import ApprovalWorkflow
# search for a workflow on this operation
workflow = self._get_approval_workflow()
if not workflow:
Expand Down
5 changes: 2 additions & 3 deletions service_catalog/models/support.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from datetime import datetime

from django.contrib.auth.models import User
from django.db.models import TextChoices, CharField, ForeignKey, DateTimeField, CASCADE, SET_NULL, Q, IntegerChoices
from django.db.models import CharField, ForeignKey, DateTimeField, CASCADE, SET_NULL, Q, IntegerChoices
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django_fsm import FSMField, transition, FSMIntegerField
from django_fsm import transition, FSMIntegerField

from Squest.utils.squest_model import SquestModel
from service_catalog.mail_utils import send_mail_support_is_closed
Expand Down
Loading

0 comments on commit 3f8ae1f

Please sign in to comment.