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:
parent
49321133e0
commit
e267893470
@ -307,17 +307,17 @@ class EditCitation(EditPrimary):
|
|||||||
self.ok_button.set_sensitive(True)
|
self.ok_button.set_sensitive(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
with DbTxn('', self.db) as trans:
|
if not self.obj.handle:
|
||||||
if not self.obj.get_handle():
|
with DbTxn(_("Add Citation (%s)") % self.obj.get_page(),
|
||||||
|
self.db) as trans:
|
||||||
self.db.add_citation(self.obj, trans)
|
self.db.add_citation(self.obj, trans)
|
||||||
msg = _("Add Citation (%s)") % self.obj.get_page()
|
else:
|
||||||
else:
|
if self.data_has_changed():
|
||||||
if not self.obj.get_gramps_id():
|
with DbTxn(_("Edit Citation (%s)") % self.obj.get_page(),
|
||||||
self.obj.set_gramps_id(
|
self.db) as trans:
|
||||||
self.db.find_next_citation_gramps_id())
|
if not self.obj.get_gramps_id():
|
||||||
self.db.commit_citation(self.obj, trans)
|
self.obj.set_gramps_id(self.db.find_next_citation_gramps_id())
|
||||||
msg = _("Edit Citation (%s)") % self.obj.get_page()
|
self.db.commit_citation(self.obj, trans)
|
||||||
trans.set_description(msg)
|
|
||||||
|
|
||||||
if self.callback:
|
if self.callback:
|
||||||
self.callback(self.obj.get_handle())
|
self.callback(self.obj.get_handle())
|
||||||
|
@ -269,13 +269,12 @@ class EditEvent(EditPrimary):
|
|||||||
self.db) as trans:
|
self.db) as trans:
|
||||||
self.db.add_event(self.obj, trans)
|
self.db.add_event(self.obj, trans)
|
||||||
else:
|
else:
|
||||||
orig = self.get_from_handle(self.obj.handle)
|
if self.data_has_changed():
|
||||||
if self.obj.serialize() != orig.serialize():
|
|
||||||
with DbTxn(_("Edit Event (%s)") % self.obj.get_gramps_id(),
|
with DbTxn(_("Edit Event (%s)") % self.obj.get_gramps_id(),
|
||||||
self.db) as trans:
|
self.db) as trans:
|
||||||
if not self.obj.get_gramps_id():
|
if not self.obj.get_gramps_id():
|
||||||
self.obj.set_gramps_id(self.db.find_next_event_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:
|
if self.callback:
|
||||||
self.callback(self.obj)
|
self.callback(self.obj)
|
||||||
|
@ -1129,7 +1129,7 @@ class EditFamily(EditPrimary):
|
|||||||
self.db.commit_person(child, trans)
|
self.db.commit_person(child, trans)
|
||||||
|
|
||||||
self.db.add_family(self.obj, 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:
|
with DbTxn(_("Edit Family"), self.db) as trans:
|
||||||
|
|
||||||
|
@ -320,16 +320,17 @@ class EditMedia(EditPrimary):
|
|||||||
|
|
||||||
self.obj.set_path(path)
|
self.obj.set_path(path)
|
||||||
|
|
||||||
with DbTxn('', self.db) as trans:
|
if not self.obj.handle:
|
||||||
if not self.obj.get_handle():
|
with DbTxn(_("Add Media Object (%s)") % self.obj.get_description(),
|
||||||
|
self.db) as trans:
|
||||||
self.db.add_media(self.obj, trans)
|
self.db.add_media(self.obj, trans)
|
||||||
msg = _("Add Media Object (%s)") % self.obj.get_description()
|
else:
|
||||||
else:
|
if self.data_has_changed():
|
||||||
if not self.obj.get_gramps_id():
|
with DbTxn(_("Edit Media Object (%s)") % self.obj.get_description(),
|
||||||
self.obj.set_gramps_id(self.db.find_next_media_gramps_id())
|
self.db) as trans:
|
||||||
self.db.commit_media(self.obj, trans)
|
if not self.obj.get_gramps_id():
|
||||||
msg = _("Edit Media Object (%s)") % self.obj.get_description()
|
self.obj.set_gramps_id(self.db.find_next_media_gramps_id())
|
||||||
trans.set_description(msg)
|
self.db.commit_media(self.obj, trans)
|
||||||
|
|
||||||
if self.callback:
|
if self.callback:
|
||||||
self.callback(self.obj)
|
self.callback(self.obj)
|
||||||
|
@ -332,16 +332,17 @@ class EditNote(EditPrimary):
|
|||||||
self.ok_button.set_sensitive(True)
|
self.ok_button.set_sensitive(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
with DbTxn('', self.db) as trans:
|
if not self.obj.handle:
|
||||||
if not self.obj.get_handle():
|
with DbTxn(_("Add Note"),
|
||||||
|
self.db) as trans:
|
||||||
self.db.add_note(self.obj, trans)
|
self.db.add_note(self.obj, trans)
|
||||||
msg = _("Add Note")
|
else:
|
||||||
else:
|
if self.data_has_changed():
|
||||||
if not self.obj.get_gramps_id():
|
with DbTxn(_("Edit Note"),
|
||||||
self.obj.set_gramps_id(self.db.find_next_note_gramps_id())
|
self.db) as trans:
|
||||||
self.db.commit_note(self.obj, trans)
|
if not self.obj.get_gramps_id():
|
||||||
msg = _("Edit Note")
|
self.obj.set_gramps_id(self.db.find_next_note_gramps_id())
|
||||||
trans.set_description(msg)
|
self.db.commit_note(self.obj, trans)
|
||||||
|
|
||||||
if self.callback:
|
if self.callback:
|
||||||
self.callback(self.obj.get_handle())
|
self.callback(self.obj.get_handle())
|
||||||
|
@ -856,19 +856,19 @@ class EditPerson(EditPrimary):
|
|||||||
|
|
||||||
self.db.set_birth_death_index(self.obj)
|
self.db.set_birth_death_index(self.obj)
|
||||||
|
|
||||||
with DbTxn('', self.db) as trans:
|
if not self.obj.handle:
|
||||||
self._update_family_ids()
|
with DbTxn(_("Add Person (%s)") % \
|
||||||
if not self.obj.get_handle():
|
self.name_displayer.display(self.obj),
|
||||||
|
self.db) as trans:
|
||||||
self.db.add_person(self.obj, trans)
|
self.db.add_person(self.obj, trans)
|
||||||
msg = _("Add Person (%s)") % \
|
else:
|
||||||
self.name_displayer.display(self.obj)
|
if self.data_has_changed():
|
||||||
else:
|
with DbTxn(_("Edit Person (%s)") % \
|
||||||
if not self.obj.get_gramps_id():
|
self.name_displayer.display(self.obj),
|
||||||
self.obj.set_gramps_id(self.db.find_next_person_gramps_id())
|
self.db) as trans:
|
||||||
self.db.commit_person(self.obj, trans)
|
if not self.obj.get_gramps_id():
|
||||||
msg = _("Edit Person (%s)") % \
|
self.obj.set_gramps_id(self.db.find_next_person_gramps_id())
|
||||||
self.name_displayer.display(self.obj)
|
self.db.commit_person(self.obj, trans)
|
||||||
trans.set_description(msg)
|
|
||||||
|
|
||||||
self._do_close()
|
self._do_close()
|
||||||
if self.callback:
|
if self.callback:
|
||||||
|
@ -301,17 +301,18 @@ class EditPlace(EditPrimary):
|
|||||||
self.ok_button.set_sensitive(True)
|
self.ok_button.set_sensitive(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
with DbTxn('', self.db) as trans:
|
place_title = place_displayer.display(self.db, self.obj)
|
||||||
place_title = place_displayer.display(self.db, self.obj)
|
if not self.obj.handle:
|
||||||
if not self.obj.get_handle():
|
with DbTxn(_("Add Place (%s)") % place_title,
|
||||||
|
self.db) as trans:
|
||||||
self.db.add_place(self.obj, trans)
|
self.db.add_place(self.obj, trans)
|
||||||
msg = _("Add Place (%s)") % place_title
|
else:
|
||||||
else:
|
if self.data_has_changed():
|
||||||
if not self.obj.get_gramps_id():
|
with DbTxn(_("Edit Place (%s)") % place_title,
|
||||||
self.obj.set_gramps_id(self.db.find_next_place_gramps_id())
|
self.db) as trans:
|
||||||
self.db.commit_place(self.obj, trans)
|
if not self.obj.get_gramps_id():
|
||||||
msg = _("Edit Place (%s)") % place_title
|
self.obj.set_gramps_id(self.db.find_next_place_gramps_id())
|
||||||
trans.set_description(msg)
|
self.db.commit_place(self.obj, trans)
|
||||||
|
|
||||||
self._do_close()
|
self._do_close()
|
||||||
if self.callback:
|
if self.callback:
|
||||||
|
@ -195,16 +195,17 @@ class EditRepository(EditPrimary):
|
|||||||
self.ok_button.set_sensitive(True)
|
self.ok_button.set_sensitive(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
with DbTxn('', self.db) as trans:
|
if not self.obj.handle:
|
||||||
if not self.obj.get_handle():
|
with DbTxn(_("Add Repository (%s)") % self.obj.get_name(),
|
||||||
|
self.db) as trans:
|
||||||
self.db.add_repository(self.obj, trans)
|
self.db.add_repository(self.obj, trans)
|
||||||
msg = _("Add Repository (%s)") % self.obj.get_name()
|
else:
|
||||||
else:
|
if self.data_has_changed():
|
||||||
if not self.obj.get_gramps_id():
|
with DbTxn(_("Edit Repository (%s)") % self.obj.get_name(),
|
||||||
self.obj.set_gramps_id(self.db.find_next_repository_gramps_id())
|
self.db) as trans:
|
||||||
self.db.commit_repository(self.obj, trans)
|
if not self.obj.get_gramps_id():
|
||||||
msg = _("Edit Repository (%s)") % self.obj.get_name()
|
self.obj.set_gramps_id(self.db.find_next_repository_gramps_id())
|
||||||
trans.set_description(msg)
|
self.db.commit_repository(self.obj, trans)
|
||||||
|
|
||||||
self._do_close()
|
self._do_close()
|
||||||
|
|
||||||
|
@ -216,16 +216,17 @@ class EditSource(EditPrimary):
|
|||||||
self.ok_button.set_sensitive(True)
|
self.ok_button.set_sensitive(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
with DbTxn('', self.db) as trans:
|
if not self.obj.handle:
|
||||||
if not self.obj.get_handle():
|
with DbTxn(_("Add Source (%s)") % self.obj.get_title(),
|
||||||
|
self.db) as trans:
|
||||||
self.db.add_source(self.obj, trans)
|
self.db.add_source(self.obj, trans)
|
||||||
msg = _("Add Source (%s)") % self.obj.get_title()
|
else:
|
||||||
else:
|
if self.data_has_changed():
|
||||||
if not self.obj.get_gramps_id():
|
with DbTxn(_("Edit Source (%s)") % self.obj.get_title(),
|
||||||
self.obj.set_gramps_id(self.db.find_next_source_gramps_id())
|
self.db) as trans:
|
||||||
self.db.commit_source(self.obj, trans)
|
if not self.obj.get_gramps_id():
|
||||||
msg = _("Edit Source (%s)") % self.obj.get_title()
|
self.obj.set_gramps_id(self.db.find_next_source_gramps_id())
|
||||||
trans.set_description(msg)
|
self.db.commit_source(self.obj, trans)
|
||||||
|
|
||||||
self._do_close()
|
self._do_close()
|
||||||
if self.callback:
|
if self.callback:
|
||||||
|
Loading…
Reference in New Issue
Block a user