Commit 620bec6e authored by makfire's avatar makfire

trash functionality done

parent 62b7b318
......@@ -286,6 +286,22 @@ class Command(BaseCommand):
print " GList ("+glc_node_name+") container already created !"
info_message += "\n GList ("+glc_node_name+") container already created !"
Group_node = node_collection.collection.Group();
node_doc =node_collection.one({'$and':[{'_type': u'Group'},{'name': u'Trash'}]})
if node_doc is None:
Group_node.name = unicode('Trash')
Group_node.status = unicode('PUBLISHED')
Group_node.created_by = 1
Group_node.modified_by = 1
Group_node.access_policy = unicode("PRIVATE")
Group_node.member_of.append(node_collection.one({"_type": "GSystemType", 'name': "Group"})._id)
Group_node.disclosure_policy=unicode('DISCLOSED_TO_MEM')
Group_node.visibility_policy=unicode('NOT_ANNOUNCED')
Group_node.encryption_policy=unicode('NOT_ENCRYPTED')
Group_node.edit_policy =unicode('NON_EDITABLE')
Group_node.save()
else:
print "Trash Group already created."
print "\n"
info_message += "\n\n"
log_list.append(info_message)
......
......@@ -824,20 +824,29 @@
$drContainer.css("opacity", "1");
})
// ---END of search in the data-review
function deleteNode(node_id)
function deleteNode(oid)
{
a = node_id
alert(a)
$.ajax({
url:"{% url 'delete_resource' groupid %}",
type:'Get',
data:{
'node_id':node_id
'node_id':oid
},
success:function(data){
alert(data)
//updateContent();
var $resBlankRow = $("tr#blank-row-" + oid);
// fetching resource object VIEW row
var $resViewRow = $("tr#view-row-" + oid);
// fetching resource object EDIT row
var $resEditRow = $("tr#edit-row-" + oid);
$($resEditRow).add($resViewRow).add($resBlankRow).animate({
opacity: 0.1
}, 1000).fadeOut(1000);
setCurrNoneToEditRow(oid)
}
......
{% load cache %}
<table id="data-review-table" style="width:auto">
<!-- <table> -->
......@@ -14,7 +13,9 @@
<th class="text-center right-border" colspan="3">Alignment & Level</th>
<th class="text-center right-border" colspan="7">Curate</th>
<th class="text-center right-border" colspan="3">Advance</th>
<th class="text-center right-border" colspan="2">Admin</th>
{% if user.is_superuser %}
<th class="text-center right-border" colspan="2">Admin</th>
{% endif %}
{% if title == "moderation" %}
<th class="text-center right-border" colspan="3">Moderation</th>
{% endif %}
......@@ -67,9 +68,10 @@
<th>Time Required</th>
<th class="expand-width-3 right-border">Text Complexity</th>
<!-- Admin -->
<th class="expand-width-3"> Purge </th>
<th class="expand-width-3"> Restore </th>
{% if user.is_superuser %}
<th class="expand-width-3"> Purge </th>
<th class="expand-width-3"> Restore </th>
{% endif %}
<!-- moderation -->
{% if title == "moderation" %}
<th class="expand-width-2">Discuss</th>
......
......@@ -291,11 +291,15 @@
</option> -->
</select>
</td>
<td class="deletedata">
<div class="button tiny exapnd" id = "{{resource.pk}}" onclick = "deleteNode('{{resource.pk}}')"> Delete </div>
<div class="button tiny exapnd" id = "{{resource.pk}}" onclick = "restoreNode('{{resource.pk}}')"> restore </div>
</td>
{% if user.is_superuser %}
<td class="deletedata">
<div class="button tiny exapnd" id = "{{resource.pk}}" onclick = "deleteNode('{{resource.pk}}')"> Delete </div>
</td>
<td>
<div class="button tiny exapnd" id = "{{resource.pk}}" onclick = "restoreNode('{{resource.pk}}')"> restore </div>
</td>
{% endif %}
{% if title == "moderation" %}
......
......@@ -44,6 +44,10 @@
.img-height {
height: 100%;
}
.fi-trash{
color:orange;
}
.div-height {
margin-bottom: 0.5em;
......@@ -127,12 +131,19 @@
{% trans "Files uploaded" %}: &nbsp;{{file_count}}<br>
{% trans "Quiz" %}: {{quiz_count}}<br>
{% trans "Forum" %}: {{forum_count}}<br>
<!-- FOR AWARDS -->
<!-- {% if page_count > 1 %}
<img src="/static/ndf/images/close.png">
{% endif %} -->
</h5>
</div>
{% if user.is_superuser %}
<div class"trashdiv" style="position:absolute; float:right; right:11%; top:2%;">
<a href="/Trash/data-review" > <h5> <span class = "fi-trash"> </span> <b > Trash </b> </h5> </a>
</div>
{% endif %}
</div>
<br/>
......
......@@ -656,7 +656,9 @@ def get_gapps_iconbar(request, group_id):
if k1 == "name":
if v1.lower() not in user_gapps:
del gapps[k]
if group_obj.name == 'Trash':
gapps={}
return {
"template": "ndf/gapps_iconbar.html",
"request": request,
......
......@@ -61,7 +61,6 @@ def page(request, group_id, app_id=None):
if group_ins:
group_id = str(group_ins._id)
print group_id
else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
......@@ -105,7 +104,6 @@ def page(request, group_id, app_id=None):
# End of user shelf
if request.method == "POST":
title = gst_page.name
search_field = request.POST['search_field']
page_nodes = node_collection.find({
......@@ -144,15 +142,14 @@ def page(request, group_id, app_id=None):
)
elif gst_page._id == ObjectId(app_id):
# Page list view
# Page list view
# code for moderated Groups
group_type = node_collection.one({'_id': ObjectId(group_id)})
group_info=group_type_info(group_id)
title = gst_page.name
'''
if group_info == "Moderated":
title = gst_page.name
node=group_type.prior_node[0]
page_nodes = node_collection.find({'member_of': {'$all': [ObjectId(app_id)]},
......@@ -167,12 +164,12 @@ def page(request, group_id, app_id=None):
context_instance=RequestContext(request))
elif group_info == "BaseModerated":
#code for parent Groups
#code for parent Groups
node = node_collection.find({'member_of': {'$all': [ObjectId(app_id)]},
'group_set': {'$all': [ObjectId(group_id)]},
'status': {'$nin': ['HIDDEN']}
}).sort('last_update', -1)
if node is None:
node = node_collection.find({'member_of':ObjectId(app_id)})
......@@ -182,7 +179,6 @@ def page(request, group_id, app_id=None):
# rcs content ends here
return render_to_response("ndf/page_list.html",
{'title': title,
'appId':app._id,
......@@ -193,16 +189,16 @@ def page(request, group_id, app_id=None):
},
context_instance=RequestContext(request)
)
elif group_info == "PUBLIC" or group_info == "PRIVATE" or group_info is None:
"""
Below query returns only those documents:
(a) which are pages,
(b) which belongs to given group,
(c) which has status either as DRAFT or PUBLISHED, and
(d) which has access_policy either as PUBLIC or if PRIVATE then it's created_by must be the logged-in user
"""
page_nodes = node_collection.find({'member_of': {'$all': [ObjectId(app_id)]},
elif group_info == "PUBLIC" or group_info == "PRIVATE" or group_info is None:'''
"""
Below query returns only those documents:
(a) which are pages,
(b) which belongs to given group,
(c) which has status either as DRAFT or PUBLISHED, and
(d) which has access_policy either as PUBLIC or if PRIVATE then it's created_by must be the logged-in user
"""
page_nodes = node_collection.find({'member_of': {'$all': [ObjectId(app_id)]},
'group_set': {'$all': [ObjectId(group_id)]},
'$or': [
{'access_policy': u"PUBLIC"},
......@@ -214,14 +210,12 @@ def page(request, group_id, app_id=None):
],
'status': {'$nin': ['HIDDEN']}
}).sort('last_update', -1)
# content =[]
# for nodes in page_nodes:
# content =[]
# for nodes in page_nodes:
# node,ver=get_page(request,nodes)
# if node != 'None':
# content.append(node)
return render_to_response("ndf/page_list.html",
# if node != 'None':
# content.append(node)
return render_to_response("ndf/page_list.html",
{'title': title,
'appId':app._id,
'shelf_list': shelf_list,'shelves': shelves,
......
from django.http import HttpResponse
from django.shortcuts import render_to_response # , render
from django.template import RequestContext
from gnowsys_ndf.ndf.models import *
from gnowsys_ndf.ndf.views.page import *
from gnowsys_ndf.ndf.views.page import page
from gnowsys_ndf.ndf.views.file import file
from gnowsys_ndf.ndf.views.group import group_dashboard
from gnowsys_ndf.ndf.views.methods import *
def trash_resource(request,group_id,node_id):
node = node_collection.find_one({"_id":ObjectId(node_id)})
trash_node = node_collection.find_one({"name":"Trash"});
......@@ -17,12 +16,20 @@ def trash_resource(request,group_id,node_id):
#fetch the tarsh group id
if trash_node._id not in node.group_set:
node.group_set.append(trash_node._id)
print "node",node.group_set
node.save()
return (eval('page')(request, group_id))
get_member_of = node_collection.find_one({"_id":{'$in':node.member_of}})
if get_member_of.name == 'Page':
return (eval('page')(request, group_id))
elif get_member_of.name == 'File':
return(eval('file')(request, group_id))
else:
return(eval('group_dashboard')(request, group_id))
def delete_resource(request,group_id):
node_id = request.GET.getlist('node_id','')[0]
delete_node(ObjectId(node_id),deletion_type=1)
if node_id:
delete_node(ObjectId(node_id),deletion_type=1)
else:
return HttpResponse("Nothing Deleted.")
return HttpResponse("Deleted Successfully")
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