Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
Respect My Net
Commits
4918dc4a
Commit
4918dc4a
authored
May 01, 2011
by
stef
Browse files
[enh] better commenting function, admin and comment moderation
parent
54357924
Changes
6
Hide whitespace changes
Inline
Side-by-side
bt/models.py
View file @
4918dc4a
from
django.db
import
models
from
django.utils.translation
import
ugettext
as
_
from
django.contrib.comments.moderation
import
CommentModerator
,
moderator
COUNTRIES
=
(
(
'BE'
,
_
(
'Belgium'
)),
...
...
@@ -71,3 +72,12 @@ class Comment(models.Model):
class
Attachment
(
models
.
Model
):
storage
=
models
.
FileField
(
upload_to
=
'static'
)
comment
=
models
.
ForeignKey
(
Comment
)
class
ViolationModerator
(
CommentModerator
):
email_notification
=
True
moderate_after
=
0
def
moderate
(
self
,
comment
,
content_object
,
request
):
return
True
if
Violation
not
in
moderator
.
_registry
:
moderator
.
register
(
Violation
,
ViolationModerator
)
media/css/style.css
View file @
4918dc4a
...
...
@@ -9,16 +9,17 @@ li { list-style: none; }
.fieldWrapper
label
{
width
:
200px
;
display
:
inline-block
;
}
.help_text
{
font-size
:
0.7em
;
left
:
30px
;
width
:
20%
;
position
:
absolute
;
}
.attachments
{
float
:
right
;
margin-top
:
0.4em
;
display
:
block
;
clear
:
both
;
}
.
commen
t-node
{
margin
:
1em
;
padding-bottom
:
0.4em
;
border-bottom
:
1px
solid
black
;
width
:
500px
;}
.
commen
t
{
margin
:
1em
;
}
.
repor
t-node
{
margin
:
1em
;
padding-bottom
:
0.4em
;
border-bottom
:
1px
solid
black
;
width
:
500px
;}
.
repor
t
{
margin
:
1em
;
}
.atttachsg
{
margin
:
1em
;
}
#addForm
{
margin
:
auto
;
width
:
50%
;
padding
4em;
}
#add_attach
{
cursor
:
pointer
;
}
#show_optionals
{
text-decoration
:
underline
;
color
:
blue
;
cursor
:
pointer
;
clear
:
both
;
}
#optional
{
clear
:
both
;
}
#report
dt
{
display
:
inline-block
;
width
:
14em
;
}
#report
dd
{
display
:
inline
;
}
#auth
{
float
:
right
;
clear
:
both
;
}
table
.listing
,
.pagination
{
width
:
90%
;
margin
:
auto
;
}
table
.listing
thead
td
{
font-weight
:
bold
;
border-bottom
:
1px
solid
black
;
}
dt
{
display
:
inline-block
;
width
:
14em
;
}
dd
{
display
:
inline
;
}
settings.py
View file @
4918dc4a
...
...
@@ -11,7 +11,7 @@ MEDIA_PATH = BASE_PATH+'/media'
ROOT_URL
=
''
ADMINS
=
(
#
('stef', 'stef@ctrlc.hu'),
(
'stef'
,
'stef@ctrlc.hu'
),
)
MANAGERS
=
ADMINS
...
...
@@ -128,13 +128,14 @@ INSTALLED_APPS = (
'django.contrib.sites'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'django.contrib.comments'
,
'tinymce'
,
'registration'
,
'bt'
,
'babeldjango'
,
'captcha'
,
# Uncomment the next line to enable the admin:
#
'django.contrib.admin',
'django.contrib.admin'
,
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
...
...
templates/comments/comment_notification_email.txt
0 → 100644
View file @
4918dc4a
{%load bt%}
A comment has been posted on {{ content_object }}.
The comment reads as follows:
{{ comment }}
Approve: {%root_url%}/comments/approve/{{ comment.id }}/
Delete: {%root_url%}/comments/delete/{{ comment.id }}/
templates/view.html
View file @
4918dc4a
...
...
@@ -2,16 +2,46 @@
{% load bt %}
{% load i18n %}
{% load babel %}
{% load comments %}
{% block styles %}
{% endblock %}
{% block scripts %}
<script
type=
"text/javascript"
src=
"{%media_url%}/js/jquery.1.4.2.min.js"
></script>
<script
type=
"text/javascript"
charset=
"utf-8"
>
function
bindPostCommentHandler
()
{
$
(
'
#comment_form form input.submit-preview
'
).
remove
();
$
(
'
#comment_form form
'
).
submit
(
function
()
{
var
postdata
=
$
(
'
#comment_form form
'
).
serialize
()
+
'
&csrftoken={{csrf_token}}
'
;
$
.
ajax
({
type
:
"
POST
"
,
data
:
postdata
,
url
:
"
{% comment_form_target %}
"
,
cache
:
false
,
dataType
:
"
html
"
,
success
:
function
(
html
,
textStatus
)
{
$
(
'
#comment_form form
'
).
replaceWith
(
html
);
bindPostCommentHandler
();
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
)
{
$
(
'
#comment_form form
'
).
replaceWith
(
'
Your comment was unable to be posted at this time. We apologise for the inconvenience.
'
);
}
});
return
false
;
});
}
$
(
document
).
ready
(
function
()
{
bindPostCommentHandler
();
});
</script>
{% endblock %}
{%block content%}
<ul>
<ul
id=
"report"
>
<li><dl><dt>
Operator
</dt><dd>
{{v.operator}} ({{v.country}})
</dd></dl></li>
<li><dl><dt>
Contract
</dt><dd>
{{v.contract}}
</dd></dl></li>
{%if v.resource%}
<li><dl><dt>
Resource
</dt><dd>
{{v.resource}}
</dd></dl></li>
{%endif%}
{%if v.resource_name%}
<li><dl><dt>
Resource name
</dt><dd>
{{v.resource_name}}
</dd></dl></li>
{%endif%}
{%if v.type%}
<li><dl><dt>
Type
</dt><dd>
{{v.type}}
</dd></dl></li>
{%endif%}
{%if v.media%}
<li><dl><dt>
Media
</dt><dd>
{{v.media}}
</dd></dl></li>
{%endif%}
{%if v.temporary%}
<li><dl><dt>
Temporary restriction
</dt><dd>
{{v.temporary}}
</dd></dl></li>
{%endif%}
...
...
@@ -19,12 +49,12 @@
{%if v.contract_excerpt%}
<li><dl><dt>
Contract excerpt
</dt><dd>
{{v.contract_excerpt|safe}}
</dd></dl></li>
{%endif%}
{%if v.loophole%}
<li><dl><dt>
Loophole offering
</dt><dd>
{{v.loophole}}
</dd></dl></li>
{%endif%}
{%if v.comment_set.all%}
<
div
id=
"
comments
"
>
Comments
<
li
id=
"
description
"
>
<h3>
{%trans "Description" %}
</h3>
{%for c in v.comment_set.all%}
<div
class=
"
comment
-node"
>
<span
class=
"
commen
ter"
>
{%if c.submitter_n
ick
%}{{c.submitter_n
ick
}}{%else%}{{c.submitter_email}}{%endif%}
</span>
-
<span
class=
"comment_date"
>
{{c.timestamp|datetimefmt:"short" }}
</span>
<div
class=
"
comment
"
>
{{c.comment|safe}}
</div>
<div
class=
"
description
-node"
>
<span
class=
"
submit
ter"
>
{%if c.submitter_n
ame
%}{{c.submitter_n
ame
}}{%else%}{{c.submitter_email}}{%endif%}
</span>
-
<span
class=
"comment_date"
>
{{c.timestamp|datetimefmt:"short" }}
</span>
<div
class=
"
description
"
>
{{c.comment|safe}}
</div>
{%if c.attachment_set.all%}
<div
class=
"attachs"
>
Attachments
...
...
@@ -35,7 +65,16 @@
</ul>
</div>
{%endif%}
</div>
{%endfor%}
</div>
</li>
</ul>
{%endif%}
<h3>
Comments
</h3>
{% render_comment_list for v %}
<h3>
Comment
</h3>
{% get_comment_form for v as form %}
<div
id=
"comment_form"
>
{% render_comment_form for v %}
</div>
{%endblock%}
urls.py
View file @
4918dc4a
from
django.conf.urls.defaults
import
patterns
,
include
,
url
from
django.conf
import
settings
from
django.contrib
import
admin
from
bt
import
views
as
bt
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
admin
.
autodiscover
()
urlpatterns
=
patterns
(
''
,
(
r
'^$'
,
bt
.
index
),
(
r
'^accounts/logout$'
,
'django.contrib.auth.views.logout'
,
{
'next_page'
:
'/'
}),
(
r
'^accounts/'
,
include
(
'registration.urls'
)),
url
(
r
'^captcha/'
,
include
(
'captcha.urls'
)),
(
r
'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$'
,
bt
.
ajax
),
(
r
'^add/$'
,
bt
.
add
),
(
r
'^view/(?P<id>[0-9]*)$'
,
bt
.
view
),
(
r
'^accounts/logout$'
,
'django.contrib.auth.views.logout'
,
{
'next_page'
:
'/'
}),
(
r
'^accounts/'
,
include
(
'registration.urls'
)),
(
r
'^comments/'
,
include
(
'django.contrib.comments.urls'
)),
url
(
r
'^captcha/'
,
include
(
'captcha.urls'
)),
url
(
r
'^admin/'
,
include
(
admin
.
site
.
urls
)),
)
if
settings
.
DEV_SERVER
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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