Пример #1
0
def delete_task(request, group_name, _id):
    """This method will delete task object and its Attribute and Relation
    """
    # ins_objectid  = ObjectId()
    # if ins_objectid.is_valid(group_name) is False :
    #     group_ins = node_collection.find_one({'_type': "Group", "name": group_name})
    #     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

    try:
        group_id = ObjectId(group_name)
    except:
        group_name, group_id = get_group_name_id(group_name)

    pageurl = request.GET.get("next", "")
    try:
        node = node_collection.one({'_id': ObjectId(_id)})
        if node:
            attributes = triple_collection.find({
                '_type': 'GAttribute',
                'subject': node._id
            })
            relations = triple_collection.find({
                '_type': 'GRelation',
                'subject': node._id
            })
            if attributes.count() > 0:
                for each in attributes:
                    triple_collection.one({'_id': each['_id']}).delete()

            if relations.count() > 0:
                for each in relations:
                    triple_collection.one({'_id': each['_id']}).delete()
            if len(node.post_node) > 0:
                for each in node.post_node:
                    sys_each_postnode = node_collection.find_one({'_id': each})
                    member_of_name = node_collection.find_one({
                        '_id':
                        sys_each_postnode.member_of[0]
                    }).name
                    if member_of_name == "Task":
                        sys_each_postnode.prior_node.remove(node._id)
                        sys_each_postnode.save(groupid=group_id)
                    if member_of_name == "task_update_history":
                        sys_each_postnode.delete(groupid=group_id)

            node.delete()
    except Exception as e:
        print "Exception:", e

    return HttpResponseRedirect(
        reverse('task', kwargs={'group_name': group_name}))
Пример #2
0
def delete_task(request, group_name, _id):
    """This method will delete task object and its Attribute and Relation
    """
    # ins_objectid  = ObjectId()
    # if ins_objectid.is_valid(group_name) is False :
    #     group_ins = node_collection.find_one({'_type': "Group", "name": group_name})
    #     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

    try:
        group_id = ObjectId(group_name)
    except:
        group_name, group_id = get_group_name_id(group_name)

    pageurl = request.GET.get("next", "")
    try:
        node = node_collection.one({'_id': ObjectId(_id)})
        if node:
            attributes = triple_collection.find({'_type': 'GAttribute', 'subject': node._id})
            relations = triple_collection.find({'_type': 'GRelation', 'subject': node._id})
            if attributes.count() > 0:
                for each in attributes:
                    triple_collection.one({'_id': each['_id']}).delete()

            if relations.count() > 0:
                for each in relations:
                    triple_collection.one({'_id': each['_id']}).delete()
	    if len(node.post_node) > 0 :
		for each in node.post_node :
		    sys_each_postnode = node_collection.find_one({'_id': each})
		    member_of_name = node_collection.find_one({'_id': sys_each_postnode.member_of[0]}).name
		    if member_of_name == "Task" :
			sys_each_postnode.prior_node.remove(node._id)
			sys_each_postnode.save(groupid=group_id)
		    if member_of_name == "task_update_history":
			sys_each_postnode.delete(groupid=group_id)

            node.delete()
    except Exception as e:
        print "Exception:", e

    return HttpResponseRedirect(reverse('task', kwargs={'group_name': group_name }))
Пример #3
0
def unit_order_list(request, group_id, node_id):
    response_dict = {"success": False}
    unit_id_list = request.POST.get('unit_list', [])
    print "untlst:", unit_id_list
    try:
        items_sort_list_gattr_node = triple_collection.one({
            '_type':
            'GAttribute',
            'subject':
            ObjectId(node_id),
            'attribute_type':
            at_items_sort_list._id,
            'status':
            u'PUBLISHED'
        })
        if items_sort_list_gattr_node:
            ga_node = delete_gattribute(node_id=items_sort_list_gattr_node._id,
                                        deletion_type=0)

        if unit_id_list:
            unit_id_list = json.loads(unit_id_list)
            unit_obj_list = map(
                lambda each_id: Node.get_node_by_id(ObjectId(each_id)),
                unit_id_list)
            ga_node = create_gattribute(ObjectId(node_id), 'items_sort_list',
                                        unit_obj_list)
            response_dict["success"] = True

    except Exception as module_order_list_err:
        print "\nError Occurred in module_order_list(). ", module_order_list_err
        pass
    return HttpResponse(json.dumps(response_dict))
Пример #4
0
def remove_stud_from_batch(request, group_id):
    group_name, group_id = get_group_name_id(group_id)
    if request.is_ajax() and request.method == "POST":
        batch_id = request.POST.get("batch_id", '')
        stud_id = request.POST.get("stud_id", '')
        rt_has_batch_member = node_collection.one({
            '_type': 'RelationType',
            'name': 'has_batch_member'
        })
        grelation_node = triple_collection.one({
            '_type':
            'GRelation',
            'relation_type':
            rt_has_batch_member._id,
            'subject':
            ObjectId(batch_id),
            'status':
            u'PUBLISHED',
            'right_subject':
            ObjectId(stud_id)
        })
        rel_name = grelation_node.relation_type.name
        inv_rel_name = grelation_node.relation_type.inverse_name
        subj = grelation_node.subject
        right_subj = grelation_node.right_subject

        # Remove right-subject-node's ObjectId from the value
        # corresponding to subject-node's "relation-name" key
        # referenced in relation_set field
        res = node_collection.collection.update(
            {
                '_id': subj,
                'relation_set.' + rel_name: {
                    '$exists': True
                }
            }, {'$pull': {
                'relation_set.$.' + rel_name: right_subj
            }},
            upsert=False,
            multi=False)
        # Remove subject-node's ObjectId from the value corresponding
        # to right-subject-node's "inverse-relation-name" key
        # referenced in relation_set field
        res = node_collection.collection.update(
            {
                '_id': right_subj,
                'relation_set.' + inv_rel_name: {
                    '$exists': True
                }
            }, {'$pull': {
                'relation_set.$.' + inv_rel_name: subj
            }},
            upsert=False,
            multi=False)

        grelation_node.status = u"DELETED"
        grelation_node.save(groupid=group_id)
        status = "success"
        return HttpResponse(json.dumps(status, cls=NodeJSONEncoder))
