mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-17 04:09:25 +08:00
Lint using autoflake and isort
This commit is contained in:
parent
d126fdbd32
commit
aa52da056c
35 changed files with 128 additions and 115 deletions
|
@ -1,6 +1,7 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
|
|
||||||
from .models import CustomUser
|
from .models import CustomUser
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 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):
|
class CustomUser(AbstractUser):
|
||||||
# first_name inherited from base user class
|
# first_name inherited from base user class
|
||||||
|
|
|
@ -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 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.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
|
# There can be multiple subject instances with the same name, only differing in course, year level, and semester. We filter them here
|
||||||
|
|
||||||
|
|
|
@ -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.db.models.signals import post_migrate
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from config.settings import SEED_DATA, ROOT_DIR, get_secret
|
from django_celery_beat.models import CrontabSchedule, PeriodicTask
|
||||||
from django_celery_beat.models import PeriodicTask, CrontabSchedule
|
|
||||||
from .models import CustomUser
|
from .models import CustomUser
|
||||||
import os
|
|
||||||
import json
|
|
||||||
|
|
||||||
# Function to fill in users table with test data on dev/staging
|
# Function to fill in users table with test data on dev/staging
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.urls import path, include
|
|
||||||
from rest_framework.routers import DefaultRouter
|
|
||||||
from accounts import views
|
from accounts import views
|
||||||
|
from django.urls import include, path
|
||||||
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
router = DefaultRouter()
|
router = DefaultRouter()
|
||||||
router.register(r"users", views.CustomUserViewSet, basename="users")
|
router.register(r"users", views.CustomUserViewSet, basename="users")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
import re
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class UppercaseValidator(object):
|
class UppercaseValidator(object):
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
from rest_framework import status
|
|
||||||
from accounts.models import CustomUser
|
|
||||||
from accounts import serializers
|
from accounts import serializers
|
||||||
from rest_framework.decorators import action
|
from accounts.models import CustomUser
|
||||||
from rest_framework.response import Response
|
|
||||||
from djoser.conf import settings
|
|
||||||
from djoser.views import UserViewSet as DjoserUserViewSet
|
|
||||||
from django.contrib.auth.tokens import default_token_generator
|
from django.contrib.auth.tokens import default_token_generator
|
||||||
|
from django.core.cache import cache
|
||||||
from djoser import signals
|
from djoser import signals
|
||||||
from djoser.compat import get_user_email
|
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.permissions import IsAuthenticated
|
||||||
|
from rest_framework.response import Response
|
||||||
|
|
||||||
|
|
||||||
class CustomUserViewSet(DjoserUserViewSet):
|
class CustomUserViewSet(DjoserUserViewSet):
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
from config.settings import DEBUG, MEDIA_ROOT, SERVE_MEDIA
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
|
from django.contrib import admin
|
||||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
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 (
|
from drf_spectacular.views import (
|
||||||
SpectacularAPIView,
|
SpectacularAPIView,
|
||||||
SpectacularRedocView,
|
SpectacularRedocView,
|
||||||
SpectacularSwaggerView,
|
SpectacularSwaggerView,
|
||||||
)
|
)
|
||||||
from django.contrib import admin
|
|
||||||
from config.settings import DEBUG, SERVE_MEDIA, MEDIA_ROOT
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("accounts/", include("accounts.urls")),
|
path("accounts/", include("accounts.urls")),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.urls import path
|
|
||||||
from billing import views
|
from billing import views
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.BillingHistoryView.as_view()),
|
path("", views.BillingHistoryView.as_view()),
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from rest_framework import status
|
from datetime import datetime
|
||||||
from rest_framework.views import APIView
|
|
||||||
from rest_framework.response import Response
|
import stripe
|
||||||
from rest_framework.permissions import IsAuthenticated
|
|
||||||
from config.settings import STRIPE_SECRET_KEY
|
from config.settings import STRIPE_SECRET_KEY
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from datetime import datetime
|
from rest_framework import status
|
||||||
import stripe
|
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
|
# Make sure to set your secret key
|
||||||
stripe.api_key = STRIPE_SECRET_KEY
|
stripe.api_key = STRIPE_SECRET_KEY
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from celery import Celery
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from celery import Celery
|
||||||
|
|
||||||
# Set the default Django settings module for the 'celery' program.
|
# Set the default Django settings module for the 'celery' program.
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
import os
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from pathlib import Path
|
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'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
# Backend folder (/backend)
|
# Backend folder (/backend)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.urls import path, include
|
from django.urls import include, path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("api/v1/", include("api.urls")),
|
path("api/v1/", include("api.urls")),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from djoser import email
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from djoser import email
|
||||||
|
|
||||||
|
|
||||||
class ActivationEmail(email.ActivationEmail):
|
class ActivationEmail(email.ActivationEmail):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from unfold.admin import ModelAdmin
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from unfold.admin import ModelAdmin
|
||||||
|
|
||||||
from .models import Notification
|
from .models import Notification
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from rest_framework import serializers
|
|
||||||
from notifications.models import Notification
|
from notifications.models import Notification
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
class NotificationSerializer(serializers.ModelSerializer):
|
class NotificationSerializer(serializers.ModelSerializer):
|
||||||
|
|
|
@ -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.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
|
# Template for running actions after user have paid for a subscription
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.urls import path, include
|
from django.urls import include, path
|
||||||
from notifications.views import NotificationViewSet
|
from notifications.views import NotificationViewSet
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from rest_framework import viewsets
|
from django.core.cache import cache
|
||||||
from notifications.models import Notification
|
from notifications.models import Notification
|
||||||
from notifications.serializers import NotificationSerializer
|
from notifications.serializers import NotificationSerializer
|
||||||
|
from rest_framework import viewsets
|
||||||
from rest_framework.exceptions import PermissionDenied
|
from rest_framework.exceptions import PermissionDenied
|
||||||
from django.core.cache import cache
|
|
||||||
|
|
||||||
|
|
||||||
class NotificationViewSet(viewsets.ModelViewSet):
|
class NotificationViewSet(viewsets.ModelViewSet):
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from payments import views
|
from payments import views
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("checkout_session/", views.StripeCheckoutView.as_view()),
|
path("checkout_session/", views.StripeCheckoutView.as_view()),
|
||||||
path("webhook/", views.stripe_webhook_view, name="Stripe Webhook"),
|
path("webhook/", views.stripe_webhook_view, name="Stripe Webhook"),
|
||||||
|
|
|
@ -1,31 +1,32 @@
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import stripe
|
||||||
|
from accounts.models import CustomUser
|
||||||
from config.settings import (
|
from config.settings import (
|
||||||
|
FRONTEND_ADDRESS,
|
||||||
|
FRONTEND_PORT,
|
||||||
STRIPE_SECRET_KEY,
|
STRIPE_SECRET_KEY,
|
||||||
STRIPE_SECRET_WEBHOOK,
|
STRIPE_SECRET_WEBHOOK,
|
||||||
URL_SCHEME,
|
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 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 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
|
stripe.api_key = STRIPE_SECRET_KEY
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
from unfold.admin import ModelAdmin
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import SearchResult
|
from unfold.admin import ModelAdmin
|
||||||
from unfold.contrib.filters.admin import RangeDateFilter
|
from unfold.contrib.filters.admin import RangeDateFilter
|
||||||
|
|
||||||
|
from .models import SearchResult
|
||||||
|
|
||||||
|
|
||||||
@admin.register(SearchResult)
|
@admin.register(SearchResult)
|
||||||
class SearchResultAdmin(ModelAdmin):
|
class SearchResultAdmin(ModelAdmin):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
|
|
||||||
from .models import SearchResult
|
from .models import SearchResult
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.db import models
|
|
||||||
from accounts.models import CustomUser
|
from accounts.models import CustomUser
|
||||||
from user_groups.models import UserGroup
|
from django.db import models
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
|
from user_groups.models import UserGroup
|
||||||
|
|
||||||
|
|
||||||
class StripePrice(models.Model):
|
class StripePrice(models.Model):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from rest_framework import serializers
|
|
||||||
from subscriptions.models import SubscriptionPlan, UserSubscription, StripePrice
|
|
||||||
from accounts.serializers import SimpleCustomUserSerializer
|
from accounts.serializers import SimpleCustomUserSerializer
|
||||||
|
from rest_framework import serializers
|
||||||
|
from subscriptions.models import StripePrice, SubscriptionPlan, UserSubscription
|
||||||
|
|
||||||
|
|
||||||
class SimpleStripePriceSerializer(serializers.ModelSerializer):
|
class SimpleStripePriceSerializer(serializers.ModelSerializer):
|
||||||
|
|
|
@ -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
|
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
|
stripe.api_key = STRIPE_SECRET_KEY
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ from celery import shared_task
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def get_user_subscription(user_id):
|
def get_user_subscription(user_id):
|
||||||
from subscriptions.models import UserSubscription
|
|
||||||
from accounts.models import CustomUser
|
from accounts.models import CustomUser
|
||||||
|
from subscriptions.models import UserSubscription
|
||||||
|
|
||||||
USER = CustomUser.objects.get(id=user_id)
|
USER = CustomUser.objects.get(id=user_id)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.urls import path, include
|
from django.urls import include, path
|
||||||
from subscriptions import views
|
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
from subscriptions import views
|
||||||
|
|
||||||
router = DefaultRouter()
|
router = DefaultRouter()
|
||||||
router.register(r"plans", views.SubscriptionPlanViewset, basename="Subscription Plans")
|
router.register(r"plans", views.SubscriptionPlanViewset, basename="Subscription Plans")
|
||||||
|
|
|
@ -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 (
|
from subscriptions.serializers import (
|
||||||
SubscriptionPlanSerializer,
|
SubscriptionPlanSerializer,
|
||||||
UserSubscriptionSerializer,
|
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):
|
class SubscriptionPlanViewset(viewsets.ModelViewSet):
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from unfold.admin import ModelAdmin
|
from unfold.admin import ModelAdmin
|
||||||
from .models import UserGroup
|
|
||||||
from unfold.contrib.filters.admin import RangeDateFilter
|
from unfold.contrib.filters.admin import RangeDateFilter
|
||||||
|
|
||||||
|
from .models import UserGroup
|
||||||
|
|
||||||
|
|
||||||
@admin.register(UserGroup)
|
@admin.register(UserGroup)
|
||||||
class UserGroupAdmin(ModelAdmin):
|
class UserGroupAdmin(ModelAdmin):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
import stripe
|
||||||
|
from config.settings import STRIPE_SECRET_KEY
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from config.settings import STRIPE_SECRET_KEY
|
|
||||||
import stripe
|
|
||||||
|
|
||||||
stripe.api_key = STRIPE_SECRET_KEY
|
stripe.api_key = STRIPE_SECRET_KEY
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from .models import UserGroup
|
from .models import UserGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
from subscriptions.models import SubscriptionPlan
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
import stripe
|
||||||
from accounts.models import CustomUser
|
from accounts.models import CustomUser
|
||||||
from .models import UserGroup
|
from config.settings import ROOT_DIR, STRIPE_SECRET_KEY
|
||||||
from subscriptions.tasks import get_user_group_subscription
|
|
||||||
from django.db.models.signals import m2m_changed, post_migrate
|
from django.db.models.signals import m2m_changed, post_migrate
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from config.settings import STRIPE_SECRET_KEY, ROOT_DIR
|
from subscriptions.models import SubscriptionPlan
|
||||||
import os
|
from subscriptions.tasks import get_user_group_subscription
|
||||||
import json
|
|
||||||
import stripe
|
from .models import UserGroup
|
||||||
|
|
||||||
stripe.api_key = STRIPE_SECRET_KEY
|
stripe.api_key = STRIPE_SECRET_KEY
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
|
from search_results.tasks import create_search_result
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
from webdriver.utils import (
|
from webdriver.utils import (
|
||||||
setup_webdriver,
|
|
||||||
selenium_action_template,
|
|
||||||
google_search,
|
|
||||||
get_element,
|
get_element,
|
||||||
get_elements,
|
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
|
# Task template
|
||||||
|
|
|
@ -2,21 +2,20 @@
|
||||||
Settings file to hold constants and functions
|
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.by import By
|
||||||
from selenium.webdriver.common.keys import Keys
|
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.support import expected_conditions as EC
|
||||||
from selenium.webdriver import FirefoxOptions
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
from selenium import webdriver
|
|
||||||
import undetected_chromedriver as uc
|
|
||||||
from config.settings import USE_PROXY, CAPTCHA_TESTING
|
|
||||||
from config.settings import get_secret
|
|
||||||
from twocaptcha import TwoCaptcha
|
from twocaptcha import TwoCaptcha
|
||||||
from whois import whois
|
from whois import whois
|
||||||
from whois.parser import PywhoisError
|
from whois.parser import PywhoisError
|
||||||
import os
|
|
||||||
import random
|
|
||||||
|
|
||||||
|
|
||||||
def take_snapshot(driver, filename="dump.png"):
|
def take_snapshot(driver, filename="dump.png"):
|
||||||
|
@ -249,7 +248,7 @@ def execute_selenium_elements(driver, timeout, elements):
|
||||||
element["default"]["key"],
|
element["default"]["key"],
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print(f"Failed to find primary element")
|
print(f"Failed to find primary element")
|
||||||
# If that fails, try to get the failover one
|
# If that fails, try to get the failover one
|
||||||
print("Trying to find legacy element")
|
print("Trying to find legacy element")
|
||||||
|
|
Loading…
Reference in a new issue