Example #1
0
def add_node(request, group_id):

    # ins_objectid  = ObjectId()
    # if ins_objectid.is_valid(group_id) is False :
    #     group_ins = node_collection.find_one({'_type': "Group","name": group_id})
    #     auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
    #     if group_ins:
    #         group_id = str(group_ins._id)
    #     else :
    #         auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
    #         if auth :
    #             group_id = str(auth._id)
    # else :
    #     pass
    group_name, group_id = get_group_name_id(group_id)

    try:
        auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
        content_org = request.POST.get("reply","")
        node = request.POST.get("node","")
        thread = request.POST.get("thread","") # getting thread _id
        forumid = request.POST.get("forumid","") # getting forum _id
        sup_id = request.POST.get("supnode","") #getting _id of it's parent node
        tw_name = request.POST.get("twistname","")
        upload_files_count=int(request.POST.get("upload_cnt",0))
        #print "upfiles=",upload_files_count
        lst=[]
        lstobj_collection=[]
        usrid = int(request.user.id)
        if upload_files_count > 0:
            #print "uploaded items",request.FILES.items()
            try:
                thread_obj = node_collection.one({'_id': ObjectId(thread)})
                access_policy = thread_obj.access_policy
            except:
                access_policy = u'PUBLIC'

            for key,value in request.FILES.items():
                fname=unicode(value.__dict__['_name'])
                #print "key=",key,"value=",value,"fname=",fname
                
                fileobj,fs=save_file(value,fname,usrid,group_id, "", "", username=unicode(request.user.username), access_policy=access_policy, count=0, first_object="")

                if type(fileobj) == list:
                    obid = str(list(fileobj)[1])
                else:
                    obid=str(fileobj)
                file_obj=node_collection.find_one({'_id': ObjectId(obid)})
                lstobj_collection.append(file_obj._id) 
        forumobj = ""
        groupobj = ""
        colg = node_collection.one({'_id':ObjectId(group_id)})
        if forumid:
            forumobj = node_collection.one({"_id": ObjectId(forumid)})
    
        sup = node_collection.one({"_id": ObjectId(sup_id)})
    
        if not sup :        
            return HttpResponse("failure")
    
        colrep = node_collection.collection.GSystem()
    
        if node == "Twist":
            name = tw_name
            colrep.member_of.append(twist_gst._id)
        elif node == "Reply":
            name = unicode("Reply of:"+str(sup._id))
            colrep.member_of.append(reply_gst._id)
        #Adding uploaded files id's in collection set of reply
        if upload_files_count > 0:
            colrep.collection_set = lstobj_collection   
    
        colrep.prior_node.append(sup._id)
        colrep.name = name
        
        if content_org:
            colrep.content_org = unicode(content_org)
            # Required to link temporary files with the current user who is modifying this document
            usrname = request.user.username
            filename = slugify(name) + "-" + usrname + "-"
            colrep.content = content_org

       
        colrep.created_by = usrid
        colrep.modified_by = usrid

        if usrid not in colrep.contributors:
            colrep.contributors.append(usrid)
        colrep.prior_node.append(sup._id)
        colrep.name = name

        if content_org:
            colrep.content_org = unicode(content_org)
            # Required to link temporary files with the current user who is modifying this document
            usrname = request.user.username
            filename = slugify(name) + "-" + usrname + "-"
            colrep.content = content_org

        usrid=int(request.user.id)
        colrep.created_by=usrid
        colrep.modified_by = usrid

        if usrid not in colrep.contributors:
            colrep.contributors.append(usrid)
        
        colrep.group_set.append(colg._id)

        colrep.save(groupid=group_id)

        # print "----------", colrep._id
        groupname = colg.name
        
        if node == "Twist" :  
            url="http://"+sitename+"/"+str(group_id)+"/forum/thread/"+str(colrep._id)
            activity=request.user.username+" -added a thread '"
            prefix="' on the forum '"+forumobj.name+"'"
            nodename=name
        
        if node == "Reply":
            threadobj=node_collection.one({"_id": ObjectId(thread)})
            url="http://"+sitename+"/"+str(group_id)+"/forum/thread/"+str(threadobj._id)
            activity=request.user.username+" -added a reply "
            prefix=" on the thread '"+threadobj.name+"' on the forum '"+forumobj.name+"'"
            nodename=""

        link = url

        for each in colg.author_set:
            if each != colg.created_by:
                bx=User.objects.get(id=each)
                msg=activity+"-"+nodename+prefix+" in the group '"+ groupname +"'\n"+"Please visit "+link+" to see the updated page"
                if bx:
                    no_check=forum_notification_status(group_id,auth._id)
                    if no_check:
                        ret = set_notif_val(request,group_id,msg,activity,bx)
        
        bx=User.objects.get(id=colg.created_by)
        msg=activity+"-"+nodename+prefix+" in the group '"+groupname+"' created by you"+"\n"+"Please visit "+link+" to see the updated page"   
        
        if bx:
            no_check=forum_notification_status(group_id,auth._id)
            if no_check:
                ret = set_notif_val(request,group_id,msg,activity,bx)
        if node == "Reply":
            # if exstng_reply:
            #     exstng_reply.prior_node =[]
            #     exstng_reply.prior_node.append(colrep._id)
            #     exstng_reply.save()

            threadobj=node_collection.one({"_id": ObjectId(thread)})
            variables=RequestContext(request,{'thread':threadobj,'user':request.user,'forum':forumobj,'groupid':group_id,'group_id':group_id})
            return render_to_response("ndf/refreshtwist.html",variables)
        else:
            templ=get_template('ndf/refreshthread.html')
            html = templ.render(Context({'forum':forumobj,'user':request.user,'groupid':group_id,'group_id':group_id}))
            return HttpResponse(html)

    except Exception as e:
        return HttpResponse(""+str(e))
    return HttpResponse("success")
Example #2
0
def create_thread(request, group_id, forum_id):
    '''
    Method to create thread
    '''

    forum = node_collection.one({'_id': ObjectId(forum_id)})

    # forum_data = {
    #                 'name':forum.name,
    #                 'content':forum.content,
    #                 'created_by':User.objects.get(id=forum.created_by).username
    #             }
    # print forum_data

    forum_threads = []
    exstng_reply = node_collection.find({'$and':[{'_type':'GSystem'},{'prior_node':ObjectId(forum._id)}],'status':{'$nin':['HIDDEN']}})
    exstng_reply.sort('created_at')
    for each in exstng_reply:
        forum_threads.append((each.name).strip().lower())

    if request.method == "POST":

        colg = node_collection.one({'_id':ObjectId(group_id)})

        name = unicode(request.POST.get('thread_name',""))
        content_org = request.POST.get('content_org',"")

        # -------------------
        colrep = node_collection.collection.GSystem()
        colrep.member_of.append(twist_gst._id)
        # ADDED ON 14th July
        colrep.access_policy = u"PUBLIC"
        colrep.url = set_all_urls(colrep.member_of)
        colrep.prior_node.append(forum._id)
        colrep.name = name
        if content_org:
            colrep.content_org = unicode(content_org)
            # Required to link temporary files with the current user who is modifying this document
            usrname = request.user.username
            filename = slugify(name) + "-" + usrname + "-"
            colrep.content = content_org

        usrid = int(request.user.id)
        colrep.created_by = usrid
        colrep.modified_by = usrid

        if usrid not in colrep.contributors:
            colrep.contributors.append(usrid)

        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)

        
        '''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)
                else:
                    no_check=True
                if no_check:
                    ret = set_notif_val(request,colg._id,msg,activity,bx)
        url_name = "/" + group_id + "/forum/thread/" + str(colrep._id)
        return HttpResponseRedirect(url_name)
        # variables = RequestContext(request,
        #                              {  'forum':forum,
        #                                 'thread':colrep,
        #                                 'eachrep':colrep,
        #                                 'groupid':group_id,
        #                                 'group_id':group_id,
        #                                 'user': request.user,
        #                                 'reply_count':0,
        #                                 'forum_threads': json.dumps(forum_threads),
        #                                 'forum_created_by':User.objects.get(id=forum.created_by).username
        #                             })
        # print "\n\n renedering to thread_details"
        # return render_to_response("ndf/thread_details.html",variables)

    else:
        return render_to_response("ndf/create_thread.html",
                                    {   'group_id':group_id,
                                        'groupid':group_id,
                                        'forum': forum,
                                        'forum_threads': json.dumps(forum_threads),
                                        'forum_created_by':User.objects.get(id=forum.created_by).username
                                    },
                              RequestContext(request))
Example #3
0
def edit_forum(request,group_id,forum_id):    
    '''
    Method to create forum and Retrieve all the forums
    '''
    forum = node_collection.one({ '_id': ObjectId(forum_id) })

    # # method to convert group_id to ObjectId if it is groupname
    # ins_objectid  = ObjectId()
    # if ins_objectid.is_valid(group_id) is False :
    #     group_ins = node_collection.find_one({'_type': "Group","name": group_id})
    #     auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
    #     if group_ins:
    #         group_id = str(group_ins._id)
    #     else :
    #         auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
    #         if auth :
    #             group_id = str(auth._id)
    # else :
    #     pass
    
    group_name, group_id = get_group_name_id(group_id)

    # getting all the values from submitted form
    if request.method == "POST":

        colg = node_collection.one({'_id':ObjectId(group_id)}) # getting group ObjectId

        colf = node_collection.one({'_id':ObjectId(forum_id)}) # creating new/empty GSystem object

        name = unicode(request.POST.get('forum_name',"")).strip() # forum name
        colf.name = name
        
        content_org = request.POST.get('content_org',"") # forum content
        if content_org:
            colf.content_org = unicode(content_org)
            usrname = request.user.username
            filename = slugify(name) + "-" + usrname + "-"
            colf.content = content_org
        
        usrid = int(request.user.id)
        usrname = unicode(request.user.username)
        
        colf.modified_by = usrid

        if usrid not in colf.contributors:
            colf.contributors.append(usrid)
        

        ################# ADDED 14th July.Its done!
        colf.access_policy = u"PUBLIC"
        colf.url = set_all_urls(colf.member_of)

        ### currently timed forum feature is not in use ###
        # sdate=request.POST.get('sdate',"")
        # shrs= request.POST.get('shrs',"") 
        # smts= request.POST.get('smts',"")
        
        # edate= request.POST.get('edate',"")
        # ehrs= request.POST.get('ehrs',"")
        # emts=request.POST.get('emts',"")
        
        # start_dt={}
        # end_dt={}
        
        # if not shrs:
        #     shrs=0
        # if not smts:
        #     smts=0
        # if sdate:
        #     sdate1=sdate.split("/") 
        #     st_date = datetime.datetime(int(sdate1[2]),int(sdate1[0]),int(sdate1[1]),int(shrs),int(smts))
        #     start_dt[start_time.name]=st_date
        
        # if not ehrs:
        #     ehrs=0
        # if not emts:
        #     emts=0
        # if edate:
        #     edate1=edate.split("/")
        #     en_date= datetime.datetime(int(edate1[2]),int(edate1[0]),int(edate1[1]),int(ehrs),int(emts))
        #     end_dt[end_time.name]=en_date
       # colf.attribute_set.append(start_dt)
       # colf.attribute_set.append(end_dt)
        colf.save(groupid=group_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/"+str(colf._id)
        for each in colg.author_set:
            bx=User.objects.get(id=each)
            activity="Edited forum"
            msg=usrname+" has edited forum -" +colf.name+" in the group -'"+colg.name+"'\n"+"Please visit "+link+" to see the forum."
            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)

        # returning response to ndf/forumdetails.html
        return HttpResponseRedirect(reverse('show', kwargs={'group_id':group_id,'forum_id': colf._id }))

        # variables=RequestContext(request,{'forum':colf})
        # return render_to_response("ndf/forumdetails.html",variables)

    # getting all the GSystem of forum to provide autocomplete/intellisence of forum names
    available_nodes = node_collection.find({'_type': u'GSystem', 'member_of': ObjectId(forum_gst._id),'group_set': ObjectId(group_id) })

    nodes_list = []
    for each in available_nodes:
      nodes_list.append(str((each.name).strip().lower()))

    return render_to_response("ndf/edit_forum.html",{'group_id':group_id,'groupid':group_id, 'nodes_list': nodes_list,'forum':forum},RequestContext(request))
Example #4
0
def add_node(request, group_id):

    # ins_objectid  = ObjectId()
    # if ins_objectid.is_valid(group_id) is False :
    #     group_ins = node_collection.find_one({'_type': "Group","name": group_id})
    #     auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
    #     if group_ins:
    #         group_id = str(group_ins._id)
    #     else :
    #         auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
    #         if auth :
    #             group_id = str(auth._id)
    # else :
    #     pass
    group_name, group_id = get_group_name_id(group_id)

    try:
        auth = node_collection.one({
            '_type': 'Author',
            'name': unicode(request.user.username)
        })
        content_org = request.POST.get("reply", "")
        node = request.POST.get("node", "")
        thread = request.POST.get("thread", "")  # getting thread _id
        forumid = request.POST.get("forumid", "")  # getting forum _id
        sup_id = request.POST.get("supnode",
                                  "")  #getting _id of it's parent node
        tw_name = request.POST.get("twistname", "")
        upload_files_count = int(request.POST.get("upload_cnt", 0))
        #print "upfiles=",upload_files_count
        lst = []
        lstobj_collection = []
        usrid = int(request.user.id)
        if upload_files_count > 0:
            #print "uploaded items",request.FILES.items()
            try:
                thread_obj = node_collection.one({'_id': ObjectId(thread)})
                access_policy = thread_obj.access_policy
            except:
                access_policy = u'PUBLIC'

            for key, value in request.FILES.items():
                fname = unicode(value.__dict__['_name'])
                #print "key=",key,"value=",value,"fname=",fname

                fileobj, fs = save_file(value,
                                        fname,
                                        usrid,
                                        group_id,
                                        "",
                                        "",
                                        username=unicode(
                                            request.user.username),
                                        access_policy=access_policy,
                                        count=0,
                                        first_object="")

                if type(fileobj) == list:
                    obid = str(list(fileobj)[1])
                else:
                    obid = str(fileobj)
                file_obj = node_collection.find_one({'_id': ObjectId(obid)})
                lstobj_collection.append(file_obj._id)
        forumobj = ""
        groupobj = ""
        colg = node_collection.one({'_id': ObjectId(group_id)})
        if forumid:
            forumobj = node_collection.one({"_id": ObjectId(forumid)})

        sup = node_collection.one({"_id": ObjectId(sup_id)})

        if not sup:
            return HttpResponse("failure")

        colrep = node_collection.collection.GSystem()

        if node == "Twist":
            name = tw_name
            colrep.member_of.append(twist_gst._id)
        elif node == "Reply":
            name = unicode("Reply of:" + str(sup._id))
            colrep.member_of.append(reply_gst._id)
        #Adding uploaded files id's in collection set of reply
        if upload_files_count > 0:
            colrep.collection_set = lstobj_collection

        colrep.prior_node.append(sup._id)
        colrep.name = name

        if content_org:
            colrep.content_org = unicode(content_org)
            # Required to link temporary files with the current user who is modifying this document
            usrname = request.user.username
            filename = slugify(name) + "-" + usrname + "-"
            colrep.content = content_org

        colrep.created_by = usrid
        colrep.modified_by = usrid

        if usrid not in colrep.contributors:
            colrep.contributors.append(usrid)
        colrep.prior_node.append(sup._id)
        colrep.name = name

        if content_org:
            colrep.content_org = unicode(content_org)
            # Required to link temporary files with the current user who is modifying this document
            usrname = request.user.username
            filename = slugify(name) + "-" + usrname + "-"
            colrep.content = content_org

        usrid = int(request.user.id)
        colrep.created_by = usrid
        colrep.modified_by = usrid

        if usrid not in colrep.contributors:
            colrep.contributors.append(usrid)

        colrep.group_set.append(colg._id)

        colrep.save(groupid=group_id)

        # print "----------", colrep._id
        groupname = colg.name

        if node == "Twist":
            url = "http://" + sitename + "/" + str(
                group_id) + "/forum/thread/" + str(colrep._id)
            activity = request.user.username + " -added a thread '"
            prefix = "' on the forum '" + forumobj.name + "'"
            nodename = name

        if node == "Reply":
            threadobj = node_collection.one({"_id": ObjectId(thread)})
            url = "http://" + sitename + "/" + str(
                group_id) + "/forum/thread/" + str(threadobj._id)
            activity = request.user.username + " -added a reply "
            prefix = " on the thread '" + threadobj.name + "' on the forum '" + forumobj.name + "'"
            nodename = ""

        link = url

        for each in colg.author_set:
            if each != colg.created_by:
                bx = User.objects.get(id=each)
                msg = activity + "-" + nodename + prefix + " in the group '" + groupname + "'\n" + "Please visit " + link + " to see the updated page"
                if bx:
                    no_check = forum_notification_status(group_id, auth._id)
                    if no_check:
                        ret = set_notif_val(request, group_id, msg, activity,
                                            bx)

        bx = User.objects.get(id=colg.created_by)
        msg = activity + "-" + nodename + prefix + " in the group '" + groupname + "' created by you" + "\n" + "Please visit " + link + " to see the updated page"

        if bx:
            no_check = forum_notification_status(group_id, auth._id)
            if no_check:
                ret = set_notif_val(request, group_id, msg, activity, bx)
        if node == "Reply":
            # if exstng_reply:
            #     exstng_reply.prior_node =[]
            #     exstng_reply.prior_node.append(colrep._id)
            #     exstng_reply.save()

            threadobj = node_collection.one({"_id": ObjectId(thread)})
            variables = RequestContext(
                request, {
                    'thread': threadobj,
                    'user': request.user,
                    'forum': forumobj,
                    'groupid': group_id,
                    'group_id': group_id
                })
            return render_to_response("ndf/refreshtwist.html", variables)
        else:
            templ = get_template('ndf/refreshthread.html')
            html = templ.render(
                Context({
                    'forum': forumobj,
                    'user': request.user,
                    'groupid': group_id,
                    'group_id': group_id
                }))
            return HttpResponse(html)

    except Exception as e:
        return HttpResponse("" + str(e))
    return HttpResponse("success")
Example #5
0
def create_thread(request, group_id, forum_id):
    '''
    Method to create thread
    '''

    forum = node_collection.one({'_id': ObjectId(forum_id)})

    # forum_data = {
    #                 'name':forum.name,
    #                 'content':forum.content,
    #                 'created_by':User.objects.get(id=forum.created_by).username
    #             }
    # print forum_data

    forum_threads = []
    exstng_reply = node_collection.find({
        '$and': [{
            '_type': 'GSystem'
        }, {
            'prior_node': ObjectId(forum._id)
        }],
        'status': {
            '$nin': ['HIDDEN']
        }
    })
    exstng_reply.sort('created_at')
    for each in exstng_reply:
        forum_threads.append((each.name).strip().lower())

    if request.method == "POST":

        colg = node_collection.one({'_id': ObjectId(group_id)})

        name = unicode(request.POST.get('thread_name', ""))
        content_org = request.POST.get('content_org', "")

        # -------------------
        colrep = node_collection.collection.GSystem()
        colrep.member_of.append(twist_gst._id)
        # ADDED ON 14th July
        colrep.access_policy = u"PUBLIC"
        colrep.url = set_all_urls(colrep.member_of)
        colrep.prior_node.append(forum._id)
        colrep.name = name
        if content_org:
            colrep.content_org = unicode(content_org)
            # Required to link temporary files with the current user who is modifying this document
            usrname = request.user.username
            filename = slugify(name) + "-" + usrname + "-"
            colrep.content = content_org

        usrid = int(request.user.id)
        colrep.created_by = usrid
        colrep.modified_by = usrid

        if usrid not in colrep.contributors:
            colrep.contributors.append(usrid)

        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])

        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:
                    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)
Example #6
0
def edit_forum(request, group_id, forum_id):
    '''
    Method to create forum and Retrieve all the forums
    '''
    forum = node_collection.one({'_id': ObjectId(forum_id)})

    # # method to convert group_id to ObjectId if it is groupname
    # ins_objectid  = ObjectId()
    # if ins_objectid.is_valid(group_id) is False :
    #     group_ins = node_collection.find_one({'_type': "Group","name": group_id})
    #     auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
    #     if group_ins:
    #         group_id = str(group_ins._id)
    #     else :
    #         auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })
    #         if auth :
    #             group_id = str(auth._id)
    # else :
    #     pass

    group_name, group_id = get_group_name_id(group_id)

    # getting all the values from submitted form
    if request.method == "POST":

        colg = node_collection.one({'_id': ObjectId(group_id)
                                    })  # getting group ObjectId

        colf = node_collection.one({'_id': ObjectId(forum_id)
                                    })  # creating new/empty GSystem object

        name = unicode(request.POST.get('forum_name',
                                        "")).strip()  # forum name
        colf.name = name

        content_org = request.POST.get('content_org', "")  # forum content
        if content_org:
            colf.content_org = unicode(content_org)
            usrname = request.user.username
            filename = slugify(name) + "-" + usrname + "-"
            colf.content = content_org

        usrid = int(request.user.id)
        usrname = unicode(request.user.username)

        colf.modified_by = usrid

        if usrid not in colf.contributors:
            colf.contributors.append(usrid)

        ################# ADDED 14th July.Its done!
        colf.access_policy = u"PUBLIC"
        colf.url = set_all_urls(colf.member_of)

        ### currently timed forum feature is not in use ###
        # sdate=request.POST.get('sdate',"")
        # shrs= request.POST.get('shrs',"")
        # smts= request.POST.get('smts',"")

        # edate= request.POST.get('edate',"")
        # ehrs= request.POST.get('ehrs',"")
        # emts=request.POST.get('emts',"")

        # start_dt={}
        # end_dt={}

        # if not shrs:
        #     shrs=0
        # if not smts:
        #     smts=0
        # if sdate:
        #     sdate1=sdate.split("/")
        #     st_date = datetime.datetime(int(sdate1[2]),int(sdate1[0]),int(sdate1[1]),int(shrs),int(smts))
        #     start_dt[start_time.name]=st_date

        # if not ehrs:
        #     ehrs=0
        # if not emts:
        #     emts=0
        # if edate:
        #     edate1=edate.split("/")
        #     en_date= datetime.datetime(int(edate1[2]),int(edate1[0]),int(edate1[1]),int(ehrs),int(emts))
        #     end_dt[end_time.name]=en_date
        # colf.attribute_set.append(start_dt)
        # colf.attribute_set.append(end_dt)
        colf.save(groupid=group_id)
        '''Code to send notification to all members of the group except those whose notification preference is turned OFF'''
        try:
            link = "http://" + sitename + "/" + str(
                colg._id) + "/forum/" + str(colf._id)
            for each in colg.author_set:
                bx = User.objects.get(id=each)
                activity = "Edited forum"
                msg = usrname + " has edited forum -" + colf.name + " in the group -'" + colg.name + "'\n" + "Please visit " + link + " to see the forum."
                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 as e:
            print e
        # returning response to ndf/forumdetails.html
        return HttpResponseRedirect(
            reverse('show',
                    kwargs={
                        'group_id': group_id,
                        'forum_id': colf._id
                    }))

        # variables=RequestContext(request,{'forum':colf})
        # return render_to_response("ndf/forumdetails.html",variables)

    # getting all the GSystem of forum to provide autocomplete/intellisence of forum names
    available_nodes = node_collection.find({
        '_type': u'GSystem',
        'member_of': ObjectId(forum_gst._id),
        'group_set': ObjectId(group_id)
    })

    nodes_list = []
    for each in available_nodes:
        nodes_list.append(str((each.name).strip().lower()))

    return render_to_response(
        "ndf/edit_forum.html", {
            'group_id': group_id,
            'groupid': group_id,
            'nodes_list': nodes_list,
            'forum': forum
        }, RequestContext(request))