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
07ffe781
Kaydet (Commit)
07ffe781
authored
Eyl 28, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Used get_current_site in comments feed class
üst
b8244c65
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
12 deletions
+31
-12
feeds.py
django/contrib/comments/feeds.py
+9
-12
feed_tests.py
tests/regressiontests/comment_tests/tests/feed_tests.py
+21
-0
urls.py
tests/regressiontests/comment_tests/urls.py
+1
-0
No files found.
django/contrib/comments/feeds.py
Dosyayı görüntüle @
07ffe781
from
django.conf
import
settings
from
django.contrib.syndication.views
import
Feed
from
django.contrib.sites.models
import
S
ite
from
django.contrib.sites.models
import
get_current_s
ite
from
django.contrib
import
comments
from
django.utils.translation
import
ugettext
as
_
class
LatestCommentFeed
(
Feed
):
"""Feed of latest comments on the current site."""
def
__call__
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
site
=
get_current_site
(
request
)
return
super
(
LatestCommentFeed
,
self
)
.
__call__
(
request
,
*
args
,
**
kwargs
)
def
title
(
self
):
if
not
hasattr
(
self
,
'_site'
):
self
.
_site
=
Site
.
objects
.
get_current
()
return
_
(
"
%(site_name)
s comments"
)
%
dict
(
site_name
=
self
.
_site
.
name
)
return
_
(
"
%(site_name)
s comments"
)
%
dict
(
site_name
=
self
.
site
.
name
)
def
link
(
self
):
if
not
hasattr
(
self
,
'_site'
):
self
.
_site
=
Site
.
objects
.
get_current
()
return
"http://
%
s/"
%
(
self
.
_site
.
domain
)
return
"http://
%
s/"
%
(
self
.
site
.
domain
)
def
description
(
self
):
if
not
hasattr
(
self
,
'_site'
):
self
.
_site
=
Site
.
objects
.
get_current
()
return
_
(
"Latest comments on
%(site_name)
s"
)
%
dict
(
site_name
=
self
.
_site
.
name
)
return
_
(
"Latest comments on
%(site_name)
s"
)
%
dict
(
site_name
=
self
.
site
.
name
)
def
items
(
self
):
qs
=
comments
.
get_model
()
.
objects
.
filter
(
site__pk
=
se
ttings
.
SITE_ID
,
site__pk
=
se
lf
.
site
.
pk
,
is_public
=
True
,
is_removed
=
False
,
)
...
...
tests/regressiontests/comment_tests/tests/feed_tests.py
Dosyayı görüntüle @
07ffe781
from
__future__
import
absolute_import
from
django.conf
import
settings
from
django.contrib.comments.models
import
Comment
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.sites.models
import
Site
from
.
import
CommentTestCase
from
..models
import
Article
class
CommentFeedTests
(
CommentTestCase
):
urls
=
'regressiontests.comment_tests.urls'
feed_url
=
'/rss/comments/'
def
setUp
(
self
):
site_2
=
Site
.
objects
.
create
(
id
=
settings
.
SITE_ID
+
1
,
domain
=
"example2.com"
,
name
=
"example2.com"
)
# A comment for another site
c5
=
Comment
.
objects
.
create
(
content_type
=
ContentType
.
objects
.
get_for_model
(
Article
),
object_pk
=
"1"
,
user_name
=
"Joe Somebody"
,
user_email
=
"jsomebody@example.com"
,
user_url
=
"http://example.com/~joe/"
,
comment
=
"A comment for the second site."
,
site
=
site_2
,
)
def
test_feed
(
self
):
response
=
self
.
client
.
get
(
self
.
feed_url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
@@ -15,3 +35,4 @@ class CommentFeedTests(CommentTestCase):
self
.
assertContains
(
response
,
'<title>example.com comments</title>'
)
self
.
assertContains
(
response
,
'<link>http://example.com/</link>'
)
self
.
assertContains
(
response
,
'</rss>'
)
self
.
assertNotContains
(
response
,
"A comment for the second site."
)
tests/regressiontests/comment_tests/urls.py
Dosyayı görüntüle @
07ffe781
...
...
@@ -15,6 +15,7 @@ urlpatterns = patterns('',
url
(
r'^flag/(\d+)/$'
,
views
.
custom_flag_comment
),
url
(
r'^delete/(\d+)/$'
,
views
.
custom_delete_comment
),
url
(
r'^approve/(\d+)/$'
,
views
.
custom_approve_comment
),
url
(
r'^cr/(\d+)/(.+)/$'
,
'django.contrib.contenttypes.views.shortcut'
,
name
=
'comments-url-redirect'
),
)
urlpatterns
+=
patterns
(
''
,
...
...
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