示例#1
0
def pile(pile_name):
    output = ""
    try:
        scrap_div_class = Setting.objects.get_value('scrap_div_class')
        piles = Pile.objects.filter(name=pile_name,is_standalone=True)
        if piles:
            for pile in piles:
                if pile.is_enabled:
                    scraps = Scrap.objects.in_pile(pile).filter(is_enabled=True)
                    if scraps:
                        for scrap in scraps:
                            rendered_scrap, was_successful = scrap_render(scrap)
                            if was_successful:
                                output += "<div class=\"" + scrap.blueprint_name + " " + scrap_div_class + "\">" + rendered_scrap + "</div>"
                            else:
                                output += rendered_scrap
                    else:
                        output += "<!-- scrap pile '" + pile_name + "' is empty -->"
                else:
                    output += "<!-- scrap pile '" + pile_name + "' is not enabled -->"
        else:
            output = "<!-- scrap pile '" + pile_name + "' was not found -->"
        return output
    except:
        output = "<!-- scrap pile '" + pile_name + "' was not found -->"
    return output
示例#2
0
def scrap(scrap_id, show_title=True):
    output = ""
    try:
        scrap = Scrap.objects.get(id=scrap_id)
        rendered_scrap, was_successful = scrap_render(scrap, show_title=show_title) 
        output += rendered_scrap
    except:
        output = "<!-- scrap not found -->"
    return output
示例#3
0
def article_update_rendered_pile(article_id):
    article = article_get(article_id)
    updated_article_rendered_pile = ""
    for scrap in article.pile.scraps():
        if scrap.is_enabled:
            rendered_scrap, status = scraps_utils.scrap_render(scrap, show_title=False)
            updated_article_rendered_pile += rendered_scrap
    article.rendered_pile = updated_article_rendered_pile
    article.updated = datetime.datetime.now()
    article.save()