How to use the dispatch.apps.content.models.Section.objects.get function in dispatch

To help you get started, we’ve selected a few dispatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
def section_edit(request, id):
    section = Section.objects.get(id=id)

    if request.method == 'POST':
        form = SectionForm(request.POST, instance=section)
        if form.is_valid():
            section = form.save()
    else:
        form = SectionForm(instance=section)

    context = {
        'title': 'Edit Section',
        'form': form,
    }

    return render(request, 'manager/section/edit.html', context)
github ubyssey / dispatch / dispatch / themes / ubyssey / scripts / import.py View on Github external
title = str(BeautifulSoup(data['title'], 'html.parser'))
        article.headline = title

        article.slug = slug
        article.snippet = data['description']
        article.seo_keyword = data['keyword']
        article.seo_description = data['description']

        date = dateutil.parser.parse(data['date'])

        article.status = Article.DRAFT
        article.is_published = True
        article.published_at = date

        try:
            section = Section.objects.get(slug=data['post_type'])
        except:
            section = Section.objects.create(slug=data['post_type'], name=data['post_type'])

        article.section = section

        article.save()

        Author.objects.create(article=article,person=author,order=0)

        article.content = self.save_content(data['content'], article)

        if article.featured_image is None and data['featured_image']:
            article.featured_image = self.save_attachment(data['featured_image'], article)

        article.save(revision=False)
github ubyssey / dispatch / dispatch / themes / ubyssey / views.py View on Github external
def section(self, request, slug=None):

        try:
            section = Section.objects.get(slug=slug)
        except:
            return self.page(request, slug)

        articles = Article.objects.filter(section=section, is_published=True).order_by('-published_at')

        context = {
            'meta': {
                'title': section.name
            },
            'section': section,
            'type': 'section',
            'articles': {
                'first': articles[0],
                'rest': articles[1:9]
            }
        }
github ubyssey / dispatch / dispatch / themes / ubyssey / views.py View on Github external
def section(self, request, section):

        section = Section.objects.get(slug=section)
        articles = Article.objects.filter(head=True,section=section)

        context = {
            'section': section,
            'articles': articles,
        }

        return render(request, 'section/base.html', context)
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
def article_add(request):
    section_id = request.GET.get('section', False)
    try:
        section = Section.objects.get(pk=section_id)
    except:
        section = None
    return render(request, 'manager/article/edit.html', {'section': section})
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
def section(request, section):
    section = Section.objects.get(name=section)
    article_list = Article.objects.filter(section=section,is_active=True,head=True).order_by('-created_at')

    q = request.GET.get('q', '')
    if q:
        article_list = article_list.filter(headline__icontains=q)

    unpublished = article_list.exclude(status=Article.PUBLISHED).count()

    paginator = Paginator(article_list, 15) # Show 15 articles per page

    page = request.GET.get('page')

    try:
        articles = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.