Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
5f47fc61
Commit
5f47fc61
authored
8 years ago
by
Jacek Lebioda
Browse files
Options
Downloads
Patches
Plain Diff
Introducing date fields
parent
f9b1bc11
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smash/web/forms.py
+27
-1
27 additions, 1 deletion
smash/web/forms.py
smash/web/views.py
+2
-1
2 additions, 1 deletion
smash/web/views.py
with
29 additions
and
2 deletions
smash/web/forms.py
+
27
−
1
View file @
5f47fc61
from
django
import
forms
from
django.forms
import
ModelForm
from
.models
import
*
from
datetime
import
datetime
"""
Possibl redundancy, but if need arises, contents of forms can be easily customized
Possibl
e
redundancy, but if need arises, contents of forms can be easily customized
"""
CURRENT_YEAR
=
datetime
.
now
().
year
YEAR_CHOICES
=
tuple
(
range
(
CURRENT_YEAR
,
CURRENT_YEAR
-
120
,
-
1
))
class
SubjectAddForm
(
ModelForm
):
date_born
=
forms
.
DateField
(
label
=
'
Date of birth
'
,
widget
=
forms
.
SelectDateWidget
(
years
=
YEAR_CHOICES
)
)
class
Meta
:
model
=
Subject
fields
=
'
__all__
'
...
...
@@ -19,6 +28,10 @@ class SubjectDetailForm(ModelForm):
class
SubjectEditForm
(
ModelForm
):
date_born
=
forms
.
DateField
(
label
=
'
Date of birth
'
,
widget
=
forms
.
SelectDateWidget
(
years
=
YEAR_CHOICES
)
)
class
Meta
:
model
=
Subject
fields
=
'
__all__
'
...
...
@@ -54,11 +67,24 @@ class AppointmentAddForm(ModelForm):
exclude
=
[
'
is_finished
'
]
class
VisitDetailForm
(
ModelForm
):
datetime_begin
=
forms
.
DateField
(
label
=
"
Visit begins on
"
,
widget
=
forms
.
SelectDateWidget
(
years
=
YEAR_CHOICES
)
)
datetime_end
=
forms
.
DateField
(
label
=
"
Visit ends on
"
,
widget
=
forms
.
SelectDateWidget
(
years
=
YEAR_CHOICES
)
)
class
Meta
:
model
=
Visit
exclude
=
[
'
is_finished
'
]
class
VisitAddForm
(
ModelForm
):
datetime_begin
=
forms
.
DateField
(
label
=
"
Visit begins on
"
,
widget
=
forms
.
SelectDateWidget
(
years
=
YEAR_CHOICES
)
)
datetime_end
=
forms
.
DateField
(
label
=
"
Visit ends on
"
,
widget
=
forms
.
SelectDateWidget
(
years
=
YEAR_CHOICES
)
)
class
Meta
:
model
=
Visit
exclude
=
[
'
is_finished
'
]
This diff is collapsed.
Click to expand it.
smash/web/views.py
+
2
−
1
View file @
5f47fc61
...
...
@@ -8,6 +8,7 @@ from .auth import * # Own wrapper for django logging in/out
from
django.forms
import
modelformset_factory
from
django.shortcuts
import
render
import
collections
import
datetime
def
index
(
request
):
if
request
.
user
.
is_authenticated
():
...
...
@@ -229,7 +230,7 @@ def mail_templates(request):
def
assignments
(
request
):
planning_list
=
Appointment
.
objects
.
none
()
approaching_list
=
Appointment
.
objects
.
filter
(
datetime_when__gt
=
datetime
.
datetime
.
now
())
approaching_list
=
Appointment
.
objects
.
filter
(
datetime_when__gt
=
datetime
.
datetime
.
now
())
context
=
{
'
planning_list
'
:
planning_list
,
...
...
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