Example #1
0
def article_scrap_reposition(request, article_id, scrap_id, position, is_page=False):
    scraps_utils.scrap_reposition(scrap_id, position)
    utils.article_update_rendered_pile(article_id)
    if is_page:
        return redirect('articles_admin_page_edit', article_id=article_id)
    else:
        return redirect('articles_admin_article_edit', article_id=article_id)
Example #2
0
def article_scrap_toggle(request, article_id, scrap_id, status, is_page=False):
    scraps_utils.scrap_toggle(scrap_id, status)
    utils.article_update_rendered_pile(article_id)
    if is_page:
        return redirect('articles_admin_page_edit', article_id=article_id)
    else:
        return redirect('articles_admin_article_edit', article_id=article_id)
Example #3
0
def article_scrap_edit(request, article_id, scrap_id, is_page=False, template=ARTICLE_SCRAP_EDIT_TEMPLATE):
    article = utils.article_get(article_id)
    scrap = scraps_utils.scrap_get(scrap_id)
    msg = None
    if request.method == 'POST':
        # only update upon save after post    
        scrap_edit_form = scraps_utils.scrap_get_edit_form(scrap, False)
        scrap_edit_form = scrap_edit_form(request.POST)
        if scrap_edit_form.is_valid():
            scraps_utils.scrap_update(scrap, request.POST)
            utils.article_update_rendered_pile(article_id)
            msg = 'Your changes to this ' + scrap.blueprint_display_name() \
                + ' scrap were saved'
            if is_page:
                return redirect('articles_admin_page_edit', article_id=article_id)
            else:
                return redirect('articles_admin_article_edit', article_id=article_id)
    else:
        scrap_edit_form = scraps_utils.scrap_edit_form_instance(scrap, False)
    h1 = "Editing \"" + article.title + "\""
    
    return direct_to_template(
        request,
        template,
        {
            'menu_current': menu_current(is_page),
            'h1': h1,
            'article': article,
            'editable_scrap': scrap,
            'scrap_edit_form': scrap_edit_form,
            'msg': msg,
            'is_page': is_page
        }
    )
Example #4
0
def article_scrap_delete(request, article_id, scrap_id, is_page=False):
    if utils.is_scrap_in_article_pile(article_id, scrap_id):
        scraps_utils.scrap_delete(scrap_id)
    utils.article_update_rendered_pile(article_id)
    if is_page:
        return redirect('articles_admin_page_edit', article_id=article_id)
    else:
        return redirect('articles_admin_article_edit', article_id=article_id)