Exemple #1
0
def save(request, site, version):
    """Save changes to page or article version"""

    try:
        version = Version.objects.get(id=version)
    except Version.DoesNotExist:
        return HttpResponse(json.dumps({'version_does_not_exist': True}))

    response = {}

    # Wrap the entire save operation in an atomic transaction
    with transaction.atomic():
        # Process submitted rows and content
        posted_rows = json.loads(request.POST['rows'])
        _save__process_rows_and_content(request, version, posted_rows)

        # Tags - common for pages and articles
        _save__process_tags(request, version)

        # Page data
        if version.page is not None:
            _save__process_page(request, version, posted_rows)
        # Article data
        elif version.article is not None:
            _save__process_article(request, version, response, posted_rows)
            Article.clear_widget_cache()

    return HttpResponse(json.dumps(response))
Exemple #2
0
def delete(request, site, article):
    try:
        active_site = Site.get_cached_by_id(site)
        Article.objects.get(id=article).delete()
        Article.clear_widget_cache()
    except Article.DoesNotExist:
        # Probably not a code error but a double-click or something, ignore
        pass
    return redirect('admin:sites.articles.list', active_site.id)