diff --git a/.drone.yml b/.drone.yml index 02719a4..b178799 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,10 +4,14 @@ kind: pipeline type: docker name: default -clone: - disable: yes - steps: + - name: check style + image: python:3.12-alpine + commands: + - pip install black isort + - black --check . + - isort -c . + - name: deploy staging image: ghcr.io/appleboy/drone-ssh environment: @@ -26,6 +30,8 @@ steps: when: branch: - main + event: + - push - name: deploy production image: ghcr.io/appleboy/drone-ssh @@ -35,7 +41,10 @@ steps: when: branch: - live + event: + - push trigger: event: + - pull_request - push diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..7795fec --- /dev/null +++ b/setup.cfg @@ -0,0 +1,4 @@ +[isort] +line_length=88 +profile=black +skip_gitignore=True diff --git a/shiftregister/app/admin.py b/shiftregister/app/admin.py index 8863a5c..35764df 100644 --- a/shiftregister/app/admin.py +++ b/shiftregister/app/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin from django.contrib.admin import DateFieldListFilter -from .models import Room, Shift, Helper, ShiftRegistration, Message, LoginToken +from .models import Helper, LoginToken, Message, Room, Shift, ShiftRegistration @admin.register(Room) diff --git a/shiftregister/app/context_processors.py b/shiftregister/app/context_processors.py index dc1d843..69d9617 100644 --- a/shiftregister/app/context_processors.py +++ b/shiftregister/app/context_processors.py @@ -1,4 +1,5 @@ from django.conf import settings + from .models import LoginToken diff --git a/shiftregister/app/dynamic_preferences_registry.py b/shiftregister/app/dynamic_preferences_registry.py index 068e83c..3a34146 100644 --- a/shiftregister/app/dynamic_preferences_registry.py +++ b/shiftregister/app/dynamic_preferences_registry.py @@ -1,8 +1,9 @@ -from dynamic_preferences.registries import global_preferences_registry -from dynamic_preferences import types -import phonenumbers import datetime +import phonenumbers +from dynamic_preferences import types +from dynamic_preferences.registries import global_preferences_registry + helper = types.Section("helper") diff --git a/shiftregister/app/forms.py b/shiftregister/app/forms.py index 9db4ca2..06daa8c 100644 --- a/shiftregister/app/forms.py +++ b/shiftregister/app/forms.py @@ -1,9 +1,10 @@ from django import forms -from .models import Helper -from phonenumber_field.formfields import PhoneNumberField -from phonenumber_field.validators import validate_international_phonenumber from django.core.exceptions import ValidationError from dynamic_preferences.registries import global_preferences_registry +from phonenumber_field.formfields import PhoneNumberField +from phonenumber_field.validators import validate_international_phonenumber + +from .models import Helper global_preferences = global_preferences_registry.manager() diff --git a/shiftregister/app/migrations/0001_initial.py b/shiftregister/app/migrations/0001_initial.py index 4beb487..aff7a3f 100644 --- a/shiftregister/app/migrations/0001_initial.py +++ b/shiftregister/app/migrations/0001_initial.py @@ -1,8 +1,9 @@ # Generated by Django 4.0.4 on 2022-04-27 14:11 -from django.db import migrations, models import django.db.models.deletion import phonenumber_field.modelfields +from django.db import migrations, models + import shiftregister.app.models diff --git a/shiftregister/app/models.py b/shiftregister/app/models.py index 26460f2..19712b0 100644 --- a/shiftregister/app/models.py +++ b/shiftregister/app/models.py @@ -1,12 +1,13 @@ -from django.db import models import secrets -from django.shortcuts import reverse from datetime import timedelta -from django.utils import timezone -from django.db.models import F, Count, Q, ExpressionWrapper, Case, When + +from django.db import models +from django.db.models import Case, Count, ExpressionWrapper, F, Q, When +from django.shortcuts import reverse from django.template import Context, Template -from phonenumber_field.modelfields import PhoneNumberField +from django.utils import timezone from dynamic_preferences.registries import global_preferences_registry +from phonenumber_field.modelfields import PhoneNumberField global_preferences = global_preferences_registry.manager() diff --git a/shiftregister/app/signals.py b/shiftregister/app/signals.py index d882bb3..ecd3612 100644 --- a/shiftregister/app/signals.py +++ b/shiftregister/app/signals.py @@ -2,7 +2,9 @@ from django.db.models.signals import pre_save from django.dispatch import receiver from django.shortcuts import reverse from django.template import Context, Template + from shiftregister.core.signals import populate_nav + from .models import Message, Shift diff --git a/shiftregister/app/sipgate/history.py b/shiftregister/app/sipgate/history.py index 6f79c35..519e78b 100644 --- a/shiftregister/app/sipgate/history.py +++ b/shiftregister/app/sipgate/history.py @@ -1,7 +1,7 @@ from datetime import timezone -from django.conf import settings -import requests +import requests +from django.conf import settings BASE_URL = "https://api.sipgate.com/v2" diff --git a/shiftregister/app/sipgate/sms.py b/shiftregister/app/sipgate/sms.py index fdc9778..8e2a76e 100644 --- a/shiftregister/app/sipgate/sms.py +++ b/shiftregister/app/sipgate/sms.py @@ -1,7 +1,6 @@ +import requests from django.conf import settings from phonenumber_field.phonenumber import PhoneNumber -import requests - BASE_URL = "https://api.sipgate.com/v2" diff --git a/shiftregister/app/tasks.py b/shiftregister/app/tasks.py index 62edb83..bcfa6c2 100644 --- a/shiftregister/app/tasks.py +++ b/shiftregister/app/tasks.py @@ -1,11 +1,12 @@ +import sentry_sdk from celery import shared_task -from .models import Message, ShiftRegistration from django.conf import settings from django.db import transaction from django.utils import timezone from dynamic_preferences.registries import global_preferences_registry + +from .models import Message, ShiftRegistration from .sipgate.sms import send as send_sms -import sentry_sdk global_preferences = global_preferences_registry.manager() diff --git a/shiftregister/app/views.py b/shiftregister/app/views.py index 2f56cda..1bfc62a 100644 --- a/shiftregister/app/views.py +++ b/shiftregister/app/views.py @@ -1,18 +1,20 @@ -from django.shortcuts import render, redirect, get_object_or_404 -from .models import Shift, LoginToken, Helper, ShiftRegistration -from django.db import transaction -from django.db.models import F, Count, Q, ExpressionWrapper -from django.core.cache import cache -from .forms import RegisterForm, EmptyForm, AstaForm -from django.db.models.fields import DateTimeField +import datetime +import math from datetime import timedelta -from django.utils import timezone + from django.conf import settings from django.contrib import messages -import datetime -from .decorators import event_state +from django.core.cache import cache +from django.db import transaction +from django.db.models import Count, ExpressionWrapper, F, Q +from django.db.models.fields import DateTimeField +from django.shortcuts import get_object_or_404, redirect, render +from django.utils import timezone from dynamic_preferences.registries import global_preferences_registry -import math + +from .decorators import event_state +from .forms import AstaForm, EmptyForm, RegisterForm +from .models import Helper, LoginToken, Shift, ShiftRegistration global_preferences = global_preferences_registry.manager() diff --git a/shiftregister/core/context_processors.py b/shiftregister/core/context_processors.py index e57a434..99a5a1a 100644 --- a/shiftregister/core/context_processors.py +++ b/shiftregister/core/context_processors.py @@ -1,4 +1,4 @@ -from .signals import populate_nav +from .signals import populate_footer_nav, populate_nav def nav(request): @@ -12,3 +12,14 @@ def nav(request): return { "nav_items": nav_items, } + + +def footer_nav(request): + nav_items = [ + item + for _, items in populate_footer_nav.send(sender=request) + if isinstance(items, list) + for item in items + ] + + return {"nav_items": nav_items} diff --git a/shiftregister/core/signals.py b/shiftregister/core/signals.py index 2764c3e..8a6c3df 100644 --- a/shiftregister/core/signals.py +++ b/shiftregister/core/signals.py @@ -1,3 +1,5 @@ from django.dispatch import Signal populate_nav = Signal() + +populate_footer_nav = Signal() diff --git a/shiftregister/fallback/admin.py b/shiftregister/fallback/admin.py index 7d9e655..bbbbd03 100644 --- a/shiftregister/fallback/admin.py +++ b/shiftregister/fallback/admin.py @@ -1,5 +1,6 @@ from django.contrib import admin from django.shortcuts import reverse + from .models import * diff --git a/shiftregister/fallback/migrations/0002_fallbackassignment.py b/shiftregister/fallback/migrations/0002_fallbackassignment.py index bc3b8ce..590c9ed 100644 --- a/shiftregister/fallback/migrations/0002_fallbackassignment.py +++ b/shiftregister/fallback/migrations/0002_fallbackassignment.py @@ -1,7 +1,7 @@ # Generated by Django 4.0.4 on 2023-05-07 16:00 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/shiftregister/fallback/migrations/0005_alter_teammember_id.py b/shiftregister/fallback/migrations/0005_alter_teammember_id.py index f1d30ad..b2bfeb7 100644 --- a/shiftregister/fallback/migrations/0005_alter_teammember_id.py +++ b/shiftregister/fallback/migrations/0005_alter_teammember_id.py @@ -1,6 +1,7 @@ # Generated by Django 4.0.4 on 2023-05-13 17:28 from django.db import migrations, models + import shiftregister.fallback.models diff --git a/shiftregister/fallback/models.py b/shiftregister/fallback/models.py index 286a1ba..53b18cd 100644 --- a/shiftregister/fallback/models.py +++ b/shiftregister/fallback/models.py @@ -1,11 +1,12 @@ -from shiftregister.importer.models import * -from django.db.models import Max, Sum -from django.db.models import Count, Exists, OuterRef, ExpressionWrapper -from django.db.models.lookups import LessThan -from django.db.models.fields import DateTimeField -from base64 import urlsafe_b64encode import math import secrets +from base64 import urlsafe_b64encode + +from django.db.models import Count, Exists, ExpressionWrapper, Max, OuterRef, Sum +from django.db.models.fields import DateTimeField +from django.db.models.lookups import LessThan + +from shiftregister.importer.models import * night_shift_query = Q(start_at__hour__gte=21) | Q(start_at__hour__lte=10) diff --git a/shiftregister/fallback/tasks.py b/shiftregister/fallback/tasks.py index bf91f09..79b27e7 100644 --- a/shiftregister/fallback/tasks.py +++ b/shiftregister/fallback/tasks.py @@ -1,14 +1,15 @@ +from datetime import datetime + from celery import shared_task -from .models import FallbackAssignment -from shiftregister.app.models import ShiftRegistration from django.conf import settings from django.db import transaction +from django.db.models import Case, Count, ExpressionWrapper, F, Q, When from django.utils import timezone from dynamic_preferences.registries import global_preferences_registry -from django.db.models import F, Count, Q, ExpressionWrapper, Case, When -from datetime import datetime -from django.utils import timezone +from shiftregister.app.models import ShiftRegistration + +from .models import FallbackAssignment global_preferences = global_preferences_registry.manager() diff --git a/shiftregister/fallback/views.py b/shiftregister/fallback/views.py index 5c04ccc..9d9adad 100644 --- a/shiftregister/fallback/views.py +++ b/shiftregister/fallback/views.py @@ -1,8 +1,10 @@ from base64 import urlsafe_b64decode + from django.contrib.auth.decorators import login_required from django.db.models import Count from django.http import HttpResponse -from django.shortcuts import render, get_object_or_404 +from django.shortcuts import get_object_or_404, render + from shiftregister.fallback.models import TeamMember # Create your views here. diff --git a/shiftregister/feedback/forms.py b/shiftregister/feedback/forms.py index 2cdfa25..e40c2a0 100644 --- a/shiftregister/feedback/forms.py +++ b/shiftregister/feedback/forms.py @@ -1,6 +1,7 @@ -from .models import Feedback -from django.forms import ModelForm from django import forms +from django.forms import ModelForm + +from .models import Feedback class FeedbackForm(ModelForm): diff --git a/shiftregister/feedback/migrations/0001_initial.py b/shiftregister/feedback/migrations/0001_initial.py index c489ba0..c947ad2 100644 --- a/shiftregister/feedback/migrations/0001_initial.py +++ b/shiftregister/feedback/migrations/0001_initial.py @@ -1,7 +1,7 @@ # Generated by Django 4.0.4 on 2023-05-25 14:16 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/shiftregister/feedback/migrations/0002_sharetoken.py b/shiftregister/feedback/migrations/0002_sharetoken.py index 6548ec2..faaaa30 100644 --- a/shiftregister/feedback/migrations/0002_sharetoken.py +++ b/shiftregister/feedback/migrations/0002_sharetoken.py @@ -1,8 +1,9 @@ # Generated by Django 4.0.4 on 2023-05-27 17:48 -from django.db import migrations, models import secrets +from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/shiftregister/feedback/models.py b/shiftregister/feedback/models.py index 6abda98..5ddb022 100644 --- a/shiftregister/feedback/models.py +++ b/shiftregister/feedback/models.py @@ -1,5 +1,7 @@ -from django.db import models from secrets import token_urlsafe + +from django.db import models + from shiftregister.app.models import Helper diff --git a/shiftregister/feedback/signals.py b/shiftregister/feedback/signals.py index bf41686..62a5293 100644 --- a/shiftregister/feedback/signals.py +++ b/shiftregister/feedback/signals.py @@ -1,6 +1,7 @@ from django.dispatch import receiver from django.shortcuts import reverse from dynamic_preferences.registries import global_preferences_registry + from shiftregister.core.signals import populate_nav global_preferences = global_preferences_registry.manager() diff --git a/shiftregister/feedback/views.py b/shiftregister/feedback/views.py index 429590e..6f95479 100644 --- a/shiftregister/feedback/views.py +++ b/shiftregister/feedback/views.py @@ -1,9 +1,11 @@ -from django.shortcuts import render, get_object_or_404 -from .forms import FeedbackForm -from .models import Feedback, ShareToken -from shiftregister.app.models import LoginToken from django.contrib import messages from django.contrib.auth.decorators import login_required +from django.shortcuts import get_object_or_404, render + +from shiftregister.app.models import LoginToken + +from .forms import FeedbackForm +from .models import Feedback, ShareToken def feedback(request, token): diff --git a/shiftregister/importer/admin.py b/shiftregister/importer/admin.py index 2378a4f..01f1530 100644 --- a/shiftregister/importer/admin.py +++ b/shiftregister/importer/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import Calendar diff --git a/shiftregister/importer/importer.py b/shiftregister/importer/importer.py index 00e243b..33d0dc8 100644 --- a/shiftregister/importer/importer.py +++ b/shiftregister/importer/importer.py @@ -1,9 +1,11 @@ from datetime import timezone + +import requests from django.conf import settings from django.db import transaction from icalendar import Calendar + from .models import Event, Room, Shift -import requests def import_calendar(calendar): diff --git a/shiftregister/importer/migrations/0001_initial.py b/shiftregister/importer/migrations/0001_initial.py index 4b6bda4..6af5f2e 100644 --- a/shiftregister/importer/migrations/0001_initial.py +++ b/shiftregister/importer/migrations/0001_initial.py @@ -1,7 +1,7 @@ # Generated by Django 4.0.4 on 2022-04-27 14:11 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/shiftregister/importer/models.py b/shiftregister/importer/models.py index f2b4e35..2d09c90 100644 --- a/shiftregister/importer/models.py +++ b/shiftregister/importer/models.py @@ -1,4 +1,5 @@ from django.db import models + from shiftregister.app.models import * diff --git a/shiftregister/importer/tasks.py b/shiftregister/importer/tasks.py index d8eaa93..948f5fb 100644 --- a/shiftregister/importer/tasks.py +++ b/shiftregister/importer/tasks.py @@ -1,4 +1,5 @@ from celery import shared_task + from .importer import import_calendar from .models import Calendar diff --git a/shiftregister/metrics/views.py b/shiftregister/metrics/views.py index 3ff7f1e..3e2cbeb 100644 --- a/shiftregister/metrics/views.py +++ b/shiftregister/metrics/views.py @@ -1,7 +1,8 @@ from django.db import models -from django.db.models import Count, Case, F, When, Sum +from django.db.models import Case, Count, F, Sum, When from django.http import HttpResponse -from shiftregister.app.models import Helper, Room, Shift, ShiftRegistration, Message + +from shiftregister.app.models import Helper, Message, Room, Shift, ShiftRegistration from shiftregister.fallback.models import FallbackAssignment from shiftregister.importer.models import Event @@ -159,9 +160,11 @@ def metrics(request): ), ( "worked_seconds_total", - worked_seconds_total.total_seconds() - if worked_seconds_total - else 0.0, + ( + worked_seconds_total.total_seconds() + if worked_seconds_total + else 0.0 + ), ), ( "worked_shifts_total", diff --git a/shiftregister/pages/admin.py b/shiftregister/pages/admin.py index 24b829a..a981f45 100644 --- a/shiftregister/pages/admin.py +++ b/shiftregister/pages/admin.py @@ -1,7 +1,9 @@ -from django.contrib import admin -from .models import Page from pathlib import Path +from django.contrib import admin + +from .models import Page + def reimport(modeladmin, request, queryset): for page in queryset: diff --git a/shiftregister/pages/apps.py b/shiftregister/pages/apps.py index b1e3e3d..894cca1 100644 --- a/shiftregister/pages/apps.py +++ b/shiftregister/pages/apps.py @@ -1,6 +1,7 @@ -from django.apps import AppConfig from pathlib import Path +from django.apps import AppConfig + class PagesConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" diff --git a/shiftregister/pages/management/commands/importhtml.py b/shiftregister/pages/management/commands/importhtml.py index 9682f3c..e530db4 100644 --- a/shiftregister/pages/management/commands/importhtml.py +++ b/shiftregister/pages/management/commands/importhtml.py @@ -1,7 +1,9 @@ +from pathlib import Path + from bs4 import BeautifulSoup from django.core.management.base import BaseCommand, CommandError + from ...models import Page -from pathlib import Path class Command(BaseCommand): diff --git a/shiftregister/pages/views.py b/shiftregister/pages/views.py index 72944ea..24070d1 100644 --- a/shiftregister/pages/views.py +++ b/shiftregister/pages/views.py @@ -1,8 +1,9 @@ -from django.views.generic import DetailView -from django.shortcuts import redirect -from django.core.validators import URLValidator from django.core.exceptions import ValidationError +from django.core.validators import URLValidator from django.http import HttpResponseNotFound +from django.shortcuts import redirect +from django.views.generic import DetailView + from .models import Page # Create your views here. diff --git a/shiftregister/settings.py b/shiftregister/settings.py index e20336c..7b4c279 100644 --- a/shiftregister/settings.py +++ b/shiftregister/settings.py @@ -10,12 +10,13 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.0/ref/settings/ """ -from pathlib import Path from os import getenv +from pathlib import Path + import sentry_sdk +from django.contrib.messages import constants as messages from sentry_sdk.integrations.celery import CeleryIntegration from sentry_sdk.integrations.django import DjangoIntegration -from django.contrib.messages import constants as messages # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent diff --git a/shiftregister/signage/migrations/0001_initial.py b/shiftregister/signage/migrations/0001_initial.py index f967012..cd38767 100644 --- a/shiftregister/signage/migrations/0001_initial.py +++ b/shiftregister/signage/migrations/0001_initial.py @@ -1,7 +1,7 @@ # Generated by Django 4.0.4 on 2022-05-18 13:10 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/shiftregister/signage/models.py b/shiftregister/signage/models.py index aa53695..627f2ad 100644 --- a/shiftregister/signage/models.py +++ b/shiftregister/signage/models.py @@ -1,2 +1,3 @@ from django.db import models + from shiftregister.app.models import * diff --git a/shiftregister/signage/views.py b/shiftregister/signage/views.py index 29d60bc..2ab36f6 100644 --- a/shiftregister/signage/views.py +++ b/shiftregister/signage/views.py @@ -1,8 +1,10 @@ from datetime import timedelta + from django.db import models -from django.db.models import Case, Count, F, ExpressionWrapper, Q, Sum, When +from django.db.models import Case, Count, ExpressionWrapper, F, Q, Sum, When from django.shortcuts import render from django.utils import timezone + from .models import Helper, Shift, ShiftRegistration diff --git a/shiftregister/team/admin.py b/shiftregister/team/admin.py index 8fdc41e..43d1845 100644 --- a/shiftregister/team/admin.py +++ b/shiftregister/team/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin + from .models import IncomingMessage, RoomViewToken # Register your models here. diff --git a/shiftregister/team/forms.py b/shiftregister/team/forms.py index 2b7d4ef..5bee2e7 100644 --- a/shiftregister/team/forms.py +++ b/shiftregister/team/forms.py @@ -1,5 +1,6 @@ from django import forms -from .models import ShiftRegistration, Helper + +from .models import Helper, ShiftRegistration # placeholder form for simple submit button use cases so we get csrf protection diff --git a/shiftregister/team/migrations/0001_initial.py b/shiftregister/team/migrations/0001_initial.py index 8a57e79..aeeb977 100644 --- a/shiftregister/team/migrations/0001_initial.py +++ b/shiftregister/team/migrations/0001_initial.py @@ -1,7 +1,7 @@ # Generated by Django 4.0.4 on 2023-05-06 23:27 -from django.db import migrations, models import phonenumber_field.modelfields +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/shiftregister/team/migrations/0004_roomviewtoken.py b/shiftregister/team/migrations/0004_roomviewtoken.py index d47f767..1c418bf 100644 --- a/shiftregister/team/migrations/0004_roomviewtoken.py +++ b/shiftregister/team/migrations/0004_roomviewtoken.py @@ -1,7 +1,8 @@ # Generated by Django 4.0.4 on 2023-05-18 15:15 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models + import shiftregister.team.models diff --git a/shiftregister/team/models.py b/shiftregister/team/models.py index 8542443..8669ca4 100644 --- a/shiftregister/team/models.py +++ b/shiftregister/team/models.py @@ -1,7 +1,9 @@ +import secrets + from django.db import models from phonenumber_field.modelfields import PhoneNumberField + from shiftregister.app.models import * -import secrets # Create your models here. diff --git a/shiftregister/team/signals.py b/shiftregister/team/signals.py index 30c2314..3a32283 100644 --- a/shiftregister/team/signals.py +++ b/shiftregister/team/signals.py @@ -1,7 +1,9 @@ from django.dispatch import receiver from django.shortcuts import reverse from dynamic_preferences.registries import global_preferences_registry + from shiftregister.core.signals import populate_nav + from .models import IncomingMessage global_preferences = global_preferences_registry.manager() diff --git a/shiftregister/team/tasks.py b/shiftregister/team/tasks.py index 2bff8c2..11ecc05 100644 --- a/shiftregister/team/tasks.py +++ b/shiftregister/team/tasks.py @@ -1,8 +1,10 @@ +import sentry_sdk from celery import shared_task from django.conf import settings + from shiftregister.app.sipgate.history import list_incoming_sms + from .models import IncomingMessage -import sentry_sdk @shared_task diff --git a/shiftregister/team/templatetags/striplogintoken.py b/shiftregister/team/templatetags/striplogintoken.py index aaa6fc1..c4e76cb 100644 --- a/shiftregister/team/templatetags/striplogintoken.py +++ b/shiftregister/team/templatetags/striplogintoken.py @@ -1,6 +1,7 @@ -from django import template from re import ASCII, sub +from django import template + register = template.Library() diff --git a/shiftregister/team/views.py b/shiftregister/team/views.py index 762a439..f0c6376 100644 --- a/shiftregister/team/views.py +++ b/shiftregister/team/views.py @@ -1,26 +1,27 @@ -from django.shortcuts import render, get_object_or_404, redirect -from django.contrib.auth.decorators import login_required -from django.utils import timezone -from django.db.models.fields import DateTimeField -from django.db.models import F, Count, Q, ExpressionWrapper, Case, When -from .models import ( - ShiftRegistration, - Room, - Shift, - Helper, - Message, - IncomingMessage, - RoomViewToken, -) -from django.views.generic import DetailView, ListView -from django.views.generic.edit import FormMixin -from django.contrib.auth.mixins import LoginRequiredMixin -from django.contrib import messages -from django.db import models, transaction -from django.core.paginator import Paginator -from .forms import BulkMessage, HelperShift, HelperMessage from datetime import timedelta +from django.contrib import messages +from django.contrib.auth.decorators import login_required +from django.contrib.auth.mixins import LoginRequiredMixin +from django.core.paginator import Paginator +from django.db import models, transaction +from django.db.models import Case, Count, ExpressionWrapper, F, Q, When +from django.db.models.fields import DateTimeField +from django.shortcuts import get_object_or_404, redirect, render +from django.utils import timezone +from django.views.generic import DetailView, ListView +from django.views.generic.edit import FormMixin + +from .forms import BulkMessage, HelperMessage, HelperShift +from .models import ( + Helper, + IncomingMessage, + Message, + Room, + RoomViewToken, + Shift, + ShiftRegistration, +) # Create your views here. diff --git a/shiftregister/urls.py b/shiftregister/urls.py index ac76b85..7b13a18 100644 --- a/shiftregister/urls.py +++ b/shiftregister/urls.py @@ -13,6 +13,7 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin from django.urls import include, path