Lint using autoflake and isort

This commit is contained in:
Keannu Bernasol 2024-10-31 00:33:13 +08:00
parent d126fdbd32
commit aa52da056c
35 changed files with 128 additions and 115 deletions

View file

@ -1,6 +1,7 @@
from django import forms
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import CustomUser

View file

@ -1,10 +1,11 @@
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.urls import reverse
from django_resized import ResizedImageField
from django.utils import timezone
from datetime import timedelta
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.urls import reverse
from django.utils import timezone
from django_resized import ResizedImageField
class CustomUser(AbstractUser):
# first_name inherited from base user class

View file

@ -1,12 +1,12 @@
from djoser.serializers import UserSerializer as BaseUserSerializer
from rest_framework.serializers import ModelSerializer, ImageField
from rest_framework import serializers
from accounts.models import CustomUser
from user_groups.serializers import SimpleUserGroupSerializer
from django.core.cache import cache
from django.core import exceptions as django_exceptions
from rest_framework.settings import api_settings
from django.contrib.auth.password_validation import validate_password
from django.core import exceptions as django_exceptions
from django.core.cache import cache
from djoser.serializers import UserSerializer as BaseUserSerializer
from rest_framework import serializers
from rest_framework.serializers import ImageField, ModelSerializer
from rest_framework.settings import api_settings
from user_groups.serializers import SimpleUserGroupSerializer
# There can be multiple subject instances with the same name, only differing in course, year level, and semester. We filter them here

View file

@ -1,10 +1,12 @@
import json
import os
from config.settings import ROOT_DIR, SEED_DATA, get_secret
from django.db.models.signals import post_migrate
from django.dispatch import receiver
from config.settings import SEED_DATA, ROOT_DIR, get_secret
from django_celery_beat.models import PeriodicTask, CrontabSchedule
from django_celery_beat.models import CrontabSchedule, PeriodicTask
from .models import CustomUser
import os
import json
# Function to fill in users table with test data on dev/staging

View file

@ -1,6 +1,6 @@
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from accounts import views
from django.urls import include, path
from rest_framework.routers import DefaultRouter
router = DefaultRouter()
router.register(r"users", views.CustomUserViewSet, basename="users")

View file

@ -1,6 +1,7 @@
import re
from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _
import re
class UppercaseValidator(object):

View file

@ -1,15 +1,15 @@
from rest_framework import status
from accounts.models import CustomUser
from accounts import serializers
from rest_framework.decorators import action
from rest_framework.response import Response
from djoser.conf import settings
from djoser.views import UserViewSet as DjoserUserViewSet
from accounts.models import CustomUser
from django.contrib.auth.tokens import default_token_generator
from django.core.cache import cache
from djoser import signals
from djoser.compat import get_user_email
from django.core.cache import cache
from djoser.conf import settings
from djoser.views import UserViewSet as DjoserUserViewSet
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
class CustomUserViewSet(DjoserUserViewSet):

View file