Пример #5
0
def delete_module(request, group_id, _id):
    """This method will delete module object and its Attribute and Relation
    """
    # 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
    try:
        group_id = ObjectId(group_id)
    except:
        group_name, group_id = get_group_name_id(group_id)

    pageurl = request.GET.get("next", "")
    try:
        node = node_collection.one({'_id': ObjectId(_id)})
        if node:
            attributes = triple_collection.find({
                '_type': 'GAttribute',
                'subject': node._id
            })
            relations = triple_collection.find({
                '_type': 'GRelation',
                'subject': node._id
            })
            if attributes.count() > 0:
                for each in attributes:
                    triple_collection.one({'_id': each['_id']}).delete()

            if relations.count() > 0:
                for each in relations:
                    triple_collection.one({'_id': each['_id']}).delete()
            node.delete()
    except Exception as e:
        print "Exception:", e
    return HttpResponseRedirect(pageurl)
Пример #6
0
def delete_module(request, group_id, _id):
    """This method will delete module object and its Attribute and Relation
    """
    # 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
    try:
        group_id = ObjectId(group_id)
    except:
        group_name, group_id = get_group_name_id(group_id)
        
    pageurl = request.GET.get("next", "")
    try:
        node = node_collection.one({'_id': ObjectId(_id)})
        if node:
            attributes = triple_collection.find({'_type': 'GAttribute', 'subject': node._id})
            relations = triple_collection.find({'_type': 'GRelation', 'subject': node._id})
            if attributes.count() > 0:
                for each in attributes:
                    triple_collection.one({'_id': each['_id']}).delete()
                    
            if relations.count() > 0:
                for each in relations:
                    triple_collection.one({'_id': each['_id']}).delete()
            node.delete()
    except Exception as e:
        print "Exception:", e
    return HttpResponseRedirect(pageurl)
Пример #7
0
def show_translation(request, group_id, node_id, lang):
    '''
    for VIEW/READ: show translated provided node to provided LANG CODE
    lang could be either proper/full language-name/language-code
    '''
    node = translated_node_id = None
    grel_node = triple_collection.one({
        '_type': 'GRelation',
        'subject': ObjectId(node_id),
        'relation_type': rt_translation_of._id,
        'language': get_language_tuple(lang),
        # 'status': 'PUBLISHED'
    })

    if grel_node:
        node = Node.get_node_by_id(grel_node.right_subject)
        translated_node_id = node._id

    # code to show other translations
    other_translations_grels = triple_collection.find({
        '_type':
        u'GRelation',
        'subject':
        ObjectId(node_id),
        'relation_type':
        rt_translation_of._id,
        'right_subject': {
            '$nin': [translated_node_id]
        }
    })

    other_translations = node_collection.find(
        {'_id': {
            '$in': [r.right_subject for r in other_translations_grels]
        }})

    # --- END of code to show other translations

    return render_to_response("ndf/translate_detail.html", {
        'group_id': Group.get_group_name_id(group_id)[1],
        'groupid': Group.get_group_name_id(group_id)[1],
        'source_node_id': node_id,
        'source_node_obj': Node.get_node_by_id(node_id),
        'node': node,
        'other_translations': other_translations,
        'card_url_name': 'show_translation',
    },
                              context_instance=RequestContext(request))
Пример #8
0
def module_order_list(request):
    response_dict = {"success": False}
    module_id_list = request.POST.get('module_list', [])
    try:
        items_sort_list_gattr_node = triple_collection.one({'_type': 'GAttribute', 'subject': group_id, 
            'attribute_type': at_items_sort_list._id, 'status': u'PUBLISHED'})
        if items_sort_list_gattr_node:
            ga_node = delete_gattribute(node_id=items_sort_list_gattr_node._id, deletion_type=0)

        if module_id_list:
            module_id_list = json.loads(module_id_list)
            module_obj_list = map(lambda each_id: Node.get_node_by_id(ObjectId(each_id)), module_id_list)
            ga_node = create_gattribute(ObjectId(group_id), 'items_sort_list', module_obj_list)
            response_dict["success"] = True

    except Exception as module_order_list_err:
        print "\nError Occurred in module_order_list(). ", module_order_list_err
        pass
    return HttpResponse(json.dumps(response_dict))
Пример #9
0
def remove_stud_from_batch(request, group_id):
    group_name, group_id = get_group_name_id(group_id)
    if request.is_ajax() and request.method == "POST":
        batch_id = request.POST.get("batch_id", '')
        stud_id = request.POST.get("stud_id", '')
        rt_has_batch_member = node_collection.one({'_type':'RelationType','name':'has_batch_member'})
        grelation_node = triple_collection.one({'_type':'GRelation',
                        'relation_type.$id':rt_has_batch_member._id,
                        'subject':ObjectId(batch_id),'status':u'PUBLISHED',
                        'right_subject': ObjectId(stud_id)})
        rel_name = grelation_node.relation_type.name
        inv_rel_name = grelation_node.relation_type.inverse_name
        subj = grelation_node.subject
        right_subj = grelation_node.right_subject

        # Remove right-subject-node's ObjectId from the value
        # corresponding to subject-node's "relation-name" key
        # referenced in relation_set field
        res = node_collection.collection.update({
            '_id': subj,
            'relation_set.' + rel_name: {'$exists': True}
        }, {
            '$pull': {'relation_set.$.' + rel_name: right_subj}
        },
            upsert=False, multi=False
        )
        # Remove subject-node's ObjectId from the value corresponding
        # to right-subject-node's "inverse-relation-name" key
        # referenced in relation_set field
        res = node_collection.collection.update({
            '_id': right_subj,
            'relation_set.' + inv_rel_name: {'$exists': True}
        }, {
            '$pull': {'relation_set.$.' + inv_rel_name: subj}
        },
            upsert=False, multi=False
        )

        grelation_node.status = u"DELETED"
        grelation_node.save(groupid=group_id)
        status = "success"
        return HttpResponse(json.dumps(status, cls=NodeJSONEncoder))
