7004: Only Event and Family Editors are checking if data_has_changed

tidy up and consistency between editors on save()
This commit is contained in:
système 2017-01-01 10:52:17 +01:00 committed by Nick Hall
parent 49321133e0
commit e267893470
9 changed files with 76 additions and 72 deletions

View File

@ -307,17 +307,17 @@ class EditCitation(EditPrimary):
self.ok_button.set_sensitive(True)
return
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
if not self.obj.handle:
with DbTxn(_("Add Citation (%s)") % self.obj.get_page(),
self.db) as trans:
self.db.add_citation(self.obj, trans)
msg = _("Add Citation (%s)") % self.obj.get_page()
else:
if self.data_has_changed():
with DbTxn(_("Edit Citation (%s)") % self.obj.get_page(),
self.db) as trans:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(
self.db.find_next_citation_gramps_id())
self.obj.set_gramps_id(self.db.find_next_citation_gramps_id())
self.db.commit_citation(self.obj, trans)
msg = _("Edit Citation (%s)") % self.obj.get_page()
trans.set_description(msg)
if self.callback:
self.callback(self.obj.get_handle())

View File

@ -269,13 +269,12 @@ class EditEvent(EditPrimary):
self.db) as trans:
self.db.add_event(self.obj, trans)
else:
orig = self.get_from_handle(self.obj.handle)
if self.obj.serialize() != orig.serialize():
if self.data_has_changed():
with DbTxn(_("Edit Event (%s)") % self.obj.get_gramps_id(),
self.db) as trans:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_event_gramps_id())
self.commit_event(self.obj, trans)
self.db.commit_event(self.obj, trans)
if self.callback:
self.callback(self.obj)

View File

@ -1129,7 +1129,7 @@ class EditFamily(EditPrimary):
self.db.commit_person(child, trans)
self.db.add_family(self.obj, trans)
elif original.serialize() != self.obj.serialize():
elif self.data_has_changed():
with DbTxn(_("Edit Family"), self.db) as trans:

View File

@ -320,16 +320,17 @@ class EditMedia(EditPrimary):
self.obj.set_path(path)
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
if not self.obj.handle:
with DbTxn(_("Add Media Object (%s)") % self.obj.get_description(),
self.db) as trans:
self.db.add_media(self.obj, trans)
msg = _("Add Media Object (%s)") % self.obj.get_description()
else:
if self.data_has_changed():
with DbTxn(_("Edit Media Object (%s)") % self.obj.get_description(),
self.db) as trans:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_media_gramps_id())
self.db.commit_media(self.obj, trans)
msg = _("Edit Media Object (%s)") % self.obj.get_description()
trans.set_description(msg)
if self.callback:
self.callback(self.obj)

View File

@ -332,16 +332,17 @@ class EditNote(EditPrimary):
self.ok_button.set_sensitive(True)
return
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
if not self.obj.handle:
with DbTxn(_("Add Note"),
self.db) as trans:
self.db.add_note(self.obj, trans)
msg = _("Add Note")
else:
if self.data_has_changed():
with DbTxn(_("Edit Note"),
self.db) as trans:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_note_gramps_id())
self.db.commit_note(self.obj, trans)
msg = _("Edit Note")
trans.set_description(msg)
if self.callback:
self.callback(self.obj.get_handle())

View File

@ -856,19 +856,19 @@ class EditPerson(EditPrimary):
self.db.set_birth_death_index(self.obj)
with DbTxn('', self.db) as trans:
self._update_family_ids()
if not self.obj.get_handle():
if not self.obj.handle:
with DbTxn(_("Add Person (%s)") % \
self.name_displayer.display(self.obj),
self.db) as trans:
self.db.add_person(self.obj, trans)
msg = _("Add Person (%s)") % \
self.name_displayer.display(self.obj)
else:
if self.data_has_changed():
with DbTxn(_("Edit Person (%s)") % \
self.name_displayer.display(self.obj),
self.db) as trans:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_person_gramps_id())
self.db.commit_person(self.obj, trans)
msg = _("Edit Person (%s)") % \
self.name_displayer.display(self.obj)
trans.set_description(msg)
self._do_close()
if self.callback:

View File

@ -301,17 +301,18 @@ class EditPlace(EditPrimary):
self.ok_button.set_sensitive(True)
return
with DbTxn('', self.db) as trans:
place_title = place_displayer.display(self.db, self.obj)
if not self.obj.get_handle():
if not self.obj.handle:
with DbTxn(_("Add Place (%s)") % place_title,
self.db) as trans:
self.db.add_place(self.obj, trans)
msg = _("Add Place (%s)") % place_title
else:
if self.data_has_changed():
with DbTxn(_("Edit Place (%s)") % place_title,
self.db) as trans:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_place_gramps_id())
self.db.commit_place(self.obj, trans)
msg = _("Edit Place (%s)") % place_title
trans.set_description(msg)
self._do_close()
if self.callback:

View File

@ -195,16 +195,17 @@ class EditRepository(EditPrimary):
self.ok_button.set_sensitive(True)
return
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
if not self.obj.handle:
with DbTxn(_("Add Repository (%s)") % self.obj.get_name(),
self.db) as trans:
self.db.add_repository(self.obj, trans)
msg = _("Add Repository (%s)") % self.obj.get_name()
else:
if self.data_has_changed():
with DbTxn(_("Edit Repository (%s)") % self.obj.get_name(),
self.db) as trans:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_repository_gramps_id())
self.db.commit_repository(self.obj, trans)
msg = _("Edit Repository (%s)") % self.obj.get_name()
trans.set_description(msg)
self._do_close()

View File

@ -216,16 +216,17 @@ class EditSource(EditPrimary):
self.ok_button.set_sensitive(True)
return
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
if not self.obj.handle:
with DbTxn(_("Add Source (%s)") % self.obj.get_title(),
self.db) as trans:
self.db.add_source(self.obj, trans)
msg = _("Add Source (%s)") % self.obj.get_title()
else:
if self.data_has_changed():
with DbTxn(_("Edit Source (%s)") % self.obj.get_title(),
self.db) as trans:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_source_gramps_id())
self.db.commit_source(self.obj, trans)
msg = _("Edit Source (%s)") % self.obj.get_title()
trans.set_description(msg)
self._do_close()
if self.callback: