diff --git a/ChangeLog b/ChangeLog index 4920f40ad..b72e518d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,19 @@ +2008-02-07 Raphael Ackermann + * src/Editors/_EditEvent.py: + * src/Editors/_EditFamily.py: + * src/Editors/_EditMedia.py: + * src/Editors/_EditNote.py: + * src/Editors/_EditPerson.py: + * src/Editors/_EditPlace.py: + * src/Editors/_EditPrimary.py: + * src/Editors/_EditRepository.py: + * src/Editors/_EditSource.py: + 0001745: fix where on update empty ID field would not be filled + automatically + 2008-02-07 Jerome Rapinat - * src/DateHandler/_Date_fr.py : fix issue with french calendar and - year only #1733 + * src/DateHandler/_Date_fr.py : fix issue with french calendar and + year only #1733 2008-02-07 Raphael Ackermann * src/Editors/_EditPerson.py: pylint fixes & doc fixes diff --git a/src/Editors/_EditEvent.py b/src/Editors/_EditEvent.py index 6fff0df6d..13d1a899e 100644 --- a/src/Editors/_EditEvent.py +++ b/src/Editors/_EditEvent.py @@ -220,14 +220,16 @@ class EditEvent(EditPrimary): self.ok_button.set_sensitive(True) return - if self.obj.handle == None: + if not self.obj.handle: trans = self.db.transaction_begin() - self.db.add_event(self.obj,trans) - self.db.transaction_commit(trans,_("Add Event")) + self.db.add_event(self.obj, trans) + self.db.transaction_commit(trans, _("Add Event")) else: - orig = self.dbstate.db.get_event_from_handle(self.obj.handle) + orig = self.get_from_handle(self.obj.handle) if cmp(self.obj.serialize(),orig.serialize()): trans = self.db.transaction_begin() + 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.transaction_commit(trans,_("Edit Event")) diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index bc7cf2fb6..1d37c21a8 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -943,7 +943,7 @@ class EditFamily(EditPrimary): person.remove_parent_family_handle(self.obj.handle) self.db.commit_person(person,trans) - # add the family from children which have been addedna + # add the family to children which have been added for ref in new_set.difference(orig_set): person = self.db.get_person_from_handle(ref.ref) person.add_parent_family_handle(self.obj.handle) @@ -952,6 +952,8 @@ class EditFamily(EditPrimary): if self.object_is_empty(): self.db.remove_family(self.obj.handle,trans) else: + if not self.obj.get_gramps_id(): + self.obj.set_gramps_id(self.db.find_next_family_gramps_id()) self.db.commit_family(self.obj,trans) self.db.transaction_commit(trans,_("Edit Family")) diff --git a/src/Editors/_EditMedia.py b/src/Editors/_EditMedia.py index 10c968356..1d0bc3786 100644 --- a/src/Editors/_EditMedia.py +++ b/src/Editors/_EditMedia.py @@ -227,12 +227,16 @@ class EditMedia(EditPrimary): self.obj.set_path(Utils.get_unicode_path(path)) trans = self.db.transaction_begin() - if self.obj.get_handle(): - self.db.commit_media_object(self.obj, trans) - else: + if not self.obj.get_handle(): self.db.add_object(self.obj, trans) - self.db.transaction_commit(trans, _("Edit Media Object (%s)" - ) % self.obj.get_description()) + msg = _("Add Media Object (%s)") % self.obj.get_description() + else: + if not self.obj.get_gramps_id(): + self.obj.set_gramps_id(self.db.find_next_object_gramps_id()) + self.db.commit_media_object(self.obj, trans) + msg = _("Edit Media Object (%s)") % self.obj.get_description() + + self.db.transaction_commit(trans, msg) if self.callback: self.callback(self.obj) diff --git a/src/Editors/_EditNote.py b/src/Editors/_EditNote.py index bc8ed3e42..f721dd36e 100644 --- a/src/Editors/_EditNote.py +++ b/src/Editors/_EditNote.py @@ -480,11 +480,16 @@ class EditNote(EditPrimary): self.update_note() - if self.obj.get_handle(): - self.db.commit_note(self.obj,trans) - else: + if not self.obj.get_handle(): self.db.add_note(self.obj,trans) - self.db.transaction_commit(trans, _("Edit Note")) + msg = _("Add Note") + else: + 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") + + self.db.transaction_commit(trans, msg) if self.callback: self.callback(self.obj.get_handle()) diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index fdcb5a0e6..f1981e537 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -619,7 +619,7 @@ class EditPerson(EditPrimary): idval = self.obj.get_gramps_id() person = self.db.get_person_from_gramps_id(idval) if person: - name = self.nd.display(person) + name = self.name_displayer.display(person) return (True, idval, name) return (False, '', '') @@ -688,7 +688,6 @@ class EditPerson(EditPrimary): """ Save the data. """ - self.ok_button.set_sensitive(False) if self.object_is_empty(): ErrorDialog(_("Cannot save person"), @@ -719,12 +718,13 @@ class EditPerson(EditPrimary): if not self.obj.get_handle(): self.db.add_person(self.obj, trans) + msg = _("Add Person (%s)") % self.name_displayer.display(self.obj) else: 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) - msg = _("Edit Person (%s)") % self.nd.display(self.obj) self.db.transaction_commit(trans, msg) self.close() if self.callback: diff --git a/src/Editors/_EditPlace.py b/src/Editors/_EditPlace.py index a750f5461..0b125b02c 100644 --- a/src/Editors/_EditPlace.py +++ b/src/Editors/_EditPlace.py @@ -262,12 +262,15 @@ class EditPlace(EditPrimary): title = self.obj.get_title() trans = self.db.transaction_begin() - if self.obj.get_handle(): - self.db.commit_place(self.obj,trans) - else: + if not self.obj.get_handle(): self.db.add_place(self.obj,trans) - self.db.transaction_commit( - trans, _("Edit Place (%s)") % self.obj.get_title()) + msg = _("Add Place (%s)") % self.obj.get_title() + else: + 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)") % self.obj.get_title() + self.db.transaction_commit(trans, msg) if self.callback: self.callback(self.obj) diff --git a/src/Editors/_EditPrimary.py b/src/Editors/_EditPrimary.py index 831d6c079..8763694e6 100644 --- a/src/Editors/_EditPrimary.py +++ b/src/Editors/_EditPrimary.py @@ -39,7 +39,7 @@ class EditPrimary(ManagedWindow.ManagedWindow): self.dp = DateHandler.parser self.dd = DateHandler.displayer - self.nd = name_displayer + self.name_displayer = name_displayer self.obj = obj self.dbstate = state self.uistate = uistate diff --git a/src/Editors/_EditRepository.py b/src/Editors/_EditRepository.py index 5aaa043a7..a6e377cce 100644 --- a/src/Editors/_EditRepository.py +++ b/src/Editors/_EditRepository.py @@ -141,7 +141,7 @@ class EditRepository(EditPrimary): self.define_cancel_button(self.glade.get_widget('cancel')) self.define_ok_button(self.glade.get_widget('ok'), self.save) - def save(self,*obj): + def save(self, *obj): self.ok_button.set_sensitive(False) if self.object_is_empty(): from QuestionDialog import ErrorDialog @@ -152,12 +152,16 @@ class EditRepository(EditPrimary): return trans = self.db.transaction_begin() - if self.obj.get_handle() == None: - self.db.add_repository(self.obj,trans) + if not self.obj.get_handle(): + self.db.add_repository(self.obj, trans) + msg = _("Add Repository (%s)") % self.obj.get_name() else: - self.db.commit_repository(self.obj,trans) - msg = _("Edit Repository (%s)") % self.obj.get_name() - self.db.transaction_commit(trans,msg) + 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() + + self.db.transaction_commit(trans, msg) self.close() def _cleanup_on_exit(self): diff --git a/src/Editors/_EditSource.py b/src/Editors/_EditSource.py index 9b58cf979..eb97bb089 100644 --- a/src/Editors/_EditSource.py +++ b/src/Editors/_EditSource.py @@ -160,7 +160,7 @@ class EditSource(EditPrimary): def build_menu_names(self,source): return (_('Edit Source'), self.get_menu_title()) - def save(self,*obj): + def save(self, *obj): self.ok_button.set_sensitive(False) if self.object_is_empty(): from QuestionDialog import ErrorDialog @@ -172,12 +172,16 @@ class EditSource(EditPrimary): return trans = self.db.transaction_begin() - if self.obj.get_handle() == None: - self.db.add_source(self.obj,trans) + if not self.obj.get_handle(): + self.db.add_source(self.obj, trans) + msg = _("Add Source (%s)") % self.obj.get_title() else: - self.db.commit_source(self.obj,trans) - self.db.transaction_commit(trans, - _("Edit Source (%s)") % self.obj.get_title()) + 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() + + self.db.transaction_commit(trans, msg) self.close() def _cleanup_on_exit(self):