Skip to content

Commit

Permalink
isort
Browse files Browse the repository at this point in the history
Signed-off-by: Jason <[email protected]>
  • Loading branch information
JasonLovesDoggo committed Feb 8, 2024
1 parent 2c7adbb commit fe16a91
Show file tree
Hide file tree
Showing 61 changed files with 142 additions and 155 deletions.
3 changes: 2 additions & 1 deletion core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from martor.widgets import AdminMartorWidget

from . import models
from .forms import (
AnnouncementAdminForm,
Expand All @@ -26,8 +27,8 @@
from .models import Comment, StaffMember
from .utils.actions import *
from .utils.filters import (
OrganizationListFilter,
BlogPostAuthorListFilter,
OrganizationListFilter,
PostTypeFilter,
)

Expand Down
1 change: 1 addition & 0 deletions core/api/serializers/announcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from core.api.serializers.custom import PrimaryKeyAndSlugRelatedField
from core.api.serializers.tag import TagSerializer

from ... import models


Expand Down
3 changes: 2 additions & 1 deletion core/api/serializers/blogpost.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from rest_framework import serializers

from core.api.serializers.custom import PrimaryKeyAndSlugRelatedField
from .tag import TagSerializer

from ... import models
from .tag import TagSerializer


class BlogPostSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 1 addition & 1 deletion core/api/serializers/course.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from rest_framework import serializers

from ... import models
from .organization import OrganizationSerializer
from .tag import TagSerializer
from ... import models


class TermSerializer(serializers.ModelSerializer):
Expand Down
9 changes: 5 additions & 4 deletions core/api/serializers/custom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from core.api.utils.github import get_model_choices
from core.api.utils.gravatar import gravatar_url
from core.models import Tag, User, Organization, Comment
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from django.utils.encoding import smart_str
from rest_framework import serializers
from rest_framework.fields import Field, MultipleChoiceField, ChoiceField
from rest_framework.fields import ChoiceField, Field, MultipleChoiceField

from core.api.utils.github import get_model_choices
from core.api.utils.gravatar import gravatar_url
from core.models import Comment, Organization, Tag, User


class PrimaryKeyAndSlugRelatedField(serializers.SlugRelatedField):
Expand Down
3 changes: 2 additions & 1 deletion core/api/serializers/organization.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from rest_framework import serializers

from core.api.serializers.custom import PrimaryKeyAndSlugRelatedField
from .tag import TagSerializer

from ... import models
from .tag import TagSerializer


class OrganizationSerializer(serializers.ModelSerializer):
Expand Down
3 changes: 2 additions & 1 deletion core/api/serializers/timetable.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from rest_framework import serializers

from core.api.serializers.custom import PrimaryKeyAndSlugRelatedField
from .course import CourseSerializer, TermSerializer

from ... import models
from .course import CourseSerializer, TermSerializer


class TimetableSerializer(serializers.ModelSerializer):
Expand Down
4 changes: 2 additions & 2 deletions core/api/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers

from .tag import TagSerializer
from ..utils.gravatar import gravatar_url
from ... import models
from ...models import User
from ..utils.gravatar import gravatar_url
from .tag import TagSerializer


class UserSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 1 addition & 1 deletion core/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rest_framework.routers import SimpleRouter
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

from .v3.objects.main import ObjectList, ObjectNew, ObjectSingle, ObjectRetrieve
from .v3.objects.main import ObjectList, ObjectNew, ObjectRetrieve, ObjectSingle
from .v3.views.user import UserDeleteView, UserRestoreView
from .views import *

Expand Down
2 changes: 1 addition & 1 deletion core/api/utils/github.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from os import environ
from typing import Iterable, Tuple, Optional, List, TYPE_CHECKING
from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple

from django.db import connection
from django.db.models import Model
Expand Down
10 changes: 3 additions & 7 deletions core/api/utils/polymorphism.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
from __future__ import annotations

from functools import lru_cache
from json import JSONDecodeError
from typing import Literal, List, Set, Protocol, Optional
from typing import Any, Callable, Dict, Iterable, List, Literal, Optional, Protocol, Set

from django.core.exceptions import BadRequest
from django.db.models import Model, Q
from django.shortcuts import get_object_or_404
from memoization import cached
from rest_framework import generics

from functools import lru_cache
from core.utils.types import APIObjOperations
from rest_framework.serializers import BaseSerializer

from typing import Iterable, Any, Dict, Callable

from core.api.v3.objects import *
from core.api.v3.objects.base import BaseProvider

from core.utils.types import APIObjOperations

type IgnoredKey = str | Iterable[str]
type SerializerItems = Dict[str, BaseSerializer]
Expand Down
6 changes: 3 additions & 3 deletions core/api/v3/objects/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from .announcement import *
from .blog_post import *
from .post_interactions import *
from .event import *
from .courses import *
from .event import *
from .exhibit import *
from .flatpage import *
from .organization import *
from .post_interactions import *
from .tag import *
from .term import *
from .timetable import *
from .user import *
from .exhibit import *
12 changes: 6 additions & 6 deletions core/api/v3/objects/announcement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from core.utils.mail import send_mail
from django.conf import settings
from django.contrib.admin.models import LogEntry
from django.contrib.contenttypes.models import ContentType
Expand All @@ -9,18 +8,19 @@
from rest_framework import permissions, serializers
from rest_framework.exceptions import ValidationError

from .base import BaseProvider

from core.api.serializers.custom import (
TagRelatedField,
SingleUserField,
OrganizationField,
CommentField,
LikeField,
OrganizationField,
SingleUserField,
SupervisorField,
TagRelatedField,
)
from core.api.utils import ModelAbilityField
from core.models import Announcement, User
from core.utils.mail import send_mail

from .base import BaseProvider


def exec_validator(value, serializer_field):
Expand Down
6 changes: 4 additions & 2 deletions core/api/v3/objects/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import List, Dict, Final
from rest_framework.serializers import BaseSerializer
from abc import ABC
from typing import Dict, Final, List

from django.db.models.base import ModelBase
from rest_framework.serializers import BaseSerializer

from core.utils.types import APIObjOperations

type SerializerItems = Dict[str, BaseSerializer]
Expand Down
5 changes: 3 additions & 2 deletions core/api/v3/objects/blog_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
from django.contrib.contenttypes.models import ContentType
from rest_framework import permissions, serializers

from .base import BaseProvider
from core.api.serializers.custom import (
TagRelatedField,
CommentField,
LikeField,
SingleUserField,
TagRelatedField,
)
from core.models import BlogPost

from .base import BaseProvider


class Serializer(serializers.ModelSerializer):
likes = LikeField()
Expand Down
9 changes: 3 additions & 6 deletions core/api/v3/objects/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
from rest_framework import permissions, serializers
from rest_framework.exceptions import ParseError

from .announcement import Inner
from core.api.serializers.custom import OrganizationField, TagRelatedField
from core.models import Event

from .announcement import Inner
from .base import BaseProvider
from core.api.serializers.custom import (
TagRelatedField,
OrganizationField,
)
from core.models import Event

AOE = datetime.timezone(datetime.timedelta(hours=-12), name="AoE")

Expand Down
10 changes: 5 additions & 5 deletions core/api/v3/objects/exhibit.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from django.utils import timezone
from rest_framework import permissions, serializers


from .base import BaseProvider
from core.api.serializers.custom import (
TagRelatedField,
SingleUserField,
LikeField,
CommentField,
LikeField,
SingleUserField,
TagRelatedField,
)
from core.models import Exhibit

from .base import BaseProvider


class Serializer(serializers.ModelSerializer):
likes = LikeField()
Expand Down
1 change: 0 additions & 1 deletion core/api/v3/objects/flatpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.contrib.flatpages.models import FlatPage
from rest_framework import permissions, serializers


from .base import BaseProvider


Expand Down
15 changes: 6 additions & 9 deletions core/api/v3/objects/main.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
from __future__ import annotations

from typing import Dict, Callable, List, Tuple
from typing import Callable, Dict, List, Tuple

from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist, BadRequest
from django.core.exceptions import BadRequest, ObjectDoesNotExist
from django.db.models import Model, QuerySet
from django.http import QueryDict, JsonResponse
from django.http import JsonResponse, QueryDict
from django.urls import NoReverseMatch, reverse
from drf_spectacular.utils import (
extend_schema,
OpenApiParameter,
)
from drf_spectacular.utils import OpenApiParameter, extend_schema
from rest_framework import generics
from core.api.utils.mixins import LookupField

from core.api.utils import GenericAPIViewWithDebugInfo, GenericAPIViewWithLastModified
from core.api.utils.mixins import LookupField

__all__ = ["ObjectList", "ObjectSingle", "ObjectRetrieve", "ObjectNew"]

from core.api.utils.polymorphism import get_providers_by_operation, ObjectAPIView
from core.api.utils.polymorphism import ObjectAPIView, get_providers_by_operation


@extend_schema(
Expand Down
4 changes: 2 additions & 2 deletions core/api/v3/objects/organization.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from core.api.serializers.custom import MembersField, TagRelatedField, SingleUserField
from django.contrib.admin.models import LogEntry
from django.contrib.contenttypes.models import ContentType
from django.db.models import Count
from rest_framework import permissions, serializers

from core import models
from core.api.serializers.custom import MembersField, SingleUserField, TagRelatedField

from .base import BaseProvider
from core import models


class Serializer(serializers.ModelSerializer):
Expand Down
15 changes: 7 additions & 8 deletions core/api/v3/objects/post_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
from django.contrib.admin.models import LogEntry
from django.contrib.contenttypes.models import ContentType
from django.utils import timezone
from rest_framework import permissions, serializers
from rest_framework import status
from rest_framework import permissions, serializers, status
from rest_framework.exceptions import ValidationError
from rest_framework.permissions import IsAuthenticated, BasePermission
from rest_framework.permissions import BasePermission, IsAuthenticated
from rest_framework.response import Response


from .base import BaseProvider
from core.api.serializers.custom import (
ContentTypeField,
CommentField,
SingleUserField,
ContentTypeField,
LikeField,
SingleUserField,
)
from core.models import Comment, User, Like
from core.models import Comment, Like, User

from .base import BaseProvider

typedir: dict[str, str] = {
"blogpost": "core | blogpost",
Expand Down
2 changes: 1 addition & 1 deletion core/api/v3/objects/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from django.contrib.contenttypes.models import ContentType
from rest_framework import permissions, serializers

from core import models

from .base import BaseProvider
from core import models


class Serializer(serializers.ModelSerializer):
Expand Down
4 changes: 2 additions & 2 deletions core/api/v3/objects/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from django.utils import timezone
from rest_framework import permissions, serializers


from .base import BaseProvider
from core.api.serializers.course import CourseSerializer
from core.models import Term

from .base import BaseProvider


class Serializer(serializers.ModelSerializer):
courses = CourseSerializer(many=True)
Expand Down
4 changes: 2 additions & 2 deletions core/api/v3/objects/timetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from django.utils import timezone
from rest_framework import permissions, serializers


from .base import BaseProvider
from core.api.serializers.course import CourseSerializer, TermSerializer
from core.models import Timetable

from .base import BaseProvider


class ViewSerializer(serializers.ModelSerializer):
term = TermSerializer()
Expand Down
Loading

0 comments on commit fe16a91

Please sign in to comment.