Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Alsijil
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Alsijil
Commits
6782f582
Verified
Commit
6782f582
authored
5 years ago
by
Tom Teichler
Browse files
Options
Downloads
Patches
Plain Diff
Add basic view logic.
parent
8c0ccc65
No related branches found
No related tags found
1 merge request
!26
Resolve "Register absences and excuses centrally"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
biscuit/apps/alsijil/forms.py
+1
-1
1 addition, 1 deletion
biscuit/apps/alsijil/forms.py
biscuit/apps/alsijil/views.py
+15
-2
15 additions, 2 deletions
biscuit/apps/alsijil/views.py
with
16 additions
and
3 deletions
biscuit/apps/alsijil/forms.py
+
1
−
1
View file @
6782f582
...
...
@@ -53,7 +53,7 @@ PersonalNoteFormSet = forms.modelformset_factory(
class
AbsentExcusedForm
(
forms
.
Form
):
date_start
=
forms
.
DateField
(
label
=
_
(
'
Start date
'
),
widget
=
forms
.
SelectDateWidget
,
initial
=
datetime
.
today
())
date_end
=
forms
.
DateField
(
label
=
_
(
'
End date
'
),
widget
=
forms
.
SelectDateWidget
,
initial
=
datetime
.
today
())
starting_lesson
=
forms
.
Choice
Field
(
label
=
_
(
'
Starting lesson
'
))
starting_lesson
=
forms
.
Integer
Field
(
label
=
_
(
'
Starting lesson
'
))
person
=
forms
.
ModelChoiceField
(
label
=
_
(
'
Person
'
),
queryset
=
Person
.
objects
.
all
(),
widget
=
Select2Widget
)
absent
=
forms
.
BooleanField
(
label
=
_
(
'
Absent
'
))
excused
=
forms
.
BooleanField
(
label
=
_
(
'
Excused
'
))
This diff is collapsed.
Click to expand it.
biscuit/apps/alsijil/views.py
+
15
−
2
View file @
6782f582
...
...
@@ -13,6 +13,7 @@ from biscuit.apps.chronos.models import LessonPeriod
from
biscuit.apps.chronos.util
import
CalendarWeek
from
biscuit.core.models
import
Group
,
Person
from
biscuit.core.decorators
import
admin_required
from
biscuit.core.util
import
messages
from
.forms
import
AbsentExcusedForm
,
LessonDocumentationForm
,
PersonalNoteFormSet
,
SelectForm
from
.models
import
LessonDocumentation
...
...
@@ -215,8 +216,20 @@ def absences_excuses(request: HttpRequest) -> HttpResponse:
if
request
.
method
==
'
POST
'
:
if
manage_absence_form
.
is_valid
():
# Get person from form
person
=
Person
.
objects
.
get
(
id
=
manage_absence_form
.
cleaned_data
[
'
person
'
])
person
=
manage_absence_form
.
cleaned_data
[
'
person
'
]
# Get dates and starting lesson
start_date
=
manage_absence_form
.
cleaned_data
[
'
date_start
'
]
end_date
=
manage_absence_form
.
cleaned_data
[
'
date_end
'
]
starting_lesson
=
manage_absence_form
.
cleaned_data
[
'
starting_lesson
'
]
# Mark person as absent
day_list
=
[]
delta
=
end_date
-
start_date
for
i
in
range
(
delta
.
days
+
1
):
day
=
start_date
+
timedelta
(
days
=
1
)
person
.
mark_absent
(
day
,
absent
=
manage_absence_form
.
cleaned_data
[
'
absent
'
],
excused
=
manage_absence_form
.
cleaned_data
[
'
excused
'
])
person
.
save
()
messages
.
success
(
request
,
_
(
'
The absence has been saved.
'
))
return
redirect
(
request
,
'
index.html
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment