diff --git a/social/comments.py b/social/comments.py
index ea24960..7767591 100644
--- a/social/comments.py
+++ b/social/comments.py
@@ -110,7 +110,7 @@ def post(request, url):
return HttpResponseRedirect('/dashboard/')
@login_required
-def reply(request, url, comment_id):
+def reply(request, comment_id):
user = request.user
prof = get_object_or_404(UserProfile, url=url)
other_user = prof.user
diff --git a/social/static/js/comment.js b/social/static/js/comment.js
index 06b8f13..c55508a 100755
--- a/social/static/js/comment.js
+++ b/social/static/js/comment.js
@@ -1,3 +1,30 @@
+var CommentForm = React.createClass({
+ getInitialState: function() {
+ return {text: ''};
+ },
+ handleTextChange: function(e) {
+ this.setState({text: e.target.value});
+ },
+ handleSubmit: function(e) {
+ e.preventDefault();
+ var text = this.state.text.trim();
+ if (!text) {
+ return;
+ }
+ this.props.onCommentSubmit({text: text});
+ this.setState({text: ''});
+ },
+
+ render: function() {
+ return (
+
+ );
+ }
+});
+
var CommentBox = React.createClass({displayName: 'CommentBox',
getInitialState: function() {
return {data: []};
@@ -18,15 +45,15 @@ var CommentBox = React.createClass({displayName: 'CommentBox',
},
componentDidMount: function() {
- this.loadCommentsFromServer();
- setInterval(this.loadCommentsFromServer, this.props.pollInterval);
- },
+ this.loadCommentsFromServer();
+ setInterval(this.loadCommentsFromServer, this.props.pollInterval);
+ },
render: function() {
return (
)
}
@@ -51,6 +78,20 @@ var CommentList = React.createClass({
});
var SubcommentList = React.createClass({
+ handleCommentSubmit: function(comment) {
+ $.ajax({
+ url: "/comment/"+comment.id+"/reply",
+ dataType: 'json',
+ type: 'POST',
+ data: comment,
+ success: function(data) {
+ this.setState({data: data});
+ }.bind(this),
+ error: function(xhr, status, err) {
+ console.error(this.props.url, status, err.toString());
+ }.bind(this)
+ });
+ },
render: function() {
var commentNodes = this.props.data.map(function(comment) {
return (
@@ -62,6 +103,7 @@ var SubcommentList = React.createClass({
return (
{commentNodes}
+
)
}
diff --git a/social/templates/profile/comment.html b/social/templates/profile/comment.html
index d56a19d..f969c26 100644
--- a/social/templates/profile/comment.html
+++ b/social/templates/profile/comment.html
@@ -14,7 +14,7 @@
{% endfor %}
Reply
{% if c in user.userprofile.comments.all or user == c.author %}
- Delete
+ Delete
{% endif %}
diff --git a/social/templates/profile/profile.html b/social/templates/profile/profile.html
index 001bf06..6cbba20 100644
--- a/social/templates/profile/profile.html
+++ b/social/templates/profile/profile.html
@@ -47,10 +47,8 @@ Comments
{% endif %}
- {% for c in other_user.userprofile.comments.all %}
- {% if c.public or user == other_user or user in other_user.userprofile.friends.all %}
- {% include "profile/comment.html" %}
- {% endif %}
- {% endfor %}
+ {% load staticfiles %}
+
+
{% endblock %}
diff --git a/social/urls.py b/social/urls.py
index ef88e41..b30d185 100644
--- a/social/urls.py
+++ b/social/urls.py
@@ -24,8 +24,8 @@
url(r'^settings/friends/group/(?P\d+)/edit/$', views.edit_group, name='edit_group'),
url(r'^settings/friends/group/set_order/$', views.sort_group, name='sort_group'),
url(r'^profile/(?P\w+)/subscribe/$', views.subscribe, name='subscribe'),
- url(r'^profile/(?P\w+)/comment/(?P\d+)/reply/$', comments.reply, name='comment_reply'),
- url(r'^profile/(?P\w+)/comment/(?P\d+)/delete/$', comments.delete, name='comment_delete'),
+ url(r'^comment/(?P\d+)/reply/$', comments.reply, name='comment_reply'),
+ url(r'^comment/(?P\d+)/delete/$', comments.delete, name='comment_delete'),
url(r'^profile/(?P\w+)/friends/$', views.view_friends, name='view_friends'),
url(r'^profile/(?P\w+)/albums/create/$', images.create_album, name='create_album'),
url(r'^profile/(?P\w+)/albums/(?P\d+)/$', images.album, name='album'),
Comments
-