2008-02-08 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/Editors/_EditEvent.py: * src/Editors/_EditFamily.py: * src/Editors/_EditMedia.py: * src/Editors/_EditNote.py: * src/Editors/_EditPlace.py: * src/Editors/_EditRepository.py: * src/Editors/_EditSource.py: fixed: 0001347: double gid should not be allowed svn: r10007
This commit is contained in:
parent
3ce6b13bb3
commit
7219ed2b44
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2008-02-08 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||
* src/Editors/_EditEvent.py:
|
||||
* src/Editors/_EditFamily.py:
|
||||
* src/Editors/_EditMedia.py:
|
||||
* src/Editors/_EditNote.py:
|
||||
* src/Editors/_EditPlace.py:
|
||||
* src/Editors/_EditRepository.py:
|
||||
* src/Editors/_EditSource.py:
|
||||
fixed: 0001347: double gid should not be allowed
|
||||
|
||||
2008-02-08 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||
* src/Editors/_EditEvent.py:
|
||||
* src/Editors/_EditFamily.py:
|
||||
|
@ -68,7 +68,8 @@ class EditEvent(EditPrimary):
|
||||
def __init__(self, dbstate, uistate, track, event, callback=None):
|
||||
|
||||
EditPrimary.__init__(self, dbstate, uistate, track,
|
||||
event, dbstate.db.get_event_from_handle)
|
||||
event, dbstate.db.get_event_from_handle,
|
||||
dbstate.db.get_event_from_gramps_id)
|
||||
|
||||
self._init_event()
|
||||
|
||||
@ -117,44 +118,34 @@ class EditEvent(EditPrimary):
|
||||
|
||||
# place, select_place, add_del_place
|
||||
|
||||
self.place_field = PlaceEntry(
|
||||
self.dbstate,
|
||||
self.uistate,
|
||||
self.track,
|
||||
self.top.get_widget("place"),
|
||||
self.obj.set_place_handle,
|
||||
self.obj.get_place_handle,
|
||||
self.add_del_btn,
|
||||
self.share_btn)
|
||||
self.place_field = PlaceEntry(self.dbstate, self.uistate, self.track,
|
||||
self.top.get_widget("place"),
|
||||
self.obj.set_place_handle,
|
||||
self.obj.get_place_handle,
|
||||
self.add_del_btn, self.share_btn)
|
||||
|
||||
self.descr_field = MonitoredEntry(
|
||||
self.top.get_widget("event_description"),
|
||||
self.obj.set_description,
|
||||
self.obj.get_description, self.db.readonly)
|
||||
self.descr_field = MonitoredEntry(self.top.get_widget("event_description"),
|
||||
self.obj.set_description,
|
||||
self.obj.get_description,
|
||||
self.db.readonly)
|
||||
|
||||
self.gid = MonitoredEntry(
|
||||
self.top.get_widget("gid"),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id,
|
||||
self.db.readonly)
|
||||
self.gid = MonitoredEntry(self.top.get_widget("gid"),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id, self.db.readonly)
|
||||
|
||||
self.priv = PrivacyButton(
|
||||
self.top.get_widget("private"),
|
||||
self.obj, self.db.readonly)
|
||||
self.priv = PrivacyButton( self.top.get_widget("private"),
|
||||
self.obj, self.db.readonly)
|
||||
|
||||
self.event_menu = MonitoredDataType(
|
||||
self.top.get_widget("personal_events"),
|
||||
self.obj.set_type,
|
||||
self.obj.get_type,
|
||||
custom_values=self.get_custom_events())
|
||||
self.event_menu = MonitoredDataType(self.top.get_widget("personal_events"),
|
||||
self.obj.set_type,
|
||||
self.obj.get_type,
|
||||
custom_values=self.get_custom_events())
|
||||
|
||||
self.date_field = MonitoredDate(
|
||||
self.top.get_widget("date_entry"),
|
||||
self.top.get_widget("date_stat"),
|
||||
self.obj.get_date_object(),
|
||||
self.uistate,
|
||||
self.track,
|
||||
self.db.readonly)
|
||||
self.date_field = MonitoredDate(self.top.get_widget("date_entry"),
|
||||
self.top.get_widget("date_stat"),
|
||||
self.obj.get_date_object(),
|
||||
self.uistate, self.track,
|
||||
self.db.readonly)
|
||||
|
||||
def _create_tabbed_pages(self):
|
||||
"""
|
||||
@ -214,6 +205,20 @@ class EditEvent(EditPrimary):
|
||||
"enter data or cancel the edit."))
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
(uses_dupe_id, id) = self._uses_duplicate_id()
|
||||
if uses_dupe_id:
|
||||
prim_object = self.get_from_gramps_id(id)
|
||||
name = prim_object.get_description()
|
||||
msg1 = _("Cannot save event. ID already exists.")
|
||||
msg2 = _("You have attempted to use the existing GRAMPS ID with "
|
||||
"value %(id)s. This value is already used by '"
|
||||
"%(prim_object)s'. Please enter a different ID or leave "
|
||||
"blank to get the next available ID value.") % {
|
||||
'id' : id, 'prim_object' : name }
|
||||
ErrorDialog(msg1, msg2)
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
t = self.obj.get_type()
|
||||
if t.is_custom() and str(t) == '':
|
||||
|
@ -52,6 +52,7 @@ from GrampsWidgets import MonitoredDate, MonitoredEntry, PrivacyButton
|
||||
from DisplayTabs import (SourceEmbedList, AttrEmbedList, NoteTab,
|
||||
MediaBackRefList)
|
||||
from Editors.AddMedia import AddMediaObject
|
||||
from QuestionDialog import ErrorDialog
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# EditMedia
|
||||
@ -59,13 +60,14 @@ from Editors.AddMedia import AddMediaObject
|
||||
#-------------------------------------------------------------------------
|
||||
class EditMedia(EditPrimary):
|
||||
|
||||
def __init__(self, state, uistate, track, obj, callback=None):
|
||||
def __init__(self, dbstate, uistate, track, obj, callback=None):
|
||||
|
||||
EditPrimary.__init__(self, state, uistate, track, obj,
|
||||
state.db.get_object_from_handle, callback)
|
||||
EditPrimary.__init__(self, dbstate, uistate, track, obj,
|
||||
dbstate.db.get_object_from_handle,
|
||||
dbstate.db.get_object_from_gramps_id, callback)
|
||||
if not self.obj.get_handle():
|
||||
#show the addmedia dialog immediately, with track of parent.
|
||||
AddMediaObject(state, self.uistate, self.track, self.obj,
|
||||
AddMediaObject(dbstate, self.uistate, self.track, self.obj,
|
||||
self._update_addmedia)
|
||||
|
||||
def empty_object(self):
|
||||
@ -103,29 +105,23 @@ class EditMedia(EditPrimary):
|
||||
'adv-media')
|
||||
|
||||
def _setup_fields(self):
|
||||
self.date_field = MonitoredDate(
|
||||
self.glade.get_widget("date_entry"),
|
||||
self.glade.get_widget("date_edit"),
|
||||
self.obj.get_date_object(),
|
||||
self.uistate,
|
||||
self.track,
|
||||
self.db.readonly)
|
||||
self.date_field = MonitoredDate(self.glade.get_widget("date_entry"),
|
||||
self.glade.get_widget("date_edit"),
|
||||
self.obj.get_date_object(),
|
||||
self.uistate, self.track,
|
||||
self.db.readonly)
|
||||
|
||||
self.descr_window = MonitoredEntry(
|
||||
self.glade.get_widget("description"),
|
||||
self.obj.set_description,
|
||||
self.obj.get_description,
|
||||
self.db.readonly)
|
||||
self.descr_window = MonitoredEntry(self.glade.get_widget("description"),
|
||||
self.obj.set_description,
|
||||
self.obj.get_description,
|
||||
self.db.readonly)
|
||||
|
||||
self.gid = MonitoredEntry(
|
||||
self.glade.get_widget("gid"),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id,
|
||||
self.db.readonly)
|
||||
self.gid = MonitoredEntry(self.glade.get_widget("gid"),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id, self.db.readonly)
|
||||
|
||||
self.privacy = PrivacyButton(
|
||||
self.glade.get_widget("private"),
|
||||
self.obj, self.db.readonly)
|
||||
self.privacy = PrivacyButton(self.glade.get_widget("private"),
|
||||
self.obj, self.db.readonly)
|
||||
|
||||
self.pixmap = self.glade.get_widget("pixmap")
|
||||
ebox = self.glade.get_widget('eventbox')
|
||||
@ -216,6 +212,27 @@ class EditMedia(EditPrimary):
|
||||
|
||||
def save(self, *obj):
|
||||
self.ok_button.set_sensitive(False)
|
||||
if self.object_is_empty():
|
||||
ErrorDialog(_("Cannot save media object"),
|
||||
_("No data exists for this media object. Please "
|
||||
"enter data or cancel the edit."))
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
(uses_dupe_id, id) = self._uses_duplicate_id()
|
||||
if uses_dupe_id:
|
||||
prim_object = self.get_from_gramps_id(id)
|
||||
name = prim_object.get_description()
|
||||
msg1 = _("Cannot save media object. ID already exists.")
|
||||
msg2 = _("You have attempted to use the existing GRAMPS ID with "
|
||||
"value %(id)s. This value is already used by '"
|
||||
"%(prim_object)s'. Please enter a different ID or leave "
|
||||
"blank to get the next available ID value.") % {
|
||||
'id' : id, 'prim_object' : name }
|
||||
ErrorDialog(msg1, msg2)
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
path = self.glade.get_widget('path').get_text()
|
||||
|
||||
if path != self.obj.get_path():
|
||||
|
@ -54,6 +54,7 @@ from DisplayTabs import GrampsTab, NoteBackRefList
|
||||
from GrampsWidgets import (MonitoredDataType, MonitoredCheckbox,
|
||||
MonitoredEntry, PrivacyButton)
|
||||
from gen.lib import Note
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -126,8 +127,8 @@ class EditNote(EditPrimary):
|
||||
hand_cursor = gtk.gdk.Cursor(gtk.gdk.HAND2)
|
||||
regular_cursor = gtk.gdk.Cursor(gtk.gdk.XTERM)
|
||||
|
||||
def __init__(self, state, uistate, track, note, callback=None
|
||||
, callertitle = None, extratype = None):
|
||||
def __init__(self, dbstate, uistate, track, note, callback=None,
|
||||
callertitle = None, extratype = None):
|
||||
"""Create an EditNote window. Associate a note with the window.
|
||||
|
||||
@param callertitle: a text passed by calling object to add to title
|
||||
@ -138,8 +139,9 @@ class EditNote(EditPrimary):
|
||||
"""
|
||||
self.callertitle = callertitle
|
||||
self.extratype = extratype
|
||||
EditPrimary.__init__(self, state, uistate, track, note,
|
||||
state.db.get_note_from_handle, callback)
|
||||
EditPrimary.__init__(self, dbstate, uistate, track, note,
|
||||
dbstate.db.get_note_from_handle,
|
||||
dbstate.db.get_note_from_gramps_id, callback)
|
||||
|
||||
def empty_object(self):
|
||||
"""Return an empty Note object for comparison for changes.
|
||||
@ -481,6 +483,26 @@ class EditNote(EditPrimary):
|
||||
|
||||
def save(self, *obj):
|
||||
"""Save the data."""
|
||||
self.ok_button.set_sensitive(False)
|
||||
if self.object_is_empty():
|
||||
ErrorDialog(_("Cannot save note"),
|
||||
_("No data exists for this note. Please "
|
||||
"enter data or cancel the edit."))
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
(uses_dupe_id, id) = self._uses_duplicate_id()
|
||||
if uses_dupe_id:
|
||||
msg1 = _("Cannot save note. ID already exists.")
|
||||
msg2 = _("You have attempted to use the existing GRAMPS ID with "
|
||||
"value %(id)s. This value is already used. Please "
|
||||
"enter a different ID or leave "
|
||||
"blank to get the next available ID value.") % {
|
||||
'id' : id }
|
||||
ErrorDialog(msg1, msg2)
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
trans = self.db.transaction_begin()
|
||||
|
||||
self.update_note()
|
||||
|
@ -91,15 +91,16 @@ class EditPerson(EditPrimary):
|
||||
use_patronymic = locale.getlocale(locale.LC_TIME)[0] in _use_patronymic
|
||||
QR_CATEGORY = CATEGORY_QR_PERSON
|
||||
|
||||
def __init__(self, state, uistate, track, person, callback=None):
|
||||
def __init__(self, dbstate, uistate, track, person, callback=None):
|
||||
"""
|
||||
Create an EditPerson window.
|
||||
|
||||
Associates a person with the window.
|
||||
Associate a person with the window.
|
||||
|
||||
"""
|
||||
EditPrimary.__init__(self, state, uistate, track, person,
|
||||
state.db.get_person_from_handle, callback)
|
||||
EditPrimary.__init__(self, dbstate, uistate, track, person,
|
||||
dbstate.db.get_person_from_handle,
|
||||
dbstate.db.get_person_from_gramps_id, callback)
|
||||
|
||||
def empty_object(self):
|
||||
"""
|
||||
@ -606,23 +607,6 @@ class EditPerson(EditPrimary):
|
||||
if gender >= 0:
|
||||
self.obj.set_gender(gender)
|
||||
|
||||
def _person_uses_duplicate_id(self):
|
||||
"""
|
||||
Check whether a changed or added person ID already exists in the DB.
|
||||
|
||||
Return True if a duplicate person ID has been detected.
|
||||
"""
|
||||
original = self.db.get_person_from_handle(self.obj.get_handle())
|
||||
if original and original.get_gramps_id() == self.obj.get_gramps_id():
|
||||
return (False, '', '')
|
||||
else:
|
||||
idval = self.obj.get_gramps_id()
|
||||
person = self.db.get_person_from_gramps_id(idval)
|
||||
if person:
|
||||
name = self.name_displayer.display(person)
|
||||
return (True, idval, name)
|
||||
return (False, '', '')
|
||||
|
||||
def _update_family_ids(self, trans):
|
||||
# Update each of the families child lists to reflect any
|
||||
# change in ordering due to the new birth date
|
||||
@ -696,23 +680,26 @@ class EditPerson(EditPrimary):
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
(uses_dupe_id, id) = self._uses_duplicate_id()
|
||||
if uses_dupe_id:
|
||||
prim_object = self.get_from_gramps_id(id)
|
||||
name = self.name_displayer.display(prim_object)
|
||||
msg1 = _("Cannot save person. ID already exists.")
|
||||
msg2 = _("You have attempted to use the existing GRAMPS ID with "
|
||||
"value %(id)s. This value is already used by '"
|
||||
"%(prim_object)s'. Please enter a different ID or leave "
|
||||
"blank to get the next available ID value.") % {
|
||||
'id' : id, 'prim_object' : name }
|
||||
ErrorDialog(msg1, msg2)
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
self._check_for_unknown_gender()
|
||||
|
||||
set_birth_death_index(self.db, self.obj)
|
||||
|
||||
trans = self.db.transaction_begin()
|
||||
|
||||
(uses_dupe_id, person_id, name) = self._person_uses_duplicate_id()
|
||||
if uses_dupe_id:
|
||||
msg1 = _("Cannot save person. ID already exists.")
|
||||
msg2 = _("You have attempted to use the existing GRAMPS ID with "
|
||||
"value %(person_id)s. This value is already used by "
|
||||
"%(person)s. Please enter a different ID or leave "
|
||||
"blank to get the next available ID value.") % {
|
||||
'person_id' : person_id, 'person' : name }
|
||||
ErrorDialog(msg1, msg2)
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
self._update_family_ids(trans)
|
||||
|
||||
|
@ -52,6 +52,7 @@ from DisplayTabs import (GrampsTab, LocationEmbedList, SourceEmbedList,
|
||||
from GrampsWidgets import MonitoredEntry, PrivacyButton
|
||||
from Errors import ValidationError
|
||||
from PlaceUtils import conv_lat_lon
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -105,7 +106,8 @@ class EditPlace(EditPrimary):
|
||||
|
||||
def __init__(self, dbstate, uistate, track, place, callback=None):
|
||||
EditPrimary.__init__(self, dbstate, uistate, track, place,
|
||||
dbstate.db.get_place_from_handle, callback)
|
||||
dbstate.db.get_place_from_handle,
|
||||
dbstate.db.get_place_from_gramps_id, callback)
|
||||
|
||||
def empty_object(self):
|
||||
return gen.lib.Place()
|
||||
@ -141,51 +143,48 @@ class EditPlace(EditPrimary):
|
||||
def _setup_fields(self):
|
||||
mloc = self.obj.get_main_location()
|
||||
|
||||
self.title = MonitoredEntry(
|
||||
self.top.get_widget("place_title"),
|
||||
self.obj.set_title, self.obj.get_title,
|
||||
self.db.readonly)
|
||||
self.title = MonitoredEntry(self.top.get_widget("place_title"),
|
||||
self.obj.set_title, self.obj.get_title,
|
||||
self.db.readonly)
|
||||
|
||||
self.street = MonitoredEntry(
|
||||
self.top.get_widget("street"),
|
||||
mloc.set_street, mloc.get_street, self.db.readonly)
|
||||
self.street = MonitoredEntry(self.top.get_widget("street"),
|
||||
mloc.set_street, mloc.get_street,
|
||||
self.db.readonly)
|
||||
|
||||
self.city = MonitoredEntry(
|
||||
self.top.get_widget("city"),
|
||||
mloc.set_city, mloc.get_city, self.db.readonly)
|
||||
self.city = MonitoredEntry(self.top.get_widget("city"),
|
||||
mloc.set_city, mloc.get_city,
|
||||
self.db.readonly)
|
||||
|
||||
self.gid = MonitoredEntry(
|
||||
self.top.get_widget("gid"),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id, self.db.readonly)
|
||||
self.gid = MonitoredEntry(self.top.get_widget("gid"),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id, self.db.readonly)
|
||||
|
||||
self.privacy = PrivacyButton(
|
||||
self.top.get_widget("private"),
|
||||
self.obj, self.db.readonly)
|
||||
self.privacy = PrivacyButton(self.top.get_widget("private"), self.obj,
|
||||
self.db.readonly)
|
||||
|
||||
self.parish = MonitoredEntry(
|
||||
self.top.get_widget("parish"),
|
||||
mloc.set_parish, mloc.get_parish, self.db.readonly)
|
||||
self.parish = MonitoredEntry(self.top.get_widget("parish"),
|
||||
mloc.set_parish, mloc.get_parish,
|
||||
self.db.readonly)
|
||||
|
||||
self.county = MonitoredEntry(
|
||||
self.top.get_widget("county"),
|
||||
mloc.set_county, mloc.get_county, self.db.readonly)
|
||||
self.county = MonitoredEntry(self.top.get_widget("county"),
|
||||
mloc.set_county, mloc.get_county,
|
||||
self.db.readonly)
|
||||
|
||||
self.state = MonitoredEntry(
|
||||
self.top.get_widget("state"),
|
||||
mloc.set_state, mloc.get_state, self.db.readonly)
|
||||
self.state = MonitoredEntry(self.top.get_widget("state"),
|
||||
mloc.set_state, mloc.get_state,
|
||||
self.db.readonly)
|
||||
|
||||
self.phone = MonitoredEntry(
|
||||
self.top.get_widget("phone"),
|
||||
mloc.set_phone, mloc.get_phone, self.db.readonly)
|
||||
self.phone = MonitoredEntry(self.top.get_widget("phone"),
|
||||
mloc.set_phone, mloc.get_phone,
|
||||
self.db.readonly)
|
||||
|
||||
self.postal = MonitoredEntry(
|
||||
self.top.get_widget("postal"),
|
||||
mloc.set_postal_code, mloc.get_postal_code, self.db.readonly)
|
||||
self.postal = MonitoredEntry(self.top.get_widget("postal"),
|
||||
mloc.set_postal_code,
|
||||
mloc.get_postal_code, self.db.readonly)
|
||||
|
||||
self.country = MonitoredEntry(
|
||||
self.top.get_widget("country"),
|
||||
mloc.set_country, mloc.get_country, self.db.readonly)
|
||||
self.country = MonitoredEntry(self.top.get_widget("country"),
|
||||
mloc.set_country, mloc.get_country,
|
||||
self.db.readonly)
|
||||
|
||||
self.longitude = MonitoredEntry(
|
||||
self.top.get_widget("lon_entry"),
|
||||
@ -261,6 +260,26 @@ class EditPlace(EditPrimary):
|
||||
|
||||
def save(self, *obj):
|
||||
self.ok_button.set_sensitive(False)
|
||||
if self.object_is_empty():
|
||||
ErrorDialog(_("Cannot save place"),
|
||||
_("No data exists for this place. Please "
|
||||
"enter data or cancel the edit."))
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
(uses_dupe_id, id) = self._uses_duplicate_id()
|
||||
if uses_dupe_id:
|
||||
prim_object = self.get_from_gramps_id(id)
|
||||
name = prim_object.get_title()
|
||||
msg1 = _("Cannot save place. ID already exists.")
|
||||
msg2 = _("You have attempted to use the existing GRAMPS ID with "
|
||||
"value %(id)s. This value is already used by '"
|
||||
"%(prim_object)s'. Please enter a different ID or leave "
|
||||
"blank to get the next available ID value.") % {
|
||||
'id' : id, 'prim_object' : name }
|
||||
ErrorDialog(msg1, msg2)
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
trans = self.db.transaction_begin()
|
||||
if not self.obj.get_handle():
|
||||
|
@ -47,13 +47,15 @@ import gen.lib
|
||||
from GrampsWidgets import MonitoredEntry, MonitoredDataType, PrivacyButton
|
||||
from DisplayTabs import AddrEmbedList, WebEmbedList, NoteTab, SourceBackRefList
|
||||
from Editors._EditPrimary import EditPrimary
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
class EditRepository(EditPrimary):
|
||||
|
||||
def __init__(self, dbstate, uistate, track, repository):
|
||||
|
||||
EditPrimary.__init__(self, dbstate, uistate, track,
|
||||
repository, dbstate.db.get_repository_from_handle)
|
||||
EditPrimary.__init__(self, dbstate, uistate, track, repository,
|
||||
dbstate.db.get_repository_from_handle,
|
||||
dbstate.db.get_repository_from_gramps_id)
|
||||
|
||||
def empty_object(self):
|
||||
return gen.lib.Repository()
|
||||
@ -84,30 +86,23 @@ class EditRepository(EditPrimary):
|
||||
|
||||
def _setup_fields(self):
|
||||
|
||||
self.name = MonitoredEntry(
|
||||
self.glade.get_widget("repository_name"),
|
||||
self.obj.set_name,
|
||||
self.obj.get_name,
|
||||
self.db.readonly)
|
||||
self.name = MonitoredEntry(self.glade.get_widget("repository_name"),
|
||||
self.obj.set_name, self.obj.get_name,
|
||||
self.db.readonly)
|
||||
|
||||
self.type = MonitoredDataType(
|
||||
self.glade.get_widget("repository_type"),
|
||||
self.obj.set_type,
|
||||
self.obj.get_type,
|
||||
self.db.readonly,
|
||||
self.db.get_repository_types(),
|
||||
self.type = MonitoredDataType(self.glade.get_widget("repository_type"),
|
||||
self.obj.set_type, self.obj.get_type,
|
||||
self.db.readonly,
|
||||
self.db.get_repository_types(),
|
||||
)
|
||||
|
||||
self.call_number = MonitoredEntry(
|
||||
self.glade.get_widget('gid'),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id,
|
||||
self.db.readonly)
|
||||
self.call_number = MonitoredEntry(self.glade.get_widget('gid'),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id,
|
||||
self.db.readonly)
|
||||
|
||||
self.privacy = PrivacyButton(
|
||||
self.glade.get_widget("private"),
|
||||
self.obj,
|
||||
self.db.readonly)
|
||||
self.privacy = PrivacyButton(self.glade.get_widget("private"),
|
||||
self.obj, self.db.readonly)
|
||||
|
||||
def _create_tabbed_pages(self):
|
||||
|
||||
@ -146,13 +141,26 @@ class EditRepository(EditPrimary):
|
||||
def save(self, *obj):
|
||||
self.ok_button.set_sensitive(False)
|
||||
if self.object_is_empty():
|
||||
from QuestionDialog import ErrorDialog
|
||||
ErrorDialog(_("Cannot save repository"),
|
||||
_("No data exists for this repository. Please "
|
||||
"enter data or cancel the edit."))
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
(uses_dupe_id, id) = self._uses_duplicate_id()
|
||||
if uses_dupe_id:
|
||||
prim_object = self.get_from_gramps_id(id)
|
||||
name = prim_object.get_name()
|
||||
msg1 = _("Cannot save repository. ID already exists.")
|
||||
msg2 = _("You have attempted to use the existing GRAMPS ID with "
|
||||
"value %(id)s. This value is already used by '"
|
||||
"%(prim_object)s'. Please enter a different ID or leave "
|
||||
"blank to get the next available ID value.") % {
|
||||
'id' : id, 'prim_object' : name }
|
||||
ErrorDialog(msg1, msg2)
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
trans = self.db.transaction_begin()
|
||||
if not self.obj.get_handle():
|
||||
self.db.add_repository(self.obj, trans)
|
||||
|
@ -51,6 +51,7 @@ from Editors._EditPrimary import EditPrimary
|
||||
from DisplayTabs import (NoteTab, GalleryTab, DataEmbedList,
|
||||
SourceBackRefList, RepoEmbedList)
|
||||
from GrampsWidgets import MonitoredEntry, PrivacyButton
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -59,10 +60,11 @@ from GrampsWidgets import MonitoredEntry, PrivacyButton
|
||||
#-------------------------------------------------------------------------
|
||||
class EditSource(EditPrimary):
|
||||
|
||||
def __init__(self, dbstate, uistate, track,source):
|
||||
def __init__(self, dbstate, uistate, track, source):
|
||||
|
||||
EditPrimary.__init__(self, dbstate, uistate, track,
|
||||
source, dbstate.db.get_source_from_handle)
|
||||
EditPrimary.__init__(self, dbstate, uistate, track, source,
|
||||
dbstate.db.get_source_from_handle,
|
||||
dbstate.db.get_source_from_gramps_id)
|
||||
|
||||
def empty_object(self):
|
||||
return gen.lib.Source()
|
||||
@ -92,39 +94,30 @@ class EditSource(EditPrimary):
|
||||
self.define_help_button(self.glade.get_widget('help'),'adv-src')
|
||||
|
||||
def _setup_fields(self):
|
||||
self.author = MonitoredEntry(
|
||||
self.glade.get_widget("author"),
|
||||
self.obj.set_author,
|
||||
self.obj.get_author,
|
||||
self.db.readonly)
|
||||
self.author = MonitoredEntry(self.glade.get_widget("author"),
|
||||
self.obj.set_author, self.obj.get_author,
|
||||
self.db.readonly)
|
||||
|
||||
self.pubinfo = MonitoredEntry(
|
||||
self.glade.get_widget("pubinfo"),
|
||||
self.obj.set_publication_info,
|
||||
self.obj.get_publication_info,
|
||||
self.db.readonly)
|
||||
self.pubinfo = MonitoredEntry(self.glade.get_widget("pubinfo"),
|
||||
self.obj.set_publication_info,
|
||||
self.obj.get_publication_info,
|
||||
self.db.readonly)
|
||||
|
||||
self.gid = MonitoredEntry(
|
||||
self.glade.get_widget("gid"),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id,
|
||||
self.db.readonly)
|
||||
self.gid = MonitoredEntry(self.glade.get_widget("gid"),
|
||||
self.obj.set_gramps_id,
|
||||
self.obj.get_gramps_id, self.db.readonly)
|
||||
|
||||
self.priv = PrivacyButton(
|
||||
self.glade.get_widget("private"),
|
||||
self.obj, self.db.readonly)
|
||||
self.priv = PrivacyButton(self.glade.get_widget("private"), self.obj,
|
||||
self.db.readonly)
|
||||
|
||||
self.abbrev = MonitoredEntry(
|
||||
self.glade.get_widget("abbrev"),
|
||||
self.obj.set_abbreviation,
|
||||
self.obj.get_abbreviation,
|
||||
self.db.readonly)
|
||||
self.abbrev = MonitoredEntry(self.glade.get_widget("abbrev"),
|
||||
self.obj.set_abbreviation,
|
||||
self.obj.get_abbreviation,
|
||||
self.db.readonly)
|
||||
|
||||
self.title = MonitoredEntry(
|
||||
self.glade.get_widget("source_title"),
|
||||
self.obj.set_title,
|
||||
self.obj.get_title,
|
||||
self.db.readonly)
|
||||
self.title = MonitoredEntry(self.glade.get_widget("source_title"),
|
||||
self.obj.set_title, self.obj.get_title,
|
||||
self.db.readonly)
|
||||
|
||||
def _create_tabbed_pages(self):
|
||||
notebook = gtk.Notebook()
|
||||
@ -165,13 +158,25 @@ class EditSource(EditPrimary):
|
||||
def save(self, *obj):
|
||||
self.ok_button.set_sensitive(False)
|
||||
if self.object_is_empty():
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
ErrorDialog(_("Cannot save source"),
|
||||
_("No data exists for this source. Please "
|
||||
"enter data or cancel the edit."))
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
(uses_dupe_id, id) = self._uses_duplicate_id()
|
||||
if uses_dupe_id:
|
||||
prim_object = self.get_from_gramps_id(id)
|
||||
name = prim_object.get_title()
|
||||
msg1 = _("Cannot save source. ID already exists.")
|
||||
msg2 = _("You have attempted to use the existing GRAMPS ID with "
|
||||
"value %(id)s. This value is already used by '"
|
||||
"%(prim_object)s'. Please enter a different ID or leave "
|
||||
"blank to get the next available ID value.") % {
|
||||
'id' : id, 'prim_object' : name }
|
||||
ErrorDialog(msg1, msg2)
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
trans = self.db.transaction_begin()
|
||||
if not self.obj.get_handle():
|
||||
|
Loading…
Reference in New Issue
Block a user