5690: Can create multiple events with same Gramps-ID
This commit is contained in:
parent
e8297dea89
commit
3b15d81e43
@ -26,14 +26,14 @@
|
|||||||
# Python modules
|
# Python modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
|
||||||
_ = glocale.translation.gettext
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# gramps modules
|
# gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||||
|
_ = glocale.translation.gettext
|
||||||
from gramps.gen.lib import EventType, NoteType
|
from gramps.gen.lib import EventType, NoteType
|
||||||
from gramps.gen.db import DbTxn
|
from gramps.gen.db import DbTxn
|
||||||
from ..glade import Glade
|
from ..glade import Glade
|
||||||
@ -243,6 +243,9 @@ class EditEventRef(EditReference):
|
|||||||
|
|
||||||
def ok_clicked(self, obj):
|
def ok_clicked(self, obj):
|
||||||
|
|
||||||
|
if self.check_for_duplicate_id('Event'):
|
||||||
|
return
|
||||||
|
|
||||||
if self.source.handle:
|
if self.source.handle:
|
||||||
with DbTxn(_("Modify Event"), self.db) as trans:
|
with DbTxn(_("Modify Event"), self.db) as trans:
|
||||||
self.commit_event(self.source,trans)
|
self.commit_event(self.source,trans)
|
||||||
|
@ -499,6 +499,10 @@ class EditMediaRef(EditReference):
|
|||||||
self._setup_notebook_tabs(notebook_ref)
|
self._setup_notebook_tabs(notebook_ref)
|
||||||
|
|
||||||
def save(self,*obj):
|
def save(self,*obj):
|
||||||
|
|
||||||
|
if self.check_for_duplicate_id('Media'):
|
||||||
|
return
|
||||||
|
|
||||||
#first save primary object
|
#first save primary object
|
||||||
if self.source.handle:
|
if self.source.handle:
|
||||||
with DbTxn(_("Edit Media Object (%s)") %
|
with DbTxn(_("Edit Media Object (%s)") %
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||||
# 2009 Gary Burton
|
# 2009 Gary Burton
|
||||||
|
# Copyright (C) 2014 Paul Franklin
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -31,6 +32,9 @@ from gi.repository import Gtk
|
|||||||
# gramps modules
|
# gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||||
|
_ = glocale.translation.gettext
|
||||||
|
from ..dialog import ErrorDialog
|
||||||
from ..managedwindow import ManagedWindow
|
from ..managedwindow import ManagedWindow
|
||||||
from .displaytabs import GrampsTab
|
from .displaytabs import GrampsTab
|
||||||
from gramps.gen.config import config
|
from gramps.gen.config import config
|
||||||
@ -253,3 +257,43 @@ class EditReference(ManagedWindow, DbGUIElement):
|
|||||||
of the main interface, not of the displaytabs.
|
of the main interface, not of the displaytabs.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def check_for_duplicate_id(self, type):
|
||||||
|
"""
|
||||||
|
check to see if the gramps ID (if any) already exists
|
||||||
|
|
||||||
|
type : the gramps primary object type, a string
|
||||||
|
returns : True if the gramps ID already exists, else False
|
||||||
|
|
||||||
|
N.B. the various strings, string variables, and titles existed already
|
||||||
|
"""
|
||||||
|
new_id = self.source.get_gramps_id()
|
||||||
|
if new_id:
|
||||||
|
old_primary = self.db.get_from_name_and_gramps_id(type, new_id)
|
||||||
|
if old_primary:
|
||||||
|
if type == 'Event':
|
||||||
|
msg1 = _("Cannot save event. ID already exists.")
|
||||||
|
description = old_primary.get_description()
|
||||||
|
elif type == 'Media':
|
||||||
|
msg1 = _("Cannot save media object. ID already exists.")
|
||||||
|
description = old_primary.get_description()
|
||||||
|
elif type == 'Repository':
|
||||||
|
msg1 = _("Cannot save repository. ID already exists.")
|
||||||
|
description = old_primary.get_name()
|
||||||
|
if description:
|
||||||
|
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' : new_id, 'prim_object' : description }
|
||||||
|
else:
|
||||||
|
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' : new_id}
|
||||||
|
ErrorDialog(msg1, msg2)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
@ -24,14 +24,14 @@
|
|||||||
# Python modules
|
# Python modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
|
||||||
_ = glocale.translation.gettext
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# gramps modules
|
# gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||||
|
_ = glocale.translation.gettext
|
||||||
from gramps.gen.lib import NoteType
|
from gramps.gen.lib import NoteType
|
||||||
from gramps.gen.db import DbTxn
|
from gramps.gen.db import DbTxn
|
||||||
|
|
||||||
@ -189,6 +189,9 @@ class EditRepoRef(EditReference):
|
|||||||
|
|
||||||
def ok_clicked(self, obj):
|
def ok_clicked(self, obj):
|
||||||
|
|
||||||
|
if self.check_for_duplicate_id('Repository'):
|
||||||
|
return
|
||||||
|
|
||||||
if self.source.handle:
|
if self.source.handle:
|
||||||
with DbTxn(_("Modify Repository"), self.db) as trans:
|
with DbTxn(_("Modify Repository"), self.db) as trans:
|
||||||
self.db.commit_repository(self.source,trans)
|
self.db.commit_repository(self.source,trans)
|
||||||
|
@ -389,6 +389,7 @@ gramps/gui/editors/editplace.py
|
|||||||
gramps/gui/editors/editplacename.py
|
gramps/gui/editors/editplacename.py
|
||||||
gramps/gui/editors/editplaceref.py
|
gramps/gui/editors/editplaceref.py
|
||||||
gramps/gui/editors/editprimary.py
|
gramps/gui/editors/editprimary.py
|
||||||
|
gramps/gui/editors/editreference.py
|
||||||
gramps/gui/editors/editreporef.py
|
gramps/gui/editors/editreporef.py
|
||||||
gramps/gui/editors/editrepository.py
|
gramps/gui/editors/editrepository.py
|
||||||
gramps/gui/editors/editsource.py
|
gramps/gui/editors/editsource.py
|
||||||
|
@ -279,7 +279,6 @@ gramps/gui/glade/catalog/grampswidgets.py
|
|||||||
# gui/editors - the GUI editors package
|
# gui/editors - the GUI editors package
|
||||||
#
|
#
|
||||||
gramps/gui/editors/__init__.py
|
gramps/gui/editors/__init__.py
|
||||||
gramps/gui/editors/editreference.py
|
|
||||||
gramps/gui/editors/editsecondary.py
|
gramps/gui/editors/editsecondary.py
|
||||||
#
|
#
|
||||||
# gui/editors/displaytabs - the GUI display tabs package
|
# gui/editors/displaytabs - the GUI display tabs package
|
||||||
|
Loading…
x
Reference in New Issue
Block a user