Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
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
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
IGWN Computing and Software
GraceDB
GraceDB Server
Commits
e9572e23
Commit
e9572e23
authored
12 years ago
by
Branson Stephens
Browse files
Options
Downloads
Patches
Plain Diff
fixed slot duplication. template filter now returns list of slot dicts.'
parent
a1663303
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gracedb/api.py
+11
-4
11 additions, 4 deletions
gracedb/api.py
gracedb/templatetags/slot.py
+8
-5
8 additions, 5 deletions
gracedb/templatetags/slot.py
with
19 additions
and
9 deletions
gracedb/api.py
+
11
−
4
View file @
e9572e23
...
@@ -854,10 +854,17 @@ class EventSlot(APIView):
...
@@ -854,10 +854,17 @@ class EventSlot(APIView):
if
not
os
.
path
.
exists
(
filePath
):
if
not
os
.
path
.
exists
(
filePath
):
return
Response
(
"
No slot created because file does not exist
"
,
return
Response
(
"
No slot created because file does not exist
"
,
status
=
status
.
HTTP_404_NOT_FOUND
)
status
=
status
.
HTTP_404_NOT_FOUND
)
# Create the slot.
# Check for existence of the slot. If it exists, simply update the
slot
=
Slot
(
event
=
event
,
name
=
slotname
,
value
=
filename
)
# existing slot.
slot
.
save
()
try
:
return
Response
(
"
Slot created.
"
,
status
=
status
.
HTTP_201_CREATED
)
slot
=
Slot
.
objects
.
filter
(
event
=
event
).
filter
(
name
=
slotname
)[
0
]
slot
.
value
=
filename
slot
.
save
()
except
:
# Create the slot.
slot
=
Slot
(
event
=
event
,
name
=
slotname
,
value
=
filename
)
slot
.
save
()
return
Response
(
"
Slot created or updated.
"
,
status
=
status
.
HTTP_201_CREATED
)
# Delete a slot.
# Delete a slot.
def
delete
(
self
,
request
,
graceid
,
slotname
):
def
delete
(
self
,
request
,
graceid
,
slotname
):
...
...
This diff is collapsed.
Click to expand it.
gracedb/templatetags/slot.py
+
8
−
5
View file @
e9572e23
...
@@ -6,13 +6,16 @@ from ..models import Slot, EventLog
...
@@ -6,13 +6,16 @@ from ..models import Slot, EventLog
register
=
template
.
Library
()
register
=
template
.
Library
()
@register.filter
(
"
slot
"
)
@register.filter
(
"
slot
"
)
def
slot
(
event
,
slotname
):
def
slot
(
event
,
pattern
):
if
event
is
None
:
if
event
is
None
:
return
mark_safe
(
""
)
return
None
try
:
try
:
slot
=
Slot
.
objects
.
filter
(
event
=
event
).
filter
(
name
=
slotname
)[
0
]
# This returns a list of dictionary objects, like
out
=
slot
.
value
# [{'event': event, 'name': 'skymap', 'value':'skymap.png'}, ... ]
# XXX doesn't the template need the full path?
return
Slot
.
objects
.
filter
(
event
=
event
).
filter
(
name__regex
=
pattern
).
values
()
except
:
except
:
# Either there is no such slot or something went wrong.
# In either case, we want the template to just ignore it.
return
None
return
None
return
mark_safe
(
out
)
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