2
0
Fork 0

Add field 'description' to Shift model

This commit is contained in:
Luca 2022-05-10 18:34:30 +02:00
parent 737958a7ab
commit 74481b0bda
4 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,26 @@
# Generated by Django 4.0.4 on 2022-05-10 16:27
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("app", "0004_shift_required_helpers"),
]
operations = [
migrations.AddField(
model_name="shift",
name="description",
field=models.TextField(default=""),
),
migrations.AlterField(
model_name="shift",
name="required_helpers",
field=models.IntegerField(
default=0,
help_text="When this is set to zero, the room value is used instead.",
),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2022-05-10 16:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("app", "0005_shift_description_alter_shift_required_helpers"),
]
operations = [
migrations.AlterField(
model_name="shift",
name="description",
field=models.TextField(blank=True, default=""),
),
]

View File

@ -25,6 +25,7 @@ class Shift(models.Model):
required_helpers = models.IntegerField( required_helpers = models.IntegerField(
default=0, help_text="When this is set to zero, the room value is used instead." default=0, help_text="When this is set to zero, the room value is used instead."
) )
description = models.TextField(blank=True, default="")
deleted = models.BooleanField(default=False) deleted = models.BooleanField(default=False)
def __str__(self): def __str__(self):

View File

@ -26,6 +26,7 @@ def import_calendar(calendar):
for event in cal.walk("vevent"): for event in cal.walk("vevent"):
uid = event.decoded("uid").decode() uid = event.decoded("uid").decode()
summary = event.decoded("summary").decode() summary = event.decoded("summary").decode()
description = (event.decoded("description", None) or b"").decode()
start = event.decoded("dtstart").astimezone(timezone.utc) start = event.decoded("dtstart").astimezone(timezone.utc)
end = event.decoded("dtend").astimezone(timezone.utc) end = event.decoded("dtend").astimezone(timezone.utc)
location = event.decoded("location", None) location = event.decoded("location", None)
@ -56,6 +57,7 @@ def import_calendar(calendar):
"start_at": start, "start_at": start,
"duration": end - start, "duration": end - start,
"required_helpers": required_helpers, "required_helpers": required_helpers,
"description": description,
"uuid": uid, "uuid": uid,
"calendar": calendar, "calendar": calendar,
}, },
@ -79,6 +81,7 @@ def import_calendar(calendar):
e.start_at = event["start_at"] e.start_at = event["start_at"]
e.duration = event["duration"] e.duration = event["duration"]
e.required_helpers = event["required_helpers"] e.required_helpers = event["required_helpers"]
e.description = event["description"]
e.save() e.save()
events[uuid] = (room, e) events[uuid] = (room, e)