Skip to content

Commit

Permalink
Tidy project
Browse files Browse the repository at this point in the history
  • Loading branch information
lorinkoz committed Feb 22, 2021
1 parent b07fad5 commit f7a07dd
Show file tree
Hide file tree
Showing 21 changed files with 407 additions and 281 deletions.
3 changes: 3 additions & 0 deletions .flake8
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 120
ignore = B007,B305,E203,E731,F405,W503
4 changes: 2 additions & 2 deletions .github/workflows/code.yaml
Expand Up @@ -35,9 +35,9 @@ jobs:
- uses: actions/cache@v1
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-py${{ matrix.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
key: py${{ matrix.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-py-poetry-
py-poetry-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/linters.yaml
Expand Up @@ -9,10 +9,17 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Install dependencies
- uses: actions/cache@v1
with:
path: ~/.cache/pypoetry
key: py3.6-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
py-poetry-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade black
python -m pip install poetry
python -m pip install pre-commit
python -m poetry install
- name: Run linters
run: |
black --check --exclude "migrations" django_pgschemas
run: python -m pre-commit run --all-files
4 changes: 2 additions & 2 deletions .github/workflows/postgres.yaml
Expand Up @@ -35,9 +35,9 @@ jobs:
- uses: actions/cache@v1
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-py${{ matrix.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
key: py${{ matrix.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-py-poetry-
py-poetry-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
Expand Down
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: black
name: black
entry: bash -c 'poetry run black $1'
language: system
types: [python]
- id: isort
name: isort
entry: bash -c 'poetry run isort $1'
language: system
types: [python]
- id: flake8
name: flake8
entry: bash -c 'poetry run flake8 $1'
language: system
types: [python]
2 changes: 1 addition & 1 deletion django_pgschemas/__init__.py
@@ -1,3 +1,3 @@
from .schema import schema_handler
from .schema import schema_handler # noqa

default_app_config = "django_pgschemas.apps.DjangoPGSchemasConfig"
3 changes: 1 addition & 2 deletions django_pgschemas/management/commands/__init__.py
@@ -1,7 +1,6 @@
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.db.models import CharField, Q
from django.db.models import Value as V
from django.db.models import CharField, Q, Value as V
from django.db.models.functions import Concat
from django.db.utils import ProgrammingError

Expand Down
1 change: 0 additions & 1 deletion django_pgschemas/management/commands/migrateschema.py
@@ -1,4 +1,3 @@
from django.core import management
from django.core.checks import Tags, run_checks
from django.core.management.base import BaseCommand
from django.core.management.commands.migrate import Command as MigrateCommand
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Expand Up @@ -16,4 +16,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion docs/settings.rst
Expand Up @@ -107,4 +107,4 @@ Default: ``None``

Function that takes a schema descriptor and returns a string identifier for the
schema. This identifier will be used in the ``TenantFileSystemStorage`` as the
name of the tenant folder.
name of the tenant folder.
13 changes: 9 additions & 4 deletions dpgs_sandbox/app_blog/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# Generated by Django 2.1.4 on 2019-01-13 04:11

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand All @@ -15,10 +15,15 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name='BlogEntry',
name="BlogEntry",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='blogs', to=settings.AUTH_USER_MODEL)),
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, related_name="blogs", to=settings.AUTH_USER_MODEL
),
),
],
),
]
7 changes: 3 additions & 4 deletions dpgs_sandbox/app_main/migrations/0001_initial.py
Expand Up @@ -7,14 +7,13 @@ class Migration(migrations.Migration):

initial = True

dependencies = [
]
dependencies = []

operations = [
migrations.CreateModel(
name='MainData',
name="MainData",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
],
),
]
2 changes: 1 addition & 1 deletion dpgs_sandbox/app_tenants/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# Generated by Django 2.1.4 on 2019-01-13 03:07

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand Down
6 changes: 3 additions & 3 deletions dpgs_sandbox/app_tenants/migrations/0002_tenantdata_active.py
Expand Up @@ -6,13 +6,13 @@
class Migration(migrations.Migration):

dependencies = [
('app_tenants', '0001_initial'),
("app_tenants", "0001_initial"),
]

operations = [
migrations.AddField(
model_name='tenantdata',
name='active',
model_name="tenantdata",
name="active",
field=models.BooleanField(default=True),
),
]
Expand Up @@ -9,7 +9,8 @@ class Command(TenantCommand):
def add_arguments(self, parser):
super().add_arguments(parser)
parser.add_argument(
dest="url_name", help="Url name to resolve in the specified schema",
dest="url_name",
help="Url name to resolve in the specified schema",
)

def handle_tenant(self, tenant, *args, **options):
Expand Down
17 changes: 8 additions & 9 deletions dpgs_sandbox/shared_common/migrations/0001_initial.py
Expand Up @@ -7,21 +7,20 @@ class Migration(migrations.Migration):

initial = True

dependencies = [
]
dependencies = []

operations = [
migrations.CreateModel(
name='User',
name="User",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('email', models.EmailField(max_length=254, unique=True)),
('display_name', models.CharField(max_length=50)),
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("password", models.CharField(max_length=128, verbose_name="password")),
("last_login", models.DateTimeField(blank=True, null=True, verbose_name="last login")),
("email", models.EmailField(max_length=254, unique=True)),
("display_name", models.CharField(max_length=50)),
],
options={
'abstract': False,
"abstract": False,
},
),
]
3 changes: 2 additions & 1 deletion dpgs_sandbox/shared_public/migrations/0001_initial.py
@@ -1,7 +1,8 @@
# Generated by Django 2.1.4 on 2019-01-13 03:07

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

import django_pgschemas.schema
import django_pgschemas.utils

Expand Down
1 change: 0 additions & 1 deletion dpgs_sandbox/tests/test_middleware.py
Expand Up @@ -2,7 +2,6 @@

from django.http import Http404
from django.test import RequestFactory, TestCase
from django.utils.module_loading import import_string

from django_pgschemas.middleware import TenantMiddleware
from django_pgschemas.utils import get_domain_model, get_tenant_model
Expand Down
2 changes: 1 addition & 1 deletion dpgs_sandbox/tests/test_tenants.py
Expand Up @@ -97,7 +97,7 @@ def setUpClass(cls):
tenant = TenantModel(schema_name="tenant")
tenant.save(verbosity=0)
catalog = Catalog.objects.create()
catalog2 = Catalog.objects.create()
Catalog.objects.create()
with SchemaDescriptor.create(schema_name="www"):
user = User.objects.create(email="main@test.com", display_name="Main User")
user.set_password("weakpassword")
Expand Down

0 comments on commit f7a07dd

Please sign in to comment.