mirror of
https://github.com/fergalmoran/dss.git
synced 2026-03-25 15:05:51 +00:00
Closes #4
This commit is contained in:
@@ -30,6 +30,12 @@ class CommentResource(BackboneCompatibleResource):
|
||||
bundle.data['avatar_image'] = UserProfile.get_default_avatar_image()
|
||||
bundle.data['user_url'] = "/"
|
||||
bundle.data['user_name'] = "Anonymouse"
|
||||
|
||||
if bundle.request.user.is_authenticated():
|
||||
bundle.data['can_edit'] = bundle.request.user.is_staff or bundle.obj.user_id == bundle.request.user.id
|
||||
else:
|
||||
bundle.data['can_edit'] = False
|
||||
|
||||
return bundle
|
||||
|
||||
def obj_create(self, bundle, **kwargs):
|
||||
|
||||
@@ -16,21 +16,18 @@ define ['jquery', 'bootstrap', 'toastr'], ($, bootstrap, toastr) ->
|
||||
true
|
||||
true
|
||||
|
||||
messageBox: (url) ->
|
||||
messageBox: (url, success) ->
|
||||
if url
|
||||
if url.indexOf("#") is 0
|
||||
$(url).modal "open"
|
||||
else
|
||||
$.get(url,(data) ->
|
||||
$("#yes-no-positive", data).click ->
|
||||
alert("Oh yes")
|
||||
$(data).modal('show').on("shown.bs.modal", (e) ->
|
||||
$(this).find("#yes-no-positive").click ->
|
||||
success()
|
||||
)
|
||||
)
|
||||
|
||||
$(data).modal().on "hidden", ->
|
||||
$(this).remove()
|
||||
true
|
||||
).success ->
|
||||
$("input:text:visible:first").focus()
|
||||
true
|
||||
true
|
||||
|
||||
checkPlayCount: ->
|
||||
|
||||
@@ -25,22 +25,17 @@
|
||||
}
|
||||
return true;
|
||||
},
|
||||
messageBox: function(url) {
|
||||
messageBox: function(url, success) {
|
||||
if (url) {
|
||||
if (url.indexOf("#") === 0) {
|
||||
$(url).modal("open");
|
||||
} else {
|
||||
$.get(url, function(data) {
|
||||
$("#yes-no-positive", data).click(function() {
|
||||
return alert("Oh yes");
|
||||
return $(data).modal('show').on("shown.bs.modal", function(e) {
|
||||
return $(this).find("#yes-no-positive").click(function() {
|
||||
return success();
|
||||
});
|
||||
});
|
||||
return $(data).modal().on("hidden", function() {
|
||||
$(this).remove();
|
||||
return true;
|
||||
});
|
||||
}).success(function() {
|
||||
$("input:text:visible:first").focus();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
define ['app.lib/dssView', 'text!/tpl/CommentItemView'],
|
||||
(DssView, Template) ->
|
||||
define ['app.lib/dssView', 'utils', 'text!/tpl/CommentItemView'],
|
||||
(DssView, utils, Template) ->
|
||||
class CommentItemView extends DssView
|
||||
template: _.template(Template)
|
||||
events: {
|
||||
"click #delete-comment": "deleteComment"
|
||||
}
|
||||
|
||||
deleteComment: ->
|
||||
utils.messageBox "/dlg/DeleteMixConfirm", =>
|
||||
@model.destroy()
|
||||
CommentItemView
|
||||
@@ -3,7 +3,7 @@
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
define(['app.lib/dssView', 'text!/tpl/CommentItemView'], function(DssView, Template) {
|
||||
define(['app.lib/dssView', 'utils', 'text!/tpl/CommentItemView'], function(DssView, utils, Template) {
|
||||
var CommentItemView;
|
||||
CommentItemView = (function(_super) {
|
||||
|
||||
@@ -15,6 +15,17 @@
|
||||
|
||||
CommentItemView.prototype.template = _.template(Template);
|
||||
|
||||
CommentItemView.prototype.events = {
|
||||
"click #delete-comment": "deleteComment"
|
||||
};
|
||||
|
||||
CommentItemView.prototype.deleteComment = function() {
|
||||
var _this = this;
|
||||
return utils.messageBox("/dlg/DeleteMixConfirm", function() {
|
||||
return _this.model.destroy();
|
||||
});
|
||||
};
|
||||
|
||||
return CommentItemView;
|
||||
|
||||
})(DssView);
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
{% load account_tags %}
|
||||
|
||||
<div class="comment-block">
|
||||
<a href="">
|
||||
<img class="image-avatar-small" src="<%= avatar_image %>" alt="">
|
||||
</a>
|
||||
|
||||
<div class="comment-details">
|
||||
<a class="comment-user" href="<%= user_url %>">
|
||||
<%= user_name %>
|
||||
</a>
|
||||
<blockquote class="pull-right">
|
||||
<p><%= comment %></p>
|
||||
<small><%= humanise(date_created) %></small>
|
||||
</blockquote>
|
||||
<div class="itemdiv dialogdiv">
|
||||
<div class="user">
|
||||
<img alt="<%= user_name %>'s Avatar" src="<%= avatar_image %>"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="body">
|
||||
<div class="time">
|
||||
<i class="icon-time"></i>
|
||||
<span class="green"><%= humanise(date_created) %></span>
|
||||
</div>
|
||||
|
||||
<div class="name">
|
||||
<a href="#"><%= user_name %></a>
|
||||
</div>
|
||||
<div class="text"><%= comment %></div>
|
||||
|
||||
<% if (can_edit) { %>
|
||||
<div class="tools">
|
||||
<a id="delete-comment" class="btn btn-minier btn-danger">
|
||||
<i class="icon-only icon-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,2 +1,14 @@
|
||||
<h3 class="bordered">Comments</h3>
|
||||
<div id="comment-list-container"></div>
|
||||
<div class="widget-box ">
|
||||
<div class="widget-header">
|
||||
<h4 class="lighter smaller">
|
||||
<i class="icon-comment blue"></i>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<div class="widget-body">
|
||||
<div class="widget-main no-padding">
|
||||
<div id="comment-list-container" class="dialogs" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
Comments, likes, favourites, all gone, never to return.
|
||||
{% endblock %}
|
||||
{% block primarybutton %}Cancel{% endblock %}
|
||||
{% block extrabuttons %}
|
||||
<a href="#" data-bypass="true" class="btn btn-success" id="yes-no-positive">
|
||||
Proceed
|
||||
</a>
|
||||
{% block extrabuttons %}
|
||||
<button type="button" class="btn btn-success" data-dismiss="modal" id="yes-no-positive">Proceed</button>
|
||||
{% endblock %}
|
||||
@@ -12,8 +12,7 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{% block extrabuttons %}{% endblock %}
|
||||
<a href="#" data-bypass="true" data-dismiss="modal" aria-hidden="true" class="btn btn-primary">
|
||||
{% block primarybutton %}{% endblock %}</a>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{% block primarybutton %}{% endblock %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user