Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize all file with a pass of pre-commit #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ If applicable, add screenshots to help explain your problem.
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,4 @@ __pycache__/

jobs/staticfiles
logs/*.log.*
logs/*
logs/*
10 changes: 10 additions & 0 deletions .isort
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[settings]
multi_line_output=3
include_trailing_comma=true
force_grid_wrap=0
use_parentheses=true
ensure_newline_before_comments=true
line_length=88
force_single_line=true
order_by_type=true
lines_between_types=1
47 changes: 39 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/ambv/black
rev: 21.6b0
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--sl", "--profile=black"]
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
exclude: ^migrations/

- repo: https://github.com/pre-commit/mirrors-isort
rev: 'v5.9.1'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: version.txt
- id: debug-statements
- id: check-added-large-files
- id: check-docstring-first
- id: check-yaml
exclude: conda/meta.yaml
- repo: local
hooks:
- id: isort
exclude: ^migrations/
- id: sphinx-build
name: sphinx build
entry: python -m sphinx.cmd.build
args: [-a, -E, -W, doc, sphinx]
language: system
files: ^doc/
types: [file]
pass_filenames: false
- id: sphinx-doctest
name: sphinx doctest
entry: python -m sphinx.cmd.build
args: [-a, -E, -b, doctest, doc, sphinx]
language: system
files: ^doc/
types: [file]
pass_filenames: false
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ node {
throw err
}

}
}
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ bi:

delete:
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete && find . -path "*/migrations/*.pyc" -delete

2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: gunicorn jobs.wsgi --log-file -
web: gunicorn jobs.wsgi --log-file -
2 changes: 1 addition & 1 deletion Procfile.windows
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: python manage.py runserver 0.0.0.0:5000
web: python manage.py runserver 0.0.0.0:5000
7 changes: 5 additions & 2 deletions accounts/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from django.urls import include, path
from django.urls import include
from django.urls import path
from rest_framework_simplejwt.views import TokenRefreshView

from .custom_claims import MyTokenObtainPairView
from .views import EditEmployeeProfileAPIView, SocialLoginAPIView, registration
from .views import EditEmployeeProfileAPIView
from .views import SocialLoginAPIView
from .views import registration

urlpatterns = [
# path('login/', TokenObtainPairView.as_view()),
Expand Down
22 changes: 16 additions & 6 deletions accounts/api/views.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
from django.contrib.auth import get_user_model, login
from django.contrib.auth import get_user_model
from django.contrib.auth import login
from requests.exceptions import HTTPError
from rest_framework import decorators, permissions, response, status
from rest_framework.generics import GenericAPIView, RetrieveUpdateAPIView
from rest_framework import decorators
from rest_framework import permissions
from rest_framework import response
from rest_framework import status
from rest_framework.generics import GenericAPIView
from rest_framework.generics import RetrieveUpdateAPIView
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework_simplejwt.tokens import RefreshToken
from social_core.backends.oauth import BaseOAuth2
from social_core.exceptions import AuthForbidden, AuthTokenError, MissingBackend
from social_django.utils import load_backend, load_strategy
from social_core.exceptions import AuthForbidden
from social_core.exceptions import AuthTokenError
from social_core.exceptions import MissingBackend
from social_django.utils import load_backend
from social_django.utils import load_strategy

from jobsapp.api.permissions import IsEmployee

from .custom_claims import MyTokenObtainPairSerializer
from .serializers import SocialSerializer, UserCreateSerializer, UserSerializer
from .serializers import SocialSerializer
from .serializers import UserCreateSerializer
from .serializers import UserSerializer

User = get_user_model()

Expand Down
3 changes: 2 additions & 1 deletion accounts/graphql/graphql_mixins.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.contrib.auth import get_user_model
from django.db import transaction

from accounts.forms import EmployeeRegistrationForm, EmployerRegistrationForm
from accounts.forms import EmployeeRegistrationForm
from accounts.forms import EmployerRegistrationForm
from jobsapp.graphql.graphql_base import Output

UserModel = get_user_model()
Expand Down
1 change: 1 addition & 0 deletions accounts/graphql/mutations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import graphene
import graphql_jwt

from . import sub_mutations as user_mutations


Expand Down
6 changes: 4 additions & 2 deletions accounts/graphql/sub_mutations.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import graphene
import graphql_jwt

from accounts.graphql.graphql_mixins import EmployeeRegisterMixin, EmployerRegisterMixin
from jobsapp.graphql.graphql_mixins import DynamicArgsMixin, MutationMixin
from accounts.graphql.graphql_mixins import EmployeeRegisterMixin
from accounts.graphql.graphql_mixins import EmployerRegisterMixin
from jobsapp.graphql.graphql_mixins import DynamicArgsMixin
from jobsapp.graphql.graphql_mixins import MutationMixin


class EmployeeRegister(MutationMixin, DynamicArgsMixin, EmployeeRegisterMixin, graphene.Mutation):
Expand Down
3 changes: 2 additions & 1 deletion accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):
Expand Down
3 changes: 2 additions & 1 deletion accounts/migrations/0002_auto_20190326_1754.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Generated by Django 2.1.7 on 2019-03-26 11:54

import accounts.managers
from django.db import migrations

import accounts.managers


class Migration(migrations.Migration):

Expand Down
3 changes: 2 additions & 1 deletion accounts/migrations/0003_alter_user_first_name.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Django 3.2.9 on 2021-11-08 17:46

from django.db import migrations, models
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):
Expand Down
6 changes: 4 additions & 2 deletions accounts/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.conf import settings
from django.conf.urls.static import static
from django.urls import include, path
from django.urls import include
from django.urls import path

from jobsapp.views import EditProfileView, EmployerProfileEditView
from jobsapp.views import EditProfileView
from jobsapp.views import EmployerProfileEditView

from .views import *

Expand Down
10 changes: 7 additions & 3 deletions accounts/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from django.contrib import auth, messages
from django.contrib import auth
from django.contrib import messages
from django.http import HttpResponseRedirect
from django.shortcuts import redirect, render
from django.views.generic import CreateView, FormView, RedirectView
from django.shortcuts import redirect
from django.shortcuts import render
from django.views.generic import CreateView
from django.views.generic import FormView
from django.views.generic import RedirectView

from accounts.forms import *
from accounts.models import User
Expand Down
6 changes: 3 additions & 3 deletions jobs/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import graphene
import graphql_jwt
from graphene_django.debug import DjangoDebug
from graphql_jwt.settings import jwt_settings

from jobs.settings import GRAPHQL_JWT
from jobsapp.graphql import queries as jobs_queries
from accounts.graphql import mutations as auth_mutations
from jobs.settings import GRAPHQL_JWT
from jobsapp.graphql import mutations as job_mutation
from graphql_jwt.settings import jwt_settings
from jobsapp.graphql import queries as jobs_queries


def jwt_payload(user, context=None):
Expand Down
9 changes: 6 additions & 3 deletions jobs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"social_django.middleware.SocialAuthExceptionMiddleware",
"django_prometheus.middleware.PrometheusAfterMiddleware"
"django_prometheus.middleware.PrometheusAfterMiddleware",
]

ROOT_URLCONF = "jobs.urls"
Expand Down Expand Up @@ -313,5 +313,8 @@

if ENABLE_PROMETHEUS:
INSTALLED_APPS += ["django_prometheus"]
MIDDLEWARE = ['django_prometheus.middleware.PrometheusBeforeMiddleware'] + MIDDLEWARE + \
['django_prometheus.middleware.PrometheusAfterMiddleware']
MIDDLEWARE = (
["django_prometheus.middleware.PrometheusBeforeMiddleware"]
+ MIDDLEWARE
+ ["django_prometheus.middleware.PrometheusAfterMiddleware"]
)
26 changes: 15 additions & 11 deletions jobs/urls.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
from django.urls import re_path
from django.conf import settings
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.contrib.flatpages import views as flatpages_views
from django.contrib.sitemaps.views import sitemap
from django.urls import include, path
from django.urls import include
from django.urls import path
from django.urls import re_path
from django.views.decorators.csrf import csrf_exempt
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions
from django.views.decorators.csrf import csrf_exempt
from graphene_file_upload.django import FileUploadGraphQLView
from rest_framework import permissions

from jobs.sitemaps import Sitemaps, StaticViewSitemap
from resume_cv.views import load_builder, update_builder
from jobs.sitemaps import Sitemaps
from jobs.sitemaps import StaticViewSitemap
from resume_cv.views import load_builder
from resume_cv.views import update_builder

schema_view = get_schema_view(
openapi.Info(
Expand All @@ -27,10 +30,11 @@
permission_classes=(permissions.AllowAny,),
)

lang_patterns = i18n_patterns(path("", include("jobsapp.urls")),
path("", include("accounts.urls")),
path("", include("resume_cv.urls")),
)
lang_patterns = i18n_patterns(
path("", include("jobsapp.urls")),
path("", include("accounts.urls")),
path("", include("resume_cv.urls")),
)

# sitemaps = {
# '': JobViewSitemap
Expand Down Expand Up @@ -60,4 +64,4 @@
]

if settings.ENABLE_PROMETHEUS:
urlpatterns.append(path("", include('django_prometheus.urls')))
urlpatterns.append(path("", include("django_prometheus.urls")))
12 changes: 5 additions & 7 deletions jobsapp/api/custom_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ def custom_exception_handler(exc, context):
return response


"""
# to work with this custom error handler, save this file in your project,
#add this in settings.py
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'core.api.custom_exception.custom_exception_handler', #location for your file
}
# add this in settings.py
# REST_FRAMEWORK = {
# 'EXCEPTION_HANDLER': 'core.api.custom_exception.custom_exception_handler', #location for your file
# }
# and add raise_exception=True in is_valid() method
if serializer.is_valid(raise_exception=True):
"""
# if serializer.is_valid(raise_exception=True):
27 changes: 13 additions & 14 deletions jobsapp/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
from django.urls import include, path
from django.urls import include
from django.urls import path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions
from rest_framework.routers import DefaultRouter

from .views import (
ApplicantsListAPIView,
ApplicantsPerJobListAPIView,
AppliedJobsAPIView,
ApplyJobApiView,
DashboardAPIView,
JobCreateAPIView,
JobViewSet,
SearchApiView,
UpdateApplicantStatusAPIView,
already_applied_api_view,
categories_list_api_view,
)
from .views import ApplicantsListAPIView
from .views import ApplicantsPerJobListAPIView
from .views import AppliedJobsAPIView
from .views import ApplyJobApiView
from .views import DashboardAPIView
from .views import JobCreateAPIView
from .views import JobViewSet
from .views import SearchApiView
from .views import UpdateApplicantStatusAPIView
from .views import already_applied_api_view
from .views import categories_list_api_view

router = DefaultRouter()
router.register("jobs", JobViewSet)
Expand Down
3 changes: 2 additions & 1 deletion jobsapp/api/views/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.http import JsonResponse
from rest_framework import viewsets
from rest_framework.decorators import api_view, permission_classes
from rest_framework.decorators import api_view
from rest_framework.decorators import permission_classes
from rest_framework.generics import ListAPIView
from rest_framework.permissions import AllowAny
from rest_framework.views import APIView
Expand Down
Loading