Пример #10
0
def show_translation(request, group_id, node_id, lang):
    '''
    for VIEW/READ: show translated provided node to provided LANG CODE
    lang could be either proper/full language-name/language-code
    '''
    node = translated_node_id = None
    grel_node = triple_collection.one({
                            '_type': 'GRelation',
                            'subject': ObjectId(node_id),
                            'relation_type': rt_translation_of._id,
                            'language': get_language_tuple(lang),
                            # 'status': 'PUBLISHED'
                        })

    if grel_node:
        node = Node.get_node_by_id(grel_node.right_subject)
        translated_node_id = node._id

    # code to show other translations
    other_translations_grels = triple_collection.find({
                            '_type': u'GRelation',
                            'subject': ObjectId(node_id),
                            'relation_type': rt_translation_of._id,
                            'right_subject': {'$nin': [translated_node_id]}
                        })

    other_translations = node_collection.find({'_id': {'$in': [r.right_subject for r in other_translations_grels]} })

    # --- END of code to show other translations

    return render_to_response("ndf/translate_detail.html",
                          {
                            'group_id': Group.get_group_name_id(group_id)[1],
                            'groupid': Group.get_group_name_id(group_id)[1],
                            'source_node_id': node_id,
                            'source_node_obj': Node.get_node_by_id(node_id),
                            'node': node,
                            'other_translations': other_translations,
                            'card_url_name': 'show_translation',
                           },
                          context_instance=RequestContext(request))
Пример #11
0
def lesson_create_edit(request, group_id, unit_group_id=None):
    '''
    creation as well as edit of lessons
    returns following:
    {
        'success': <BOOL: 0 or 1>,
        'unit_hierarchy': <unit hierarchy json>,
        'msg': <error msg or objectid of newly created obj>
    }
    '''
    # parent_group_name, parent_group_id = Group.get_group_name_id(group_id)

    # parent unit id
    lesson_id = request.POST.get('lesson_id', None)
    lesson_language = request.POST.get('sel_lesson_lang', '')
    unit_id_post = request.POST.get('unit_id', '')
    lesson_content = request.POST.get('lesson_desc', '')
    # print "lesson_id: ", lesson_id
    # print "lesson_language: ", lesson_language
    # print "unit_id_post: ", unit_id_post
    unit_group_id = unit_id_post if unit_id_post else unit_group_id
    # getting parent unit object
    unit_group_obj = Group.get_group_name_id(unit_group_id, get_obj=True)
    result_dict = {'success': 0, 'unit_hierarchy': [], 'msg': ''}
    if request.method == "POST":
        # lesson name
        lesson_name = request.POST.get('name', '').strip()
        if not lesson_name:
            msg = 'Name can not be empty.'
            result_dict = {'success': 0, 'unit_hierarchy': [], 'msg': msg}
            # return HttpResponse(0)

        # check for uniqueness of name
        # unit_cs: unit collection_set
        unit_cs_list = unit_group_obj.collection_set
        unit_cs_objs_cur = Node.get_nodes_by_ids_list(unit_cs_list)
        if unit_cs_objs_cur:
            unit_cs_names_list = [u.name for u in unit_cs_objs_cur]

        if not lesson_id and unit_cs_objs_cur and lesson_name in unit_cs_names_list:  # same name activity
            # currently following logic was only for "en" nodes.
            # commented and expecting following in future:
            # check for uniqueness w.r.t language selected within all sibling lessons's translated nodes

            # lesson_obj = Node.get_node_by_id(lesson_id)
            # if lesson_language != lesson_obj.language[0]:
            #     if lesson_language:
            #         language = get_language_tuple(lesson_language)
            #         lesson_obj.language = language
            #         lesson_obj.save()
            msg = u'Activity with same name exists in lesson: ' + unit_group_obj.name
            result_dict = {'success': 0, 'unit_hierarchy': [], 'msg': msg}

        elif lesson_id and ObjectId.is_valid(lesson_id):  # Update
            # getting default, "en" node:
            if lesson_language != "en":
                node = translated_node_id = None
                grel_node = triple_collection.one({
                    '_type':
                    'GRelation',
                    'subject':
                    ObjectId(lesson_id),
                    'relation_type':
                    rt_translation_of._id,
                    'language':
                    get_language_tuple(lesson_language),
                    # 'status': 'PUBLISHED'
                })

                if grel_node:
                    # grelation found.
                    # transalated node exists.
                    # edit of existing translated node.

                    # node = Node.get_node_by_id(grel_node.right_subject)
                    # translated_node_id = node._id
                    lesson_id = grel_node.right_subject
                else:
                    # grelation NOT found.
                    # create transalated node.
                    user_id = request.user.id
                    new_lesson_obj = node_collection.collection.GSystem()
                    new_lesson_obj.fill_gstystem_values(
                        name=lesson_name,
                        content=lesson_content,
                        member_of=gst_lesson_id,
                        group_set=unit_group_obj._id,
                        created_by=user_id,
                        status=u'PUBLISHED')
                    # print new_lesson_obj
                    if lesson_language:
                        language = get_language_tuple(lesson_language)
                        new_lesson_obj.language = language
                    new_lesson_obj.save(groupid=group_id)

                    trans_grel_list = [ObjectId(new_lesson_obj._id)]
                    trans_grels = triple_collection.find({'_type': 'GRelation', \
                            'relation_type': rt_translation_of._id,'subject': ObjectId(lesson_id)},{'_id': 0, 'right_subject': 1})
                    for each_rel in trans_grels:
                        trans_grel_list.append(each_rel['right_subject'])
                    # translate_grel = create_grelation(node_id, rt_translation_of, trans_grel_list, language=language)

                    create_grelation(lesson_id,
                                     rt_translation_of,
                                     trans_grel_list,
                                     language=language)

            lesson_obj = Node.get_node_by_id(lesson_id)
            if lesson_obj and (lesson_obj.name != lesson_name):
                trans_lesson = get_lang_node(lesson_obj._id, lesson_language)
                if trans_lesson:
                    trans_lesson.name = lesson_name
                else:
                    lesson_obj.name = lesson_name
                # if lesson_language:
                #     language = get_language_tuple(lesson_language)
                #     lesson_obj.language = language
                lesson_obj.save(group_id=group_id)

                unit_structure = get_unit_hierarchy(unit_group_obj,
                                                    request.LANGUAGE_CODE)
                msg = u'Lesson name updated.'
                result_dict = {
                    'success': 1,
                    'unit_hierarchy': unit_structure,
                    'msg': str(lesson_obj._id)
                }
            else:
                unit_structure = get_unit_hierarchy(unit_group_obj,
                                                    request.LANGUAGE_CODE)
                msg = u'Nothing to update.'
                result_dict = {
                    'success': 1,
                    'unit_hierarchy': unit_structure,
                    'msg': msg
                }

        else:  # creating a fresh lesson object
            user_id = request.user.id
            new_lesson_obj = node_collection.collection.GSystem()
            new_lesson_obj.fill_gstystem_values(name=lesson_name,
                                                content=lesson_content,
                                                member_of=gst_lesson_id,
                                                group_set=unit_group_obj._id,
                                                created_by=user_id,
                                                status=u'PUBLISHED')
            # print new_lesson_obj
            if lesson_language:
                language = get_language_tuple(lesson_language)
                new_lesson_obj.language = language
            new_lesson_obj.save(groupid=group_id)
            unit_group_obj.collection_set.append(new_lesson_obj._id)
            unit_group_obj.save(groupid=group_id)

            unit_structure = get_unit_hierarchy(unit_group_obj,
                                                request.LANGUAGE_CODE)

            msg = u'Added lesson under lesson: ' + unit_group_obj.name
            result_dict = {
                'success': 1,
                'unit_hierarchy': unit_structure,
                'msg': str(new_lesson_obj._id)
            }
            # return HttpResponse(json.dumps(unit_structure))

    # return HttpResponse(1)
    return HttpResponse(json.dumps(result_dict))
