Commit 384b32c2 authored by saurabh's avatar saurabh

Replace with get_group_name_id wherever needed in the views

parent 6963f8f0
...@@ -23,18 +23,23 @@ def custom_app_view(request, group_id, app_name, app_id=None, app_set_id=None, a ...@@ -23,18 +23,23 @@ def custom_app_view(request, group_id, app_name, app_id=None, app_set_id=None, a
""" """
custom view for custom GAPPS custom view for custom GAPPS
""" """
ins_objectid = ObjectId() #ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : #if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) #group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) #auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: #if group_ins:
group_id = str(group_ins._id) #group_id = str(group_ins._id)
else : #else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) #auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : #if auth :
group_id = str(auth._id) #group_id = str(auth._id)
else : #else :
pass #pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
if app_id is None: if app_id is None:
if app_name == "partners": if app_name == "partners":
app_name = "Partners" app_name = "Partners"
...@@ -172,18 +177,26 @@ def custom_app_new_view(request, group_id, app_name, app_id, app_set_id=None, ap ...@@ -172,18 +177,26 @@ def custom_app_new_view(request, group_id, app_name, app_id, app_set_id=None, ap
""" """
create new instance of app_set of apps view for custom GAPPS create new instance of app_set of apps view for custom GAPPS
""" """
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
if app_id is None: if app_id is None:
app_ins = node_collection.find_one({'_type':"GSystemType", "name":app_name}) app_ins = node_collection.find_one({'_type':"GSystemType", "name":app_name})
if app_ins: if app_ins:
......
...@@ -29,6 +29,11 @@ app = node_collection.one({'_type':'GSystemType', 'name': 'E-Library'}) ...@@ -29,6 +29,11 @@ app = node_collection.one({'_type':'GSystemType', 'name': 'E-Library'})
@get_execution_time @get_execution_time
def ebook_listing(request, group_id, page_no=1): def ebook_listing(request, group_id, page_no=1):
# group_name, group_id = get_group_name_id(group_id)
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id) group_name, group_id = get_group_name_id(group_id)
all_ebooks = node_collection.find({"_type": "File", "attribute_set.educationaluse": "eBooks"}) all_ebooks = node_collection.find({"_type": "File", "attribute_set.educationaluse": "eBooks"})
......
...@@ -37,6 +37,10 @@ def resource_list(request, group_id, app_id=None, page_no=1): ...@@ -37,6 +37,10 @@ def resource_list(request, group_id, app_id=None, page_no=1):
is_video = request.GET.get('is_video', "") is_video = request.GET.get('is_video', "")
# group_name, group_id = get_group_name_id(group_id)
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id) group_name, group_id = get_group_name_id(group_id)
if app_id is None: if app_id is None:
......
...@@ -43,6 +43,7 @@ def event(request, group_id): ...@@ -43,6 +43,7 @@ def event(request, group_id):
group_id = str(auth._id) group_id = str(auth._id)
else : else :
pass pass
#view written just to show the landing page of the events #view written just to show the landing page of the events
group_inverse_rel_id = [] group_inverse_rel_id = []
Event_app = True Event_app = True
...@@ -101,17 +102,21 @@ def event_detail(request, group_id, app_id=None, app_set_id=None, app_set_instan ...@@ -101,17 +102,21 @@ def event_detail(request, group_id, app_id=None, app_set_id=None, app_set_instan
View for handling Event and it's sub-types detail-view View for handling Event and it's sub-types detail-view
""" """
auth = None auth = None
if ObjectId.is_valid(group_id) is False : # if ObjectId.is_valid(group_id) is False :
group_ins = node_collection.one({'_type': "Group","name": group_id}) # group_ins = node_collection.one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
session_node = "" session_node = ""
app = None app = None
session_node = "" session_node = ""
...@@ -306,17 +311,21 @@ def event_create_edit(request, group_id, app_set_id=None, app_set_instance_id=No ...@@ -306,17 +311,21 @@ def event_create_edit(request, group_id, app_set_id=None, app_set_instance_id=No
View for handling Event and it's sub-types create-edit-view View for handling Event and it's sub-types create-edit-view
""" """
auth = None auth = None
if ObjectId.is_valid(group_id) is False : # if ObjectId.is_valid(group_id) is False :
group_ins = node_collection.one({'_type': "Group","name": group_id}) # group_ins = node_collection.one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
''' '''
app = None app = None
if app_id is None: if app_id is None:
......
...@@ -65,17 +65,22 @@ def file(request, group_id, file_id=None, page_no=1): ...@@ -65,17 +65,22 @@ def file(request, group_id, file_id=None, page_no=1):
""" """
ins_objectid = ObjectId() ins_objectid = ObjectId()
is_video = request.GET.get('is_video', "") is_video = request.GET.get('is_video', "")
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
if file_id is None: if file_id is None:
file_ins = node_collection.find_one({'_type':"GSystemType", "name":"File"}) file_ins = node_collection.find_one({'_type':"GSystemType", "name":"File"})
if file_ins: if file_ins:
...@@ -1204,18 +1209,23 @@ def convertVideo(files, userid, fileobj, filename): ...@@ -1204,18 +1209,23 @@ def convertVideo(files, userid, fileobj, filename):
@get_execution_time @get_execution_time
def GetDoc(request, group_id): def GetDoc(request, group_id):
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
files = node_collection.find({'_type': u'File'}) files = node_collection.find({'_type': u'File'})
#return files #return files
template = "ndf/DocumentList.html" template = "ndf/DocumentList.html"
...@@ -1225,18 +1235,23 @@ def GetDoc(request, group_id): ...@@ -1225,18 +1235,23 @@ def GetDoc(request, group_id):
@get_execution_time @get_execution_time
def file_search(request, group_id): def file_search(request, group_id):
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
if request.method == "GET": if request.method == "GET":
keyword = request.GET.get("search", "") keyword = request.GET.get("search", "")
file_search = node_collection.find({'$or':[{'name':{'$regex': keyword}}, {'tags':{'$regex':keyword}}]}) #search result from file file_search = node_collection.find({'$or':[{'name':{'$regex': keyword}}, {'tags':{'$regex':keyword}}]}) #search result from file
...@@ -1250,18 +1265,23 @@ def file_search(request, group_id): ...@@ -1250,18 +1265,23 @@ def file_search(request, group_id):
def delete_file(request, group_id, _id): def delete_file(request, group_id, _id):
"""Delete file and its data """Delete file and its data
""" """
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
auth = node_collection.one({'_type': u'Author', 'name': unicode(request.user.username) }) auth = node_collection.one({'_type': u'Author', 'name': unicode(request.user.username) })
pageurl = request.GET.get("next", "") pageurl = request.GET.get("next", "")
try: try:
...@@ -1388,16 +1408,21 @@ def file_detail(request, group_id, _id): ...@@ -1388,16 +1408,21 @@ def file_detail(request, group_id, _id):
def getFileThumbnail(request, group_id, _id): def getFileThumbnail(request, group_id, _id):
"""Returns thumbnail of respective file """Returns thumbnail of respective file
""" """
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False: # if ins_objectid.is_valid(group_id) is False:
group_ins = node_collection.find_one({'_type': "Group", "name": group_id}) # group_ins = node_collection.find_one({'_type': "Group", "name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
elif auth: # elif auth:
group_id = str(auth._id) # group_id = str(auth._id)
else: # else:
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
file_node = node_collection.one({"_id": ObjectId(_id)}) file_node = node_collection.one({"_id": ObjectId(_id)})
""" """
...@@ -1453,18 +1478,23 @@ def getFileThumbnail(request, group_id, _id): ...@@ -1453,18 +1478,23 @@ def getFileThumbnail(request, group_id, _id):
def readDoc(request, _id, group_id, file_name=""): def readDoc(request, _id, group_id, file_name=""):
'''Return Files '''Return Files
''' '''
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
file_node = node_collection.one({"_id": ObjectId(_id)}) file_node = node_collection.one({"_id": ObjectId(_id)})
if file_node is not None: if file_node is not None:
...@@ -1487,18 +1517,23 @@ def readDoc(request, _id, group_id, file_name=""): ...@@ -1487,18 +1517,23 @@ def readDoc(request, _id, group_id, file_name=""):
@get_execution_time @get_execution_time
def file_edit(request,group_id,_id): def file_edit(request,group_id,_id):
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
group_obj = node_collection.one({'_id': ObjectId(group_id)}) group_obj = node_collection.one({'_id': ObjectId(group_id)})
file_node = node_collection.one({"_id": ObjectId(_id)}) file_node = node_collection.one({"_id": ObjectId(_id)})
title = GST_FILE.name title = GST_FILE.name
......
...@@ -761,18 +761,23 @@ def get_profile_pic(username): ...@@ -761,18 +761,23 @@ def get_profile_pic(username):
def delete_forum(request,group_id,node_id,relns=None): def delete_forum(request,group_id,node_id,relns=None):
""" Changing status of forum to HIDDEN """ Changing status of forum to HIDDEN
""" """
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
op = node_collection.collection.update({'_id': ObjectId(node_id)}, {'$set': {'status': u"HIDDEN"}}) op = node_collection.collection.update({'_id': ObjectId(node_id)}, {'$set': {'status': u"HIDDEN"}})
node=node_collection.one({'_id':ObjectId(node_id)}) node=node_collection.one({'_id':ObjectId(node_id)})
#send notifications to all group members #send notifications to all group members
...@@ -860,18 +865,23 @@ def delete_thread(request,group_id,forum_id,node_id): ...@@ -860,18 +865,23 @@ def delete_thread(request,group_id,forum_id,node_id):
@login_required @login_required
@get_execution_time @get_execution_time
def edit_thread(request,group_id,forum_id,thread_id): def edit_thread(request,group_id,forum_id,thread_id):
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
forum=node_collection.one({'_id':ObjectId(forum_id)}) forum=node_collection.one({'_id':ObjectId(forum_id)})
thread=node_collection.one({'_id':ObjectId(thread_id)}) thread=node_collection.one({'_id':ObjectId(thread_id)})
exstng_reply = node_collection.find({'$and':[{'_type':'GSystem'},{'prior_node':ObjectId(forum._id)}]}) exstng_reply = node_collection.find({'$and':[{'_type':'GSystem'},{'prior_node':ObjectId(forum._id)}]})
...@@ -946,6 +956,10 @@ def delete_reply(request,group_id,forum_id,thread_id,node_id): ...@@ -946,6 +956,10 @@ def delete_reply(request,group_id,forum_id,thread_id,node_id):
# else : # else :
# pass # pass
#group_name, group_id = get_group_name_id(group_id)
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id) group_name, group_id = get_group_name_id(group_id)
activity = "" activity = ""
......
...@@ -72,19 +72,24 @@ def output(request, group_id, meetingid): ...@@ -72,19 +72,24 @@ def output(request, group_id, meetingid):
def dashb(request, group_id): #ramkarnani def dashb(request, group_id): #ramkarnani
"""Renders a list of all 'Page-type-GSystems' available within the database. """Renders a list of all 'Page-type-GSystems' available within the database.
""" """
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False: # if ins_objectid.is_valid(group_id) is False:
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else: # else:
group_ins = node_collection.find_one({'_type': "Group", "_id": ObjectId(group_id)}) # group_ins = node_collection.find_one({'_type': "Group", "_id": ObjectId(group_id)})
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
online_users = cache.get(CACHE_USERS) online_users = cache.get(CACHE_USERS)
online_users = simplejson.dumps(online_users, default=encode_json) online_users = simplejson.dumps(online_users, default=encode_json)
#print "\n inside meeting \n" #print "\n inside meeting \n"
......
...@@ -23,18 +23,23 @@ def module(request, group_id, module_id=None): ...@@ -23,18 +23,23 @@ def module(request, group_id, module_id=None):
""" """
* Renders a list of all 'modules' available within the database. * Renders a list of all 'modules' available within the database.
""" """
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
if module_id is None: if module_id is None:
module_ins = node_collection.find_one({'_type':"GSystemType", "name":"Module"}) module_ins = node_collection.find_one({'_type':"GSystemType", "name":"Module"})
...@@ -73,18 +78,23 @@ def module(request, group_id, module_id=None): ...@@ -73,18 +78,23 @@ def module(request, group_id, module_id=None):
@get_execution_time @get_execution_time
def module_detail(request, group_id, _id): def module_detail(request, group_id, _id):
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group","name": group_id}) # group_ins = node_collection.find_one({'_type': "Group","name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :
pass # pass
try:
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)
course_node = node_collection.one({"_id": ObjectId(_id)}) course_node = node_collection.one({"_id": ObjectId(_id)})
if course_node._type == "GSystemType": if course_node._type == "GSystemType":
return module(request, group_id, _id) return module(request, group_id, _id)
...@@ -104,18 +114,23 @@ def module_detail(request, group_id, _id): ...@@ -104,18 +114,23 @@ def module_detail(request, group_id, _id):
def delete_module(request, group_id, _id): def delete_module(request, group_id, _id):
"""This method will delete module object and its Attribute and Relation """This method will delete module object and its Attribute and Relation
""" """
ins_objectid = ObjectId() # ins_objectid = ObjectId()
if ins_objectid.is_valid(group_id) is False : # if ins_objectid.is_valid(group_id) is False :
group_ins = node_collection.find_one({'_type': "Group", "name": group_id}) # group_ins = node_collection.find_one({'_type': "Group", "name": group_id})
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if group_ins: # if group_ins:
group_id = str(group_ins._id) # group_id = str(group_ins._id)
else : # else :
auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) }) # auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
if auth : # if auth :
group_id = str(auth._id) # group_id = str(auth._id)
else : # else :