@ -1,13 +1,13 @@
from config.settings import DEBUG, MEDIA_ROOT, SERVE_MEDIA
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import path, include
from django.urls import include, path
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerView,
)
from django.contrib import admin
from config.settings import DEBUG, SERVE_MEDIA, MEDIA_ROOT
urlpatterns = [
path("accounts/", include("accounts.urls")),

View file

@ -1,5 +1,5 @@
from django.urls import path
from billing import views
from django.urls import path
urlpatterns = [
path("", views.BillingHistoryView.as_view()),

View file

@ -1,12 +1,12 @@
from rest_framework import status
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from datetime import datetime
import stripe
from config.settings import STRIPE_SECRET_KEY
from django.core.cache import cache
from datetime import datetime
import stripe
from rest_framework import status
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
# Make sure to set your secret key
stripe.api_key = STRIPE_SECRET_KEY

View file

@ -1,6 +1,6 @@
from celery import Celery
import os
from celery import Celery
# Set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

View file

@ -1,7 +1,8 @@
import os
from datetime import timedelta
from pathlib import Path
from dotenv import load_dotenv, find_dotenv # Python dotenv
import os
from dotenv import find_dotenv, load_dotenv # Python dotenv
# Build paths inside the project like this: BASE_DIR / 'subdir'.
# Backend folder (/backend)

View file

@ -1,4 +1,4 @@
from django.urls import path, include
from django.urls import include, path
urlpatterns = [
path("api/v1/", include("api.urls")),

View file

@ -1,5 +1,5 @@
from djoser import email
from django.utils import timezone
from djoser import email
class ActivationEmail(email.ActivationEmail):

View file

@ -1,5 +1,6 @@
from unfold.admin import ModelAdmin
from django.contrib import admin
from unfold.admin import ModelAdmin
from .models import Notification

View file

@ -1,5 +1,5 @@
from rest_framework import serializers
from notifications.models import Notification
from rest_framework import serializers
class NotificationSerializer(serializers.ModelSerializer):

View file

@ -1,7 +1,7 @@
from django.dispatch import receiver
from django.db.models.signals import post_save
from notifications.models import Notification
from django.core.cache import cache
from django.db.models.signals import post_save
from django.dispatch import receiver
from notifications.models import Notification
# Template for running actions after user have paid for a subscription

View file

@ -1,4 +1,4 @@
from django.urls import path, include
from django.urls import include, path
from notifications.views import NotificationViewSet
from rest_framework.routers import DefaultRouter

View file

@ -1,8 +1,8 @@
from rest_framework import viewsets
from django.core.cache import cache
from notifications.models import Notification
from notifications.serializers import NotificationSerializer
from rest_framework import viewsets
from rest_framework.exceptions import PermissionDenied
from django.core.cache import cache
class NotificationViewSet(viewsets.ModelViewSet):

View file

@ -1,7 +1,6 @@
from django.urls import path
from payments import views
urlpatterns = [
path("checkout_session/", views.StripeCheckoutView.as_view()),
path("webhook/", views.stripe_webhook_view, name="Stripe Webhook"),

View file

@ -1,31 +1,32 @@
import json
import logging
import stripe
from accounts.models import CustomUser
from config.settings import (
FRONTEND_ADDRESS,
FRONTEND_PORT,
STRIPE_SECRET_KEY,
STRIPE_SECRET_WEBHOOK,
URL_SCHEME,
FRONTEND_ADDRESS,
FRONTEND_PORT,
)
from rest_framework.permissions import IsAuthenticated
from rest_framework.views import APIView
from rest_framework.response import Response
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework import status
import logging
import stripe
from subscriptions.models import SubscriptionPlan, UserSubscription
from accounts.models import CustomUser
from rest_framework.decorators import api_view
from subscriptions.tasks import get_user_subscription
import json
from emails.templates import (
SubscriptionAvailedEmail,
SubscriptionRefundedEmail,
SubscriptionCancelledEmail,
)
from django.core.cache import cache
from payments.serializers import CheckoutSerializer
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from drf_spectacular.utils import extend_schema
from emails.templates import (
SubscriptionAvailedEmail,
SubscriptionCancelledEmail,
SubscriptionRefundedEmail,
)
from payments.serializers import CheckoutSerializer
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from subscriptions.models import SubscriptionPlan, UserSubscription
from subscriptions.tasks import get_user_subscription
stripe.api_key = STRIPE_SECRET_KEY

View file

@ -1,8 +1,9 @@
from unfold.admin import ModelAdmin
from django.contrib import admin
from .models import SearchResult
from unfold.admin import ModelAdmin
from unfold.contrib.filters.admin import RangeDateFilter
from .models import SearchResult
@admin.register(SearchResult)
class SearchResultAdmin(ModelAdmin):

View file

@ -1,4 +1,5 @@
from celery import shared_task
from .models import SearchResult

View file

@ -1,7 +1,7 @@
from django.db import models
from accounts.models import CustomUser
from user_groups.models import UserGroup
from django.db import models
from django.utils.timezone import now
from user_groups.models import UserGroup
class StripePrice(models.Model):

View file

@ -1,6 +1,6 @@
from rest_framework import serializers
from subscriptions.models import SubscriptionPlan, UserSubscription, StripePrice
from accounts.serializers import SimpleCustomUserSerializer
from rest_framework import serializers
from subscriptions.models import StripePrice, SubscriptionPlan, UserSubscription
class SimpleStripePriceSerializer(serializers.ModelSerializer):

View file

@ -1,9 +1,10 @@
from django.dispatch import receiver
from django.db.models.signals import post_migrate, post_save
from .models import UserSubscription, StripePrice, SubscriptionPlan
from django.core.cache import cache
from config.settings import STRIPE_SECRET_KEY
import stripe
from config.settings import STRIPE_SECRET_KEY
from django.core.cache import cache
from django.db.models.signals import post_migrate, post_save
from django.dispatch import receiver
from .models import StripePrice, SubscriptionPlan, UserSubscription
stripe.api_key = STRIPE_SECRET_KEY

View file

@ -3,8 +3,8 @@ from celery import shared_task
@shared_task
def get_user_subscription(user_id):
from subscriptions.models import UserSubscription
from accounts.models import CustomUser
from subscriptions.models import UserSubscription
USER = CustomUser.objects.get(id=user_id)

View file

@ -1,6 +1,6 @@
from django.urls import path, include
from subscriptions import views
from django.urls import include, path
from rest_framework.routers import DefaultRouter
from subscriptions import views
router = DefaultRouter()
router.register(r"plans", views.SubscriptionPlanViewset, basename="Subscription Plans")

View file

@ -1,11 +1,11 @@
from django.core.cache import cache
from rest_framework import viewsets
from rest_framework.permissions import AllowAny, IsAuthenticated
from subscriptions.models import SubscriptionPlan, UserSubscription
from subscriptions.serializers import (
SubscriptionPlanSerializer,
UserSubscriptionSerializer,
)
from subscriptions.models import SubscriptionPlan, UserSubscription
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework import viewsets
from django.core.cache import cache
class SubscriptionPlanViewset(viewsets.ModelViewSet):

View file

@ -1,8 +1,9 @@
from django.contrib import admin
from unfold.admin import ModelAdmin
from .models import UserGroup
from unfold.contrib.filters.admin import RangeDateFilter
from .models import UserGroup
@admin.register(UserGroup)
class UserGroupAdmin(ModelAdmin):

View file

@ -1,7 +1,7 @@
import stripe
from config.settings import STRIPE_SECRET_KEY
from django.db import models
from django.utils.timezone import now
from config.settings import STRIPE_SECRET_KEY
import stripe
stripe.api_key = STRIPE_SECRET_KEY

View file

@ -1,4 +1,5 @@
from rest_framework import serializers
from .models import UserGroup

View file

@ -1,13 +1,15 @@
from subscriptions.models import SubscriptionPlan
import json
import os
import stripe
from accounts.models import CustomUser
from .models import UserGroup
from subscriptions.tasks import get_user_group_subscription
from config.settings import ROOT_DIR, STRIPE_SECRET_KEY
from django.db.models.signals import m2m_changed, post_migrate
from django.dispatch import receiver
from config.settings import STRIPE_SECRET_KEY, ROOT_DIR
import os
import json
import stripe
from subscriptions.models import SubscriptionPlan
from subscriptions.tasks import get_user_group_subscription
from .models import UserGroup
stripe.api_key = STRIPE_SECRET_KEY

View file

@ -1,13 +1,13 @@
from celery import shared_task
from search_results.tasks import create_search_result
from selenium.webdriver.common.by import By
from webdriver.utils import (
setup_webdriver,
selenium_action_template,
google_search,
get_element,
get_elements,
google_search,
selenium_action_template,
setup_webdriver,
)
from selenium.webdriver.common.by import By
from search_results.tasks import create_search_result
# Task template

View file

@ -2,21 +2,20 @@
Settings file to hold constants and functions
"""
import os
import random
import undetected_chromedriver as uc
from config.settings import CAPTCHA_TESTING, USE_PROXY, get_secret
from selenium import webdriver
from selenium.webdriver import FirefoxOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from config.settings import get_secret
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import FirefoxOptions
from selenium import webdriver
import undetected_chromedriver as uc
from config.settings import USE_PROXY, CAPTCHA_TESTING
from config.settings import get_secret
from selenium.webdriver.support.ui import WebDriverWait
from twocaptcha import TwoCaptcha
from whois import whois
from whois.parser import PywhoisError
import os
import random
def take_snapshot(driver, filename="dump.png"):
@ -249,7 +248,7 @@ def execute_selenium_elements(driver, timeout, elements):
element["default"]["key"],
timeout=timeout,
)
except Exception as e:
except Exception:
print(f"Failed to find primary element")
# If that fails, try to get the failover one
print("Trying to find legacy element")