ci: check code style

pull/1/head
Luca 8 months ago
parent c3f2c0bcfa
commit 5ac11e16e8

@ -4,10 +4,14 @@ kind: pipeline
type: docker type: docker
name: default name: default
clone:
disable: yes
steps: steps:
- name: check style
image: python:3.12-alpine
commands:
- pip install black isort
- black --check .
- isort -c .
- name: deploy staging - name: deploy staging
image: ghcr.io/appleboy/drone-ssh image: ghcr.io/appleboy/drone-ssh
environment: environment:
@ -26,6 +30,8 @@ steps:
when: when:
branch: branch:
- main - main
event:
- push
- name: deploy production - name: deploy production
image: ghcr.io/appleboy/drone-ssh image: ghcr.io/appleboy/drone-ssh
@ -35,7 +41,10 @@ steps:
when: when:
branch: branch:
- live - live
event:
- push
trigger: trigger:
event: event:
- pull_request
- push - push

@ -0,0 +1,4 @@
[isort]
line_length=88
profile=black
skip_gitignore=True

@ -1,7 +1,7 @@
from django.contrib import admin from django.contrib import admin
from django.contrib.admin import DateFieldListFilter 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) @admin.register(Room)

@ -1,4 +1,5 @@
from django.conf import settings from django.conf import settings
from .models import LoginToken from .models import LoginToken

@ -1,8 +1,9 @@
from dynamic_preferences.registries import global_preferences_registry
from dynamic_preferences import types
import phonenumbers
import datetime import datetime
import phonenumbers
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry
helper = types.Section("helper") helper = types.Section("helper")

@ -1,9 +1,10 @@
from django import forms 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 django.core.exceptions import ValidationError
from dynamic_preferences.registries import global_preferences_registry 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() global_preferences = global_preferences_registry.manager()

@ -1,8 +1,9 @@
# Generated by Django 4.0.4 on 2022-04-27 14:11 # Generated by Django 4.0.4 on 2022-04-27 14:11
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
import phonenumber_field.modelfields import phonenumber_field.modelfields
from django.db import migrations, models
import shiftregister.app.models import shiftregister.app.models

@ -1,12 +1,13 @@
from django.db import models
import secrets import secrets
from django.shortcuts import reverse
from datetime import timedelta 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 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 dynamic_preferences.registries import global_preferences_registry
from phonenumber_field.modelfields import PhoneNumberField
global_preferences = global_preferences_registry.manager() global_preferences = global_preferences_registry.manager()

@ -2,7 +2,9 @@ from django.db.models.signals import pre_save
from django.dispatch import receiver from django.dispatch import receiver
from django.shortcuts import reverse from django.shortcuts import reverse
from django.template import Context, Template from django.template import Context, Template
from shiftregister.core.signals import populate_nav from shiftregister.core.signals import populate_nav
from .models import Message, Shift from .models import Message, Shift

@ -1,7 +1,7 @@
from datetime import timezone 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" BASE_URL = "https://api.sipgate.com/v2"

@ -1,7 +1,6 @@
import requests
from django.conf import settings from django.conf import settings
from phonenumber_field.phonenumber import PhoneNumber from phonenumber_field.phonenumber import PhoneNumber
import requests
BASE_URL = "https://api.sipgate.com/v2" BASE_URL = "https://api.sipgate.com/v2"

@ -1,11 +1,12 @@
import sentry_sdk
from celery import shared_task from celery import shared_task
from .models import Message, ShiftRegistration
from django.conf import settings from django.conf import settings
from django.db import transaction from django.db import transaction
from django.utils import timezone from django.utils import timezone
from dynamic_preferences.registries import global_preferences_registry from dynamic_preferences.registries import global_preferences_registry
from .models import Message, ShiftRegistration
from .sipgate.sms import send as send_sms from .sipgate.sms import send as send_sms
import sentry_sdk
global_preferences = global_preferences_registry.manager() global_preferences = global_preferences_registry.manager()

@ -1,18 +1,20 @@
from django.shortcuts import render, redirect, get_object_or_404 import datetime
from .models import Shift, LoginToken, Helper, ShiftRegistration import math
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
from datetime import timedelta from datetime import timedelta
from django.utils import timezone
from django.conf import settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
import datetime from django.core.cache import cache
from .decorators import event_state 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 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() global_preferences = global_preferences_registry.manager()

@ -1,4 +1,4 @@
from .signals import populate_nav from .signals import populate_footer_nav, populate_nav
def nav(request): def nav(request):
@ -12,3 +12,14 @@ def nav(request):
return { return {
"nav_items": nav_items, "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}

@ -1,3 +1,5 @@
from django.dispatch import Signal from django.dispatch import Signal
populate_nav = Signal() populate_nav = Signal()
populate_footer_nav = Signal()

@ -1,5 +1,6 @@
from django.contrib import admin from django.contrib import admin
from django.shortcuts import reverse from django.shortcuts import reverse
from .models import * from .models import *

@ -1,7 +1,7 @@
# Generated by Django 4.0.4 on 2023-05-07 16:00 # Generated by Django 4.0.4 on 2023-05-07 16:00
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

@ -1,6 +1,7 @@
# Generated by Django 4.0.4 on 2023-05-13 17:28 # Generated by Django 4.0.4 on 2023-05-13 17:28
from django.db import migrations, models from django.db import migrations, models
import shiftregister.fallback.models import shiftregister.fallback.models

@ -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 math
import secrets 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) night_shift_query = Q(start_at__hour__gte=21) | Q(start_at__hour__lte=10)

@ -1,14 +1,15 @@
from datetime import datetime
from celery import shared_task from celery import shared_task
from .models import FallbackAssignment
from shiftregister.app.models import ShiftRegistration
from django.conf import settings from django.conf import settings
from django.db import transaction from django.db import transaction
from django.db.models import Case, Count, ExpressionWrapper, F, Q, When
from django.utils import timezone from django.utils import timezone
from dynamic_preferences.registries import global_preferences_registry 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() global_preferences = global_preferences_registry.manager()

@ -1,8 +1,10 @@
from base64 import urlsafe_b64decode from base64 import urlsafe_b64decode
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.db.models import Count from django.db.models import Count
from django.http import HttpResponse 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 from shiftregister.fallback.models import TeamMember
# Create your views here. # Create your views here.

@ -1,6 +1,7 @@
from .models import Feedback
from django.forms import ModelForm
from django import forms from django import forms
from django.forms import ModelForm
from .models import Feedback
class FeedbackForm(ModelForm): class FeedbackForm(ModelForm):

@ -1,7 +1,7 @@
# Generated by Django 4.0.4 on 2023-05-25 14:16 # Generated by Django 4.0.4 on 2023-05-25 14:16
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

@ -1,8 +1,9 @@
# Generated by Django 4.0.4 on 2023-05-27 17:48 # Generated by Django 4.0.4 on 2023-05-27 17:48
from django.db import migrations, models
import secrets import secrets
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

@ -1,5 +1,7 @@
from django.db import models
from secrets import token_urlsafe from secrets import token_urlsafe
from django.db import models
from shiftregister.app.models import Helper from shiftregister.app.models import Helper

@ -1,6 +1,7 @@
from django.dispatch import receiver from django.dispatch import receiver
from django.shortcuts import reverse from django.shortcuts import reverse
from dynamic_preferences.registries import global_preferences_registry from dynamic_preferences.registries import global_preferences_registry
from shiftregister.core.signals import populate_nav from shiftregister.core.signals import populate_nav
global_preferences = global_preferences_registry.manager() global_preferences = global_preferences_registry.manager()

@ -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 import messages
from django.contrib.auth.decorators import login_required 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): def feedback(request, token):

@ -1,4 +1,5 @@
from django.contrib import admin from django.contrib import admin
from .models import Calendar from .models import Calendar

@ -1,9 +1,11 @@
from datetime import timezone from datetime import timezone
import requests
from django.conf import settings from django.conf import settings
from django.db import transaction from django.db import transaction
from icalendar import Calendar from icalendar import Calendar
from .models import Event, Room, Shift from .models import Event, Room, Shift
import requests
def import_calendar(calendar): def import_calendar(calendar):

@ -1,7 +1,7 @@
# Generated by Django 4.0.4 on 2022-04-27 14:11 # Generated by Django 4.0.4 on 2022-04-27 14:11
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

@ -1,4 +1,5 @@
from django.db import models from django.db import models
from shiftregister.app.models import * from shiftregister.app.models import *

@ -1,4 +1,5 @@
from celery import shared_task from celery import shared_task
from .importer import import_calendar from .importer import import_calendar
from .models import Calendar from .models import Calendar

