The view of manager announcements.

def announcements_view(request):
    ''' The view of manager announcements. '''
    page_name = "Manager 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 and announcement_form.is_valid():
        announcement_form.save(request)
        return HttpResponseRedirect(reverse('managers:announcements'))

    # A pseudo-dictionary, actually a list with items of form:
    # (announcement, announcement_pin_form)
    announcements_dict = list()
    for a in Announcement.objects.filter(pinned=True):
        pin_form = None
        if (a.manager.incumbent == userProfile) or request.user.is_superuser:
            pin_form = PinForm(
                request.POST if "pin-{0}".format(a.pk) else None,
                instance=a,
                )
            if pin_form.is_valid():
                pin_form.save()
                return HttpResponseRedirect(reverse('managers:announcements'))
        announcements_dict.append((a, pin_form))
    # Oldest genesis of an pinned announcement to be displayed.
    within_life = now() - timedelta(hours=settings.ANNOUNCEMENT_LIFE)
    for a in Announcement.objects.filter(pinned=False, post_date__gte=within_life):
        pin_form = None
        if request.user.is_superuser or (a.manager.incumbent == userProfile):
            pin_form = PinForm(
                request.POST if "pin-{0}".format(a.pk) else None,
                instance=a,
                )
        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))