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
cb699e9c
Commit
cb699e9c
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
appointments api is timezone aware
parent
3c947a7d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!60
Resolve "Export to Excel"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/api_views/appointment.py
+6
-2
6 additions, 2 deletions
smash/web/api_views/appointment.py
with
6 additions
and
2 deletions
smash/web/api_views/appointment.py
+
6
−
2
View file @
cb699e9c
import
traceback
import
traceback
from
datetime
import
datetime
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.decorators
import
login_required
from
django.http
import
JsonResponse
from
django.http
import
JsonResponse
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.utils
import
timezone
from
web.models
import
Appointment
from
web.models
import
Appointment
from
web.views
import
e500_error
from
web.views
import
e500_error
...
@@ -29,9 +31,11 @@ def get_appointments(request, type, min_date, max_date):
...
@@ -29,9 +31,11 @@ def get_appointments(request, type, min_date, max_date):
raise
TypeError
(
"
Unknown query type:
"
+
type
)
raise
TypeError
(
"
Unknown query type:
"
+
type
)
if
min_date
is
not
None
:
if
min_date
is
not
None
:
min_date
=
datetime
.
strptime
(
min_date
,
"
%Y-%m-%d
"
).
replace
(
tzinfo
=
timezone
.
now
().
tzinfo
)
result
=
result
.
filter
(
datetime_when__gt
=
min_date
)
result
=
result
.
filter
(
datetime_when__gt
=
min_date
)
if
max_date
is
not
None
:
if
max_date
is
not
None
:
max_date
=
datetime
.
strptime
(
max_date
,
"
%Y-%m-%d
"
).
replace
(
tzinfo
=
timezone
.
now
().
tzinfo
)
result
=
result
.
filter
(
datetime_when__lt
=
max_date
)
result
=
result
.
filter
(
datetime_when__lt
=
max_date
)
return
result
.
order_by
(
"
datetime_when
"
)
return
result
.
order_by
(
"
datetime_when
"
)
...
@@ -57,12 +61,12 @@ def appointments(request, type):
...
@@ -57,12 +61,12 @@ def appointments(request, type):
sliced_subjects
=
all_appointments
[
start
:(
start
+
length
)]
sliced_subjects
=
all_appointments
[
start
:(
start
+
length
)]
appointments
=
sliced_subjects
result_
appointments
=
sliced_subjects
count_filtered
=
all_appointments
.
count
()
count_filtered
=
all_appointments
.
count
()
data
=
[]
data
=
[]
for
appointment
in
appointments
:
for
appointment
in
result_
appointments
:
data
.
append
(
serialize_appointment
(
appointment
))
data
.
append
(
serialize_appointment
(
appointment
))
return
JsonResponse
({
return
JsonResponse
({
...
...
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