<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def edit_type_view(request, semester, pk, profile=None):
 """ View for a manager to edit the details of a particular WorkshiftType. """

    wtype = get_object_or_404(WorkshiftType, pk=pk)
    full_management = utils.can_manage(request.user, semester)
    any_management = utils.can_manage(request.user, semester, any_pool=True)

    if not any_management:
        messages.add_message(
            request,
            messages.ERROR,
            MESSAGES["ADMINS_ONLY"],
        )
        return HttpResponseRedirect(semester.get_view_url())

    if full_management:
        if "delete" in request.POST:
            messages.add_message(
                request,
                messages.INFO,
                "Workshift type deleted.",
            )
            wtype.delete()
            return HttpResponseRedirect(wurl(
                "workshift:list_types",
                sem_url=semester.sem_url,
            ))

    edit_form = WorkshiftTypeForm(
        data=request.POST if "edit" in request.POST else None,
        instance=wtype,
        prefix="edit",
        read_only=not full_management,
    )

    queryset = RegularWorkshift.objects.filter(
        workshift_type=wtype,
    )

    if not full_management:
        queryset = queryset.filter(
            pool__managers__incumbent__user=request.user,
        )

    shifts_formset = RegularWorkshiftFormSet(
        data=request.POST if "edit" in request.POST else None,
        prefix="shifts",
        queryset=queryset,
    )

    if edit_form.is_valid() and shifts_formset.is_valid():
        if full_management:
            wtype = edit_form.save()
        shifts_formset.save(wtype)
        return HttpResponseRedirect(wtype.get_view_url())

    page_name = "Edit {}".format(wtype.title)

    return render_to_response("edit_type.html", {
        "page_name": page_name,
        "shift": wtype,
        "edit_form": edit_form,
        "shifts_formset": shifts_formset,
    }, context_instance=RequestContext(request))