diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f1b11df..7b15cd4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ --- exclude: "^docs/|/migrations/" -default_stages: [commit] +default_stages: [pre-commit] default_language_version: python: python3.10 @@ -17,7 +17,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v6.0.0 hooks: - id: check-yaml - id: end-of-file-fixer @@ -31,19 +31,19 @@ repos: - id: check-executables-have-shebangs - id: check-merge-conflict - - repo: https://github.com/psf/black - rev: 23.1.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.3.1 hooks: - id: black - repo: https://github.com/adrienverge/yamllint.git - rev: v1.30.0 + rev: v1.38.0 hooks: - id: yamllint args: [ --format, parsable, --strict ] - repo: https://github.com/PyCQA/bandit - rev: 1.7.5 + rev: 1.9.4 hooks: - id: bandit args: ['-iii', '-ll', '-s', 'B404', 'B602', 'B603', 'B607'] @@ -51,13 +51,13 @@ repos: exclude: ^test/ - repo: https://github.com/PyCQA/docformatter - rev: v1.5.1 + rev: v1.7.7 hooks: - id: docformatter args: [ --in-place, --wrap-summaries=115, --wrap-descriptions=120 ] - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 7.3.0 hooks: - id: flake8 args: ["--config=setup.cfg"] @@ -73,13 +73,13 @@ repos: ] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 8.0.1 hooks: - id: isort name: isort (python) - repo: https://github.com/rtts/djhtml - rev: 3.0.6 + rev: 3.0.11 hooks: - id: djhtml @@ -90,7 +90,7 @@ repos: additional_dependencies: ["toml"] - repo: https://github.com/pycqa/pylint - rev: v2.17.1 + rev: v4.0.5 hooks: - id: pylint exclude: | @@ -127,7 +127,7 @@ repos: - djangorestframework-jsonapi - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.1.1 + rev: v1.20.0 hooks: - id: mypy exclude: "[a-zA-Z]*/(migrations)/(.)*" @@ -159,7 +159,7 @@ repos: ] - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 + rev: v3.21.2 hooks: - id: pyupgrade args: [ "--py36-plus", "--py37-plus", "--py38-plus", "--py39-plus" ] diff --git a/config/__init__.py b/config/__init__.py index 3f8d4fc..1df0d6f 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -1 +1 @@ -"""init placeholders for config.""" +"""Init placeholders for config.""" diff --git a/config/api_router.py b/config/api_router.py index a1836d4..a0a528e 100644 --- a/config/api_router.py +++ b/config/api_router.py @@ -1,4 +1,5 @@ """Create your user API router here.""" + from django.conf import settings from rest_framework.routers import BaseRouter, DefaultRouter, SimpleRouter @@ -13,7 +14,6 @@ UserViewSet, ) - router = BaseRouter() if settings.DEBUG: diff --git a/config/settings/base.py b/config/settings/base.py index 946aa57..4e89c8d 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -1,9 +1,9 @@ """Base settings to build other settings files upon.""" + from pathlib import Path import environ - ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent # onebarangay_psql/ APPS_DIR = ROOT_DIR / "onebarangay_psql" diff --git a/config/settings/local.py b/config/settings/local.py index 62159bb..88c0e19 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -1,9 +1,9 @@ """Define your local settings here.""" + # pylint: disable=W0401,W0614 from .base import * # noqa from .base import env - # GENERAL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#debug diff --git a/config/settings/production.py b/config/settings/production.py index 8a8731a..ef983d3 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -1,4 +1,5 @@ """Define your production settings here.""" + import logging import sentry_sdk @@ -10,7 +11,6 @@ from .base import * # noqa from .base import env - # GENERAL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#secret-key diff --git a/config/settings/test.py b/config/settings/test.py index b02bf4f..ff05c48 100644 --- a/config/settings/test.py +++ b/config/settings/test.py @@ -1,9 +1,9 @@ """With these settings, tests run faster.""" + # pylint: disable=wildcard-import,unused-wildcard-import from .base import * # noqa from .base import env - # GENERAL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#secret-key diff --git a/config/wsgi.py b/config/wsgi.py index e4ece34..54d75a7 100644 --- a/config/wsgi.py +++ b/config/wsgi.py @@ -11,13 +11,13 @@ middleware here, or combine a Django application with an application of another framework. """ + import os import sys from pathlib import Path from django.core.wsgi import get_wsgi_application - # This allows easy placement of apps within the interior # onebarangay_psql directory. ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent diff --git a/merge_production_dotenvs_in_dotenv.py b/merge_production_dotenvs_in_dotenv.py index ac2831f..b986cc6 100644 --- a/merge_production_dotenvs_in_dotenv.py +++ b/merge_production_dotenvs_in_dotenv.py @@ -1,11 +1,11 @@ """Merge Environments in .env file.""" + import os from collections.abc import Sequence from pathlib import Path import pytest - ROOT_DIR_PATH = Path(__file__).parent.resolve() PRODUCTION_DOTENVS_DIR_PATH = ROOT_DIR_PATH / ".envs" / ".production" PRODUCTION_DOTENV_FILE_PATHS = [ diff --git a/onebarangay_psql/__init__.py b/onebarangay_psql/__init__.py index 22cc60e..9b1cd34 100644 --- a/onebarangay_psql/__init__.py +++ b/onebarangay_psql/__init__.py @@ -1,4 +1,5 @@ """INIT file for module onebarangay_psql.""" + __version__ = "0.1.0" __version_info__ = tuple( int(num) if num.isdigit() else num diff --git a/onebarangay_psql/announcement/admin.py b/onebarangay_psql/announcement/admin.py index 36ed57d..4a9eb8f 100644 --- a/onebarangay_psql/announcement/admin.py +++ b/onebarangay_psql/announcement/admin.py @@ -1,4 +1,5 @@ """Register your announcement models here.""" + from django.contrib import admin from django.utils.html import strip_tags from import_export import resources diff --git a/onebarangay_psql/announcement/apps.py b/onebarangay_psql/announcement/apps.py index e575df4..83fbfde 100644 --- a/onebarangay_psql/announcement/apps.py +++ b/onebarangay_psql/announcement/apps.py @@ -1,4 +1,5 @@ """Create your app config for announcement apps.""" + import contextlib from django.apps import AppConfig diff --git a/onebarangay_psql/announcement/factories.py b/onebarangay_psql/announcement/factories.py index 3e23233..088ee5c 100644 --- a/onebarangay_psql/announcement/factories.py +++ b/onebarangay_psql/announcement/factories.py @@ -1,4 +1,5 @@ """Create your announcement factories here.""" + import factory from django.utils.text import slugify from factory import Faker diff --git a/onebarangay_psql/announcement/models.py b/onebarangay_psql/announcement/models.py index 5eff7f5..4d6224a 100644 --- a/onebarangay_psql/announcement/models.py +++ b/onebarangay_psql/announcement/models.py @@ -1,4 +1,5 @@ """Create your announcement models here.""" + from auditlog.registry import auditlog from django.contrib.auth import get_user_model from django.db import models @@ -8,7 +9,6 @@ from taggit.managers import TaggableManager from tinymce.models import HTMLField - user = get_user_model() diff --git a/onebarangay_psql/announcement/permission.py b/onebarangay_psql/announcement/permission.py index 5ca6d78..2b10e39 100644 --- a/onebarangay_psql/announcement/permission.py +++ b/onebarangay_psql/announcement/permission.py @@ -1,4 +1,5 @@ """Create your announcement permissions here.""" + from rest_framework import permissions diff --git a/onebarangay_psql/announcement/serializer.py b/onebarangay_psql/announcement/serializer.py index b5035dc..66d4c6f 100644 --- a/onebarangay_psql/announcement/serializer.py +++ b/onebarangay_psql/announcement/serializer.py @@ -1,4 +1,5 @@ """Create your announcement serializer here.""" + from rest_framework_json_api import serializers from rest_framework_json_api.relations import HyperlinkedRelatedField from taggit.serializers import TaggitSerializer, TagListSerializerField diff --git a/onebarangay_psql/announcement/tests/test_drf_http_methods.py b/onebarangay_psql/announcement/tests/test_drf_http_methods.py index 2b7ef16..f7e6d3d 100644 --- a/onebarangay_psql/announcement/tests/test_drf_http_methods.py +++ b/onebarangay_psql/announcement/tests/test_drf_http_methods.py @@ -1,4 +1,5 @@ """Create your announcement drf http methods tests here.""" + from django.contrib.auth import get_user_model from django.test.client import Client from django.urls import reverse @@ -6,7 +7,6 @@ from onebarangay_psql.announcement.models import Announcement - User = get_user_model() diff --git a/onebarangay_psql/announcement/tests/test_drf_urls.py b/onebarangay_psql/announcement/tests/test_drf_urls.py index ffa768e..4aeb903 100644 --- a/onebarangay_psql/announcement/tests/test_drf_urls.py +++ b/onebarangay_psql/announcement/tests/test_drf_urls.py @@ -1,10 +1,10 @@ """Create your test for the DRF urls.""" + import pytest from django.urls import resolve, reverse from onebarangay_psql.announcement.models import Announcement - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/announcement/tests/test_drf_views.py b/onebarangay_psql/announcement/tests/test_drf_views.py index 3220832..c2aed28 100644 --- a/onebarangay_psql/announcement/tests/test_drf_views.py +++ b/onebarangay_psql/announcement/tests/test_drf_views.py @@ -1,4 +1,5 @@ """Create your announcement drf viewset tests here.""" + import pytest from _pytest.fixtures import FixtureRequest from django.test import RequestFactory @@ -10,7 +11,6 @@ from onebarangay_psql.announcement.viewset import AnnouncementViewSet from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/announcement/tests/test_model.py b/onebarangay_psql/announcement/tests/test_model.py index 51c7a78..cd15fb7 100644 --- a/onebarangay_psql/announcement/tests/test_model.py +++ b/onebarangay_psql/announcement/tests/test_model.py @@ -1,10 +1,10 @@ """Create your announcement model tests here.""" + import pytest from onebarangay_psql.announcement.models import Announcement from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/announcement/viewset.py b/onebarangay_psql/announcement/viewset.py index e2a6c09..39cb308 100644 --- a/onebarangay_psql/announcement/viewset.py +++ b/onebarangay_psql/announcement/viewset.py @@ -1,4 +1,5 @@ """Create your announcement views here.""" + from django.utils.html import strip_tags from push_notifications.models import GCMDevice from rest_framework import viewsets diff --git a/onebarangay_psql/appointment/admin.py b/onebarangay_psql/appointment/admin.py index 3da9c42..bcb3b52 100644 --- a/onebarangay_psql/appointment/admin.py +++ b/onebarangay_psql/appointment/admin.py @@ -1,4 +1,5 @@ """Register your appointment models here.""" + from django.contrib import admin from import_export import resources from import_export.admin import ImportExportModelAdmin diff --git a/onebarangay_psql/appointment/apps.py b/onebarangay_psql/appointment/apps.py index 70394d4..d45cfeb 100644 --- a/onebarangay_psql/appointment/apps.py +++ b/onebarangay_psql/appointment/apps.py @@ -1,4 +1,5 @@ """Create your appointment apps here.""" + from django.apps import AppConfig diff --git a/onebarangay_psql/appointment/factories.py b/onebarangay_psql/appointment/factories.py index bdf93b6..2a8622b 100644 --- a/onebarangay_psql/appointment/factories.py +++ b/onebarangay_psql/appointment/factories.py @@ -1,4 +1,5 @@ """Create your appointment factories here.""" + from zoneinfo import ZoneInfo import factory @@ -9,7 +10,6 @@ from onebarangay_psql.appointment.models import Appointment from onebarangay_psql.users.factories import UserFactory - with open(APPS_DIR / "media/appointment/government_id/default.png", "rb") as f: image = SimpleUploadedFile(f.name, f.read(), content_type="image/jpeg") diff --git a/onebarangay_psql/appointment/models.py b/onebarangay_psql/appointment/models.py index ea09c9e..c24f0e5 100644 --- a/onebarangay_psql/appointment/models.py +++ b/onebarangay_psql/appointment/models.py @@ -1,4 +1,5 @@ """Create your appointment models here.""" + from datetime import timedelta from auditlog.registry import auditlog diff --git a/onebarangay_psql/appointment/permissions.py b/onebarangay_psql/appointment/permissions.py index 26f1b95..873c0f4 100644 --- a/onebarangay_psql/appointment/permissions.py +++ b/onebarangay_psql/appointment/permissions.py @@ -1,4 +1,5 @@ """Create your appointment permissions here.""" + from rest_framework import permissions from rest_framework.request import Request from rest_framework.views import APIView diff --git a/onebarangay_psql/appointment/serializer.py b/onebarangay_psql/appointment/serializer.py index 612373b..292e94e 100644 --- a/onebarangay_psql/appointment/serializer.py +++ b/onebarangay_psql/appointment/serializer.py @@ -1,4 +1,5 @@ """Create your appointment serializer here.""" + from rest_framework_json_api import serializers from rest_framework_json_api.relations import HyperlinkedRelatedField diff --git a/onebarangay_psql/appointment/tests/test_drf_http_methods.py b/onebarangay_psql/appointment/tests/test_drf_http_methods.py index 6b78c81..0ee09d4 100644 --- a/onebarangay_psql/appointment/tests/test_drf_http_methods.py +++ b/onebarangay_psql/appointment/tests/test_drf_http_methods.py @@ -1,4 +1,5 @@ """Create your appointment drf http methods tests here.""" + from datetime import datetime from zoneinfo import ZoneInfo @@ -12,7 +13,6 @@ from config.settings.base import APPS_DIR from onebarangay_psql.appointment.models import Appointment - User = get_user_model() diff --git a/onebarangay_psql/appointment/tests/test_drf_urls.py b/onebarangay_psql/appointment/tests/test_drf_urls.py index 74c6da3..e1865c5 100644 --- a/onebarangay_psql/appointment/tests/test_drf_urls.py +++ b/onebarangay_psql/appointment/tests/test_drf_urls.py @@ -1,10 +1,10 @@ """Create your test for the appointment DRF urls.""" + import pytest from django.urls import resolve, reverse from onebarangay_psql.appointment.models import Appointment - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/appointment/tests/test_drf_views.py b/onebarangay_psql/appointment/tests/test_drf_views.py index 48f8412..6ac15e1 100644 --- a/onebarangay_psql/appointment/tests/test_drf_views.py +++ b/onebarangay_psql/appointment/tests/test_drf_views.py @@ -1,4 +1,5 @@ """Create your appointment drf viewset tests here.""" + from datetime import datetime from zoneinfo import ZoneInfo @@ -18,7 +19,6 @@ from onebarangay_psql.appointment.viewset import AppointmentViewSet, StatusUpdateViewSet from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/appointment/tests/test_model.py b/onebarangay_psql/appointment/tests/test_model.py index be19167..ba1c22f 100644 --- a/onebarangay_psql/appointment/tests/test_model.py +++ b/onebarangay_psql/appointment/tests/test_model.py @@ -1,4 +1,5 @@ """Create your appointment model tests here.""" + import zoneinfo from datetime import datetime, timedelta @@ -7,7 +8,6 @@ from onebarangay_psql.appointment.models import Appointment from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/appointment/viewset.py b/onebarangay_psql/appointment/viewset.py index eee179e..d81e926 100644 --- a/onebarangay_psql/appointment/viewset.py +++ b/onebarangay_psql/appointment/viewset.py @@ -1,4 +1,5 @@ """Create your appointment views here.""" + from rest_framework import mixins, viewsets from rest_framework.decorators import action from rest_framework.permissions import IsAdminUser, IsAuthenticated diff --git a/onebarangay_psql/log/__init__.py b/onebarangay_psql/log/__init__.py index ad82db5..add0b67 100644 --- a/onebarangay_psql/log/__init__.py +++ b/onebarangay_psql/log/__init__.py @@ -1,2 +1,3 @@ """Default init file for log package.""" + from .views import prometheus_metrics # noqa: F401 diff --git a/onebarangay_psql/log/middleware.py b/onebarangay_psql/log/middleware.py index 0ffd4ba..d12e18d 100644 --- a/onebarangay_psql/log/middleware.py +++ b/onebarangay_psql/log/middleware.py @@ -1,4 +1,5 @@ """Page Views and Time Spent custom middleware for Prometheus.""" + import time from onebarangay_psql.utils.prometheus import PROM_GRAPHQL_REQUEST_TIME, PROM_PAGEVIEWS diff --git a/onebarangay_psql/log/views.py b/onebarangay_psql/log/views.py index 30c1791..4e76e21 100644 --- a/onebarangay_psql/log/views.py +++ b/onebarangay_psql/log/views.py @@ -1,4 +1,5 @@ """Views for Prometheus monitoring.""" + from django.http import HttpResponse from django.views.decorators.csrf import csrf_exempt from prometheus_client import CONTENT_TYPE_LATEST diff --git a/onebarangay_psql/rbi/admin.py b/onebarangay_psql/rbi/admin.py index d0a5d09..6d27f99 100644 --- a/onebarangay_psql/rbi/admin.py +++ b/onebarangay_psql/rbi/admin.py @@ -1,4 +1,5 @@ """Register your rbi models here.""" + from datetime import datetime from django.contrib import admin diff --git a/onebarangay_psql/rbi/apps.py b/onebarangay_psql/rbi/apps.py index 961de30..12cf62c 100644 --- a/onebarangay_psql/rbi/apps.py +++ b/onebarangay_psql/rbi/apps.py @@ -1,4 +1,5 @@ """Create your rbi apps here.""" + from django.apps import AppConfig diff --git a/onebarangay_psql/rbi/factories.py b/onebarangay_psql/rbi/factories.py index 1bf3a5c..d6f1c8b 100644 --- a/onebarangay_psql/rbi/factories.py +++ b/onebarangay_psql/rbi/factories.py @@ -1,4 +1,5 @@ """Create your rbi factories here.""" + from zoneinfo import ZoneInfo import factory diff --git a/onebarangay_psql/rbi/models.py b/onebarangay_psql/rbi/models.py index 01b72ce..affb06e 100644 --- a/onebarangay_psql/rbi/models.py +++ b/onebarangay_psql/rbi/models.py @@ -1,4 +1,5 @@ """Create your rbi models here.""" + from auditlog.registry import auditlog from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models diff --git a/onebarangay_psql/rbi/serializers.py b/onebarangay_psql/rbi/serializers.py index ecd5873..b83870f 100644 --- a/onebarangay_psql/rbi/serializers.py +++ b/onebarangay_psql/rbi/serializers.py @@ -1,4 +1,5 @@ """Create your rbi serializers here.""" + from rest_framework_json_api import serializers from onebarangay_psql.rbi.models import FamilyMember, HouseRecord diff --git a/onebarangay_psql/rbi/tests/test_drf_http_methods.py b/onebarangay_psql/rbi/tests/test_drf_http_methods.py index e92eca8..6f8129f 100644 --- a/onebarangay_psql/rbi/tests/test_drf_http_methods.py +++ b/onebarangay_psql/rbi/tests/test_drf_http_methods.py @@ -1,4 +1,5 @@ """Create your rbi drf http methods tests here.""" + import datetime from zoneinfo import ZoneInfo diff --git a/onebarangay_psql/rbi/tests/test_drf_urls.py b/onebarangay_psql/rbi/tests/test_drf_urls.py index 5094256..2d280c6 100644 --- a/onebarangay_psql/rbi/tests/test_drf_urls.py +++ b/onebarangay_psql/rbi/tests/test_drf_urls.py @@ -1,4 +1,5 @@ """Create your rbi drf urls tests here.""" + from django.urls import resolve from rest_framework.reverse import reverse diff --git a/onebarangay_psql/rbi/tests/test_drf_views.py b/onebarangay_psql/rbi/tests/test_drf_views.py index 2205def..7b4bb22 100644 --- a/onebarangay_psql/rbi/tests/test_drf_views.py +++ b/onebarangay_psql/rbi/tests/test_drf_views.py @@ -1,4 +1,5 @@ """Create your rbi drf viewsets test here.""" + import pytest from django.test import RequestFactory from django.urls import reverse @@ -13,7 +14,6 @@ from onebarangay_psql.rbi.viewset import FamilyMemberViewSet, HouseRecordViewSet from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/rbi/tests/test_model.py b/onebarangay_psql/rbi/tests/test_model.py index 05b8a4a..f7708b4 100644 --- a/onebarangay_psql/rbi/tests/test_model.py +++ b/onebarangay_psql/rbi/tests/test_model.py @@ -1,4 +1,5 @@ """Create your rbi model tests here.""" + import datetime from zoneinfo import ZoneInfo diff --git a/onebarangay_psql/rbi/viewset.py b/onebarangay_psql/rbi/viewset.py index 876c987..a8805de 100644 --- a/onebarangay_psql/rbi/viewset.py +++ b/onebarangay_psql/rbi/viewset.py @@ -1,4 +1,5 @@ """Create your rbi viewsets here.""" + from rest_framework import viewsets from rest_framework.permissions import IsAdminUser diff --git a/onebarangay_psql/statistics/admin.py b/onebarangay_psql/statistics/admin.py index 15ed351..32f4168 100644 --- a/onebarangay_psql/statistics/admin.py +++ b/onebarangay_psql/statistics/admin.py @@ -1,6 +1,6 @@ """Register your statistics models here.""" + from adminactions import actions from django.contrib import admin - actions.add_to_site(admin.site) diff --git a/onebarangay_psql/statistics/apps.py b/onebarangay_psql/statistics/apps.py index b7358cc..08a2050 100644 --- a/onebarangay_psql/statistics/apps.py +++ b/onebarangay_psql/statistics/apps.py @@ -1,4 +1,5 @@ """Create your statistics apps here.""" + from django.apps import AppConfig diff --git a/onebarangay_psql/statistics/management/commands/setup_test_data.py b/onebarangay_psql/statistics/management/commands/setup_test_data.py index 771c5cc..ce30b55 100644 --- a/onebarangay_psql/statistics/management/commands/setup_test_data.py +++ b/onebarangay_psql/statistics/management/commands/setup_test_data.py @@ -1,4 +1,5 @@ """Create your custom management commands here.""" + import random from datetime import date, datetime, timedelta from pathlib import Path @@ -22,7 +23,6 @@ from onebarangay_psql.users.models import Profile from onebarangay_psql.utils.refresh_material_view import refresh_mv - NUM_USERS = 50 NUM_APPOINTMENTS = 25 NUM_APPOINTMENTS_PER_USER = 4 @@ -143,7 +143,7 @@ def handle(self, *args, **kwargs): def set_sequence( - model: Union[Appointment, Announcement, User, HouseRecord, FamilyMember] + model: Union[Appointment, Announcement, User, HouseRecord, FamilyMember], ) -> None: """Reset the id sequence of a table. diff --git a/onebarangay_psql/statistics/models.py b/onebarangay_psql/statistics/models.py index 8598e8a..6956607 100644 --- a/onebarangay_psql/statistics/models.py +++ b/onebarangay_psql/statistics/models.py @@ -1,4 +1,5 @@ """Create your statistics models here.""" + from django.db import models diff --git a/onebarangay_psql/statistics/serializers.py b/onebarangay_psql/statistics/serializers.py index ee284f0..2bac5db 100644 --- a/onebarangay_psql/statistics/serializers.py +++ b/onebarangay_psql/statistics/serializers.py @@ -1,4 +1,5 @@ """Create your statistics serializers here.""" + from rest_framework_json_api import serializers from onebarangay_psql.statistics import models diff --git a/onebarangay_psql/statistics/tests/test_drf_urls.py b/onebarangay_psql/statistics/tests/test_drf_urls.py index 412aa03..c847559 100644 --- a/onebarangay_psql/statistics/tests/test_drf_urls.py +++ b/onebarangay_psql/statistics/tests/test_drf_urls.py @@ -1,4 +1,5 @@ """Create your statistics drf urls tests here.""" + import pytest from django.urls import resolve, reverse diff --git a/onebarangay_psql/statistics/tests/test_drf_views.py b/onebarangay_psql/statistics/tests/test_drf_views.py index c2d9795..c00af7d 100644 --- a/onebarangay_psql/statistics/tests/test_drf_views.py +++ b/onebarangay_psql/statistics/tests/test_drf_views.py @@ -1,4 +1,5 @@ """Create your statistics drf viewsets test here.""" + import pytest from django.test import RequestFactory from django.urls import reverse diff --git a/onebarangay_psql/statistics/viewset.py b/onebarangay_psql/statistics/viewset.py index e450a44..73cbf9a 100644 --- a/onebarangay_psql/statistics/viewset.py +++ b/onebarangay_psql/statistics/viewset.py @@ -1,4 +1,5 @@ """Create your statistics viewsets here.""" + import datetime import time from typing import Any @@ -104,8 +105,7 @@ def create(self, request: Request, *args: Any, **kwargs: Any) -> Response: """Create a new refresh materialized view.""" start_time = time.monotonic() with connection.cursor() as cursor: - cursor.execute( - """ + cursor.execute(""" REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_total; REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_user_signup; REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_appointment; @@ -117,8 +117,7 @@ def create(self, request: Request, *args: Any, **kwargs: Any) -> Response: REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_social_class; REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_user_signup_monthly; REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_user_login_monthly; - """ - ) + """) end_time = time.monotonic() serializer = self.get_serializer( diff --git a/onebarangay_psql/users/adapters.py b/onebarangay_psql/users/adapters.py index d8c54d7..314aea7 100644 --- a/onebarangay_psql/users/adapters.py +++ b/onebarangay_psql/users/adapters.py @@ -1,4 +1,5 @@ """Create your Adapters for user's app.""" + from typing import Any from allauth.account.adapter import DefaultAccountAdapter diff --git a/onebarangay_psql/users/admin.py b/onebarangay_psql/users/admin.py index 6469d9e..2b802e4 100644 --- a/onebarangay_psql/users/admin.py +++ b/onebarangay_psql/users/admin.py @@ -1,4 +1,5 @@ """Register your user models here..""" + from django.contrib import admin from django.contrib.auth import admin as auth_admin, get_user_model from django.utils.translation import gettext as _ @@ -8,7 +9,6 @@ from onebarangay_psql.users.forms import UserAdminChangeForm, UserAdminCreationForm from onebarangay_psql.users.models import Profile - User = get_user_model() diff --git a/onebarangay_psql/users/api/serializers.py b/onebarangay_psql/users/api/serializers.py index c0396c9..0f43a34 100644 --- a/onebarangay_psql/users/api/serializers.py +++ b/onebarangay_psql/users/api/serializers.py @@ -1,4 +1,5 @@ """Create your user and profile serializers here.""" + from django.contrib.auth import get_user_model from rest_framework_json_api import serializers from rest_framework_json_api.relations import HyperlinkedRelatedField @@ -6,7 +7,6 @@ from onebarangay_psql.users.models import Profile from onebarangay_psql.utils.choice_field import ChoicesField - User = get_user_model() diff --git a/onebarangay_psql/users/api/views.py b/onebarangay_psql/users/api/views.py index 58c3af5..d737ff4 100644 --- a/onebarangay_psql/users/api/views.py +++ b/onebarangay_psql/users/api/views.py @@ -1,4 +1,5 @@ """Create your user API views here.""" + from django.contrib.auth import get_user_model from django.shortcuts import get_object_or_404 from push_notifications.api.rest_framework import ( @@ -26,7 +27,6 @@ from onebarangay_psql.users.models import Profile from onebarangay_psql.users.permissions import IsOwnProfile - User = get_user_model() diff --git a/onebarangay_psql/users/apps.py b/onebarangay_psql/users/apps.py index 68b4103..0589ecc 100644 --- a/onebarangay_psql/users/apps.py +++ b/onebarangay_psql/users/apps.py @@ -1,4 +1,5 @@ """Create your app config for user apps.""" + import contextlib from django.apps import AppConfig diff --git a/onebarangay_psql/users/context_processors.py b/onebarangay_psql/users/context_processors.py index e8917f0..d856d14 100644 --- a/onebarangay_psql/users/context_processors.py +++ b/onebarangay_psql/users/context_processors.py @@ -1,4 +1,5 @@ """Cree your context processors here for user's app.""" + from django.conf import settings diff --git a/onebarangay_psql/users/factories.py b/onebarangay_psql/users/factories.py index 391dc03..5b97bfc 100644 --- a/onebarangay_psql/users/factories.py +++ b/onebarangay_psql/users/factories.py @@ -1,4 +1,5 @@ """Create your test factories here.""" + from collections.abc import Sequence from typing import Any diff --git a/onebarangay_psql/users/forms.py b/onebarangay_psql/users/forms.py index 8c7c008..fb1b121 100644 --- a/onebarangay_psql/users/forms.py +++ b/onebarangay_psql/users/forms.py @@ -1,10 +1,10 @@ """Create forms for the user's app.""" + from allauth.account.forms import SignupForm from allauth.socialaccount.forms import SignupForm as SocialSignupForm from django.contrib.auth import forms as admin_forms, get_user_model from django.utils.translation import gettext_lazy as _ - User = get_user_model() diff --git a/onebarangay_psql/users/models.py b/onebarangay_psql/users/models.py index 30b54fc..aea1f1b 100644 --- a/onebarangay_psql/users/models.py +++ b/onebarangay_psql/users/models.py @@ -1,4 +1,5 @@ """Create your announcement models here.""" + from auditlog.registry import auditlog from django.contrib.auth.models import AbstractUser from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator diff --git a/onebarangay_psql/users/permissions.py b/onebarangay_psql/users/permissions.py index 7dd59b2..5ef8007 100644 --- a/onebarangay_psql/users/permissions.py +++ b/onebarangay_psql/users/permissions.py @@ -1,4 +1,5 @@ """Create your custom permissions for user's app.""" + from django.views import View from rest_framework import permissions from rest_framework.request import Request diff --git a/onebarangay_psql/users/signals.py b/onebarangay_psql/users/signals.py index 2622e64..2b2765c 100644 --- a/onebarangay_psql/users/signals.py +++ b/onebarangay_psql/users/signals.py @@ -1,11 +1,11 @@ """Create your own signals for your user's model.""" + from django.contrib.auth import get_user_model from django.db.models.signals import post_save from django.dispatch import receiver from onebarangay_psql.users.models import Profile - User = get_user_model() diff --git a/onebarangay_psql/users/tests/test_admin.py b/onebarangay_psql/users/tests/test_admin.py index ba4c9ac..767195c 100644 --- a/onebarangay_psql/users/tests/test_admin.py +++ b/onebarangay_psql/users/tests/test_admin.py @@ -1,9 +1,9 @@ """Create your tests for the admin app here.""" + import pytest from django.contrib.auth import get_user_model from django.urls import reverse - pytestmark = pytest.mark.django_db User = get_user_model() diff --git a/onebarangay_psql/users/tests/test_drf_urls.py b/onebarangay_psql/users/tests/test_drf_urls.py index 39499ad..f97099f 100644 --- a/onebarangay_psql/users/tests/test_drf_urls.py +++ b/onebarangay_psql/users/tests/test_drf_urls.py @@ -1,10 +1,10 @@ """Create your test for the DRF urls.""" + import pytest from django.urls import resolve, reverse from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/users/tests/test_drf_views.py b/onebarangay_psql/users/tests/test_drf_views.py index 0831a40..fc918bc 100644 --- a/onebarangay_psql/users/tests/test_drf_views.py +++ b/onebarangay_psql/users/tests/test_drf_views.py @@ -1,11 +1,11 @@ """Create your test for the DRF views.""" + import pytest from django.test import RequestFactory from onebarangay_psql.users.api.views import ProfileViewSet, UserViewSet from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/users/tests/test_forms.py b/onebarangay_psql/users/tests/test_forms.py index 560865f..c4efc58 100644 --- a/onebarangay_psql/users/tests/test_forms.py +++ b/onebarangay_psql/users/tests/test_forms.py @@ -1,11 +1,11 @@ """Module for all Form Tests.""" + import pytest from django.utils.translation import gettext_lazy as _ from onebarangay_psql.users.forms import UserAdminCreationForm from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/users/tests/test_models.py b/onebarangay_psql/users/tests/test_models.py index 920d303..b9cd52a 100644 --- a/onebarangay_psql/users/tests/test_models.py +++ b/onebarangay_psql/users/tests/test_models.py @@ -1,9 +1,9 @@ """Create your user and profile test models here.""" + import pytest from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/users/tests/test_permission.py b/onebarangay_psql/users/tests/test_permission.py index 835561f..421491d 100644 --- a/onebarangay_psql/users/tests/test_permission.py +++ b/onebarangay_psql/users/tests/test_permission.py @@ -1,4 +1,5 @@ """Create your test for permissions.""" + from datetime import datetime import pytest @@ -10,7 +11,6 @@ from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/users/tests/test_swagger_ui.py b/onebarangay_psql/users/tests/test_swagger_ui.py index 84a7c5a..7b5f619 100644 --- a/onebarangay_psql/users/tests/test_swagger_ui.py +++ b/onebarangay_psql/users/tests/test_swagger_ui.py @@ -1,9 +1,9 @@ """Create your swagger-ui test here.""" + import pytest from django.test import Client from django.urls import reverse - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/users/tests/test_urls.py b/onebarangay_psql/users/tests/test_urls.py index 5e12ad8..38c150d 100644 --- a/onebarangay_psql/users/tests/test_urls.py +++ b/onebarangay_psql/users/tests/test_urls.py @@ -1,10 +1,10 @@ """Create your test for user urls.""" + import pytest from django.urls import resolve, reverse from onebarangay_psql.users.models import User - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/users/tests/test_views.py b/onebarangay_psql/users/tests/test_views.py index e0d5db3..dc1e0f4 100644 --- a/onebarangay_psql/users/tests/test_views.py +++ b/onebarangay_psql/users/tests/test_views.py @@ -1,4 +1,5 @@ """Create your test for the user views here.""" + import pytest from django.conf import settings from django.contrib import messages @@ -19,7 +20,6 @@ user_detail_view, ) - pytestmark = pytest.mark.django_db diff --git a/onebarangay_psql/users/urls.py b/onebarangay_psql/users/urls.py index 3346c30..ff28b1b 100644 --- a/onebarangay_psql/users/urls.py +++ b/onebarangay_psql/users/urls.py @@ -1,4 +1,5 @@ """Create your URL for the user's app.""" + from django.urls import path from onebarangay_psql.users.views import ( @@ -7,7 +8,6 @@ user_update_view, ) - app_name = "users" urlpatterns = [ path("~redirect/", view=user_redirect_view, name="redirect"), diff --git a/onebarangay_psql/utils/choice_field.py b/onebarangay_psql/utils/choice_field.py index 2565c3e..41b8197 100644 --- a/onebarangay_psql/utils/choice_field.py +++ b/onebarangay_psql/utils/choice_field.py @@ -1,4 +1,5 @@ """Create your custom choice field here.""" + from rest_framework_json_api import serializers diff --git a/onebarangay_psql/utils/pagination.py b/onebarangay_psql/utils/pagination.py index 9a80a3f..e00c3c0 100644 --- a/onebarangay_psql/utils/pagination.py +++ b/onebarangay_psql/utils/pagination.py @@ -1,4 +1,5 @@ """Custom pagination for onebarangay_psql.""" + from rest_framework.pagination import PageNumberPagination diff --git a/onebarangay_psql/utils/prometheus.py b/onebarangay_psql/utils/prometheus.py index 9232397..7629358 100644 --- a/onebarangay_psql/utils/prometheus.py +++ b/onebarangay_psql/utils/prometheus.py @@ -1,6 +1,6 @@ """Util for getting the prometheus metrics.""" -from prometheus_client import CollectorRegistry, Counter, Histogram, generate_latest +from prometheus_client import CollectorRegistry, Counter, Histogram, generate_latest registry = CollectorRegistry() diff --git a/onebarangay_psql/utils/refresh_material_view.py b/onebarangay_psql/utils/refresh_material_view.py index 155fc13..c5ddcd2 100644 --- a/onebarangay_psql/utils/refresh_material_view.py +++ b/onebarangay_psql/utils/refresh_material_view.py @@ -1,4 +1,5 @@ """Refreshes Material Views.""" + import datetime import time @@ -11,8 +12,7 @@ def refresh_mv(): """Refresh Materialized Views in the Database.""" start_time = time.monotonic() with connection.cursor() as cursor: - cursor.execute( - """ + cursor.execute(""" REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_total; REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_user_signup; REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_user_signup_monthly; @@ -24,8 +24,7 @@ def refresh_mv(): REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_civil_status; REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_average; REFRESH MATERIALIZED VIEW CONCURRENTLY materialized_statistics_social_class; - """ - ) + """) end_time = time.monotonic() RefreshMaterializedView.objects.create( diff --git a/onebarangay_psql/utils/storages.py b/onebarangay_psql/utils/storages.py index a1db531..633f89a 100644 --- a/onebarangay_psql/utils/storages.py +++ b/onebarangay_psql/utils/storages.py @@ -1,4 +1,5 @@ """Utility for storing static files in Google Cloud Storage.""" + from storages.backends.gcloud import GoogleCloudStorage