Commit 34afc780 authored by saurabh's avatar saurabh

bug in delete file fixed.

parent 732fafd4
......@@ -499,8 +499,8 @@
csrfmiddlewaretoken: '{{ csrf_token }}'
},
success: function(data) {
data = JSON.parse(data)
window.location.replace("{% url 'file' group_id %}");
data = JSON.parse(data)
window.location.replace("{% url 'file' group_id %}");
}
});
......
......@@ -17,12 +17,27 @@ def trash_resource(request,group_id,node_id):
Iff node's group_set is empty, send to Trash group.
'''
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
node_obj = node_collection.find_one({"_id":ObjectId(node_id)})
group_obj = node_collection.find_one({"_id":ObjectId(group_id)})
trash_group = node_collection.find_one({"name":"Trash"});
if trash_group._id in node_obj.group_set:
try:
if node_obj._id:
delete_node(ObjectId(node_obj._id),deletion_type=1)
response_dict['success'] = True
except Exception as e:
pass
return HttpResponse(json.dumps(group_id))
if ObjectId(group_id) in node_obj.group_set:
node_obj.group_set.remove(ObjectId(group_id))
if node_obj.group_set:
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)
......@@ -40,9 +55,7 @@ def trash_resource(request,group_id,node_id):
return HttpResponseRedirect(reverse('page', kwargs={'group_id': group_id}))
# return (eval('page')(request, group_id))
elif "File" in node_obj.member_of_names_list and not "CourseEventGroup" in group_obj.member_of_names_list :
if GSTUDIO_SITE_NAME == "NROER":
return HttpResponseRedirect(reverse('e-library', kwargs={'group_id': group_id}))
return HttpResponseRedirect(reverse('file', kwargs={'group_id': group_id}))
return HttpResponse(json.dumps(group_id))
# elif get_member_of.name == 'File':
# return(eval('file')(request, group_id))
elif "CourseEventGroup" in group_obj.member_of_names_list:
......@@ -79,7 +92,7 @@ def restore_resource(request, group_id):
if node_to_be_restore.snapshot.keys():
node_to_be_restore.group_set = [ObjectId(i) for i in node_to_be_restore.snapshot.keys()]
node_to_be_restore.save()
node_to_be_restore.save(group_id)
# print "--- ", node_to_be_restore.group_set
response_dict['success'] = True
except Exception as e:
......
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