def has_breadcrumbs(context): _html = " <div class='linha-inicio hidden-xs'> <ol>" _site_url = get_site_url_id(context.request) _p = PortalCatalog.objects.filter(site__url=_site_url, ) aux = '/' count = 0 _url = reescrever_url(context.request).strip('/').split('/') if len(_url) == 1: _html += "<li class='active'>Pagina Inicial</li>" else: for i in _url: if i not in ['folder_contents', 'createObject', 'edit']: if count < len(_url) - 1: aux += i + '/' if count == 0: _html += "<li><a href='%s'>Inicio</a> - </li>" % aux else: text_link = _p.get(path_url=aux) _html += "<li><a href='%s'>%s</a> - </li>" % ( aux, text_link.titulo) count += 1 else: aux += i + '/' text_link = _p.get(path_url=aux) _html += "<li class='active'>%s</li>" % text_link.titulo else: _html += "<li class='active'>[...]</li>" _html += "</ol> </div>" return format_html(_html)
def edit(request): path_url = reescrever_url(request) tipo = request.GET['edit'] _site_url = get_site_url_id(request) _content_url = get_url_id_content(request) portlet = Portlet.objects.filter(site__url=_site_url).get(portlet=tipo) if portlet.categoria == 'destaque': form = PortletDestaqueForm(request.POST or None, instance=portlet) else: form = PortletForm(request.POST or None, instance=portlet) if form.is_valid(): model = form.save(commit=False) _url = slugify(model.titulo) model.save() path_url += '@@manage-portlets' return redirect(path_url) template = 'comum/portlets.html' context = { 'form': form, } return render(request, template, context)
def delete(request): path_url = reescrever_url(request) portlet_url = request.GET['delete'] _site_url = get_site_url_id(request) portlet = Portlet.objects.filter(site__url=_site_url).get( portlet=portlet_url) portlet.delete() path_url += '@@manage-portlets' return redirect(path_url)
def has_list_objects_arquivo(context, **kwargs): _site_url = get_site_url_id(context.request) _path_url = reescrever_url(context.request) _portal_catalog = PortalCatalog.objects.filter( site__url=_site_url, path_url__startswith=_path_url, tipo='ATArquivo').values_list('url', flat=True) _arquivo = Arquivo.objects.filter(site__url=_site_url, url__in=_portal_catalog) return _arquivo
def has_list_pastas(context): url_site = reescrever_url(context.request) _p = PortalCatalog.objects.filter(path_url__startswith=url_site, ).exclude( path_url=url_site).order_by('ordenador') nivel = len(url_site.strip('/').split('/')) + 1 _html = "<ul id='ordenador'>" for i in _p: if len(i.path_url.strip('/').split('/')) == nivel: _html += "<li id='%s'><a href='%s' class='%s' >%s %s</a></li>" % ( i.id, i.path_url, WORKFLOW_COLOR[i.workflow], ICONS[i.tipo], i.titulo) _html += '</ul>' return format_html(_html)
def has_action_view_edit(context, action): _new_url = '' _url_aux = fraguiment_url(context.request) _url_default = context.request.path if action in ['edit', 'folder_contents']: if action not in _url_aux: _new_url = '%s%s/' % (_url_default, action) else: _new_url = _url_default elif action == 'view': _new_url = reescrever_url(context.request) return _new_url
def has_list_objects_agenda(context, **kwargs): _site_url = get_site_url_id(context.request) _path_url = reescrever_url(context.request) _portal_catalog = PortalCatalog.objects.filter( site__url=_site_url, path_url__startswith=_path_url, tipo='ATAgenda').values_list('url', flat=True) _agenda = Agenda.objects.filter(site__url=_site_url, url__in=_portal_catalog) if 'hoje' in kwargs: today_min = datetime.combine(date.today(), time.min) today_max = datetime.combine(date.today(), time.max) _agenda = _agenda.filter(data_at__range=(today_min, today_max)) _agenda = _agenda.order_by('data_at') return _agenda
def has_list_objects_noticia(context, **kwargs): _site_url = get_site_url_id(context.request) _path_url = reescrever_url(context.request) _portal_catalog = PortalCatalog.objects.filter( site__url=_site_url, path_url__startswith=_path_url, tipo='ATNoticia').values_list('url', flat=True) _noticia = Noticia.objects.filter(site__url=_site_url, url__in=_portal_catalog) if 'tag' in context.request.GET: tag = context.request.GET['tag'] _noticia = _noticia.filter(tag=tag) return _noticia
def create(request): path_url = reescrever_url(request) content_url = get_url_id_content(request) site = get_site_url(request) tipo = request.GET['create'] if tipo == 'destaque': form = PortletDestaqueForm(request.POST or None) else: form = PortletForm(request.POST or None) if form.is_valid(): model = form.save(commit=False) _url = '%s-%s' % (slugify(model.titulo), content_url) model.portlet = _url model.site = site model.posicao = 'left' if tipo != 'destaque': model.tipo = CONTENT_BY_TYPE[tipo] else: model.categoria = tipo if site.url == content_url: model.origem = 'pagina-inicial' model.save() if site.url != content_url: portal_catalog = PortalCatalog.objects.filter(site=site).get( url=content_url) _obj = portal_catalog.get_content_object() _obj.portlet.add(model) path_url += '@@manage-portlets' return redirect(path_url) template = 'comum/portlets.html' context = { 'form': form, } return render(request, template, context)
def has_portlets(context): _url = reescrever_url(context.request).strip('/').split('/') _site_url = get_site_url_id(context.request) _result = [] _new_url = ('/%s/') % _url[0] for item in _url: _p = None if item == _site_url: p_ = Portlet.objects.filter(site__url=_site_url, origem='pagina-inicial') else: _new_url = ('%s%s/') % (_new_url, item) portal_catalog = PortalCatalog.objects.filter( site__url=_site_url).get(path_url=_new_url) _obj = portal_catalog.get_content_object() p_ = _obj.portlet.all() for i in p_: _result.append(i) return _result
def has_action_view_delete(context): _url = reescrever_url(context.request) return ('%sdelete/') % _url
def has_formata_url_view_tag(context): _url = reescrever_url(context.request) _content_url = get_url_id_content(context.request) return _url.replace('/' + _content_url, '')
def format_menu_portlets(context): _new_url = reescrever_url(context.request) return '%s%s' % (_new_url, "@@manage-portlets")
def has_formata_url(context): return reescrever_url(context.request)