Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
7106a1e5
Kaydet (Commit)
7106a1e5
authored
Şub 24, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #819 from erikr/master
Fixed #16302 -- Ensured contrib.comments is IPv6 capable.
üst
deb4e097
ade992c6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
3 deletions
+57
-3
models.py
django/contrib/comments/models.py
+1
-1
1.6.txt
docs/releases/1.6.txt
+24
-0
comment_view_tests.py
...regressiontests/comment_tests/tests/comment_view_tests.py
+32
-2
No files found.
django/contrib/comments/models.py
Dosyayı görüntüle @
7106a1e5
...
@@ -60,7 +60,7 @@ class Comment(BaseCommentAbstractModel):
...
@@ -60,7 +60,7 @@ class Comment(BaseCommentAbstractModel):
# Metadata about the comment
# Metadata about the comment
submit_date
=
models
.
DateTimeField
(
_
(
'date/time submitted'
),
default
=
None
)
submit_date
=
models
.
DateTimeField
(
_
(
'date/time submitted'
),
default
=
None
)
ip_address
=
models
.
IPAddressField
(
_
(
'IP address'
)
,
blank
=
True
,
null
=
True
)
ip_address
=
models
.
GenericIPAddressField
(
_
(
'IP address'
),
unpack_ipv4
=
True
,
blank
=
True
,
null
=
True
)
is_public
=
models
.
BooleanField
(
_
(
'is public'
),
default
=
True
,
is_public
=
models
.
BooleanField
(
_
(
'is public'
),
default
=
True
,
help_text
=
_
(
'Uncheck this box to make the comment effectively '
\
help_text
=
_
(
'Uncheck this box to make the comment effectively '
\
'disappear from the site.'
))
'disappear from the site.'
))
...
...
docs/releases/1.6.txt
Dosyayı görüntüle @
7106a1e5
...
@@ -152,6 +152,30 @@ Backwards incompatible changes in 1.6
...
@@ -152,6 +152,30 @@ Backwards incompatible changes in 1.6
{{ title }}{# Translators: Extracted and associated with 'Welcome' below #}
{{ title }}{# Translators: Extracted and associated with 'Welcome' below #}
<h1>{% trans "Welcome" %}</h1>
<h1>{% trans "Welcome" %}</h1>
* The :doc:`comments </ref/contrib/comments/index>` app now uses a ``GenericIPAddressField``
for storing commenters' IP addresses, to support comments submitted from IPv6 addresses.
Until now, it stored them in an ``IPAddressField``, which is only meant to support IPv4.
When saving a comment made from an IPv6 address, the address would be silently truncated
on MySQL databases, and raise an exception on Oracle.
You will need to change the column type in your database to benefit from this change.
For MySQL, execute this query on your project's database:
.. code-block:: sql
ALTER TABLE django_comments MODIFY ip_address VARCHAR(39);
For Oracle, execute this query:
.. code-block:: sql
ALTER TABLE DJANGO_COMMENTS MODIFY (ip_address VARCHAR2(39));
If you do not apply this change, the behaviour is unchanged: on MySQL, IPv6 addresses
are silently truncated; on Oracle, an exception is generated. No database
change is needed for SQLite or PostgreSQL databases.
.. warning::
.. warning::
In addition to the changes outlined in this section, be sure to review the
In addition to the changes outlined in this section, be sure to review the
...
...
tests/regressiontests/comment_tests/tests/comment_view_tests.py
Dosyayı görüntüle @
7106a1e5
...
@@ -101,13 +101,43 @@ class CommentViewTests(CommentTestCase):
...
@@ -101,13 +101,43 @@ class CommentViewTests(CommentTestCase):
settings
.
DEBUG
=
olddebug
settings
.
DEBUG
=
olddebug
def
testCreateValidComment
(
self
):
def
testCreateValidComment
(
self
):
address
=
"1.2.3.4"
a
=
Article
.
objects
.
get
(
pk
=
1
)
a
=
Article
.
objects
.
get
(
pk
=
1
)
data
=
self
.
getValidData
(
a
)
data
=
self
.
getValidData
(
a
)
self
.
response
=
self
.
client
.
post
(
"/post/"
,
data
,
REMOTE_ADDR
=
"1.2.3.4"
)
self
.
response
=
self
.
client
.
post
(
"/post/"
,
data
,
REMOTE_ADDR
=
address
)
self
.
assertEqual
(
self
.
response
.
status_code
,
302
)
self
.
assertEqual
(
self
.
response
.
status_code
,
302
)
self
.
assertEqual
(
Comment
.
objects
.
count
(),
1
)
self
.
assertEqual
(
Comment
.
objects
.
count
(),
1
)
c
=
Comment
.
objects
.
all
()[
0
]
c
=
Comment
.
objects
.
all
()[
0
]
self
.
assertEqual
(
c
.
ip_address
,
"1.2.3.4"
)
self
.
assertEqual
(
c
.
ip_address
,
address
)
self
.
assertEqual
(
c
.
comment
,
"This is my comment"
)
def
testCreateValidCommentIPv6
(
self
):
"""
Test creating a valid comment with a long IPv6 address.
Note that this test should fail when Comment.ip_address is an IPAddress instead of a GenericIPAddress,
but does not do so on SQLite or PostgreSQL, because they use the TEXT and INET types, which already
allow storing an IPv6 address internally.
"""
address
=
"2a02::223:6cff:fe8a:2e8a"
a
=
Article
.
objects
.
get
(
pk
=
1
)
data
=
self
.
getValidData
(
a
)
self
.
response
=
self
.
client
.
post
(
"/post/"
,
data
,
REMOTE_ADDR
=
address
)
self
.
assertEqual
(
self
.
response
.
status_code
,
302
)
self
.
assertEqual
(
Comment
.
objects
.
count
(),
1
)
c
=
Comment
.
objects
.
all
()[
0
]
self
.
assertEqual
(
c
.
ip_address
,
address
)
self
.
assertEqual
(
c
.
comment
,
"This is my comment"
)
def
testCreateValidCommentIPv6Unpack
(
self
):
address
=
"::ffff:18.52.18.52"
a
=
Article
.
objects
.
get
(
pk
=
1
)
data
=
self
.
getValidData
(
a
)
self
.
response
=
self
.
client
.
post
(
"/post/"
,
data
,
REMOTE_ADDR
=
address
)
self
.
assertEqual
(
self
.
response
.
status_code
,
302
)
self
.
assertEqual
(
Comment
.
objects
.
count
(),
1
)
c
=
Comment
.
objects
.
all
()[
0
]
# We trim the '::ffff:' bit off because it is an IPv4 addr
self
.
assertEqual
(
c
.
ip_address
,
address
[
7
:])
self
.
assertEqual
(
c
.
comment
,
"This is my comment"
)
self
.
assertEqual
(
c
.
comment
,
"This is my comment"
)
def
testPostAsAuthenticatedUser
(
self
):
def
testPostAsAuthenticatedUser
(
self
):
...
...
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