code: def edit_shift_view(request, semester, pk, profile=None):
      
      shift = get_object_or_404(RegularWorkshift, pk=pk)
  
      if shift.is_manager_shift:
          # XXX: Bad way of doing this, we should make manager_shift point to
          # the related Manager object directly
          try:
              manager = Manager.objects.get(title=shift.workshift_type.title)
          except Manager.DoesNotExist:
              pass
          else:
              return HttpResponseRedirect(manager.get_edit_url())
  
      if not utils.can_manage(request.user, semester=semester, pool=shift.pool):
          messages.add_message(
              request,
              messages.ERROR,
              MESSAGES["ADMINS_ONLY"],
          )
          return HttpResponseRedirect(semester.get_view_url())
  
      edit_form = RegularWorkshiftForm(
          data=request.POST if "edit" in request.POST else None,
          instance=shift,
          semester=semester,
      )
  
      if "delete" in request.POST:
          # Open instances are deleted automatically
          shift.delete()
          return HttpResponseRedirect(wurl(
              "workshift:manage",
              sem_url=semester.sem_url,
          ))
      elif edit_form.is_valid():
          shift = edit_form.save()
          return HttpResponseRedirect(shift.get_view_url())
  
      page_name = "Edit {}".format(shift)
  
      return render_to_response("edit_shift.html", {
          "page_name": page_name,
          "shift": shift,
          "edit_form": edit_form,
      }, context_instance=RequestContext(request))
docs: View for a manager to edit the details of a particular RegularWorkshift.