# 89 Ecoaccount recorded state reset (fix)
* fixes bug where recorded state of eco account has been reset, if a deduction is created from the detail view of the ecoaccount itself
This commit is contained in:
parent
14a38b43de
commit
1786bd965b
@ -310,17 +310,19 @@ class Compensation(AbstractCompensation, CEFMixin, CoherenceMixin):
|
|||||||
)
|
)
|
||||||
return docs
|
return docs
|
||||||
|
|
||||||
def mark_as_edited(self, user: User, request: HttpRequest = None, edit_comment: str = None):
|
def mark_as_edited(self, user: User, request: HttpRequest = None, edit_comment: str = None, reset_recorded: bool = True):
|
||||||
""" Performs internal logic for setting the recordedd/checked state of the related intervention
|
""" Performs internal logic for setting the recordedd/checked state of the related intervention
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
user (User): The performing user
|
user (User): The performing user
|
||||||
request (HttpRequest): The performing request
|
request (HttpRequest): The performing request
|
||||||
|
edit_comment (str): Additional comment for the log entry
|
||||||
|
reset_recorded (bool): Whether the record-state of the object should be reset
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.intervention.mark_as_edited(user, request, edit_comment)
|
self.intervention.mark_as_edited(user, request, edit_comment, reset_recorded)
|
||||||
|
|
||||||
def is_ready_for_publish(self) -> bool:
|
def is_ready_for_publish(self) -> bool:
|
||||||
""" Not inherited by RecordableObjectMixin
|
""" Not inherited by RecordableObjectMixin
|
||||||
|
@ -370,7 +370,7 @@ class NewDeductionModalForm(BaseModalForm):
|
|||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
deduction = self.instance.add_deduction(self)
|
deduction = self.instance.add_deduction(self)
|
||||||
self.instance.mark_as_edited(self.user, self.request)
|
self.instance.mark_as_edited(self.user, self.request, reset_recorded=False)
|
||||||
return deduction
|
return deduction
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,17 +250,20 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
)
|
)
|
||||||
return deduction
|
return deduction
|
||||||
|
|
||||||
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None):
|
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None, reset_recorded: bool = True):
|
||||||
""" In case the object or a related object changed, internal processes need to be started, such as
|
""" In case the object or a related object changed, internal processes need to be started, such as
|
||||||
unrecord and uncheck
|
unrecord and uncheck
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
performing_user (User): The user which performed the editing action
|
performing_user (User): The user which performed the editing action
|
||||||
|
request (HttpRequest): The used request for this action
|
||||||
|
edit_comment (str): Additional comment for the log entry
|
||||||
|
reset_recorded (bool): Whether the record-state of the object should be reset
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
super().mark_as_edited(performing_user, request)
|
super().mark_as_edited(performing_user, request, edit_comment, reset_recorded)
|
||||||
if self.checked:
|
if self.checked:
|
||||||
self.set_unchecked()
|
self.set_unchecked()
|
||||||
|
|
||||||
|
@ -262,12 +262,15 @@ class RecordableObjectMixin(models.Model):
|
|||||||
|
|
||||||
return action
|
return action
|
||||||
|
|
||||||
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None):
|
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None, reset_recorded: bool = True):
|
||||||
""" In case the object or a related object changed, internal processes need to be started, such as
|
""" In case the object or a related object changed, internal processes need to be started, such as
|
||||||
unrecord and uncheck
|
unrecord and uncheck
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
performing_user (User): The user which performed the editing action
|
performing_user (User): The user which performed the editing action
|
||||||
|
request (HttpRequest): The used request for this action
|
||||||
|
edit_comment (str): Additional comment for the log entry
|
||||||
|
reset_recorded (bool): Whether the record-state of the object should be reset
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
@ -277,7 +280,7 @@ class RecordableObjectMixin(models.Model):
|
|||||||
self.log.add(action)
|
self.log.add(action)
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
if self.recorded:
|
if self.recorded and reset_recorded:
|
||||||
action = self.set_unrecorded(performing_user)
|
action = self.set_unrecorded(performing_user)
|
||||||
self.log.add(action)
|
self.log.add(action)
|
||||||
if request:
|
if request:
|
||||||
|
Loading…
Reference in New Issue
Block a user