Ejemplo n.º 1
0
def site_announce(request):
    site = get_current_site(request)
    
    if request.method == "POST":
        a_form = SiteAnnouncementForm(request.POST)
        if a_form.is_valid():
            a_form.cleaned_data['sites'] = [site.id]
            new_announcement = a_form.save()
    else:
        a_form = SiteAnnouncementForm()
    
    return render(request, 'megaphone/announce.html', {
        'a_form': a_form,
    })
def site_announce(request):
    if not request.user.is_superuser:
        return HttpResponseForbidden()

    site = get_current_site(request)

    if request.method == "POST":
        a_form = SiteAnnouncementForm(request.POST)
        if a_form.is_valid():
            a_form.cleaned_data["sites"] = [site.id]
            new_announcement = a_form.save()
    else:
        a_form = SiteAnnouncementForm()

    return render(request, "megaphone/announce.html", {"a_form": a_form})