Esempio n. 1
0
def suggestions(request):
    """Show a list of all accepted suggestions and their status."""
    if request.method == 'POST':
        form = SuggestionForm(request.POST)
        if form.is_valid():
            obj = form.save()
            mark_if_spam(obj)
            messages.add_message(request, messages.INFO,
                                 'Suggestion submitted.')
            return redirect('suggestions-list')
    else:
        form = SuggestionForm()

    open_objs = Suggestion.objects.filter(
        state__in=Suggestion.OPEN_STATES,
        is_reviewed=True)
    resolved_objs = Suggestion.objects.filter(
        state__in=Suggestion.RESOLVED_STATES,
        is_reviewed=True)

    ret = render(
        request, 'suggestions/suggestions_list.html',
        {'form': form,
         'open_suggestions': open_objs,
         'resolved_suggestions': resolved_objs})
    return ret
Esempio n. 2
0
def submit(request):
    """Submit a new suggestion."""
    success = False
    if request.method == 'POST':
        form = SuggestionForm(request.POST)
        if form.is_valid():
            form.save()
            success = True
    else:
        form = SuggestionForm()

    ret = render(
        request, 'suggestions/submit_form.html',
        {'form': form,
         'success': success})
    return ret
Esempio n. 3
0
def suggestions(request):
    """Show a list of all accepted suggestions and their status."""
    if request.method == 'POST':
        form = SuggestionForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('suggestions-list')
    else:
        form = SuggestionForm()

    open_objs = Suggestion.objects.filter(
        state__in=Suggestion.OPEN_STATES)
    resolved_objs = Suggestion.objects.filter(
        state__in=Suggestion.RESOLVED_STATES)

    ret = render(
        request, 'suggestions/suggestions_list.html',
        {'form': form,
         'open_suggestions': open_objs,
         'resolved_suggestions': resolved_objs})
    return ret
Esempio n. 4
0
def suggestions(request):
    """Show a list of all accepted suggestions and their status."""
    if request.method == 'POST':
        form = SuggestionForm(request.POST)
        if form.is_valid():
            obj = form.save()
            mark_if_spam(obj)
            messages.add_message(request, messages.INFO,
                                 'Suggestion submitted.')
            return redirect('suggestions-list')
    else:
        form = SuggestionForm()

    open_objs = Suggestion.objects.filter(
        state__in=Suggestion.OPEN_STATES,
        is_reviewed=True).order_by('-submitted')
    resolved_objs = Suggestion.objects.filter(
        state__in=Suggestion.RESOLVED_STATES,
        is_reviewed=True).order_by('-resolved')

    ret = render(
        request, 'suggestions/suggestions_list.html',
        {'form': form,
         'open_suggestions': open_objs,
         'resolved_suggestions': resolved_objs})
    return ret