Merge pull request '# 89 Ecoaccount recorded state reset (fix)' (#94) from 89_Ecoaccount_recorded_state_reset into master
Reviewed-on: SGD-Nord/konova#94
This commit is contained in:
commit
e7bab1cbbb
@ -310,17 +310,19 @@ class Compensation(AbstractCompensation, CEFMixin, CoherenceMixin):
|
||||
)
|
||||
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
|
||||
|
||||
Args:
|
||||
user (User): The performing user
|
||||
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:
|
||||
|
||||
"""
|
||||
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:
|
||||
""" Not inherited by RecordableObjectMixin
|
||||
|
@ -370,7 +370,7 @@ class NewDeductionModalForm(BaseModalForm):
|
||||
|
||||
def save(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
|
||||
|
||||
|
||||
|
@ -250,17 +250,20 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
||||
)
|
||||
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
|
||||
unrecord and uncheck
|
||||
|
||||
Args:
|
||||
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:
|
||||
|
||||
"""
|
||||
super().mark_as_edited(performing_user, request)
|
||||
super().mark_as_edited(performing_user, request, edit_comment, reset_recorded)
|
||||
if self.checked:
|
||||
self.set_unchecked()
|
||||
|
||||
|
@ -262,12 +262,15 @@ class RecordableObjectMixin(models.Model):
|
||||
|
||||
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
|
||||
unrecord and uncheck
|
||||
|
||||
Args:
|
||||
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:
|
||||
|
||||
@ -277,7 +280,7 @@ class RecordableObjectMixin(models.Model):
|
||||
self.log.add(action)
|
||||
self.save()
|
||||
|
||||
if self.recorded:
|
||||
if self.recorded and reset_recorded:
|
||||
action = self.set_unrecorded(performing_user)
|
||||
self.log.add(action)
|
||||
if request:
|
||||
|
Loading…
Reference in New Issue
Block a user