Commit dad918c1 authored by saurabh's avatar saurabh

multiple resources delete button added

parent 0b51ac56
......@@ -2,8 +2,8 @@
{% load i18n %}
{% load ndf_tags %}
{% get_group_name groupid as group_name_tag %}
{% check_is_gstaff groupid request.user as is_gstaff %}
{% get_node groupid as group_obj %}
{% block title %} {{title}} {% endblock %}
......@@ -252,6 +252,13 @@ margin-top:5px !important;
<div class="coll_label row" style="display:none;">
<span class="small-12 columns">Create Collection</span>
<div class="small-11 columns"><input type="text" class="coll_value" placeholder="Enter collection name" name="coll_name"/></div><a class="create_coll"><span class="fi-check" style="color:green;"></span></a>
{% if group_obj.created_by == request.user.id or user.is_superuser %}
<div class="small-11 columns">
<a class="tiny button radius right-btn delete-multiple-files" title="Delete {{node.member_of_names_list.0}}">{% trans 'Delete Files' %}</a>
</div>
{% endif %}
</div>
</ul>
</div>
......@@ -741,6 +748,41 @@ margin-top:5px !important;
alert("Your video file uploaded succesfully, But still in process, play video about 1 hour after");
{% endif %}
$(".delete-multiple-files").click(function(){
// var coll_node = $(".coll_value").val()
var coll_arr = []
$('.filenode:checked').each(function() {
coll_arr.push($(this).val());
});
// alert(coll_arr);
var r = confirm("Do you want to save the collection of selected elements");
if (r == true) {
x = "Your collection is saved successfully";
$.ajax({
type: "POST",
url: "{% url 'delete_multiple_resources' group_id %}",
datatype: "html",
data:{
collection: coll_arr,
csrfmiddlewaretoken: '{{ csrf_token }}'
},
success: function(data) {
alert("File(s) deleted successfully");
location.reload();
}
});
} else {
x = "Cancelled";
}
})
// </script>
{% endblock %}
......@@ -7,7 +7,7 @@
{% get_group_name groupid as group_name_tag %}
{% get_gstudio_twitter_via as twitter_via %}
{% check_is_gstaff groupid request.user as is_gstaff %}
{# % get_gstudio_facebook_app_id as fb_app_id % #}
{% get_gstudio_facebook_app_id as fb_app_id %}
<script type="text/javascript" src="/static/ndf/bower_components/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/static/ndf/bower_components/ckeditor/config.js"></script>
......@@ -18,15 +18,29 @@
var x = location.href;
var hostname = location.host;
// x = "https://www.facebook.com/dialog/feed?app_id={{fb_app_id}}&redirect_uri=http://www.metastudio.org/home/&link="+location.href+"&caption= {{node.name}}&description={{node.content|safe}}&picture=" + hostname + "{% url 'read_file' group_name_tag node download_filename %}";
// $(".share_link").attr("href",x);
x = "https://www.facebook.com/dialog/feed?app_id=146799965703412&redirect_uri=http://www.metastudio.org/home/&link="+location.href+"&caption= {{node.name}}&description={{node.content|safe}}&picture=" + hostname + "{% url 'read_file' group_name_tag node download_filename %}";
$(".share_link").attr("href",x);
hrefs = "href=https://twitter.com/share";
b = "large";
c = location.href;
d = location.href+"tweet-button";
e = "atMetaStudio";
selected_child = window.location.search.replace("?selected=", "");
if(selected_child){
$(".twitter-share-button").remove();
d = location.hostname + ":8000" + "/" + "{{group_id}}" + "/" + "file" + "/" + selected_child +"tweet-button";
parent_div = $(".share_link");
console.log(parent_div);
parent_div.append("<a class='twitter-share-button' href='' data-size='' data-url='' data-count-url='' data-via='' data-related=''data-hashtags='' data-text=''>TweetNew</a>");
$(document).ready();
c = location.hostname + ":8000" + "/" + "{{group_id}}" + "/" + "file" + "/" + selected_child;
}
else{
d = location.href+"tweet-button";
c = location.href;
}
console.log(selected_child);
f = "twitterapi,twitter";
// g= "{{node.tags|striptags}}";
// h="hello ghello";
......@@ -38,11 +52,11 @@
$(".twitter-share-button").attr("data-related",f);
// $(".twitter-share-button").attr("data-hashtags",g);
// $(".twitter-share-button").attr("data-text",h);
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
});
</script>
<script type="text/javascript">
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
</script>
......@@ -566,11 +580,10 @@
<br>
{% get_gstudio_social_share_resource as social_share %}
{% if social_share and "Group" not in node.member_of_names_list and "PartnerGroup" not in node.member_of_names_list %}
{% comment %} <a class = "share_link" href="#" accesskey="l" target="_blank" title="Share on Facebook">
<a class = "share_link" href="#" accesskey="l" target="_blank" title="Share on Facebook">
<img src="/static/ndf/images/Facebook_logo.png" width="30px">
{% endcomment %}
</a>
<a class="twitter-share-button"href="" data-size="" data-url="" data-count-url="" data-via="" data-related=""
<a class="twitter-share-button" href="" data-size="" data-url="" data-count-url="" data-via="" data-related=""
data-hashtags="" data-text="">TweetNew</a>
{% endif %}
......
......@@ -218,9 +218,9 @@ def get_node_type(node):
@get_execution_time
@register.assignment_tag
def get_node(node):
if node:
obj = node_collection.one({"_id": ObjectId(node)})
def get_node(node_id):
if node_id:
obj = node_collection.one({"_id": ObjectId(node_id)})
if obj:
return obj
else:
......
......@@ -4,6 +4,7 @@ urlpatterns = patterns('gnowsys_ndf.ndf.views.trash',
url(r'^/delete/(?P<node_id>[\w-]+)$', 'trash_resource',name='trash_resource'),
url(r'^/delete$', 'delete_resource',name='delete_resource'),
url(r'^/restore$', 'restore_resource',name='restore_resource'),
url(r'^/delete_multiple_resources', 'delete_multiple_resources', name='delete_multiple_resources'),
)
......@@ -99,3 +99,30 @@ def restore_resource(request, group_id):
# print "\n Resore Exception ===== ", str(e)
pass
return HttpResponse(json.dumps(response_dict))
@get_execution_time
def delete_multiple_resources(request,group_id):
files_list = request.POST.getlist("collection[]", '')
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
group_obj = node_collection.find_one({"_id":ObjectId(group_id)})
trash_group = node_collection.find_one({"name":"Trash"})
files_list_obj = []
for each in files_list:
node_obj = node_collection.find_one({"_id":ObjectId(each)})
if ObjectId(group_id) in node_obj.group_set:
node_obj.group_set.remove(ObjectId(group_id))
if ObjectId(auth._id) in node_obj.group_set:
node_obj.group_set.remove(ObjectId(auth._id))
node_obj.save()
if not node_obj.group_set:
# Add Trash group _id to node_obj's group_set
if trash_group._id not in node_obj.group_set:
node_obj.group_set.append(trash_group._id)
node_obj.status = u"DELETED"
if node_obj.collection_set:
if trash_group._id not in node_obj.group_set:
node_obj.group_set.append(trash_group._id)
node_obj.status = u"DELETED"
node_obj.save()
return HttpResponse(json.dumps(files_list))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment