Example #1
0
def showdir(request):
    from time import mktime
    path = request.POST.get('path', None)
    if not path or path.strip() == '':
        parent = BaseObject.resolveID(request.session.get('main_object', None))
        if not parent:
            parent = Page.objects.get(parent__isnull=True)
    else:
        from core.views import get_object_by_url
        parent = get_object_by_url(path)

    imgs = BaseObject.nodes(parents=[parent], types=['Photo']).all()
    ret = ""
    for r in imgs:
        try:
            ret += """<table class="imageBlock0" cellpadding="0" cellspacing="0"
				filename="%s" fname="%s" ext="%s" path="%s" linkto="%s"
				fsize="%d" date="%s" fwidth="%d" fheight="%d" md5="%s">
				<tr><td valign="bottom" align="center">
				 <div class="imageBlock1">
				  <div class="imageImage">
				   <img src="%s" alt="%s" style="max-width:104px; max-height:116px;"/>
				  </div>
				  <div class="imageName">%s</div>
				 </div>
				</td></tr></table>\n""" % (r.url(), r.url(), "jpg", r.url(), r.url(),
                               r.image.size, r.date_modified.ctime(),
                               r.image.width, r.image.height, r.id,
                               r.thumb_url(), r.title, r.title)
        except:
            pass
    return HttpResponse(ret)
Example #2
0
def showdir(request):
	from time import mktime
	path = request.POST.get('path', None)
	if not path or path.strip() == '':
		parent = BaseObject.resolveID(request.session.get('main_object', None))
		if not parent:
			parent = Page.objects.get(parent__isnull=True)
	else:
		from core.views import get_object_by_url
		parent = get_object_by_url(path)

	imgs = BaseObject.nodes(parents=[parent], types=['Photo']).all()
	ret = ""
	for r in imgs:
		try:
			ret += """<table class="imageBlock0" cellpadding="0" cellspacing="0"
				filename="%s" fname="%s" ext="%s" path="%s" linkto="%s"
				fsize="%d" date="%s" fwidth="%d" fheight="%d" md5="%s">
				<tr><td valign="bottom" align="center">
				 <div class="imageBlock1">
				  <div class="imageImage">
				   <img src="%s" alt="%s" style="max-width:104px; max-height:116px;"/>
				  </div>
				  <div class="imageName">%s</div>
				 </div>
				</td></tr></table>\n""" % (r.url(), r.url(), "jpg", r.url(), r.url(),
					r.image.size, r.date_modified.ctime(), r.image.width, r.image.height,
					r.id, r.thumb_url(), r.title, r.title)
		except:
			pass
	return HttpResponse( ret )
Example #3
0
def sitemap(request):
    from core.types.support import State
    from core.types.link import Link

    public = State.objects.get(name=u'опубликованный')
    nodes_params = dict(types=['Link', 'Page'],
                        sort_fields=['position'],
                        states=[public],
                        not_browse=False)

    def set_children(parents, depth=0):
        from collections import defaultdict
        children = defaultdict(list)
        objects = BaseObject.nodes(**nodes_params).parents(
            *parents).query_set.only('id', 'slug', 'parent', 'title', 'type')
        while depth:
            depth -= 1
            set_children(objects, depth)
        for object in objects:
            children[object.parent_id].append(object)
            object.type == 'Link' and links.append(object.id)
        for parent in parents:
            parent.children = children[parent.id]

    frontpage = BaseObject.objects.filter(parent__id=None).only('id')[0]
    objects = BaseObject.nodes(
        **nodes_params).parents(frontpage).query_set.only(
            'id', 'slug', 'parent', 'title', 'type')
    links = [object.id for object in objects if object.type == 'Link']
    set_children(objects, depth=1)
    links = Link.objects.only('url').in_bulk(links)
    return {'sitemap': objects, 'links': links}
Example #4
0
def sitemap(request):
	from core.types.support import State
	from core.types.link import Link

	public = State.objects.get(name=u'опубликованный')
	nodes_params = dict(types=['Link', 'Page'], sort_fields=['position'], states=[public], not_browse=False)

	def set_children(parents, depth=0):
		from collections import defaultdict
		children = defaultdict(list)
		objects = BaseObject.nodes(**nodes_params).parents(*parents).query_set.only('id', 'slug', 'parent', 'title', 'type')
		while depth:
			depth -= 1
			set_children(objects, depth)
		for object in objects:
			children[object.parent_id].append(object)
			object.type == 'Link' and links.append(object.id)
		for parent in parents:
			parent.children = children[parent.id]

	frontpage = BaseObject.objects.filter(parent__id=None).only('id')[0]
	objects = BaseObject.nodes(**nodes_params).parents(frontpage).query_set.only('id', 'slug', 'parent', 'title', 'type')
	links = [object.id for object in objects if object.type == 'Link']
	set_children(objects, depth=1)
	links = Link.objects.only('url').in_bulk(links)
	return {'sitemap': objects, 'links': links}
