def handle(self, *args, **options):

        history_manager = HistoryManager()
        rcs_obj = RCS()

        collection = get_database()[Triple.collection_name]
        cur = collection.Triple.find({'_type': 'GAttribute'})

        for n in cur:
            if type(n['attribute_type']) == ObjectId:
                attr_type = collection.Node.one({'_id': n['attribute_type']})
                if attr_type:
                    collection.update({'_id': n['_id']}, {
                        '$set': {
                            'attribute_type': {
                                "$ref": attr_type.collection_name,
                                "$id": attr_type._id,
                                "$db": attr_type.db.name
                            }
                        }
                    })
                else:
                    collection.remove({'_id': n['_id']})

            subject_doc = collection.Node.one({'_id': n.subject})
            n.name = subject_doc.name + " -- " + n.attribute_type[
                'name'] + " -- " + n.object_value

            # Creates a history (version-file) for GAttribute documents
            if history_manager.create_or_replace_json_file(n):
                fp = history_manager.get_file_path(n)
                message = "This document (" + n.name + ") is created on " + subject_doc.created_at.strftime(
                    "%d %B %Y")
                rcs_obj.checkin(fp, 1, message.encode('utf-8'), "-i")
    def handle(self, *args, **options):

        history_manager = HistoryManager()
        rcs_obj = RCS()

        collection = get_database()[Triple.collection_name]
        cur = collection.Triple.find({"_type": "GAttribute"})

        for n in cur:
            if type(n["attribute_type"]) == ObjectId:
                attr_type = collection.Node.one({"_id": n["attribute_type"]})
                if attr_type:
                    collection.update(
                        {"_id": n["_id"]},
                        {
                            "$set": {
                                "attribute_type": {
                                    "$ref": attr_type.collection_name,
                                    "$id": attr_type._id,
                                    "$db": attr_type.db.name,
                                }
                            }
                        },
                    )
                else:
                    collection.remove({"_id": n["_id"]})

            subject_doc = collection.Node.one({"_id": n.subject})
            n.name = subject_doc.name + " -- " + n.attribute_type["name"] + " -- " + n.object_value

            # Creates a history (version-file) for GAttribute documents
            if history_manager.create_or_replace_json_file(n):
                fp = history_manager.get_file_path(n)
                message = "This document (" + n.name + ") is created on " + subject_doc.created_at.strftime("%d %B %Y")
                rcs_obj.checkin(fp, 1, message.encode("utf-8"), "-i")
Exemplo n.º 3
0
from gnowsys_ndf.ndf.org2any import org2html
from gnowsys_ndf.ndf.views.methods import get_node_common_fields, get_translate_common_fields, get_page, get_resource_type, diff_string, get_node_metadata, create_grelation_list, get_execution_time, parse_data
from gnowsys_ndf.ndf.management.commands.data_entry import create_gattribute
from gnowsys_ndf.ndf.views.html_diff import htmldiff
from gnowsys_ndf.ndf.views.methods import get_versioned_page, get_page, get_resource_type, diff_string, node_thread_access
from gnowsys_ndf.ndf.views.methods import create_gattribute, create_grelation, get_group_name_id, create_thread_for_node, delete_grelation

from gnowsys_ndf.ndf.templatetags.ndf_tags import group_type_info, get_relation_value

from gnowsys_ndf.mobwrite.diff_match_patch import diff_match_patch

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

gst_page = node_collection.one({'_type': 'GSystemType', 'name': GAPPS[0]})
history_manager = HistoryManager()
rcs = RCS()
app = gst_page

#######################################################################################################################################
# VIEWS DEFINED FOR GAPP -- 'PAGE'
#######################################################################################################################################


@get_execution_time
def page(request, group_id, app_id=None, page_no=1):
    """Renders a list of all 'Page-type-GSystems' available within the database.
    """
    try:
        group_id = ObjectId(group_id)
    except:
        group_name, group_id = get_group_name_id(group_id)