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
e1768bdc
Commit
e1768bdc
authored
Aug 08, 2016
by
Dmitry Dygalo
Committed by
Tom Christie
Aug 08, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed various typos (#4366)
parent
febaa4db
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
33 additions
and
33 deletions
+33
-33
rest_framework/compat.py
+1
-1
rest_framework/fields.py
+3
-3
rest_framework/negotiation.py
+1
-1
rest_framework/pagination.py
+8
-8
rest_framework/serializers.py
+2
-2
rest_framework/templatetags/rest_framework.py
+1
-1
rest_framework/utils/field_mapping.py
+1
-1
rest_framework/utils/html.py
+1
-1
rest_framework/versioning.py
+2
-2
rest_framework/viewsets.py
+1
-1
tests/test_authentication.py
+1
-1
tests/test_fields.py
+2
-2
tests/test_filters.py
+3
-3
tests/test_model_serializer.py
+1
-1
tests/test_pagination.py
+3
-3
tests/test_templatetags.py
+1
-1
tests/test_testing.py
+1
-1
No files found.
rest_framework/compat.py
View file @
e1768bdc
...
...
@@ -168,7 +168,7 @@ except ImportError:
crispy_forms
=
None
# coreapi is optional (Note that uritemplate is a depend
a
ncy of coreapi)
# coreapi is optional (Note that uritemplate is a depend
e
ncy of coreapi)
try
:
import
coreapi
import
uritemplate
...
...
rest_framework/fields.py
View file @
e1768bdc
...
...
@@ -395,8 +395,8 @@ class Field(object):
# determine if we should use null instead.
return
''
if
getattr
(
self
,
'allow_blank'
,
False
)
else
None
elif
ret
==
''
and
not
self
.
required
:
# If the field is blank, and empt
y
ness is valid then
# determine if we should use empt
y
ness instead.
# If the field is blank, and empt
i
ness is valid then
# determine if we should use empt
i
ness instead.
return
''
if
getattr
(
self
,
'allow_blank'
,
False
)
else
empty
return
ret
return
dictionary
.
get
(
self
.
field_name
,
empty
)
...
...
@@ -1346,7 +1346,7 @@ class FilePathField(ChoiceField):
def
__init__
(
self
,
path
,
match
=
None
,
recursive
=
False
,
allow_files
=
True
,
allow_folders
=
False
,
required
=
None
,
**
kwargs
):
# Defer to Django's FilePathField implmentation to get the
# Defer to Django's FilePathField impl
e
mentation to get the
# valid set of choices.
field
=
DjangoFilePathField
(
path
,
match
=
match
,
recursive
=
recursive
,
allow_files
=
allow_files
,
...
...
rest_framework/negotiation.py
View file @
e1768bdc
...
...
@@ -90,7 +90,7 @@ class DefaultContentNegotiation(BaseContentNegotiation):
def
get_accept_list
(
self
,
request
):
"""
Given the incoming request, return a tokeni
s
ed list of media
Given the incoming request, return a tokeni
z
ed list of media
type strings.
"""
header
=
request
.
META
.
get
(
'HTTP_ACCEPT'
,
'*/*'
)
...
...
rest_framework/pagination.py
View file @
e1768bdc
...
...
@@ -64,10 +64,10 @@ def _get_displayed_page_numbers(current, final):
This implementation gives one page to each side of the cursor,
or two pages to the side when the cursor is at the edge, then
ensures that any breaks between non-continous page numbers never
ensures that any breaks between non-contin
u
ous page numbers never
remove only a single page.
For an al
ernativ
ative implementation which gives two pages to each side of
For an al
tern
ative implementation which gives two pages to each side of
the cursor, eg. as in GitHub issue list pagination, see:
https://gist.github.com/tomchristie/321140cebb1c4a558b15
...
...
@@ -476,10 +476,10 @@ class CursorPagination(BasePagination):
# Determine the position of the final item following the page.
if
len
(
results
)
>
len
(
self
.
page
):
has_following_postion
=
True
has_following_pos
i
tion
=
True
following_position
=
self
.
_get_position_from_instance
(
results
[
-
1
],
self
.
ordering
)
else
:
has_following_postion
=
False
has_following_pos
i
tion
=
False
following_position
=
None
# If we have a reverse queryset, then the query ordering was in reverse
...
...
@@ -490,14 +490,14 @@ class CursorPagination(BasePagination):
if
reverse
:
# Determine next and previous positions for reverse cursors.
self
.
has_next
=
(
current_position
is
not
None
)
or
(
offset
>
0
)
self
.
has_previous
=
has_following_postion
self
.
has_previous
=
has_following_pos
i
tion
if
self
.
has_next
:
self
.
next_position
=
current_position
if
self
.
has_previous
:
self
.
previous_position
=
following_position
else
:
# Determine next and previous positions for forward cursors.
self
.
has_next
=
has_following_postion
self
.
has_next
=
has_following_pos
i
tion
self
.
has_previous
=
(
current_position
is
not
None
)
or
(
offset
>
0
)
if
self
.
has_next
:
self
.
next_position
=
following_position
...
...
@@ -534,7 +534,7 @@ class CursorPagination(BasePagination):
# our marker.
break
# The item in this postion has the same position as the item
# The item in this pos
i
tion has the same position as the item
# following it, we can't use it as a marker position, so increment
# the offset and keep seeking to the previous item.
compare
=
position
...
...
@@ -582,7 +582,7 @@ class CursorPagination(BasePagination):
# our marker.
break
# The item in this postion has the same position as the item
# The item in this pos
i
tion has the same position as the item
# following it, we can't use it as a marker position, so increment
# the offset and keep seeking to the previous item.
compare
=
position
...
...
rest_framework/serializers.py
View file @
e1768bdc
...
...
@@ -1383,7 +1383,7 @@ class ModelSerializer(Serializer):
def
get_unique_together_validators
(
self
):
"""
Determine a default set of validators for any unique_together contraints.
Determine a default set of validators for any unique_together con
s
traints.
"""
model_class_inheritance_tree
=
(
[
self
.
Meta
.
model
]
+
...
...
@@ -1414,7 +1414,7 @@ class ModelSerializer(Serializer):
def
get_unique_for_date_validators
(
self
):
"""
Determine a default set of validators for the following contraints:
Determine a default set of validators for the following con
s
traints:
* unique_for_date
* unique_for_month
...
...
rest_framework/templatetags/rest_framework.py
View file @
e1768bdc
...
...
@@ -189,7 +189,7 @@ def urlize_quoted_links(text, trim_url_limit=None, nofollow=True, autoescape=Tru
leading punctuation (opening parens) and it'll still do the right thing.
If trim_url_limit is not None, the URLs in link text longer than this limit
will truncated to trim_url_limit-3 characters and appended with an elipsis.
will truncated to trim_url_limit-3 characters and appended with an el
l
ipsis.
If nofollow is True, the URLs in link text will get a rel="nofollow"
attribute.
...
...
rest_framework/utils/field_mapping.py
View file @
e1768bdc
"""
Helper functions for mapping model fields to a dictionary of default
keyword arguments that should be used for their equiv
e
lent serializer fields.
keyword arguments that should be used for their equiv
a
lent serializer fields.
"""
import
inspect
...
...
rest_framework/utils/html.py
View file @
e1768bdc
...
...
@@ -14,7 +14,7 @@ def is_html_input(dictionary):
def
parse_html_list
(
dictionary
,
prefix
=
''
):
"""
Used to suport list values in HTML forms.
Used to sup
p
ort list values in HTML forms.
Supports lists of primitives and/or dictionaries.
* List of primitives.
...
...
rest_framework/versioning.py
View file @
e1768bdc
...
...
@@ -94,7 +94,7 @@ class NamespaceVersioning(BaseVersioning):
The difference is in the backend - this implementation uses
Django's URL namespaces to determine the version.
An example URL conf that is namespaced into two sep
e
rate versions
An example URL conf that is namespaced into two sep
a
rate versions
# users/urls.py
urlpatterns = [
...
...
@@ -147,7 +147,7 @@ class HostNameVersioning(BaseVersioning):
invalid_version_message
=
_
(
'Invalid version in hostname.'
)
def
determine_version
(
self
,
request
,
*
args
,
**
kwargs
):
hostname
,
sep
e
rator
,
port
=
request
.
get_host
()
.
partition
(
':'
)
hostname
,
sep
a
rator
,
port
=
request
.
get_host
()
.
partition
(
':'
)
match
=
self
.
hostname_regex
.
match
(
hostname
)
if
not
match
:
return
self
.
default_version
...
...
rest_framework/viewsets.py
View file @
e1768bdc
...
...
@@ -112,7 +112,7 @@ class ViewSetMixin(object):
if
method
==
'options'
:
# This is a special case as we always provide handling for the
# options method in the base `View` class.
# Unlike the other explicitly defined actions, 'metadata' is implict.
# Unlike the other explicitly defined actions, 'metadata' is implic
i
t.
self
.
action
=
'metadata'
else
:
self
.
action
=
self
.
action_map
.
get
(
method
)
...
...
tests/test_authentication.py
View file @
e1768bdc
...
...
@@ -440,7 +440,7 @@ class FailingAuthAccessedInRenderer(TestCase):
class
NoAuthenticationClassesTests
(
TestCase
):
def
test_permission_message_with_no_authentication_classes
(
self
):
"""
An unauthenticated request made against a view that contain
e
s no
An unauthenticated request made against a view that contains no
`authentication_classes` but do contain `permissions_classes` the error
code returned should be 403 with the exception's message.
"""
...
...
tests/test_fields.py
View file @
e1768bdc
...
...
@@ -974,7 +974,7 @@ class TestDateField(FieldValues):
class
TestCustomInputFormatDateField
(
FieldValues
):
"""
Valid and invalid values for `DateField` with a cutom input format.
Valid and invalid values for `DateField` with a cu
s
tom input format.
"""
valid_inputs
=
{
'1 Jan 2001'
:
datetime
.
date
(
2001
,
1
,
1
),
...
...
@@ -1041,7 +1041,7 @@ class TestDateTimeField(FieldValues):
class
TestCustomInputFormatDateTimeField
(
FieldValues
):
"""
Valid and invalid values for `DateTimeField` with a cutom input format.
Valid and invalid values for `DateTimeField` with a cu
s
tom input format.
"""
valid_inputs
=
{
'1:35pm, 1 Jan 2001'
:
datetime
.
datetime
(
2001
,
1
,
1
,
13
,
35
,
tzinfo
=
timezone
.
UTC
()),
...
...
tests/test_filters.py
View file @
e1768bdc
...
...
@@ -711,7 +711,7 @@ class OrderingFilterTests(TestCase):
serializer_class
=
OrderingFilterSerializer
filter_backends
=
(
filters
.
OrderingFilter
,)
ordering
=
(
'title'
,)
or
e
dering_fields
=
(
'text'
,)
ordering_fields
=
(
'text'
,)
view
=
OrderingListView
.
as_view
()
request
=
factory
.
get
(
''
)
...
...
@@ -819,7 +819,7 @@ class OrderingFilterTests(TestCase):
queryset
=
OrderingFilterModel
.
objects
.
all
()
filter_backends
=
(
filters
.
OrderingFilter
,)
ordering
=
(
'title'
,)
# note: no ordering_fields and serializer_class spe
fic
ied
# note: no ordering_fields and serializer_class spe
cif
ied
def
get_serializer_class
(
self
):
return
OrderingFilterSerializer
...
...
@@ -842,7 +842,7 @@ class OrderingFilterTests(TestCase):
filter_backends
=
(
filters
.
OrderingFilter
,)
ordering
=
(
'title'
,)
# note: no ordering_fields and serializer_class
# or get_serializer_class spe
fic
ied
# or get_serializer_class spe
cif
ied
view
=
OrderingListView
.
as_view
()
request
=
factory
.
get
(
'/'
,
{
'ordering'
:
'text'
})
...
...
tests/test_model_serializer.py
View file @
e1768bdc
...
...
@@ -136,7 +136,7 @@ class TestModelSerializer(TestCase):
class
TestRegularFieldMappings
(
TestCase
):
def
test_regular_fields
(
self
):
"""
Model fields should map to their equiv
e
lent serializer fields.
Model fields should map to their equiv
a
lent serializer fields.
"""
class
TestSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
...
...
tests/test_pagination.py
View file @
e1768bdc
...
...
@@ -67,8 +67,8 @@ class TestPaginationIntegration:
def
test_setting_page_size_over_maximum
(
self
):
"""
When page_size parameter exceeds maxi
u
mum allowable,
then it should be capped to the maxi
u
mum.
When page_size parameter exceeds maximum allowable,
then it should be capped to the maximum.
"""
request
=
factory
.
get
(
'/'
,
{
'page_size'
:
1000
})
response
=
self
.
view
(
request
)
...
...
@@ -259,7 +259,7 @@ class TestPageNumberPaginationOverride:
def
setup
(
self
):
class
OverriddenDjangoPaginator
(
DjangoPaginator
):
# override the count in our overriden Django Paginator
# override the count in our overrid
d
en Django Paginator
# we will only return one page, with one item
count
=
1
...
...
tests/test_templatetags.py
View file @
e1768bdc
...
...
@@ -13,7 +13,7 @@ factory = APIRequestFactory()
class
TemplateTagTests
(
TestCase
):
def
test_add_query_param_with_non_latin_charact
o
r
(
self
):
def
test_add_query_param_with_non_latin_charact
e
r
(
self
):
# Ensure we don't double-escape non-latin characters
# that are present in the querystring.
# See #1314.
...
...
tests/test_testing.py
View file @
e1768bdc
...
...
@@ -78,7 +78,7 @@ class TestAPITestClient(TestCase):
response
=
self
.
client
.
get
(
'/session-view/'
)
self
.
assertEqual
(
response
.
data
[
'active_session'
],
False
)
# Subsequ
a
nt requests have an active session
# Subsequ
e
nt requests have an active session
response
=
self
.
client
.
get
(
'/session-view/'
)
self
.
assertEqual
(
response
.
data
[
'active_session'
],
True
)
...
...
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