fix: Call the AbstractMISP.from_dict at the end of the function to ensure the edited flag remains false

pull/700/head
Tom King 2021-01-14 18:58:35 +00:00 committed by Raphaël Vinot
parent f71c250402
commit 7e7f463d77
1 changed files with 4 additions and 1 deletions

View File

@ -998,7 +998,6 @@ class MISPEventReport(AbstractMISP):
def from_dict(self, **kwargs):
if 'EventReport' in kwargs:
kwargs = kwargs['EventReport']
super().from_dict(**kwargs)
self.distribution = kwargs.pop('distribution', None)
if self.distribution is not None:
@ -1038,6 +1037,8 @@ class MISPEventReport(AbstractMISP):
if kwargs.get('deleted'):
self.deleted = kwargs.pop('deleted')
super().from_dict(**kwargs)
def __repr__(self) -> str:
if hasattr(self, 'name'):
return '<{self.__class__.__name__}(name={self.name})'.format(self=self)
@ -1383,6 +1384,7 @@ class MISPEvent(AbstractMISP):
if kwargs.get('SharingGroup'):
self.SharingGroup = MISPSharingGroup()
self.SharingGroup.from_dict(**kwargs.pop('SharingGroup'))
super(MISPEvent, self).from_dict(**kwargs)
def to_dict(self) -> Dict:
@ -1495,6 +1497,7 @@ class MISPEvent(AbstractMISP):
event_report = MISPEventReport()
event_report.from_dict(name=name, content=content, **kwargs)
self.event_reports.append(event_report)
self.edited = True
return event_report
def get_object_by_id(self, object_id: Union[str, int]) -> MISPObject: