Commit ea5e4789 authored by Kedar A.'s avatar Kedar A. 💻

Fixed error while thread creation.

parent 9cec8ce2
......@@ -1534,7 +1534,7 @@ class GSystemType(Node):
gst_id = ObjectId(gst_name_or_id) if ObjectId.is_valid(gst_name_or_id) else None
gst_obj = node_collection.one({
"_type": "GSystemType",
"_type": {"$in": ["GSystemType", "MetaType"]},
"$or":[
{"_id": gst_id},
{"name": unicode(gst_name_or_id)}
......
......@@ -535,27 +535,31 @@ def create_thread(request, group_id, forum_id):
colrep.group_set.append(colg._id)
colrep.save(groupid=group_id)
has_thread_rt = node_collection.one({"_type": "RelationType", "name": u"has_thread"})
gr = create_grelation(forum._id, has_thread_rt, colrep._id)
gr = create_grelation(forum._id, has_thread_rt, [colrep._id])
'''Code to send notification to all members of the group except those whose notification preference is turned OFF'''
link="http://"+sitename+"/"+str(colg._id)+"/forum/thread/"+str(colrep._id)
for each in colg.author_set:
bx=User.objects.filter(id=each)
if bx:
bx=User.objects.get(id=each)
else:
continue
activity="Added thread"
msg=request.user.username+" has added a thread in the forum " + forum.name + " in the group -'" + colg.name+"'\n"+"Please visit "+link+" to see the thread."
if bx:
auth = node_collection.one({'_type': 'Author', 'name': unicode(bx.username) })
if colg._id and auth:
no_check=forum_notification_status(colg._id,auth._id)
try:
'''Code to send notification to all members of the group except those whose notification preference is turned OFF'''
link="http://"+sitename+"/"+str(colg._id)+"/forum/thread/"+str(colrep._id)
for each in colg.author_set:
bx=User.objects.filter(id=each)
if bx:
bx=User.objects.get(id=each)
else:
no_check=True
if no_check:
ret = set_notif_val(request,colg._id,msg,activity,bx)
continue
activity="Added thread"
msg=request.user.username+" has added a thread in the forum " + forum.name + " in the group -'" + colg.name+"'\n"+"Please visit "+link+" to see the thread."
if bx:
auth = node_collection.one({'_type': 'Author', 'name': unicode(bx.username) })
if colg._id and auth:
no_check=forum_notification_status(colg._id,auth._id)
else:
no_check=True
if no_check:
ret = set_notif_val(request,colg._id,msg,activity,bx)
except Exception, e:
print e
url_name = "/" + group_id + "/forum/thread/" + str(colrep._id)
return HttpResponseRedirect(url_name)
# variables = RequestContext(request,
......
......@@ -2941,9 +2941,8 @@ def create_grelation(subject_id, relation_type_node, right_subject_id_or_list, *
else:
# Case: When already existing entry doesn't exists in newly come list of right_subject(s)
# So change their status from PUBLISHED to DELETED
# right_subject_id_or_list.remove(n.right_subject)
n.status = u"DELETED"
n.save()
n.save(triple_node=relation_type_node, triple_id=relation_type_node._id)
info_message = " MultipleGRelation: GRelation (" + n.name + \
") status updated from 'PUBLISHED' to 'DELETED' successfully.\n"
......
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