@ -1,7 +1,8 @@
from django.db import models 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 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.fallback.models import FallbackAssignment
from shiftregister.importer.models import Event from shiftregister.importer.models import Event
@ -159,9 +160,11 @@ def metrics(request):
), ),
( (
"worked_seconds_total", "worked_seconds_total",
(
worked_seconds_total.total_seconds() worked_seconds_total.total_seconds()
if worked_seconds_total if worked_seconds_total
else 0.0, else 0.0
),
), ),
( (
"worked_shifts_total", "worked_shifts_total",

@ -1,6 +1,8 @@
from pathlib import Path
from django.contrib import admin from django.contrib import admin
from .models import Page from .models import Page
from pathlib import Path
def reimport(modeladmin, request, queryset): def reimport(modeladmin, request, queryset):

@ -1,6 +1,7 @@
from django.apps import AppConfig
from pathlib import Path from pathlib import Path
from django.apps import AppConfig
class PagesConfig(AppConfig): class PagesConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField" default_auto_field = "django.db.models.BigAutoField"

@ -1,7 +1,9 @@
from pathlib import Path
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from ...models import Page from ...models import Page
from pathlib import Path
class Command(BaseCommand): class Command(BaseCommand):

@ -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.exceptions import ValidationError
from django.core.validators import URLValidator
from django.http import HttpResponseNotFound from django.http import HttpResponseNotFound
from django.shortcuts import redirect
from django.views.generic import DetailView
from .models import Page from .models import Page
# Create your views here. # Create your views here.

@ -10,12 +10,13 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/ https://docs.djangoproject.com/en/4.0/ref/settings/
""" """
from pathlib import Path
from os import getenv from os import getenv
from pathlib import Path
import sentry_sdk import sentry_sdk
from django.contrib.messages import constants as messages
from sentry_sdk.integrations.celery import CeleryIntegration from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.django import DjangoIntegration 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'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent

@ -1,7 +1,7 @@
# Generated by Django 4.0.4 on 2022-05-18 13:10 # Generated by Django 4.0.4 on 2022-05-18 13:10
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

@ -1,2 +1,3 @@
from django.db import models from django.db import models
from shiftregister.app.models import * from shiftregister.app.models import *

@ -1,8 +1,10 @@
from datetime import timedelta from datetime import timedelta
from django.db import models 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.shortcuts import render
from django.utils import timezone from django.utils import timezone
from .models import Helper, Shift, ShiftRegistration from .models import Helper, Shift, ShiftRegistration

@ -1,4 +1,5 @@
from django.contrib import admin from django.contrib import admin
from .models import IncomingMessage, RoomViewToken from .models import IncomingMessage, RoomViewToken
# Register your models here. # Register your models here.

@ -1,5 +1,6 @@
from django import forms 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 # placeholder form for simple submit button use cases so we get csrf protection

@ -1,7 +1,7 @@
# Generated by Django 4.0.4 on 2023-05-06 23:27 # Generated by Django 4.0.4 on 2023-05-06 23:27
from django.db import migrations, models
import phonenumber_field.modelfields import phonenumber_field.modelfields
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

@ -1,7 +1,8 @@
# Generated by Django 4.0.4 on 2023-05-18 15:15 # Generated by Django 4.0.4 on 2023-05-18 15:15
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.db import migrations, models
import shiftregister.team.models import shiftregister.team.models

@ -1,7 +1,9 @@
import secrets
from django.db import models from django.db import models
from phonenumber_field.modelfields import PhoneNumberField from phonenumber_field.modelfields import PhoneNumberField
from shiftregister.app.models import * from shiftregister.app.models import *
import secrets
# Create your models here. # Create your models here.

@ -1,7 +1,9 @@
from django.dispatch import receiver from django.dispatch import receiver
from django.shortcuts import reverse from django.shortcuts import reverse
from dynamic_preferences.registries import global_preferences_registry from dynamic_preferences.registries import global_preferences_registry
from shiftregister.core.signals import populate_nav from shiftregister.core.signals import populate_nav
from .models import IncomingMessage from .models import IncomingMessage
global_preferences = global_preferences_registry.manager() global_preferences = global_preferences_registry.manager()

@ -1,8 +1,10 @@
import sentry_sdk
from celery import shared_task from celery import shared_task
from django.conf import settings from django.conf import settings
from shiftregister.app.sipgate.history import list_incoming_sms from shiftregister.app.sipgate.history import list_incoming_sms
from .models import IncomingMessage from .models import IncomingMessage
import sentry_sdk
@shared_task @shared_task

@ -1,6 +1,7 @@
from django import template
from re import ASCII, sub from re import ASCII, sub
from django import template
register = template.Library() register = template.Library()

@ -1,26 +1,27 @@
from django.shortcuts import render, get_object_or_404, redirect from datetime import timedelta
from django.contrib import messages
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.utils import timezone 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.db.models.fields import DateTimeField
from django.db.models import F, Count, Q, ExpressionWrapper, Case, When 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 ( from .models import (
ShiftRegistration,
Room,
Shift,
Helper, Helper,
Message,
IncomingMessage, IncomingMessage,
Message,
Room,
RoomViewToken, RoomViewToken,
Shift,
ShiftRegistration,
) )
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
# Create your views here. # Create your views here.

@ -13,6 +13,7 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path 1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import include, path from django.urls import include, path

Loading…
Cancel
Save