Пример #12
0
def translate(request, group_id, node_id, lang, translated_node_id=None, **kwargs):
    '''
    for EDIT: translate provided node to provided LANG CODE
    lang could be either proper/full language-name/language-code
    `node_id` is _id of source node.
    '''
    group_name, group_id = Group.get_group_name_id(group_id)
    language = get_language_tuple(lang)
    source_obj = Node.get_node_by_id(node_id)

    existing_grel = translate_grel = translated_node = None

    if translated_node_id:
        translated_node = Node.get_node_by_id(translated_node_id)
    else:
        # get translated_node
        existing_grel = triple_collection.one({
                                            '_type': 'GRelation',
                                            'subject': ObjectId(node_id),
                                            'relation_type': rt_translation_of._id,
                                            'language': language
                                        })

        if existing_grel:
            # get existing translated_node
            translated_node = Node.get_node_by_id(existing_grel.right_subject)
            translate_grel = existing_grel

    if request.method == 'GET':
        return render_to_response("ndf/translate_form.html",
                              {
                                'group_id': group_id,
                                'node_obj': translated_node,
                                'source_obj': source_obj,
                                'post_url': reverse('translate', kwargs={
                                        'group_id': group_id,
                                        'node_id': node_id,
                                        'lang': lang,
                                        })
                               },
                              context_instance=RequestContext(request))

    elif request.method == 'POST':  # explicit `if` check for `POST`
        if not translated_node:
            # create a new translated new
            # translated_node = node_collection.collection.GSystem()
            # copy source_obj's data into a new
            if source_obj._type == "Group":
                translated_node = node_collection.collection.GSystem()
                exclude_fields = ['_id','member_of','_type','type_of','modified_by','prior_node','post_node']
                for each in translated_node:
                    if each not in exclude_fields:
                        translated_node[each] = source_obj[each]
                translated_node.group_set.append(source_obj._id)
            else:
                translated_node = source_obj.__deepcopy__()
                translated_node['_id'] = ObjectId()

        translated_node.fill_gstystem_values(request=request,
                                            language=language,
                                            **kwargs)
        trans_alt_name = request.POST.get('altnames', None)
        
        translated_node.altnames = unicode(trans_alt_name)
        translated_node.member_of = [ObjectId(trans_node_gst_id)]
        translated_node.save(group_id=group_id)
        if not existing_grel:
            trans_grel_list = [ObjectId(translated_node._id)]
            trans_grels = triple_collection.find({'_type': 'GRelation', \
                            'relation_type': rt_translation_of._id,'subject': ObjectId(node_id)},{'_id': 0, 'right_subject': 1})
            for each_rel in trans_grels:
                trans_grel_list.append(each_rel['right_subject'])
            translate_grel = create_grelation(node_id, rt_translation_of, trans_grel_list, language=language)

    # page_gst_name, page_gst_id = Node.get_name_id_from_type('Page', 'GSystemType')
    # return HttpResponseRedirect(reverse('page_details', kwargs={'group_id': group_id, 'app_id': page_gst_id }))
    # return HttpResponseRedirect(reverse('all_translations', kwargs={'group_id': group_id, 'node_id': node_id }))
    return HttpResponseRedirect(reverse('show_translation', kwargs={'group_id': group_id, 'node_id': node_id, 'lang': lang }))
