def all_announcements_view(request):
    ''' The view of manager announcements. '''
    page_name = "Archives - All Announcements"
    userProfile = UserProfile.objects.get(user=request.user)
    announcement_form = None
    manager_positions = Manager.objects.filter(incumbent=userProfile)
    if manager_positions:
        announcement_form = AnnouncementForm(
            request.POST if "post_announcement" in request.POST else None,
            profile=userProfile,
            )
        if announcement_form.is_valid():
            announcement_form.save()
            return HttpResponseRedirect(reverse('managers:all_announcements'))

    # A pseudo-dictionary, actually a list with items of form (announcement,
    # announcement_pin_form)
    announcements_dict = list()
    for a in Announcement.objects.all():
        pin_form = None
        if a.manager.incumbent == userProfile or request.user.is_superuser:
            pin_form = PinForm(
                request.POST if "pin-{0}".format(a.pk) in request.POST else None,
                instance=a,
                )
            if pin_form.is_valid():
                pin_form.save()
                return HttpResponseRedirect(reverse('managers:all_announcements'))
        announcements_dict.append((a, pin_form))
    return render_to_response('announcements.html', {
        'page_name': page_name,
        'manager_positions': manager_positions,
        'announcements_dict': announcements_dict,
        'announcement_form': announcement_form,
        }, context_instance=RequestContext(request))
The view of manager announcements.