Skip to content
Snippets Groups Projects
Commit a3ec31e4 authored by Julian's avatar Julian
Browse files

Remove unrelated changes

parent c74ab97c
No related branches found
No related tags found
1 merge request!360Resolve "Add absence management to course book student dialog"
<template>
<mobile-fullscreen-dialog v-model="popup">
<template #activator="activator">
<!-- button +? -->
<!-- -> popup = true -->
</template>
<template #title>
<!-- Abwesenheit/Entschuldigung erfassen -->
<!-- Abwesenheit/Entschuldigung Zusammenfassung -->
</template>
<template #content>
<absence-form v-if="form" />
<absence-summary v-else />
</template>
<template #actions>
<!-- secondary -->
<!-- TODO: Return to form on cancel? form=true -->
<cancel-button
@click="popup = false"
disabled="loading"
/>
<!-- primary -->
<save-button
v-if="form"
i18n-key="actions.continue"
@click="form = false"
:loading="loading"
/>
<save-button
v-if="form"
i18n-key="actions.confirm"
@click="confirm"
:loading="loading"
/>
</template>
</mobile-fullscreen-dialog>
</template>
<script>
import MobileFullscreenDialog from "aleksis.core/components/generic/dialogs/MobileFullscreenDialog.vue";
import AbsenceForm from "./AbsenceForm.vue";
import AbsenceSummary from "./AbsenceSummary.vue";
import CancelButton from "aleksis.core/components/generic/buttons/CancelButton.vue";
import SaveButton from "aleksis.core/components/generic/buttons/SaveButton.vue";
export default {
name: "AbsenceDialog",
components: {
MobileFullscreenDialog,
AbsenceForm,
AbsenceSummary,
CancelButton,
SaveButton,
},
data() {
return {
popup: false,
form: true,
loading: false,
};
},
methods: {
confirm() {
// TODO: Send mutation (shown in absence-summary)
popup = false,
},
},
};
</script>
<template>
<v-container>
<v-row>
<!-- persons -->
<!-- v-autocomplete -->
</v-row>
<v-row>
<!-- Start -->
<v-col
cols="12"
:sm="6"
>
<date-field
:value="value"
@input="$emit('input', $event)"
:label="$t('date_select.label')"
:disabled="loading"
/>
</v-col>
<!-- End -->
<v-col
cols="12"
:sm="6"
>
<date-field
:value="value"
@input="$emit('input', $event)"
:label="$t('date_select.label')"
:disabled="loading"
/>
</v-col>
</v-row>
<v-row>
<!-- comment -->
</v-row>
<v-row>
<!-- TODO: Component from Julian -->
</v-row>
</v-container>
</template>
<script>
import DateField from "aleksis.core/components/generic/forms/DateField.vue";
export default {
name: "AbsenceForm",
components: {
DateField,
},
};
</script>
<template>
<!-- TODO: Hide header -->
<c-r-u-d-iterator
:gql-query=""
:gql-additional-query-args="FROM FORM"
:enable-create="false"
:enable-edit="false"
:elevated="false"
>
<template #default="{ items }">
<!-- expandable card per person -->
</template>
</c-r-u-d-iterator>
</template>
<script>
import CRUDIterator from "aleksis.core/components/generic/CRUDIterator.vue";
export default {
name: "AbsenceSummary",
components: {
CRUDIterator,
},
};
</script>
# Uses core persons query
query persons {
persons: persons {
id
firstName
lastName
}
}
query lessonsForPersons(
$persons: [ID!]!
$start: Date!
$end: Date!
) {
items: lessonsForPersons(
persons: $persons
start: $start
end: $end
) {
id
lessons {
id
datetimeStart
datetimeEnd
course {
id
name
}
subject {
id
name
shortName
colourFg
colourBg
}
}
}
}
# Use absencesInputType?
mutation createAbsences(
$persons: [ID!]!
$start: Date!
$end: Date!
$comment: String
$reason: ID!
) {
createAbsences(
person: $persons
start: $start
end: $end
comment: $comment
reason: $reason
) {
items: absences {
ok
}
}
}
......@@ -17,10 +17,7 @@ from ..models import Documentation
from .documentation import (
DocumentationBatchCreateOrUpdateMutation,
DocumentationType,
)
from .absences import (
LessonsForPersonType,
AbsencesBatchCreateMutation,
)
from .participation_status import ParticipationStatusBatchPatchMutation
......@@ -175,5 +172,4 @@ class Query(graphene.ObjectType):
class Mutation(graphene.ObjectType):
create_or_update_documentations = DocumentationBatchCreateOrUpdateMutation.Field()
create_absences = AbsencesBatchCreateMutation.Field()
update_participation_statuses = ParticipationStatusBatchPatchMutation.Field()
import graphene
from datetime import datetime
from aleksis.apps.kolego.models import Absence
from .documentation import DocumentationType
from ..models import Documentation, ParticipationStatus
class LessonsForPersonType(graphene.ObjectType):
id = graphene.ID() # noqa
lessons = graphene.List(DocumentationType)
class AbsencesBatchCreateMutation(graphene.Mutation):
class Arguments:
persons = graphene.List(graphene.ID)
start = graphene.Date()
end = graphene.Date()
comment = graphene.String()
reason = graphene.ID()
ok = graphene.Boolean()
@classmethod
def mutate(cls, root, info, persons, start, end, comment, reason): # noqa
# TODO: Check permissions for ParticipationStatus & KolegoAbsence
# See MR 356
# DocumentationBatchCreateOrUpdateMutation.create_or_update
# at least already checks permissions.
for person in persons:
# Get all documentations for this person between start & end
docs, dummies = Documentation.get_documentations_for_person(
person,
datetime.combine(start, datetime.min.time()),
datetime.combine(end, datetime.max.time()),
)
# Create doc for dummies that are already in the past
future = False
for dummy in dummies:
lesson_event, dummy_start, dummy_end = Documentation.parse_dummy(dummy.id)
if dummy_start < datetime.now():
# In the past -> Create a Documentation
docs.append(
Documentation.create_from_lesson_event(
info.context.user,
lesson_event,
dummy_start,
dummy_end,
)
)
else:
future = True
# Create a ParticipationStatus for each documentation
for doc in docs:
# Set person & absence_reason directly from id
ParticipationStatus.objects.create(
person_id=person,
related_documentation=doc,
absence_reason_id=reason,
)
# If there are still dummy documentations in the future
# create a Kolego Absence
if future:
# TODO: Are date_start & date_end from CalendarEvent enough
# or more needed?
# Set reason & person directly from id
Absence.objects.create(
date_start=datetime.now().date(),
date_end=end,
reason_id=reason,
person_id=person,
comment=comment,
)
# Return ok=True if everything went well.
return AbsencesBatchCreateMutation(ok=True)
from datetime import datetime
from django.core.exceptions import PermissionDenied
from django.utils.timezone import localdate, localtime
import graphene
from graphene_django.types import DjangoObjectType
......@@ -97,6 +94,11 @@ class DocumentationInputType(graphene.InputObjectType):
group_note = graphene.String(required=False)
class LessonsForPersonType(graphene.ObjectType):
id = graphene.ID() # noqa
lessons = graphene.List(DocumentationType)
class DocumentationBatchCreateOrUpdateMutation(graphene.Mutation):
class Arguments:
input = graphene.List(DocumentationInputType)
......
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