Пример #13
0
def restore_triple_objects(rcs_triples_path):
    print "\nRestoring Triples.."
    global log_file
    log_file.write("\nRestoring Triples. ")
    for dir_, _, files in os.walk(rcs_triples_path):
        for filename in files:
            filepath =  os.path.join(dir_, filename)
            triple_json = get_json_file(filepath)
            if triple_json and ('_id' in triple_json):
                triple_obj = triple_collection.one({'_id': ObjectId(triple_json['_id'])})
            else:
                triple_obj = None

            if triple_obj:
                log_file.write("\n Found Existing Triple : \n\t " + str(triple_obj))
                triple_obj = update_schema_id_for_triple(triple_obj)
                log_file.write("\n Updated Triple : \n\t " + str(triple_obj))
                triple_obj.save()
                if triple_obj._type == "GRelation":
                    if triple_obj.right_subject != triple_json['right_subject']:
                        if type(triple_obj.right_subject) == list:
                            triple_collection.collection.update(
                                {'_id': triple_obj._id},
                                {'$addToSet': {'right_subject': triple_json['right_subject']}},
                                multi=False, upsert=False)
                        else:
                            triple_collection.collection.update(
                                {'_id': triple_obj._id},
                                {'$set': {'right_subject': triple_json['right_subject']}},
                                multi=False, upsert=False)
                        log_file.write("\n GRelation Updated : \n\t OLD: " + str(triple_obj), + "\n\tNew: "+str(triple_json))

                if triple_obj._type == "GAttribute":
                    if triple_obj.object_value != triple_json['object_value']:
                        if type(triple_obj.object_value) == list:
                            triple_collection.collection.update(
                                {'_id': triple_obj._id},
                                {'$addToSet': {'object_value': triple_json['object_value']}},
                                multi=False, upsert=False)
                        else:
                            triple_collection.collection.update(
                                {'_id': triple_obj._id},
                                {'$set': {'object_value': triple_json['object_value']}},
                                multi=False, upsert=False)
                        log_file.write("\n GAttribute Updated: \n\t OLD: " + str(triple_obj) + "\n\tNew: "+str(triple_json))
            else:
                copy_version_file(filepath)
                log_file.write("\n RCS file copied : \n\t" + str(filepath))

                try:
                    log_file.write("\n Inserting Triple doc : " + str(triple_json))
                    triple_json = update_schema_id_for_triple(triple_json)

                    node_id = triple_collection.collection.insert(triple_json)
                    triple_obj = triple_collection.one({'_id': node_id})
                    triple_node_RT_AT_id = None
                    # if 'attribute_type' in triple_json:
                    #     triple_node_RT_AT_id = triple_json['attribute_type']
                    # else:
                    #     triple_node_RT_AT_id = triple_json['relation_type']
                    # triple_node_RT_AT = node_collection.one({'_id': ObjectId(triple_node_RT_AT_id)})
                    # triple_obj.save(triple_node=triple_node_RT_AT, triple_id=triple_node_RT_AT._id)
                    triple_obj.save()
                    log_file.write("\nUpdate RCS using save()")
                except Exception as tr_insert_err:
                    log_file.write("\nError while inserting Triple obj" + str(tr_insert_err))
                    pass
Пример #14
0
def setup_default_gapps():
  '''
  This sets up default GAPPS for group(s).
  '''

  default_gapps_names_list = ["Page", "File", "Forum", "MIS", "Task", "Batch", "Event"]# "Meeting"]
  info_message = "\n Default GAPPS names: " + str(default_gapps_names_list)

  # Fetch GAPPS and populate their document-node in a different list
  default_gapps_list = [] # Will hold document of each corresponding GAPP name from above given list
  meta_type_gapp = node_collection.one({'_type': "MetaType", 'name': META_TYPE[0]})
  info_message += "\n Default GAPPS list: \n"
  for each in default_gapps_names_list:
    gapp_node = node_collection.one({'_type': "GSystemType", 'member_of': meta_type_gapp._id, 'name': each})

    if gapp_node:
      default_gapps_list.append(gapp_node)
      info_message += " " + gapp_node.name + "("+str(gapp_node._id)+")\n"

  log_list.append(info_message)

  # If length of list-of-names & list-of-documents doesn't match throw Exception
  if len(default_gapps_names_list) != len(default_gapps_list):
    error_message = "\n GAPPSSetupError: Few GAPPS not found!!!\n"
    log_list.append(error_message)
    raise Exception(error_message)

  # Fetch AttributeType node - apps_list
  at_apps_list = node_collection.one({'_type': "AttributeType", 'name': "apps_list"})
  if not at_apps_list:
    error_message = "\n GAPPSSetupError: AttributeType (apps_list) doesn't exists.. please create explicitly!!!\n"
    log_list.append(error_message)
    raise Exception(error_message)
  info_message = "\n AttributeType: " + at_apps_list.name + "("+str(at_apps_list._id)+")\n"
  log_list.append(info_message)

  # Fetch MIS_admin group - required for fetching GSystems of College GSystemType
  mis_admin = node_collection.one({'_type': "Group",
                                   '$or': [{'name': {'$regex': u"MIS_admin", '$options': 'i'}},
                                           {'altnames': {'$regex': u"MIS_admin", '$options': 'i'}}],
                                   'group_type': "PRIVATE"
                                  },
                                  {'name': 1}
                                  )
  if not mis_admin:
    error_message = "\n GAPPSSetupError: Group (MIS_admin) doesn't exists.. please check!!!\n"
    log_list.append(error_message)
    raise Exception(error_message)
  info_message = "\n Group: " + mis_admin.name + "("+str(mis_admin._id)+")\n"
  log_list.append(info_message)

  # Fetch GSystems of College GSystemType belonging to MIS_admin group
  college = node_collection.one({'_type': "GSystemType", 'name': u"College"}, {'name': 1})
  if not college:
    error_message = "\n GAPPSSetupError: GSystemType (College) doesn't exists.. please check!!!\n"
    log_list.append(error_message)
    raise Exception(error_message)
  info_message = "\n GSystemType: " + college.name + "("+str(college._id)+")\n"
  log_list.append(info_message)

  college_cur = list(node_collection.find({'_type': "GSystem", 'member_of': college._id, 'group_set': mis_admin._id}))

  for i, each in enumerate(college_cur):
    g = node_collection.one({'_type': "Group", 'name': each.name, 'group_type': "PRIVATE"}, {'name': 1})
    if g:
      info_message = "\n "+str(i+1)+") Setting GAPPS for this college group ("+g.name+" -- "+str(g._id)+")\n"
      log_list.append(info_message)

      is_apps_list = triple_collection.one({'_type': "GAttribute", 'subject': g._id, 'attribute_type': at_apps_list._id})
      if is_apps_list:
        info_message = " Default GAPPs list already exists for Group ("+g.name+" -- "+str(g._id)+"), so overriding it..."
        log_list.append(info_message)
        res = triple_collection.collection.update({'_id': is_apps_list._id}, {'$set': {'object_value': default_gapps_list}}, upsert=False, multi=False)
        if res["n"]:
          is_apps_list.reload()
          info_message = "\n Successfully overridden: " + str(is_apps_list._id) + "\n"
          log_list.append(info_message)
        else:
          info_message = "\n Not overridden: " + str(is_apps_list._id) + "\n"
          log_list.append(info_message)

      else:
        info_message = " Default GAPPs list doesn't exists for Group ("+g.name+" -- "+str(g._id)+"), so creating..."
        log_list.append(info_message)
        ga = create_gattribute(g._id, at_apps_list, default_gapps_list)
        info_message = "\n Successfully created: " + str(ga._id) + "\n"
        log_list.append(info_message)

    else:
      error_message = "\n GAPPSSetupError: This college group ("+each.name+") doesn't exists.. please create explicitly!!!\n"
      log_list.append(error_message)
