Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
whats-open
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
9
Issues
9
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
whats-open
Commits
e7fb748a
Commit
e7fb748a
authored
Mar 06, 2018
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed implementation of the assign_bulk_schedules method
parent
2ff7744e
Pipeline
#2166
canceled with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
whats-open/api/admin.py
whats-open/api/admin.py
+17
-1
No files found.
whats-open/api/admin.py
View file @
e7fb748a
...
...
@@ -10,10 +10,13 @@ https://docs.djangoproject.com/en/1.11/ref/contrib/admin/
# Django Imports
from
django.contrib
import
admin
from
django.contrib.gis.admin
import
OSMGeoAdmin
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.http
import
HttpResponseRedirect
from
django.shortcuts
import
render
# App Imports
from
.models
import
Facility
,
Schedule
,
OpenTime
,
Category
,
Location
,
Alert
@
admin
.
register
(
Facility
)
class
FacilityAdmin
(
admin
.
ModelAdmin
):
"""
...
...
@@ -28,11 +31,24 @@ class FacilityAdmin(admin.ModelAdmin):
self
.
message_user
(
request
,
"Successfully removed special schedules from %d facilities."
%
num
)
def
assign_bulk_schedules
(
self
,
request
,
queryset
):
num
=
queryset
.
count
()
if
'bulk_schedule'
in
request
.
POST
:
print
(
'request'
,
request
.
POST
)
try
:
new_schedule
=
Schedule
.
objects
.
get
(
pk
=
request
.
POST
[
'schedule'
])
name
=
new_schedule
.
name
for
facility
in
queryset
:
facility
.
main_schedule
=
new_schedule
facility
.
save
()
self
.
message_user
(
request
,
"Set %s as main schedule for %d facilities."
%
(
name
,
num
))
except
ObjectDoesNotExist
:
self
.
message_user
(
request
,
"Unable to set schedule for %d facilities."
%
num
)
return
HttpResponseRedirect
(
request
.
get_full_path
())
return
render
(
request
,
'bulk_schedules_intermediate.html'
,
context
=
{
'facilities'
:
queryset
,
'schedules'
:
Schedule
.
objects
.
all
()})
assign_bulk_schedules
.
short_description
=
'Assign a
schedule to
multiple facilities'
assign_bulk_schedules
.
short_description
=
'Assign a
main schedule for
multiple facilities'
# a list of all actions to be added
actions
=
[
drop_special_schedules
,
assign_bulk_schedules
,
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment