Exemplo n.º 1
0
def image_detail(request, group_id, _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
    try:
        group_id = ObjectId(group_id)
    except:
        group_name, group_id = get_group_name_id(group_id)

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

    # First get the navigation list till topic from theme map
    nav_l=request.GET.get('nav_li','')
    breadcrumbs_list = []
    nav_li = ""

    if nav_l:
      nav_li = nav_l

    if img_node._type == "GSystemType":
    	return imageDashboard(request, group_id, _id)
    img_node.get_neighbourhood(img_node.member_of)
    thread_node = None
    allow_to_comment = None
    thread_node, allow_to_comment = node_thread_access(group_id, img_node)

    imageCollection = node_collection.find({'member_of': {'$all': [ObjectId(GST_IMAGE._id)]},
                                              '_type': 'File','fs_file_ids': {'$ne': []},
                                              'group_set': {'$all': [ObjectId(group_id)]},
                                              '$or': [
                                                {'access_policy': u"PUBLIC"},
                                                {'$and': [
                                                  {'access_policy': u"PRIVATE"},
                                                  {'created_by': request.user.id}
                                                  ]
                                                }
                                              ]
                                            }).sort("last_update", -1)

    return render_to_response("ndf/image_detail.html",
                                  { 'node': img_node,
                                    'group_id': group_id, 'nav_list':nav_li,
                                    'node_has_thread': thread_node,
                                    'allow_to_comment':allow_to_comment,
                                    'groupid':group_id, 'imageCollection': imageCollection
                                  },
                                  context_instance = RequestContext(request)
        )
Exemplo n.º 2
0
def image_detail(request, group_id, _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
    try:
        group_id = ObjectId(group_id)
    except:
        group_name, group_id = get_group_name_id(group_id)

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

    # First get the navigation list till topic from theme map
    nav_l=request.GET.get('nav_li','')
    breadcrumbs_list = []
    nav_li = ""

    if nav_l:
      nav_li = nav_l

    if img_node._type == "GSystemType":
    	return imageDashboard(request, group_id, _id)
    img_node.get_neighbourhood(img_node.member_of)
    thread_node = None
    allow_to_comment = None
    thread_node, allow_to_comment = node_thread_access(group_id, img_node)

    imageCollection = node_collection.find({'member_of': {'$all': [ObjectId(GST_IMAGE._id)]},
                                              '_type': 'File','fs_file_ids': {'$ne': []},
                                              'group_set': {'$all': [ObjectId(group_id)]},
                                              '$or': [
                                                {'access_policy': u"PUBLIC"},
                                                {'$and': [
                                                  {'access_policy': u"PRIVATE"},
                                                  {'created_by': request.user.id}
                                                  ]
                                                }
                                              ]
                                            }).sort("last_update", -1)

    return render_to_response("ndf/image_detail.html",
                                  { 'node': img_node,
                                    'group_id': group_id, 'nav_list':nav_li,
                                    'node_has_thread': thread_node,
                                    'allow_to_comment':allow_to_comment,
                                    'groupid':group_id, 'imageCollection': imageCollection
                                  },
                                  context_instance = RequestContext(request)
        )
Exemplo n.º 3
0
def video_detail(request, group_id, _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
    try:
        group_id = ObjectId(group_id)
    except:
        group_name, group_id = get_group_name_id(group_id)

    vid_node = node_collection.one({"_id": ObjectId(_id)})
    vid_node.get_neighbourhood(vid_node.member_of)
    thread_node = None
    allow_to_comment = None
    thread_node, allow_to_comment = node_thread_access(group_id, vid_node)

    # First get the navigation list till topic from theme map
    nav_l=request.GET.get('nav_li','')
    breadcrumbs_list = []
    nav_li = ""

    if nav_l:
      nav_li = nav_l

    if vid_node._type == "GSystemType":
        return videoDashboard(request, group_id, _id)
    video_obj=request.GET.get("vid_id","")
    return render_to_response("ndf/video_detail.html",
                                  { 'node': vid_node,
                                    'node_has_thread': thread_node,
                                    'allow_to_comment':allow_to_comment,
                                    'group_id': group_id,
                                    'groupid':group_id, 'nav_list':nav_li,
                                    'video_obj':video_obj
                                  },
                                  context_instance = RequestContext(request)
        )
Exemplo n.º 4
0
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)

    if app_id is None:
        app_ins = node_collection.find_one({
            '_type': "GSystemType",
            "name": "Page"
        })
        if app_ins:
            app_id = str(app_ins._id)
    from gnowsys_ndf.settings import GSTUDIO_NO_OF_OBJS_PP
    content = []
    version = []
    con = []
    group_object = node_collection.one({'_id': ObjectId(group_id)})

    # Code for user shelf
    shelves = []
    shelf_list = {}
    auth = node_collection.one({
        '_type': 'Author',
        'name': unicode(request.user.username)
    })

    if request.method == "POST":
        title = gst_page.name
        search_field = request.POST['search_field']
        page_nodes = node_collection.find({
            'member_of': {
                '$all': [ObjectId(app_id)]
            },
            '$or': [{
                '$and': [{
                    'name': {
                        '$regex': search_field,
                        '$options': 'i'
                    }
                }, {
                    '$or': [{
                        'access_policy': u"PUBLIC"
                    }, {
                        '$and': [{
                            'access_policy': u"PRIVATE"
                        }, {
                            'created_by': request.user.id
                        }]
                    }]
                }]
            }, {
                '$and': [{
                    'tags': {
                        '$regex': search_field,
                        '$options': 'i'
                    }
                }, {
                    '$or': [{
                        'access_policy': u"PUBLIC"
                    }, {
                        '$and': [{
                            'access_policy': u"PRIVATE"
                        }, {
                            'created_by': request.user.id
                        }]
                    }]
                }]
            }],
            'group_set': {
                '$all': [ObjectId(group_id)]
            },
            'status': {
                '$nin': ['HIDDEN']
            }
        }).sort('last_update', -1)
        paginator_pages = paginator.Paginator(page_nodes, page_no,
                                              GSTUDIO_NO_OF_OBJS_PP)
        return render_to_response("ndf/page_list.html", {
            'title': title,
            'appId': app._id,
            'shelf_list': shelf_list,
            'shelves': shelves,
            'searching': True,
            'query': search_field,
            'page_nodes': page_nodes,
            'groupid': group_id,
            'group_id': group_id,
            'page_info': paginator_pages
        },
                                  context_instance=RequestContext(request))

    elif gst_page._id == ObjectId(app_id):
        group_type = node_collection.one({'_id': ObjectId(group_id)})
        group_info = group_type_info(group_id)
        node = node_collection.find({'member_of': ObjectId(app_id)})
        title = gst_page.name
        """
          Below query returns only those documents:
          (a) which are pages,
          (b) which belongs to given group,
          (c) which has status either as DRAFT or PUBLISHED, and
          (d) which has access_policy either as PUBLIC or if PRIVATE then it's created_by must be the logged-in user
        """
        page_nodes = node_collection.find({
            'member_of': {
                '$all': [ObjectId(app_id)]
            },
            'group_set': {
                '$all': [ObjectId(group_id)]
            },
            '$or': [{
                'access_policy': u"PUBLIC"
            }, {
                '$and': [{
                    'access_policy': u"PRIVATE"
                }, {
                    'created_by': request.user.id
                }]
            }],
            'status': {
                '$nin': ['HIDDEN']
            }
        }).sort('last_update', -1)
        paginator_pages = paginator.Paginator(page_nodes, page_no,
                                              GSTUDIO_NO_OF_OBJS_PP)
        return render_to_response("ndf/page_list.html", {
            'title': title,
            'appId': app._id,
            'shelf_list': shelf_list,
            'shelves': shelves,
            'page_nodes': page_nodes,
            'groupid': group_id,
            'group_id': group_id,
            'page_info': paginator_pages
        },
                                  context_instance=RequestContext(request))

    else:
        # Page Single instance view
        page_node = node_collection.one({"_id": ObjectId(app_id)})
        thread_node = None
        allow_to_comment = None
        annotations = None
        if page_node:
            annotations = json.dumps(page_node.annotations)
            page_node.get_neighbourhood(page_node.member_of)

            thread_node, allow_to_comment = node_thread_access(
                group_id, page_node)
        return render_to_response('ndf/page_details.html', {
            'node': page_node,
            'node_has_thread': thread_node,
            'appId': app._id,
            'group_id': group_id,
            'shelf_list': shelf_list,
            'allow_to_comment': allow_to_comment,
            'annotations': annotations,
            'shelves': shelves,
            'groupid': group_id
        },
                                  context_instance=RequestContext(request))
Exemplo n.º 5
0
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)

    if app_id is None:
        app_ins = node_collection.find_one({'_type': "GSystemType", "name": "Page"})
        if app_ins:
            app_id = str(app_ins._id)
    from gnowsys_ndf.settings import GSTUDIO_NO_OF_OBJS_PP
    content=[]
    version=[]
    con=[]
    group_object = node_collection.one({'_id': ObjectId(group_id)})

    # Code for user shelf
    shelves = []
    shelf_list = {}
    auth = node_collection.one({'_type': 'Author', 'name': unicode(request.user.username) })


    if request.method == "POST":
        title = gst_page.name
        search_field = request.POST['search_field']
        page_nodes = node_collection.find({
                                            'member_of': {'$all': [ObjectId(app_id)]},
                                            '$or': [
                                              {'$and': [
                                                {'name': {'$regex': search_field, '$options': 'i'}},
                                                {'$or': [
                                                  {'access_policy': u"PUBLIC"},
                                                  {'$and': [{'access_policy': u"PRIVATE"}, {'created_by': request.user.id}]}
                                                  ]
                                                }
                                                ]
                                              },
                                              {'$and': [
                                                {'tags': {'$regex':search_field, '$options': 'i'}},
                                                {'$or': [
                                                  {'access_policy': u"PUBLIC"},
                                                  {'$and': [{'access_policy': u"PRIVATE"}, {'created_by': request.user.id}]}
                                                  ]
                                                }
                                                ]
                                              }
                                            ],
                                            'group_set': {'$all': [ObjectId(group_id)]},
                                            'status': {'$nin': ['HIDDEN']}
                                        }).sort('last_update', -1)
        paginator_pages = paginator.Paginator(page_nodes, page_no, GSTUDIO_NO_OF_OBJS_PP)
        return render_to_response("ndf/page_list.html",
                                  {'title': title,
                                   'appId':app._id,'shelf_list': shelf_list,'shelves': shelves,
                                   'searching': True, 'query': search_field,
                                   'page_nodes': page_nodes, 'groupid':group_id, 'group_id':group_id,
                                   'page_info':paginator_pages
                                  },
                                  context_instance=RequestContext(request)
        )

    elif gst_page._id == ObjectId(app_id):
        group_type = node_collection.one({'_id': ObjectId(group_id)})
        group_info=group_type_info(group_id)
        node = node_collection.find({'member_of':ObjectId(app_id)})
        title = gst_page.name
        """
          Below query returns only those documents:
          (a) which are pages,
          (b) which belongs to given group,
          (c) which has status either as DRAFT or PUBLISHED, and
          (d) which has access_policy either as PUBLIC or if PRIVATE then it's created_by must be the logged-in user
        """
        page_nodes = node_collection.find({'member_of': {'$all': [ObjectId(app_id)]},
                                               'group_set': {'$all': [ObjectId(group_id)]},
                                               '$or': [
                                                {'access_policy': u"PUBLIC"},
                                                {'$and': [
                                                  {'access_policy': u"PRIVATE"},
                                                  {'created_by': request.user.id}
                                                  ]
                                                }
                                               ],
                                               'status': {'$nin': ['HIDDEN']}
                                           }).sort('last_update', -1)
        paginator_pages = paginator.Paginator(page_nodes, page_no, GSTUDIO_NO_OF_OBJS_PP)
        return render_to_response("ndf/page_list.html",
                                          {'title': title,
                                           'appId':app._id,
                                           'shelf_list': shelf_list,'shelves': shelves,
                                           'page_nodes': page_nodes,
                                           'groupid':group_id,
                                           'group_id':group_id,
                                           'page_info':paginator_pages
                                          },
                                          context_instance=RequestContext(request))

    else:
        # Page Single instance view
        page_node = node_collection.one({"_id": ObjectId(app_id)})
        thread_node = None
        allow_to_comment = None
        annotations = None
        if page_node:
          annotations = json.dumps(page_node.annotations)
          page_node.get_neighbourhood(page_node.member_of)

          thread_node, allow_to_comment = node_thread_access(group_id, page_node)
        return render_to_response('ndf/page_details.html',
                                  {'node': page_node,
                                    'node_has_thread': thread_node,
                                    'appId': app._id,
                                    'group_id': group_id,
                                    'shelf_list': shelf_list,
                                    'allow_to_comment':allow_to_comment,
                                    'annotations': annotations,
                                    'shelves': shelves,
                                    'groupid': group_id
                                  },
                                  context_instance = RequestContext(request)
        )