Пример #15
0
def setup_default_gapps():
    '''
  This sets up default GAPPS for group(s).
  '''

    default_gapps_names_list = [
        "Page", "File", "Forum", "MIS", "Task", "Batch", "Event"
    ]  # "Meeting"]
    info_message = "\n Default GAPPS names: " + str(default_gapps_names_list)

    # Fetch GAPPS and populate their document-node in a different list
    default_gapps_list = [
    ]  # Will hold document of each corresponding GAPP name from above given list
    meta_type_gapp = node_collection.one({
        '_type': "MetaType",
        'name': META_TYPE[0]
    })
    info_message += "\n Default GAPPS list: \n"
    for each in default_gapps_names_list:
        gapp_node = node_collection.one({
            '_type': "GSystemType",
            'member_of': meta_type_gapp._id,
            'name': each
        })

        if gapp_node:
            default_gapps_list.append(gapp_node)
            info_message += " " + gapp_node.name + "(" + str(
                gapp_node._id) + ")\n"

    log_list.append(info_message)

    # If length of list-of-names & list-of-documents doesn't match throw Exception
    if len(default_gapps_names_list) != len(default_gapps_list):
        error_message = "\n GAPPSSetupError: Few GAPPS not found!!!\n"
        log_list.append(error_message)
        raise Exception(error_message)

    # Fetch AttributeType node - apps_list
    at_apps_list = node_collection.one({
        '_type': "AttributeType",
        'name': "apps_list"
    })
    if not at_apps_list:
        error_message = "\n GAPPSSetupError: AttributeType (apps_list) doesn't exists.. please create explicitly!!!\n"
        log_list.append(error_message)
        raise Exception(error_message)
    info_message = "\n AttributeType: " + at_apps_list.name + "(" + str(
        at_apps_list._id) + ")\n"
    log_list.append(info_message)

    # Fetch MIS_admin group - required for fetching GSystems of College GSystemType
    mis_admin = node_collection.one(
        {
            '_type':
            "Group",
            '$or': [{
                'name': {
                    '$regex': u"MIS_admin",
                    '$options': 'i'
                }
            }, {
                'altnames': {
                    '$regex': u"MIS_admin",
                    '$options': 'i'
                }
            }],
            'group_type':
            "PRIVATE"
        }, {'name': 1})
    if not mis_admin:
        error_message = "\n GAPPSSetupError: Group (MIS_admin) doesn't exists.. please check!!!\n"
        log_list.append(error_message)
        raise Exception(error_message)
    info_message = "\n Group: " + mis_admin.name + "(" + str(
        mis_admin._id) + ")\n"
    log_list.append(info_message)

    # Fetch GSystems of College GSystemType belonging to MIS_admin group
    college = node_collection.one({
        '_type': "GSystemType",
        'name': u"College"
    }, {'name': 1})
    if not college:
        error_message = "\n GAPPSSetupError: GSystemType (College) doesn't exists.. please check!!!\n"
        log_list.append(error_message)
        raise Exception(error_message)
    info_message = "\n GSystemType: " + college.name + "(" + str(
        college._id) + ")\n"
    log_list.append(info_message)

    college_cur = list(
        node_collection.find({
            '_type': "GSystem",
            'member_of': college._id,
            'group_set': mis_admin._id
        }))

    for i, each in enumerate(college_cur):
        g = node_collection.one(
            {
                '_type': "Group",
                'name': each.name,
                'group_type': "PRIVATE"
            }, {'name': 1})
        if g:
            info_message = "\n " + str(
                i + 1
            ) + ") Setting GAPPS for this college group (" + g.name + " -- " + str(
                g._id) + ")\n"
            log_list.append(info_message)

            is_apps_list = triple_collection.one({
                '_type':
                "GAttribute",
                'subject':
                g._id,
                'attribute_type':
                at_apps_list._id
            })
            if is_apps_list:
                info_message = " Default GAPPs list already exists for Group (" + g.name + " -- " + str(
                    g._id) + "), so overriding it..."
                log_list.append(info_message)
                res = triple_collection.collection.update(
                    {'_id': is_apps_list._id},
                    {'$set': {
                        'object_value': default_gapps_list
                    }},
                    upsert=False,
                    multi=False)
                if res["n"]:
                    is_apps_list.reload()
                    info_message = "\n Successfully overridden: " + str(
                        is_apps_list._id) + "\n"
                    log_list.append(info_message)
                else:
                    info_message = "\n Not overridden: " + str(
                        is_apps_list._id) + "\n"
                    log_list.append(info_message)

            else:
                info_message = " Default GAPPs list doesn't exists for Group (" + g.name + " -- " + str(
                    g._id) + "), so creating..."
                log_list.append(info_message)
                ga = create_gattribute(g._id, at_apps_list, default_gapps_list)
                info_message = "\n Successfully created: " + str(ga._id) + "\n"
                log_list.append(info_message)

        else:
            error_message = "\n GAPPSSetupError: This college group (" + each.name + ") doesn't exists.. please create explicitly!!!\n"
            log_list.append(error_message)
Пример #16
0
def translate(request,
              group_id,
              node_id,
              lang,
              translated_node_id=None,
              **kwargs):
    '''
    for EDIT: translate provided node to provided LANG CODE
    lang could be either proper/full language-name/language-code
    `node_id` is _id of source node.
    '''
    group_name, group_id = Group.get_group_name_id(group_id)
    language = get_language_tuple(lang)
    source_obj = Node.get_node_by_id(node_id)

    existing_grel = translate_grel = translated_node = None

    if translated_node_id:
        translated_node = Node.get_node_by_id(translated_node_id)
    else:
        # get translated_node
        existing_grel = triple_collection.one({
            '_type':
            'GRelation',
            'subject':
            ObjectId(node_id),
            'relation_type':
            rt_translation_of._id,
            'language':
            language
        })

        if existing_grel:
            # get existing translated_node
            translated_node = Node.get_node_by_id(existing_grel.right_subject)
            translate_grel = existing_grel

    if request.method == 'GET':
        return render_to_response("ndf/translate_form.html", {
            'group_id':
            group_id,
            'node_obj':
            translated_node,
            'source_obj':
            source_obj,
            'post_url':
            reverse('translate',
                    kwargs={
                        'group_id': group_id,
                        'node_id': node_id,
                        'lang': lang,
                    }),
            'cancel_url':
            reverse('show_translation',
                    kwargs={
                        'group_id': group_id,
                        'node_id': node_id,
                        'lang': lang,
                    })
        },
                                  context_instance=RequestContext(request))

    elif request.method == 'POST':  # explicit `if` check for `POST`
        if not translated_node:
            # create a new translated new
            # translated_node = node_collection.collection.GSystem()
            # copy source_obj's data into a new
            if source_obj._type == "Group":
                translated_node = node_collection.collection.GSystem()
                exclude_fields = [
                    '_id', 'member_of', '_type', 'type_of', 'modified_by',
                    'prior_node', 'post_node'
                ]
                for each in translated_node:
                    if each not in exclude_fields:
                        translated_node[each] = source_obj[each]
                translated_node.group_set.append(source_obj._id)
            else:
                translated_node = source_obj.__deepcopy__()
                translated_node['_id'] = ObjectId()

        translated_node.fill_gstystem_values(request=request,
                                             language=language,
                                             **kwargs)
        trans_alt_name = request.POST.get('altnames', None)

        translated_node.altnames = unicode(trans_alt_name)
        translated_node.member_of = [ObjectId(trans_node_gst_id)]
        translated_node.save(group_id=group_id)
        if not existing_grel:
            trans_grel_list = [ObjectId(translated_node._id)]
            trans_grels = triple_collection.find({'_type': 'GRelation', \
                            'relation_type': rt_translation_of._id,'subject': ObjectId(node_id)},{'_id': 0, 'right_subject': 1})
            for each_rel in trans_grels:
                trans_grel_list.append(each_rel['right_subject'])
            translate_grel = create_grelation(node_id,
                                              rt_translation_of,
                                              trans_grel_list,
                                              language=language)

    # page_gst_name, page_gst_id = Node.get_name_id_from_type('Page', 'GSystemType')
    # return HttpResponseRedirect(reverse('page_details', kwargs={'group_id': group_id, 'app_id': page_gst_id }))
    # return HttpResponseRedirect(reverse('all_translations', kwargs={'group_id': group_id, 'node_id': node_id }))
    return HttpResponseRedirect(
        reverse('show_translation',
                kwargs={
                    'group_id': group_id,
                    'node_id': node_id,
                    'lang': lang
                }))
Пример #17
0
def lesson_create_edit(request, group_id, unit_group_id=None):
    '''
    creation as well as edit of lessons
    returns following:
    {
        'success': <BOOL: 0 or 1>,
        'unit_hierarchy': <unit hierarchy json>,
        'msg': <error msg or objectid of newly created obj>
    }
    '''
    # parent_group_name, parent_group_id = Group.get_group_name_id(group_id)

    # parent unit id
    lesson_id = request.POST.get('lesson_id', None)
    lesson_language = request.POST.get('sel_lesson_lang','')
    unit_id_post = request.POST.get('unit_id', '')
    lesson_content = request.POST.get('lesson_desc', '')
    # print "lesson_id: ", lesson_id
    # print "lesson_language: ", lesson_language
    # print "unit_id_post: ", unit_id_post
    unit_group_id = unit_id_post if unit_id_post else unit_group_id
    # getting parent unit object
    unit_group_obj = Group.get_group_name_id(unit_group_id, get_obj=True)
    result_dict = {'success': 0, 'unit_hierarchy': [], 'msg': ''}
    if request.method == "POST":
        # lesson name
        lesson_name = request.POST.get('name', '').strip()
        if not lesson_name:
            msg = 'Name can not be empty.'
            result_dict = {'success': 0, 'unit_hierarchy': [], 'msg': msg}
            # return HttpResponse(0)

        # check for uniqueness of name
        # unit_cs: unit collection_set
        unit_cs_list = unit_group_obj.collection_set
        unit_cs_objs_cur = Node.get_nodes_by_ids_list(unit_cs_list)
        if unit_cs_objs_cur:
            unit_cs_names_list = [u.name for u in unit_cs_objs_cur]

        if not lesson_id and unit_cs_objs_cur  and  lesson_name in unit_cs_names_list:  # same name activity
            # currently following logic was only for "en" nodes.
            # commented and expecting following in future:
            # check for uniqueness w.r.t language selected within all sibling lessons's translated nodes

            # lesson_obj = Node.get_node_by_id(lesson_id)
            # if lesson_language != lesson_obj.language[0]:
            #     if lesson_language:
            #         language = get_language_tuple(lesson_language)
            #         lesson_obj.language = language
            #         lesson_obj.save()
            msg = u'Activity with same name exists in lesson: ' + unit_group_obj.name
            result_dict = {'success': 0, 'unit_hierarchy': [], 'msg': msg}

        elif lesson_id and ObjectId.is_valid(lesson_id):  # Update
            # getting default, "en" node:
            if lesson_language != "en":
                node = translated_node_id = None
                grel_node = triple_collection.one({
                                        '_type': 'GRelation',
                                        'subject': ObjectId(lesson_id),
                                        'relation_type': rt_translation_of._id,
                                        'language': get_language_tuple(lesson_language),
                                        # 'status': 'PUBLISHED'
                                    })

                if grel_node:
                    # grelation found.
                    # transalated node exists.
                    # edit of existing translated node.

                    # node = Node.get_node_by_id(grel_node.right_subject)
                    # translated_node_id = node._id
                    lesson_id = grel_node.right_subject
                else:
                    # grelation NOT found.
                    # create transalated node.
                    user_id = request.user.id
                    new_lesson_obj = node_collection.collection.GSystem()
                    new_lesson_obj.fill_gstystem_values(name=lesson_name,
                                                    content=lesson_content,
                                                    member_of=gst_lesson_id,
                                                    group_set=unit_group_obj._id,
                                                    created_by=user_id,
                                                    status=u'PUBLISHED')
                    # print new_lesson_obj
                    if lesson_language:
                        language = get_language_tuple(lesson_language)
                        new_lesson_obj.language = language
                    new_lesson_obj.save(groupid=group_id)
                    
                    trans_grel_list = [ObjectId(new_lesson_obj._id)]
                    trans_grels = triple_collection.find({'_type': 'GRelation', \
                            'relation_type': rt_translation_of._id,'subject': ObjectId(lesson_id)},{'_id': 0, 'right_subject': 1})
                    for each_rel in trans_grels:
                        trans_grel_list.append(each_rel['right_subject'])
                    # translate_grel = create_grelation(node_id, rt_translation_of, trans_grel_list, language=language)

                    create_grelation(lesson_id, rt_translation_of, trans_grel_list, language=language)

            lesson_obj = Node.get_node_by_id(lesson_id)
            if lesson_obj and (lesson_obj.name != lesson_name):
                trans_lesson = get_lang_node(lesson_obj._id,lesson_language)
                if trans_lesson:
                    trans_lesson.name = lesson_name
                else:
                    lesson_obj.name = lesson_name
                # if lesson_language:
                #     language = get_language_tuple(lesson_language)
                #     lesson_obj.language = language
                lesson_obj.save(group_id=group_id)

                unit_structure = get_unit_hierarchy(unit_group_obj, request.LANGUAGE_CODE)
                msg = u'Lesson name updated.'
                result_dict = {'success': 1, 'unit_hierarchy': unit_structure, 'msg': str(lesson_obj._id)}
            else:
                unit_structure = get_unit_hierarchy(unit_group_obj, request.LANGUAGE_CODE)
                msg = u'Nothing to update.'
                result_dict = {'success': 1, 'unit_hierarchy': unit_structure, 'msg': msg}

        else: # creating a fresh lesson object
            user_id = request.user.id
            new_lesson_obj = node_collection.collection.GSystem()
            new_lesson_obj.fill_gstystem_values(name=lesson_name,
                                            content=lesson_content,
                                            member_of=gst_lesson_id,
                                            group_set=unit_group_obj._id,
                                            created_by=user_id,
                                            status=u'PUBLISHED')
            # print new_lesson_obj
            if lesson_language:
                language = get_language_tuple(lesson_language)
                new_lesson_obj.language = language
            new_lesson_obj.save(groupid=group_id)
            unit_group_obj.collection_set.append(new_lesson_obj._id)
            unit_group_obj.save(groupid=group_id)

            unit_structure = get_unit_hierarchy(unit_group_obj, request.LANGUAGE_CODE)

            msg = u'Added lesson under lesson: ' + unit_group_obj.name
            result_dict = {'success': 1, 'unit_hierarchy': unit_structure, 'msg': str(new_lesson_obj._id)}
            # return HttpResponse(json.dumps(unit_structure))

    # return HttpResponse(1)
    return HttpResponse(json.dumps(result_dict))
