main #1

Merged
xAndy merged 12 commits from main into live 2025-05-15 23:25:56 +02:00
4 changed files with 33 additions and 3 deletions
Showing only changes of commit 7e4ff4366b - Show all commits

View File

@ -3,6 +3,12 @@ from django.contrib import admin
from .models import Calendar
def update_calendar(modeladmin, request, queryset):
for calendar in queryset:
calendar.update()
@admin.register(Calendar)
class CalendarAdmin(admin.ModelAdmin):
list_display = ("url", "needs_fallback", "has_errors")
actions = (update_calendar,)

View File

@ -0,0 +1,18 @@
# Generated by Django 5.0.4 on 2025-05-12 22:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("importer", "0002_calendar_needs_fallback"),
]
operations = [
migrations.AlterField(
model_name="calendar",
name="url",
field=models.URLField(max_length=1000, primary_key=True, serialize=False),
),
]

View File

@ -4,10 +4,17 @@ from shiftregister.app.models import *
class Calendar(models.Model):
url = models.URLField(primary_key=True)
url = models.URLField(primary_key=True, max_length=1000)
needs_fallback = models.BooleanField(default=False, editable=True)
has_errors = models.BooleanField(default=False, editable=False)
def update(self):
# break circular import
from .importer import import_calendar
self.has_errors = not import_calendar(self)
self.save()
class Event(Shift):
uuid = models.UUIDField(primary_key=True, editable=False)

View File

@ -7,5 +7,4 @@ from .models import Calendar
@shared_task
def import_shifts():
for calendar in Calendar.objects.all():
calendar.has_errors = not import_calendar(calendar)
calendar.save()
calendar.update()