<commit_before>
''' -- imports from installed packages -- ''' 
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django_mongokit import get_database
from gnowsys_ndf.ndf.org2any import org2html

try:
	from bson import ObjectId
except ImportError:  # old pymongo
	from pymongo.objectid import ObjectId

''' -- imports from application folders/files -- '''
from gnowsys_ndf.ndf.models import Node, GRelation,GSystemType,File,Triple
from gnowsys_ndf.ndf.views.file import *

#######################################################################################################################################

db = get_database()
collection = db[Node.collection_name]
collection_tr = db[Triple.collection_name]
GST_browse_resource = collection.GSystemType.one({'_type':'GSystemType', 'name': 'Browse Resource'})
app = collection.GSystemType.one({'_type':'GSystemType', 'name': 'Browse Resource'})
pandoravideoCollection=collection.Node.find({'member_of':pandora_video_st._id})

#######################################################################################################################################

def resource_list(request,group_id,app_id=None):

	ins_objectid  = ObjectId()
	is_video = request.GET.get('is_video', "")
	if ins_objectid.is_valid(group_id) is False :
		group_ins = collection.Node.find_one({'_type': "Group","name": group_id})
		auth = collection.Node.one({'_type': 'Author', 'name': unicode(request.user.username) })
		if group_ins:
		    group_id = str(group_ins._id)
		else :
		    auth = collection.Node.one({'_type': 'Author', 'name': unicode(request.user.username) })
		    if auth :
		        group_id = str(auth._id)
	else :
	    pass
	if app_id is None:
	    app_ins = collection.Node.find_one({'_type':'GSystemType', 'name': 'Browse Resource'})
	    if app_ins:
	        app_id = str(app_ins._id)


	# if GST_browse_resource._id == ObjectId(app_id):
	"""
	* Renders a list of all 'Resources(XCR)' available within the database.
	"""
	title = GST_browse_resource.name

	file_id = GST_FILE._id
	datavisual = []
	 
	files = collection.Node.find({'member_of': {'$all': [ObjectId(file_id)]}, 
	                                '_type': 'File', 'fs_file_ids':{'$ne': []}, 
	                                'group_set': {'$all': [ObjectId(group_id)]},
	                                '$or': [
	                                  {'access_policy': u"PUBLIC"},
	                                  {'$and': [
	                                      {'access_policy': u"PRIVATE"}, 
	                                      {'created_by': request.user.id}
	                                    ]
	                                  }
	                                ]
	                              }).sort("last_update", -1)

	docCollection = collection.Node.find({'member_of': {'$nin': [ObjectId(GST_IMAGE._id), ObjectId(GST_VIDEO._id)]}, 
	                                        '_type': 'File','fs_file_ids': {'$ne': []}, 
	                                        'group_set': {'$all': [ObjectId(group_id)]},
	                                        '$or': [
	                                          {'access_policy': u"PUBLIC"},
	                                          {'$and': [<commit_msg>minor changes made in browse_resource.py<commit_after>
''' -- imports from installed packages -- ''' 
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django_mongokit import get_database
from gnowsys_ndf.ndf.org2any import org2html

try:
	from bson import ObjectId
except ImportError:  # old pymongo
	from pymongo.objectid import ObjectId

''' -- imports from application folders/files -- '''
from gnowsys_ndf.ndf.models import Node, GRelation,GSystemType,File,Triple
from gnowsys_ndf.ndf.views.file import *

#######################################################################################################################################

db = get_database()
collection = db[Node.collection_name]
collection_tr = db[Triple.collection_name]
GST_browse_resource = collection.GSystemType.one({'_type':'GSystemType', 'name': 'Browse Resource'})
app = collection.GSystemType.one({'_type':'GSystemType', 'name': 'Browse Resource'})
pandoravideoCollection=collection.Node.find({'member_of':pandora_video_st._id})

#######################################################################################################################################

def resource_list(request,group_id,app_id=None):

	ins_objectid  = ObjectId()
	is_video = request.GET.get('is_video', "")
	if ins_objectid.is_valid(group_id) is False :
		group_ins = collection.Node.find_one({'_type': "Group","name": group_id})
		auth = collection.Node.one({'_type': 'Author', 'name': unicode(request.user.username) })
		if group_ins:
		    group_id = str(group_ins._id)
		else :
		    auth = collection.Node.one({'_type': 'Author', 'name': unicode(request.user.username) })
		    if auth :
		        group_id = str(auth._id)
	else :
	    pass
	if app_id is None:
	    app_ins = collection.Node.find_one({'_type':'GSystemType', 'name': 'Browse Resource'})
	    if app_ins:
	        app_id = str(app_ins._id)


	# if GST_browse_resource._id == ObjectId(app_id):
	"""
	* Renders a list of all 'Resources(XCR)' available within the database.
	"""
	title = GST_browse_resource.name

	file_id = GST_FILE._id
	datavisual = []
	 
	files = collection.Node.find({'$or':[{'member_of': {'$all': [ObjectId(file_id)]}, 
	                                '_type': 'File', 'fs_file_ids':{'$ne': []}, 
	                                'group_set': {'$all': [ObjectId(group_id)]},
	                                '$or': [
	                                  {'access_policy': u"PUBLIC"},
	                                  {'$and': [
	                                      {'access_policy': u"PRIVATE"}, 
	                                      {'created_by': request.user.id}
	                                    ]
	                                  }
	                                ]
	                              },
                                    {'member_of': {'$all': [pandora_video_st._id]}}
                                       ]}).sort("last_update", -1)

	docCollection = collection.Node.find({'member_of': {'$nin': [ObjectId(GST_IMAGE._id), ObjectId(GST_VIDEO._id)]}, 
	                                        '_type': 'File','fs_file_ids': {'$ne': []}, 
	                                        'group_set': {'$all': [ObjectId(group_id)]},
	                                        '$or': [
	                                          {'access_policy': u"PUBLIC"},
	                                          {'$and': [
{'fraction_non_alphanumeric': 0.20512065921130077, 'fraction_numerical': 0.0008828722778104767, 'mean_word_length': 2.3482758620689657, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6535775', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1844, 'n_words': 343}