Пример #18
0
def restore_triple_objects(rcs_triples_path):
    print "\nRestoring Triples.."
    global log_file
    log_file.write("\nRestoring Triples. ")
    for dir_, _, files in os.walk(rcs_triples_path):
        for filename in files:
            filepath =  os.path.join(dir_, filename)
            triple_json = get_json_file(filepath)
            if triple_json and ('_id' in triple_json):
                triple_obj = triple_collection.one({'_id': ObjectId(triple_json['_id'])})
            else:
                triple_obj = None

            if triple_obj:
                log_file.write("\n Found Existing Triple : \n\t " + str(triple_obj))
                triple_obj = update_schema_id_for_triple(triple_obj)
                log_file.write("\n Updated Triple : \n\t " + str(triple_obj))
                triple_obj.save()
                if triple_obj._type == "GRelation":
                    if triple_obj.right_subject != triple_json['right_subject']:
                        if type(triple_obj.right_subject) == list:
                            triple_collection.collection.update(
                                {'_id': triple_obj._id},
                                {'$addToSet': {'right_subject': triple_json['right_subject']}},
                                multi=False, upsert=False)
                        else:
                            triple_collection.collection.update(
                                {'_id': triple_obj._id},
                                {'$set': {'right_subject': triple_json['right_subject']}},
                                multi=False, upsert=False)
                        log_file.write("\n GRelation Updated : \n\t OLD: " + str(triple_obj), + "\n\tNew: "+str(triple_json))

                if triple_obj._type == "GAttribute":
                    if triple_obj.object_value != triple_json['object_value']:
                        if type(triple_obj.object_value) == list:
                            triple_collection.collection.update(
                                {'_id': triple_obj._id},
                                {'$addToSet': {'object_value': triple_json['object_value']}},
                                multi=False, upsert=False)
                        else:
                            triple_collection.collection.update(
                                {'_id': triple_obj._id},
                                {'$set': {'object_value': triple_json['object_value']}},
                                multi=False, upsert=False)
                        log_file.write("\n GAttribute Updated: \n\t OLD: " + str(triple_obj) + "\n\tNew: "+str(triple_json))
            else:
                copy_version_file(filepath)
                log_file.write("\n RCS file copied : \n\t" + str(filepath))

                try:
                    log_file.write("\n Inserting Triple doc : " + str(triple_json))
                    triple_json = update_schema_id_for_triple(triple_json)

                    node_id = triple_collection.collection.insert(triple_json)
                    triple_obj = triple_collection.one({'_id': node_id})
                    triple_node_RT_AT_id = None
                    # if 'attribute_type' in triple_json:
                    #     triple_node_RT_AT_id = triple_json['attribute_type']
                    # else:
                    #     triple_node_RT_AT_id = triple_json['relation_type']
                    # triple_node_RT_AT = node_collection.one({'_id': ObjectId(triple_node_RT_AT_id)})
                    # triple_obj.save(triple_node=triple_node_RT_AT, triple_id=triple_node_RT_AT._id)
                    triple_obj.save()
                    log_file.write("\nUpdate RCS using save()")
                except Exception as tr_insert_err:
                    log_file.write("\nError while inserting Triple obj" + str(tr_insert_err))
                    pass