Example #5
0
def trash(object, request):
	"""
		PageTemplate trash -- корзина
		Возвращает список объектов parent-ом которых она является.
		TODO: добавить paginator
	"""
	from core.models import BaseObject
	objects = BaseObject.nodes(parents=[object.id], foruser=True, sort_fields=['-date_modified'])
	if not request.user.is_superuser:
		objects = objects.authors(request.user)
	return {'objects':objects.all()}
Example #6
0
	def set_children(parents, depth=0):
		from collections import defaultdict
		children = defaultdict(list)
		objects = BaseObject.nodes(**nodes_params).parents(*parents).query_set.only('id', 'slug', 'parent', 'title', 'type')
		while depth:
			depth -= 1
			set_children(objects, depth)
		for object in objects:
			children[object.parent_id].append(object)
			object.type == 'Link' and links.append(object.id)
		for parent in parents:
			parent.children = children[parent.id]
Example #7
0
 def set_children(parents, depth=0):
     from collections import defaultdict
     children = defaultdict(list)
     objects = BaseObject.nodes(**nodes_params).parents(
         *parents).query_set.only('id', 'slug', 'parent', 'title', 'type')
     while depth:
         depth -= 1
         set_children(objects, depth)
     for object in objects:
         children[object.parent_id].append(object)
         object.type == 'Link' and links.append(object.id)
     for parent in parents:
         parent.children = children[parent.id]
Example #8
0
def showtree(request):
	path = ''
	if request.POST.has_key('path'): path = request.POST['path']

	obj = BaseObject.resolveID(request.session.get('main_object', None))
	current_node = obj.walktree()[-1]
	p = Page.objects.get(parent__isnull=True)

	ret = ""
	for node in BaseObject.nodes(types=['Page'], parents=[current_node.parent]).all():
		if node.id == current_node.id:
			ret += """<div class="folderOpened %s" path="%s" pathtype="%s">%s (%d)</div>"""%(
				'folderAct', node.get_absolute_url(), "images", node.title[:30], len(node.get_images()) )
		else:
			ret +=  """<div class="folder%s %s" path="%s" pathtype="%s">%s (%d)</div>"""%(
				"S", "", node.get_absolute_url(), "images", node.title[:30], len(node.get_images()) )
	return HttpResponse( ret )
Example #9
0
    def render(self, context):
        if len(self.param_array)==1:
            pa = self.param_array[0].resolve(context)
            self.param_array = [template.Variable(x) for x in reduce(lambda x,y:x+y, pa)]

	filters = {}
#        nodes = BaseObject.nodes()
        ns = BaseObject.nodes().namespace()
        limit = 0

        for i in xrange(len(self.param_array)/2):
            try:
                k = self.param_array[2*i].resolve(context)
            except template.VariableDoesNotExist, E:
                k = eval('u"%s"'%str(self.param_array[2*i]))
            try:
                v = self.param_array[2*i+1].resolve(context)
            except template.VariableDoesNotExist, E:
                v = eval('SafeUnicode(u"%s")'%str(self.param_array[2*i+1]))
Example #10
0
def photoline(request):
	result = BaseObject.nodes()(types=['News'], sort_fields=['-date_published'], states=[u'опубликовынный',u'на главной']).all()[:100]

	all_imgs = []
	for x in result:
		all_imgs.extend( x.get_images() )

	format = request.GET.get("format", "medium")
	if format != "small":
		format = "medium"
		x = y = 160
		count = 25
	else:
		x =  y = 80
		count = 70

	print "EEE", len(all_imgs), count
	imgs = random.sample(all_imgs, count)

	return { 'imgs': imgs, 'format': format, 'x': x, 'y': y }
