Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor 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-Core
Commits
00427523
Commit
00427523
authored
7 years ago
by
Frank Poetzsch-Heffter
Browse files
Options
Downloads
Patches
Plain Diff
Datumsprüfung verbessert
parent
1c00de44
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!86
Merge school-apps
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
schoolapps/aub/forms.py
+24
-12
24 additions, 12 deletions
schoolapps/aub/forms.py
schoolapps/aub/templates/aub/apply_for.html
+7
-9
7 additions, 9 deletions
schoolapps/aub/templates/aub/apply_for.html
with
31 additions
and
21 deletions
schoolapps/aub/forms.py
+
24
−
12
View file @
00427523
from
django
import
forms
from
django.core.exceptions
import
ValidationError
from
django.utils
import
timezone
#from django.utils import timezone
from
datetime
import
datetime
class
ApplyForAUBForm
(
forms
.
Form
):
...
...
@@ -15,27 +16,39 @@ class ApplyForAUBForm(forms.Form):
def
clean
(
self
):
cleaned_data
=
super
().
clean
()
def
clean_from_to_date
(
self
):
# not related to a form field, just to clean datetime values
from_date
=
self
.
cleaned_data
[
'
from_date
'
]
from_time
=
self
.
cleaned_data
[
'
from_time
'
]
to_date
=
self
.
cleaned_data
[
'
to_date
'
]
to_time
=
self
.
cleaned_data
[
'
to_time
'
]
from_datetime
=
datetime
.
combine
(
from_date
,
from_time
)
print
(
from_datetime
)
to_datetime
=
datetime
.
combine
(
to_date
,
to_time
)
if
(
from_datetime
<
datetime
.
now
())
or
(
to_datetime
<
datetime
.
now
()):
raise
ValidationError
(
'
Die Befreiung kann nicht für vergangenen Unterricht durchgeführt werden (Datumsfehler).
'
)
elif
from_datetime
>
to_datetime
:
raise
ValidationError
(
'
Das erste Datum liegt später als das zweiten Datum.
'
)
return
True
def
clean_from_date
(
self
):
data
=
self
.
cleaned_data
[
'
from_date
'
]
print
(
data
,
timezone
.
datetime
.
time
(
timezone
.
now
())
)
if
data
<
timezone
.
datetime
.
date
(
timezone
.
now
()):
raise
ValidationError
(
'
Die Befreiung kann nur zukünftig durchgeführt werden (Datumsfehler).
'
)
# if data < timezone.datetime.date(timezone.now()):
# raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden (Datumsfehler).')
return
data
def
clean_to_date
(
self
):
data
=
self
.
cleaned_data
[
'
to_date
'
]
# if data < timezone.datetime.date(timezone.now()):
# raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden.')
return
data
def
clean_from_time
(
self
):
data
=
self
.
cleaned_data
[
'
from_time
'
]
if
data
<
timezone
.
datetime
.
time
(
timezone
.
now
()):
raise
ValidationError
(
'
Die Befreiung kann nur zukünftig durchgeführt werden (Zeitfehler).
'
)
#print('Data:', type(data), 'Now:', type(timezone.datetime.time(timezone.now())))
# if data < timezone.datetime.time(timezone.now()):
# raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden (Zeitfehler).')
return
data
...
...
@@ -44,12 +57,11 @@ class ApplyForAUBForm(forms.Form):
# if data < timezone.datetime.time(timezone.now()):
# raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden.')
return
data
def
clean_description
(
self
):
data
=
self
.
cleaned_data
[
'
description
'
]
self
.
clean_from_to_date
()
if
len
(
data
)
<
10
:
raise
ValidationError
(
'
Bitte teilen Sie uns etwas mehr über Ihren Befreiungswunsch mit.
'
)
...
...
This diff is collapsed.
Click to expand it.
schoolapps/aub/templates/aub/apply_for.html
+
7
−
9
View file @
00427523
...
...
@@ -2,7 +2,7 @@
<main>
<h5>
Antrag auf Unterrichtsbefreiung
</h5>
Hiermit beantrage ich die Freistellung vom Unterricht wie folgt.
<form
action=
""
method=
"post"
>
{% csrf_token %}
<div
class=
"flow-text red-text"
>
...
...
@@ -11,14 +11,12 @@
<div
class=
"row"
>
<!-- From date and time -->
<div
class=
"col s12 m6"
>
<h6>
Beginn der Befreiung:
</h6>
<div
class=
"red-text"
>
{{ form.from_date.errors }}
</div>
<div
class=
"red-text"
>
{{ form.from_time.errors }}
</div>
<div
class=
"col s2"
>
Von:
<h5>
Von:
</h5>
</div>
<div
class=
"input-field col s6"
>
...
...
@@ -42,12 +40,10 @@
<!-- To date and time -->
<div
class=
"col s12 m6"
>
<h6>
Ende der Befreiung:
</h6>
<div
class=
"red-text"
>
{{ form.to_date.errors }}
</div>
<div
class=
"red-text"
>
{{ form.to_time.errors }}
</div>
<div
class=
"col s2"
>
Bis:
<h5>
Bis:
</h5>
</div>
<div
class=
"input-field col s6"
>
<input
id=
"{{ form.to_date.id_for_label }}"
type=
"text"
...
...
@@ -72,9 +68,11 @@
<!-- Description -->
<div
class=
"red-text col s12"
>
{{ form.description.errors }}
</div>
<div
class=
"input-field col s12"
>
<div
class=
"col s1"
>
<h5>
Grund:
</h5>
</div>
<div
class=
"input-field col s11"
>
<textarea
id=
"{{ form.description.id_for_label }}"
required
name=
"{{ form.description.html_name }}"
class=
"materialize-textarea"
>
{{ form.description.value }}
</textarea>
...
...
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