def save(self): entry = ShiftLogEntry.objects.create(person=self.profile, entry_type=ShiftLogEntry.SIGNOUT) instance = self.cleaned_data["pk"] instance.workshifter = None if utils.past_sign_out(instance): instance.liable = self.profile instance.logs.add(entry) instance.save() return instance
def save(self, note=None): entry = ShiftLogEntry.objects.create( person=self.profile, entry_type=ShiftLogEntry.SIGNOUT, note=note, ) instance = self.cleaned_data["pk"] instance.workshifter = None if utils.past_sign_out(instance): instance.liable = self.profile instance.logs.add(entry) instance.save() return instance
def save(self, note=None): instance = self.cleaned_data["pk"] instance.workshifter = None if utils.past_sign_out(instance): instance.liable = self.profile instance.save(update_fields=["workshifter", "liable"]) instance.logs.add( ShiftLogEntry.objects.create( person=self.profile, entry_type=ShiftLogEntry.SIGNOUT, note=note, ) ) return instance
def save(self, note=None): instance = self.cleaned_data["pk"] liable = False workshifter = instance.workshifter or instance.liable if workshifter != self.profile: notify.send( self.profile.user, verb="signed you out of", action_object=instance, recipient=workshifter.user, ) if note is None: note = "Signed out by {}".format( self.profile ) elif not self.undo: if utils.past_sign_out(instance): liable = True instance.workshifter = None if liable: instance.liable = workshifter else: instance.liable = None instance.save(update_fields=["workshifter", "liable"]) instance.logs.add( ShiftLogEntry.objects.create( person=workshifter, entry_type=ShiftLogEntry.SIGNOUT, note=note, ) ) return instance