2008-02-07 Raphael Ackermann <raphael.ackermann@gmail.com>

* 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

svn: r10004
This commit is contained in:
Raphael Ackermann 2008-02-08 13:40:04 +00:00
parent beb3b62518
commit 6776b91ca5
10 changed files with 74 additions and 37 deletions

View File

@ -1,6 +1,19 @@
2008-02-07 Raphael Ackermann <raphael.ackermann@gmail.com>
* 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 <romjerome@yahoo.fr>
* 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 <raphael.ackermann@gmail.com>
* src/Editors/_EditPerson.py: pylint fixes & doc fixes

View File

@ -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"))

View File

@ -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"))

View File

@ -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)

View File

@ -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())

View File

@ -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:

View File

@ -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)

View File

@ -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

View File

@ -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):

View File

@ -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):