Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bennylope committed Nov 23, 2023
1 parent 62d42e2 commit fa96a8b
Show file tree
Hide file tree
Showing 54 changed files with 95 additions and 114 deletions.
2 changes: 2 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import django

import pytest


Expand Down Expand Up @@ -67,6 +68,7 @@ def pytest_configure():
)
django.setup()


@pytest.fixture(autouse=True)
def enable_db_access_for_all_tests(db):
pass
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -90,7 +89,7 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'furo'
html_theme = "furo"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
5 changes: 3 additions & 2 deletions example/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.contrib import admin

from .models import Account, AccountUser, AccountOwner

from .models import Account
from .models import AccountOwner
from .models import AccountUser

admin.site.register(Account)
admin.site.register(AccountUser)
Expand Down
15 changes: 11 additions & 4 deletions example/accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Generated by Django 2.2.4 on 2019-12-10 18:25

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

import organizations.base
import organizations.fields

Expand Down Expand Up @@ -50,7 +52,9 @@ class Migration(migrations.Migration):
organizations.fields.SlugField(
blank=True,
editable=False,
help_text="The name in all lowercase, suitable for URL identification",
help_text=(
"The name in all lowercase, suitable for URL identification"
),
max_length=200,
populate_from="name",
unique=True,
Expand Down Expand Up @@ -178,7 +182,10 @@ class Migration(migrations.Migration):
(
"invitee_identifier",
models.CharField(
help_text="The contact identifier for the invitee, email, phone number, social media handle, etc.",
help_text=(
"The contact identifier for the invitee, email, "
"phone number, social media handle, etc."
),
max_length=1000,
),
),
Expand Down
10 changes: 4 additions & 6 deletions example/accounts/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from django.db import models

from organizations.abstract import (
AbstractOrganization,
AbstractOrganizationInvitation,
AbstractOrganizationOwner,
AbstractOrganizationUser,
)
from organizations.abstract import AbstractOrganization
from organizations.abstract import AbstractOrganizationInvitation
from organizations.abstract import AbstractOrganizationOwner
from organizations.abstract import AbstractOrganizationUser


class Account(AbstractOrganization):
Expand Down
6 changes: 3 additions & 3 deletions example/conf/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.conf.urls import include, url
from django.conf.urls import include
from django.contrib import admin
from django.urls import path

from organizations.backends import invitation_backend, registration_backend

from organizations.backends import invitation_backend
from organizations.backends import registration_backend

urlpatterns = [
path("admin/", admin.site.urls),
Expand Down
10 changes: 1 addition & 9 deletions example/conf/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@
"""
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "conf.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "conf.settings")
application = get_wsgi_application()

# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
5 changes: 3 additions & 2 deletions example/vendors/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.contrib import admin

from .models import Vendor, VendorUser, VendorOwner

from .models import Vendor
from .models import VendorOwner
from .models import VendorUser

admin.site.register(Vendor)
admin.site.register(VendorUser)
Expand Down
15 changes: 11 additions & 4 deletions example/vendors/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Generated by Django 2.2.4 on 2019-12-10 18:25

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

import organizations.base
import organizations.fields

Expand Down Expand Up @@ -54,7 +56,9 @@ class Migration(migrations.Migration):
organizations.fields.SlugField(
blank=True,
editable=False,
help_text="The name in all lowercase, suitable for URL identification",
help_text=(
"The name in all lowercase, suitable for URL identification"
),
max_length=200,
populate_from="name",
unique=True,
Expand Down Expand Up @@ -195,7 +199,10 @@ class Migration(migrations.Migration):
(
"invitee_identifier",
models.CharField(
help_text="The contact identifier for the invitee, email, phone number, social media handle, etc.",
help_text=(
"The contact identifier for the invitee, email, "
"phone number, social media handle, etc."
),
max_length=1000,
),
),
Expand Down
10 changes: 4 additions & 6 deletions example/vendors/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from django.contrib.auth.models import Permission
from django.db import models

from organizations.abstract import (
AbstractOrganization,
AbstractOrganizationInvitation,
AbstractOrganizationOwner,
AbstractOrganizationUser,
)
from organizations.abstract import AbstractOrganization
from organizations.abstract import AbstractOrganizationInvitation
from organizations.abstract import AbstractOrganizationOwner
from organizations.abstract import AbstractOrganizationUser


class Vendor(AbstractOrganization):
Expand Down
4 changes: 1 addition & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import nox


NOX_DIR = os.path.abspath(os.path.dirname(__file__))

DEFAULT_INTERPRETER = "3.8"
Expand Down Expand Up @@ -46,7 +45,7 @@ def manage(session, *args):
session.install("six")
session.install("django-autoslug")
session.install("Django==3.1")
session.install('-e', '.')
session.install("-e", ".")
args = args if args else session.posargs
session.run("python", "manage.py", *args)

Expand Down Expand Up @@ -105,7 +104,6 @@ def publish(session):
session.run("python", "-m", "twine", "upload", "dist/*")



@nox.session(python=DEFAULT_INTERPRETER, reuse_venv=True)
def docs(session):
session.run("make", "-C", "docs", "clean")
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
"""

from setuptools import setup

setup()
4 changes: 1 addition & 3 deletions src/organizations/abstract.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@

import warnings

from django.conf import settings
from django.db import models
from django.urls import reverse
from django.utils.translation import gettext_lazy as _


from organizations.base import AbstractBaseInvitation
from organizations.base import AbstractBaseOrganization
from organizations.base import AbstractBaseOrganizationOwner
from organizations.base import AbstractBaseOrganizationUser
from organizations.base import with_metaclass
from organizations.base import OrgMeta
from organizations.base import with_metaclass
from organizations.fields import AutoCreatedField
from organizations.fields import AutoLastModifiedField
from organizations.fields import SlugField
Expand Down
1 change: 0 additions & 1 deletion src/organizations/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django.contrib import admin

from organizations import models
Expand Down
1 change: 0 additions & 1 deletion src/organizations/app_settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django.conf import settings
from django.contrib.auth.models import User

Expand Down
1 change: 0 additions & 1 deletion src/organizations/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django.apps import AppConfig


Expand Down
1 change: 0 additions & 1 deletion src/organizations/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from importlib import import_module
from typing import Optional # noqa
from typing import Text # noqa
Expand Down
5 changes: 2 additions & 3 deletions src/organizations/backends/defaults.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

"""Backend classes should provide common interface"""

import email.utils
Expand Down Expand Up @@ -144,8 +143,8 @@ def email_message(
):
"""
Returns an email message for a new user. This can be easily overridden.
For instance, to send an HTML message, use the EmailMultiAlternatives message_class
and attach the additional conent.
For instance, to send an HTML message, use the EmailMultiAlternatives
message_class and attach the additional conent.
"""
if sender:
try:
Expand Down
1 change: 0 additions & 1 deletion src/organizations/backends/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django import forms
from django.contrib.auth.forms import UserCreationForm

Expand Down
14 changes: 7 additions & 7 deletions src/organizations/backends/modeled.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

"""
Invitations that use an invitation model
"""
Expand Down Expand Up @@ -42,12 +41,13 @@ class ModelInvitation(InvitationBackend):

def __init__(self, org_model=None, namespace=None):
super().__init__(org_model=org_model, namespace=namespace)
self.invitation_model = (
self.org_model.invitation_model
) # type: OrganizationInvitationBase
self.invitation_model = self.org_model.invitation_model # type: OrganizationInvitationBase # noqa: E501

def get_invitation_queryset(self):
"""Return this to use a custom queryset that checks for expiration, for example"""
"""Return available invitations.
Use a custom queryset that checks for expiration, for example.
"""
return self.invitation_model.objects.all()

def get_invitation_accepted_url(self):
Expand Down Expand Up @@ -171,8 +171,8 @@ def email_message(
):
"""
Returns an invitation email message. This can be easily overridden.
For instance, to send an HTML message, use the EmailMultiAlternatives message_class
and attach the additional conent.
For instance, to send an HTML message, use the EmailMultiAlternatives
message_class and attach the additional conent.
"""
from_email = "%s %s <%s>" % (
sender.first_name,
Expand Down
5 changes: 2 additions & 3 deletions src/organizations/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import uuid

from django.conf import settings
Expand All @@ -24,7 +23,6 @@ def __new__(cls, name, this_bases, d):
return type.__new__(metaclass, "temporary_class", (), {})



class OrgMeta(ModelBase):
"""
Base metaclass for dynamically linking related organization models.
Expand Down Expand Up @@ -326,7 +324,8 @@ class AbstractBaseInvitation(models.Model):
invitee_identifier = models.CharField(
max_length=1000,
help_text=_(
"The contact identifier for the invitee, email, phone number, social media handle, etc."
"The contact identifier for the invitee, email, phone number,"
" social media handle, etc."
),
)

Expand Down
1 change: 0 additions & 1 deletion src/organizations/base_admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django.contrib import admin


Expand Down
2 changes: 0 additions & 2 deletions src/organizations/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


class OwnershipRequired(Exception):
"""
Exception to raise if the owner is being removed before the
Expand Down
1 change: 0 additions & 1 deletion src/organizations/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django import forms
from django.contrib.auth import get_user_model
from django.contrib.sites.shortcuts import get_current_site
Expand Down
1 change: 0 additions & 1 deletion src/organizations/managers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django.db import models


Expand Down
4 changes: 3 additions & 1 deletion src/organizations/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class Migration(migrations.Migration):
"slug",
organizations.fields.SlugField(
editable=True,
help_text="The name in all lowercase, suitable for URL identification",
help_text=(
"The name in all lowercase, suitable for URL identification"
),
max_length=200,
populate_from="name",
unique=True,
Expand Down
5 changes: 4 additions & 1 deletion src/organizations/migrations/0004_organizationinvitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ class Migration(migrations.Migration):
(
"invitee_identifier",
models.CharField(
help_text="The contact identifier for the invitee, email, phone number, social media handle, etc.",
help_text=(
"The contact identifier for the invitee, email, "
"phone number, social media handle, etc."
),
max_length=1000,
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Generated by Django 4.0.7 on 2022-09-30 17:00

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


class Migration(migrations.Migration):
Expand Down
Loading

0 comments on commit fa96a8b

Please sign in to comment.