Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-notes-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-notes-api
Commits
26854cd7
Commit
26854cd7
authored
Nov 24, 2014
by
Oleg Marshev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use own convert str.
parent
a8aaab76
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
notesapi/v1/views.py
+10
-5
No files found.
notesapi/v1/views.py
View file @
26854cd7
...
@@ -10,7 +10,6 @@ from rest_framework.views import APIView
...
@@ -10,7 +10,6 @@ from rest_framework.views import APIView
from
rest_framework.decorators
import
api_view
,
permission_classes
from
rest_framework.decorators
import
api_view
,
permission_classes
from
annotator.annotation
import
Annotation
from
annotator.annotation
import
Annotation
from
annotator.atoi
import
atoi
CREATE_FILTER_FIELDS
=
(
'updated'
,
'created'
,
'consumer'
,
'id'
)
CREATE_FILTER_FIELDS
=
(
'updated'
,
'created'
,
'consumer'
,
'id'
)
UPDATE_FILTER_FIELDS
=
(
'updated'
,
'created'
,
'user'
,
'consumer'
)
UPDATE_FILTER_FIELDS
=
(
'updated'
,
'created'
,
'user'
,
'consumer'
)
...
@@ -31,9 +30,9 @@ class AnnotationSearchView(APIView):
...
@@ -31,9 +30,9 @@ class AnnotationSearchView(APIView):
params
=
request
.
QUERY_PARAMS
.
dict
()
params
=
request
.
QUERY_PARAMS
.
dict
()
if
'offset'
in
params
:
if
'offset'
in
params
:
kwargs
[
'offset'
]
=
atoi
(
params
.
pop
(
'offset'
),
default
=
None
)
kwargs
[
'offset'
]
=
_convert_str
(
params
.
pop
(
'offset'
)
)
if
'limit'
in
params
:
if
'limit'
in
params
:
kwargs
[
'limit'
]
=
atoi
(
params
.
pop
(
'limit'
),
default
=
None
)
kwargs
[
'limit'
]
=
_convert_str
(
params
.
pop
(
'limit'
)
)
# All remaining parameters are considered searched fields.
# All remaining parameters are considered searched fields.
kwargs
[
'query'
]
=
params
kwargs
[
'query'
]
=
params
...
@@ -135,13 +134,19 @@ class AnnotationDetailView(APIView):
...
@@ -135,13 +134,19 @@ class AnnotationDetailView(APIView):
def
_filter_input
(
annotation
,
fields
):
def
_filter_input
(
annotation
,
fields
):
"""
Pop given fields from annotation.
"""
for
field
in
fields
:
for
field
in
fields
:
annotation
.
pop
(
field
,
None
)
annotation
.
pop
(
field
,
None
)
return
annotation
return
annotation
def
_convert_str
(
value
,
default
=
0
):
def
_convert_str
(
value
,
default
=
None
):
"""
Convert given value to string.
"""
try
:
try
:
return
int
(
v
or
default
)
return
int
(
v
alue
or
default
)
except
ValueError
:
except
ValueError
:
return
default
return
default
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