(request)
return render(request, 'herald/herald_base.html', context)
List latest herald_list items
List latest herald_list items
List latest herald_list items
def herald_list(request):
    """
    List latest herald_list items
    """

    # List newly submitted links.
    show = request.GET.get('show', 'upcoming')
    # Filter for or exclude published links
    if show == 'published':
        stories = SharedLink.objects.filter(status=SharedLink.PUBLISHED)
    else:
        stories = SharedLink.objects.exclude(status=SharedLink.PUBLISHED)

    stories = stories.order_by('-creation_date')
    stories = stories.select_related('author', 'author__profile')
    user = request.user
    form = HeraldSubmit(user=user)

    if request.method == 'POST':

        form = HeraldSubmit(data=request.POST, user=user)

        if form.is_valid():
            # Add the Link attribute.
            link = form.cleaned_data['url']
            text = form.cleaned_data['text']

            # Create the herald_list objects.
            herald = SharedLink.objects.create(author=user, text=text, url=link)
            messages.success(request, 'Submitted for review.')
            return redirect(reverse('herald_list'))

    # Apply a limit
    stories = stories[:settings.HERALD_LIST_COUNT]
    count = SharedLink.objects.filter(author=user, status=SharedLink.SUBMITTED).count()
    allow_submit = count < form.MAX
    context = dict(stories=stories, tab='herald_list', show=show, form=form, allow_submit=allow_submit)

    return render(request, 'herald/herald_base.html', context)
def herald_list ( request ) : # List newly submitted links. show = request . GET . get ( 'show' , 'upcoming' ) # Filter for or exclude published links if show == 'published' : stories = SharedLink . objects . filter ( status = SharedLink . PUBLISHED ) else : stories = SharedLink . objects . exclude ( status = SharedLink . PUBLISHED ) stories = stories . order_by ( '-creation_date' ) stories = stories . select_related ( 'author' , 'author__profile' ) user = request . user form = HeraldSubmit ( user = user ) if request . method == 'POST' : form = HeraldSubmit ( data = request . POST , user = user ) if form . is_valid ( ) : # Add the Link attribute. link = form . cleaned_data [ 'url' ] text = form . cleaned_data [ 'text' ] # Create the herald_list objects. herald = SharedLink . objects . create ( author = user , text = text , url = link ) messages . success ( request , 'Submitted for review.' ) return redirect ( reverse ( 'herald_list' ) ) # Apply a limit stories = stories [ : settings . HERALD_LIST_COUNT ] count = SharedLink . objects . filter ( author = user , status = SharedLink . SUBMITTED ) . count ( ) allow_submit = count < form . MAX context = dict ( stories = stories , tab = 'herald_list' , show = show , form = form , allow_submit = allow_submit ) return render ( request , 'herald/herald_base.html' , context )