Example #11
0
def showtree(request):
    path = ''
    if request.POST.has_key('path'): path = request.POST['path']

    obj = BaseObject.resolveID(request.session.get('main_object', None))
    current_node = obj.walktree()[-1]
    p = Page.objects.get(parent__isnull=True)

    ret = ""
    for node in BaseObject.nodes(types=['Page'],
                                 parents=[current_node.parent]).all():
        if node.id == current_node.id:
            ret += """<div class="folderOpened %s" path="%s" pathtype="%s">%s (%d)</div>""" % (
                'folderAct', node.get_absolute_url(), "images",
                node.title[:30], len(node.get_images()))
        else:
            ret += """<div class="folder%s %s" path="%s" pathtype="%s">%s (%d)</div>""" % (
                "S", "", node.get_absolute_url(), "images", node.title[:30],
                len(node.get_images()))
    return HttpResponse(ret)
Example #12
0
    def render(self, context):
        if len(self.param_array) == 1:
            pa = self.param_array[0].resolve(context)
            self.param_array = [
                template.Variable(x) for x in reduce(lambda x, y: x + y, pa)
            ]

        filters = {}
        #        nodes = BaseObject.nodes()
        ns = BaseObject.nodes().namespace()
        limit = 0

        for i in xrange(len(self.param_array) / 2):
            try:
                k = self.param_array[2 * i].resolve(context)
            except template.VariableDoesNotExist, E:
                k = eval('u"%s"' % str(self.param_array[2 * i]))
            try:
                v = self.param_array[2 * i + 1].resolve(context)
            except template.VariableDoesNotExist, E:
                v = eval('SafeUnicode(u"%s")' %
                         str(self.param_array[2 * i + 1]))
Example #13
0
def reviewer_list(request):
    from core.models import BaseObject
    objs = BaseObject.nodes(states=[u'на редактировании'],
                            sort_fields=['date_modified']).all()
    return {'obj_list': objs}
Example #14
0
File: news.py Project: vden/TsoguNG
 def get_nested_links(self):
     return BaseObject.nodes().parents(self).types('Link').states(
         u'опубликованный').all()
Example #15
0
            if k not in ns: continue

            if k == u"limit": 
                limit = int(v)
            elif k in (u'cascade', u'foruser'):
#                nodes = eval('''nodes.%s()'''%k)
		filters[str(k)] = True
	    elif k == u'search':
		filters['search'] = eval(''' u'%s' ''' % v)
            elif type(v) == SafeUnicode:
#                nodes = eval('''nodes.%s(u"%s")'''%(k,v))
		if not filters.has_key(str(k)):	filters[str(k)] = []
		filters[str(k)].append(eval(''' u'%s' ''' % v))
            else:
#                nodes = eval('''nodes.%s("%s")'''%(k,v))
		if not filters.has_key(str(k)):	filters[str(k)] = []
		filters[str(k)].append(eval(''' '%s' ''' % v))

	print 'FILTERS', filters
	nodes = BaseObject.nodes(**filters)

        if limit>0:
            context[self.var] = nodes.limit(limit)
        else:
            context[self.var] = nodes.all()
        
        return ''

                
Example #16
0
def reviewer_list(request):
	from core.models import BaseObject
	objs = BaseObject.nodes(states = [u'на редактировании'], sort_fields = ['date_modified']).all()
	return {'obj_list':objs}
Example #17
0
File: news.py Project: vden/TsoguNG
	def get_nested_links(self):
		return BaseObject.nodes().parents(self).types('Link').states(u'опубликованный').all()
Example #18
0
                v = eval('SafeUnicode(u"%s")' %
                         str(self.param_array[2 * i + 1]))

            if k not in ns: continue

            if k == u"limit":
                limit = int(v)
            elif k in (u'cascade', u'foruser'):
                #                nodes = eval('''nodes.%s()'''%k)
                filters[str(k)] = True
            elif k == u'search':
                filters['search'] = eval(''' u'%s' ''' % v)
            elif type(v) == SafeUnicode:
                #                nodes = eval('''nodes.%s(u"%s")'''%(k,v))
                if not filters.has_key(str(k)): filters[str(k)] = []
                filters[str(k)].append(eval(''' u'%s' ''' % v))
            else:
                #                nodes = eval('''nodes.%s("%s")'''%(k,v))
                if not filters.has_key(str(k)): filters[str(k)] = []
                filters[str(k)].append(eval(''' '%s' ''' % v))

        print 'FILTERS', filters
        nodes = BaseObject.nodes(**filters)

        if limit > 0:
            context[self.var] = nodes.limit(limit)
        else:
            context[self.var] = nodes.all()

        return ''