def METHOD_NAME(self, request, *args, **kwargs):
    if self.pk_url_kwarg in kwargs:
        self.object = self.get_object()
        if not (self.object.is_admin(request.user) or self.object.is_manager(request.user)):
            # only unit admins or managers can edit units
            raise PermissionDenied
        if not self.object.is_editable():
            # unit with imported data can not be edited
            raise PermissionDenied
    else:
        self.object = None
    if self.object is None:
        # Creating new units is currently disabled
        return HttpResponse(status_code=404)
    form = self.get_form()
    period_formset_with_days = self.get_period_formset()
    if self._validate_forms(form, period_formset_with_days):
        return self.forms_valid(form, period_formset_with_days)
    else:
        return self.forms_invalid(form, period_formset_with_days)