Skip to content
Snippets Groups Projects
Verified Commit 74dbfa6d authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Drop period_after

parent c3456b0f
No related branches found
No related tags found
1 merge request!2Resolve "Frontend for Models"
Showing
with 45 additions and 57 deletions
...@@ -27,10 +27,6 @@ export default { ...@@ -27,10 +27,6 @@ export default {
text: this.$t("lesrooster.slot.weekday"), text: this.$t("lesrooster.slot.weekday"),
value: "weekday", value: "weekday",
}, },
{
text: this.$t("lesrooster.break.period_after"),
value: "period",
},
{ {
text: this.$t("lesrooster.slot.time_start"), text: this.$t("lesrooster.slot.time_start"),
value: "timeStart", value: "timeStart",
...@@ -55,7 +51,6 @@ export default { ...@@ -55,7 +51,6 @@ export default {
return { return {
...item, ...item,
period: null, period: null,
periodAfter: item.period,
weekday: this.weekdayAsInt(item.weekday), weekday: this.weekdayAsInt(item.weekday),
timeGrid: item.timeGrid.id, timeGrid: item.timeGrid.id,
}; };
...@@ -66,7 +61,7 @@ export default { ...@@ -66,7 +61,7 @@ export default {
id: item.id, id: item.id,
name: item.name, name: item.name,
weekday: this.weekdayAsInt(item.weekday), weekday: this.weekdayAsInt(item.weekday),
periodAfter: item.period, period: null,
timeStart: item.timeStart, timeStart: item.timeStart,
timeEnd: item.timeEnd, timeEnd: item.timeEnd,
timeGrid: item.timeGrid.id, timeGrid: item.timeGrid.id,
......
...@@ -16,7 +16,7 @@ query breakSlots($orderBy: [String], $filters: JSONString) { ...@@ -16,7 +16,7 @@ query breakSlots($orderBy: [String], $filters: JSONString) {
} }
} }
weekday weekday
period: periodAfter period
timeStart timeStart
timeEnd timeEnd
canEdit canEdit
...@@ -41,7 +41,7 @@ mutation createBreakSlot($input: CreateBreakSlotInput!) { ...@@ -41,7 +41,7 @@ mutation createBreakSlot($input: CreateBreakSlotInput!) {
} }
} }
weekday weekday
period: periodAfter period
timeStart timeStart
timeEnd timeEnd
canEdit canEdit
...@@ -68,8 +68,7 @@ mutation createBreakSlots($input: [BatchCreateBreakSlotInput]!) { ...@@ -68,8 +68,7 @@ mutation createBreakSlots($input: [BatchCreateBreakSlotInput]!) {
} }
} }
weekday weekday
period: periodAfter period
periodAfter
timeStart timeStart
timeEnd timeEnd
canEdit canEdit
...@@ -107,7 +106,7 @@ mutation updateBreakSlots($input: [BatchPatchBreakSlotInput]!) { ...@@ -107,7 +106,7 @@ mutation updateBreakSlots($input: [BatchPatchBreakSlotInput]!) {
} }
} }
weekday weekday
period: periodAfter period
timeStart timeStart
timeEnd timeEnd
canEdit canEdit
......
...@@ -16,7 +16,6 @@ query slots($orderBy: [String], $filters: JSONString) { ...@@ -16,7 +16,6 @@ query slots($orderBy: [String], $filters: JSONString) {
} }
weekday weekday
period period
periodAfter
timeStart timeStart
timeEnd timeEnd
canEdit canEdit
...@@ -69,7 +68,6 @@ mutation createSlots($input: [BatchCreateSlotInput]!) { ...@@ -69,7 +68,6 @@ mutation createSlots($input: [BatchCreateSlotInput]!) {
} }
weekday weekday
period period
periodAfter
timeStart timeStart
timeEnd timeEnd
canEdit canEdit
...@@ -146,7 +144,6 @@ mutation carryOverSlots( ...@@ -146,7 +144,6 @@ mutation carryOverSlots(
} }
weekday weekday
period period
periodAfter
timeStart timeStart
timeEnd timeEnd
canEdit canEdit
...@@ -174,7 +171,6 @@ mutation copySlotsFromGrid($toTimeGrid: ID!, $fromTimeGrid: ID!) { ...@@ -174,7 +171,6 @@ mutation copySlotsFromGrid($toTimeGrid: ID!, $fromTimeGrid: ID!) {
} }
weekday weekday
period period
periodAfter
timeStart timeStart
timeEnd timeEnd
canEdit canEdit
......
...@@ -254,9 +254,10 @@ export default { ...@@ -254,9 +254,10 @@ export default {
}; };
}, },
result(data) { result(data) {
console.log(data);
this.weekdays = Array.from( this.weekdays = Array.from(
new Set(data.data.items.map((slot) => slot.weekday)) new Set(data.data.items.map((slot) => slot.weekday))
); ).sort();
}, },
skip() { skip() {
return this.internalTimeGrid === null; return this.internalTimeGrid === null;
......
...@@ -8,7 +8,6 @@ export default defineComponent({ ...@@ -8,7 +8,6 @@ export default defineComponent({
id: String, id: String,
model: String, model: String,
period: Number, period: Number,
periodAfter: Number,
weekday: String, weekday: String,
timeStart: String, timeStart: String,
timeEnd: String, timeEnd: String,
......
...@@ -56,8 +56,7 @@ export default defineComponent({ ...@@ -56,8 +56,7 @@ export default defineComponent({
input: this.slots.weekdays.map((weekday) => ({ input: this.slots.weekdays.map((weekday) => ({
name: "", name: "",
timeGrid: this.timeGrid, timeGrid: this.timeGrid,
period: this.breaks ? undefined : this.slots.period, period: this.slots.period,
periodAfter: this.breaks ? this.slots.period : undefined,
weekday: parseInt(weekday[2]), weekday: parseInt(weekday[2]),
timeStart: this.slots.timeStart, timeStart: this.slots.timeStart,
timeEnd: this.slots.timeEnd, timeEnd: this.slots.timeEnd,
......
...@@ -32,7 +32,6 @@ fragment supervisionFields on SupervisionType { ...@@ -32,7 +32,6 @@ fragment supervisionFields on SupervisionType {
} }
} }
weekday weekday
periodAfter
timeStart timeStart
timeEnd timeEnd
canEdit canEdit
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
"create_items_success": "Pausen erfolgreich erstellt.", "create_items_success": "Pausen erfolgreich erstellt.",
"create_items_error": "Fehler beim Erstellen der Pausen.", "create_items_error": "Fehler beim Erstellen der Pausen.",
"repr": { "repr": {
"default": "Pause vor Stunde {periodAfter}, von {timeStart} bis {timeEnd}", "default": "Pause von {timeStart} bis {timeEnd}",
"weekday_short": "{weekday}, {timeStart} bis {timeEnd}" "weekday_short": "{weekday}, {timeStart} bis {timeEnd}"
} }
}, },
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
"create_items_success": "The breaks where created successfully.", "create_items_success": "The breaks where created successfully.",
"create_items_error": "Error creating breaks.", "create_items_error": "Error creating breaks.",
"repr": { "repr": {
"default": "Break before period {periodAfter}, from {timeStart} to {timeEnd}", "default": "Break from {timeStart} to {timeEnd}",
"weekday_short": "{weekday}, {timeStart} to {timeEnd}" "weekday_short": "{weekday}, {timeStart} to {timeEnd}"
} }
}, },
......
# Generated by Django 4.2.5 on 2023-10-26 13:12
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("lesrooster", "0013_supervision_subject_supervisionsubstitution_subject"),
]
operations = [
migrations.RemoveField(
model_name="breakslot",
name="period_after",
),
]
...@@ -374,14 +374,9 @@ class Lesson(TeacherPropertiesMixin, RoomPropertiesMixin, ExtensibleModel): ...@@ -374,14 +374,9 @@ class Lesson(TeacherPropertiesMixin, RoomPropertiesMixin, ExtensibleModel):
class BreakSlot(Slot): class BreakSlot(Slot):
"""A break is a time period that can supervised and in which no lessons take place.""" """A break is a time period that can supervised and in which no lessons take place."""
period_after = models.IntegerField(
verbose_name=_("Period after"),
)
def __str__(self) -> str: def __str__(self) -> str:
return ( return (
f"{self.period_after - 1}./{self.period_after}. " f"{time_format(self.time_start)} - {time_format(self.time_end)}"
f"({time_format(self.time_start)} - {time_format(self.time_end)})"
) )
class Meta: class Meta:
......
...@@ -20,7 +20,6 @@ from ..models import BreakSlot ...@@ -20,7 +20,6 @@ from ..models import BreakSlot
from .slot import slot_filters from .slot import slot_filters
break_filters = slot_filters.copy() break_filters = slot_filters.copy()
break_filters["period_after"] = break_filters.pop("period")
class BreakSlotType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType): class BreakSlotType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType):
...@@ -33,7 +32,7 @@ class BreakSlotType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType): ...@@ -33,7 +32,7 @@ class BreakSlotType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType):
"time_grid", "time_grid",
"name", "name",
"weekday", "weekday",
"period_after", "period",
"time_start", "time_start",
"time_end", "time_end",
) )
...@@ -56,7 +55,7 @@ class BreakSlotCreateMutation(DjangoCreateMutation): ...@@ -56,7 +55,7 @@ class BreakSlotCreateMutation(DjangoCreateMutation):
"time_grid", "time_grid",
"name", "name",
"weekday", "weekday",
"period_after", "period",
"time_start", "time_start",
"time_end", "time_end",
) )
...@@ -78,7 +77,7 @@ class BreakSlotBatchCreateMutation(PermissionBatchPatchMixin, DjangoBatchCreateM ...@@ -78,7 +77,7 @@ class BreakSlotBatchCreateMutation(PermissionBatchPatchMixin, DjangoBatchCreateM
"time_grid", "time_grid",
"name", "name",
"weekday", "weekday",
"period_after", "period",
"time_start", "time_start",
"time_end", "time_end",
) )
...@@ -102,7 +101,7 @@ class BreakSlotBatchPatchMutation(PermissionBatchPatchMixin, DjangoBatchPatchMut ...@@ -102,7 +101,7 @@ class BreakSlotBatchPatchMutation(PermissionBatchPatchMixin, DjangoBatchPatchMut
"time_grid", "time_grid",
"name", "name",
"weekday", "weekday",
"period_after", "period",
"time_start", "time_start",
"time_end", "time_end",
) )
...@@ -34,7 +34,6 @@ slot_filters = { ...@@ -34,7 +34,6 @@ slot_filters = {
class SlotType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType): class SlotType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType):
model = graphene.String(default_value="Default") model = graphene.String(default_value="Default")
period_after = graphene.Int()
class Meta: class Meta:
model = Slot model = Slot
...@@ -51,9 +50,6 @@ class SlotType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType): ...@@ -51,9 +50,6 @@ class SlotType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType):
def resolve_model(root, info): def resolve_model(root, info):
return root.get_real_instance_class().__name__ return root.get_real_instance_class().__name__
@staticmethod
def resolve_period_after(root, info):
return getattr(root.get_real_instance(), "period_after", None)
class SlotCreateMutation(DjangoCreateMutation): class SlotCreateMutation(DjangoCreateMutation):
...@@ -117,33 +113,29 @@ class CarryOverSlotsMutation(graphene.Mutation): ...@@ -117,33 +113,29 @@ class CarryOverSlotsMutation(graphene.Mutation):
if only and len(only) > 0: if only and len(only) > 0:
slots_on_day = slots_on_day.filter(id__in=only) slots_on_day = slots_on_day.filter(id__in=only)
periods = []
periods_after = []
result = [] result = []
new_ids = []
for slot in slots_on_day: for slot in slots_on_day:
slot: BreakSlot | Slot
klass = slot.get_real_instance_class()
defaults = {"name": slot.name, "time_start": slot.time_start, "time_end": slot.time_end} defaults = {"name": slot.name, "time_start": slot.time_start, "time_end": slot.time_end}
if hasattr(slot, "period_after"):
defaults["period_after"] = slot.period_after
periods_after.append(slot.period_after)
if slot.period is not None: if slot.period is not None:
periods.append(slot.period) new_slot = Slot.objects.non_polymorphic().update_or_create(
weekday=to_day, time_grid=time_grid, period=slot.period, defaults=defaults
)[0]
else:
new_slot = Slot.objects.non_polymorphic().update_or_create(
weekday=to_day, time_grid=time_grid, time_start=slot.time_start, time_end=slot.time_end, defaults=defaults
)[0]
result.append(new_slot)
new_ids.append(new_slot.pk)
result.append(
klass.objects.update_or_create(
weekday=to_day, time_grid=time_grid, period=slot.period, defaults=defaults
)[0]
)
if not only or not len(only): if not only or not len(only):
objects_to_delete = Slot.objects.filter(weekday=to_day, time_grid=time_grid).exclude( objects_to_delete = Slot.objects.filter(weekday=to_day, time_grid=time_grid).exclude(
Q(Slot___period__in=periods) | Q(BreakSlot___period_after__in=periods_after) pk__in=new_ids
) )
objects_to_delete.delete() objects_to_delete.delete()
...@@ -185,9 +177,6 @@ class CopySlotsFromDifferentTimeGridMutation(graphene.Mutation): ...@@ -185,9 +177,6 @@ class CopySlotsFromDifferentTimeGridMutation(graphene.Mutation):
defaults = {"name": slot.name, "time_start": slot.time_start, "time_end": slot.time_end} defaults = {"name": slot.name, "time_start": slot.time_start, "time_end": slot.time_end}
if hasattr(slot, "period_after"):
defaults["period_after"] = slot.period_after
result.append( result.append(
klass.objects.update_or_create( klass.objects.update_or_create(
weekday=slot.weekday, time_grid=time_grid, period=slot.period, defaults=defaults weekday=slot.weekday, time_grid=time_grid, period=slot.period, defaults=defaults
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment