Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
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
django-rest-framework
Commits
4dd71d68
Commit
4dd71d68
authored
Jan 08, 2017
by
Artem Muterko
Committed by
Tom Christie
Jan 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove extra parentheses (#4789)
parent
44a99a11
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
9 deletions
+9
-9
rest_framework/fields.py
+1
-1
rest_framework/pagination.py
+1
-1
rest_framework/relations.py
+1
-1
rest_framework/renderers.py
+4
-4
rest_framework/request.py
+1
-1
rest_framework/versioning.py
+1
-1
No files found.
rest_framework/fields.py
View file @
4dd71d68
...
...
@@ -149,7 +149,7 @@ def to_choices_dict(choices):
# choices = [('Category', ((1, 'First'), (2, 'Second'))), (3, 'Third')]
ret
=
OrderedDict
()
for
choice
in
choices
:
if
(
not
isinstance
(
choice
,
(
list
,
tuple
)
)):
if
not
isinstance
(
choice
,
(
list
,
tuple
)):
# single choice
ret
[
choice
]
=
choice
else
:
...
...
rest_framework/pagination.py
View file @
4dd71d68
...
...
@@ -131,7 +131,7 @@ def _reverse_ordering(ordering_tuple):
ordering and return a new tuple, eg. `('created', '-uuid')`.
"""
def
invert
(
x
):
return
x
[
1
:]
if
(
x
.
startswith
(
'-'
)
)
else
'-'
+
x
return
x
[
1
:]
if
x
.
startswith
(
'-'
)
else
'-'
+
x
return
tuple
([
invert
(
item
)
for
item
in
ordering_tuple
])
...
...
rest_framework/relations.py
View file @
4dd71d68
...
...
@@ -503,7 +503,7 @@ class ManyRelatedField(Field):
return
[]
relationship
=
get_attribute
(
instance
,
self
.
source_attrs
)
return
relationship
.
all
()
if
(
hasattr
(
relationship
,
'all'
)
)
else
relationship
return
relationship
.
all
()
if
hasattr
(
relationship
,
'all'
)
else
relationship
def
to_representation
(
self
,
iterable
):
return
[
...
...
rest_framework/renderers.py
View file @
4dd71d68
...
...
@@ -540,7 +540,7 @@ class BrowsableAPIRenderer(BaseRenderer):
# If possible, serialize the initial content for the generic form
default_parser
=
view
.
parser_classes
[
0
]
renderer_class
=
getattr
(
default_parser
,
'renderer_class'
,
None
)
if
(
hasattr
(
view
,
'get_serializer'
)
and
renderer_class
)
:
if
hasattr
(
view
,
'get_serializer'
)
and
renderer_class
:
# View has a serializer defined and parser class has a
# corresponding renderer that can be used to render the data.
...
...
@@ -598,7 +598,7 @@ class BrowsableAPIRenderer(BaseRenderer):
paginator
=
getattr
(
view
,
'paginator'
,
None
)
if
isinstance
(
data
,
list
):
pass
elif
(
paginator
is
not
None
and
data
is
not
None
)
:
elif
paginator
is
not
None
and
data
is
not
None
:
try
:
paginator
.
get_results
(
data
)
except
(
TypeError
,
KeyError
):
...
...
@@ -738,7 +738,7 @@ class AdminRenderer(BrowsableAPIRenderer):
ret
=
template_render
(
template
,
context
,
request
=
renderer_context
[
'request'
])
# Creation and deletion should use redirects in the admin style.
if
(
response
.
status_code
==
status
.
HTTP_201_CREATED
)
and
(
'Location'
in
response
)
:
if
response
.
status_code
==
status
.
HTTP_201_CREATED
and
'Location'
in
response
:
response
.
status_code
=
status
.
HTTP_303_SEE_OTHER
response
[
'Location'
]
=
request
.
build_absolute_uri
()
ret
=
''
...
...
@@ -764,7 +764,7 @@ class AdminRenderer(BrowsableAPIRenderer):
)
paginator
=
getattr
(
context
[
'view'
],
'paginator'
,
None
)
if
(
paginator
is
not
None
and
data
is
not
None
)
:
if
paginator
is
not
None
and
data
is
not
None
:
try
:
results
=
paginator
.
get_results
(
data
)
except
(
TypeError
,
KeyError
):
...
...
rest_framework/request.py
View file @
4dd71d68
...
...
@@ -152,7 +152,7 @@ class Request(object):
force_user
=
getattr
(
request
,
'_force_auth_user'
,
None
)
force_token
=
getattr
(
request
,
'_force_auth_token'
,
None
)
if
(
force_user
is
not
None
or
force_token
is
not
None
)
:
if
force_user
is
not
None
or
force_token
is
not
None
:
forced_auth
=
ForcedAuthentication
(
force_user
,
force_token
)
self
.
authenticators
=
(
forced_auth
,)
...
...
rest_framework/versioning.py
View file @
4dd71d68
...
...
@@ -117,7 +117,7 @@ class NamespaceVersioning(BaseVersioning):
def
determine_version
(
self
,
request
,
*
args
,
**
kwargs
):
resolver_match
=
getattr
(
request
,
'resolver_match'
,
None
)
if
(
resolver_match
is
None
or
not
resolver_match
.
namespace
)
:
if
resolver_match
is
None
or
not
resolver_match
.
namespace
:
return
self
.
default_version
# Allow for possibly nested namespaces.
...
...
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