Ejemplo n.º 1
0
    def read_relation_lines(self):
        if not self.current_relationship_person_handle:
            LOG.warning("Unknown person for relationship in line %d!" % self.lineno)
            return None
        rel_person = self.db.get_person_from_handle(self.current_relationship_person_handle)
        while 1:
            line = self.get_next_line()
            if line is None or line == "end":
                break
            if line == "":
                continue

            # match relationship type and related person
            line_re = re.compile("^- ([^:]+): (.*)$")
            matches = line_re.match(line)
            if matches:
                #split related person into fields
                fields = matches.groups()[1].split(" ")
                if fields:
                    (idx,asso_p) = self.parse_person(fields,0,Person.UNKNOWN,None)
                    pref = PersonRef()
                    pref.set_relation(matches.groups()[0])
                    LOG.warning("TODO: Handle association types properly")
                    pref.set_reference_handle(asso_p.get_handle())
                    rel_person.add_person_ref(pref)
                    self.db.commit_person(rel_person,self.trans)
                else:
                    LOG.warning("Invalid name of person in line %d" % self.lineno)
            else:
                LOG.warning("Invalid relationship in line %d" % self.lineno)
                break
        self.current_mode = None
        return None
Ejemplo n.º 2
0
 def add_button_clicked(self, obj):
     from .. import EditPersonRef
     try:
         ref = PersonRef()
         ref.rel = _('Godfather')
         EditPersonRef(self.dbstate, self.uistate, self.track, ref,
                       self.add_callback)
     except WindowActiveError:
         pass
Ejemplo n.º 3
0
 def add_button_clicked(self, obj):
     from .. import EditPersonRef
     try:
         ref = PersonRef()
         ref.rel = _('Godfather')
         EditPersonRef(
             self.dbstate, self.uistate, self.track,
             ref, self.add_callback)
     except WindowActiveError:
         pass
Ejemplo n.º 4
0
 def _handle_drag(self, row, obj):
     """
     And event reference that is from a drag and drop has
     an unknown event reference type
     """
     from .. import EditPersonRef
     try:
         ref = PersonRef(obj)
         ref.rel = _('Unknown')
         EditPersonRef(self.dbstate, self.uistate, self.track, ref,
                       self.add_callback)
     except WindowActiveError:
         pass
Ejemplo n.º 5
0
 def _handle_drag(self, row, obj):
     """
     And event reference that is from a drag and drop has
     an unknown event reference type
     """
     from .. import EditPersonRef
     try:
         ref = PersonRef(obj)
         ref.rel = _('Unknown')
         EditPersonRef(
             self.dbstate, self.uistate, self.track,
             ref, self.add_callback)
     except WindowActiveError:
         pass
Ejemplo n.º 6
0
    def handle_extra_type(self, objtype, obj):
        """
        Called when a person is dropped onto the list.  objtype will be
        'person-link' and obj will contain a person handle.
        """
        person = self.dbstate.db.get_person_from_handle(obj)

        from .. import EditPersonRef
        try:
            ref = PersonRef()
            ref.rel = _('Unknown')
            if person:
                ref.ref = person.get_handle()
            EditPersonRef(self.dbstate, self.uistate, self.track, ref,
                          self.add_callback)
        except WindowActiveError:
            pass
Ejemplo n.º 7
0
    def handle_extra_type(self, objtype, obj):
        """
        Called when a person is dropped onto the list.  objtype will be
        'person-link' and obj will contain a person handle.
        """
        person = self.dbstate.db.get_person_from_handle(obj)

        from .. import EditPersonRef
        try:
            ref = PersonRef()
            ref.rel = _('Unknown')
            if person:
                ref.ref = person.get_handle()
            EditPersonRef(
                self.dbstate, self.uistate, self.track,
                ref, self.add_callback)
        except WindowActiveError:
            pass
Ejemplo n.º 8
0
    def read_relation_lines(self):
        if not self.current_relationship_person_handle:
            LOG.warning("Unknown person for relationship in line %d!" % self.lineno)
            return None
        rel_person = self.db.get_person_from_handle(self.current_relationship_person_handle)
        while 1:
            line = self.get_next_line()
            if line is None or line == "end":
                break
            if line == "":
                continue

            # match relationship type and related person
            line_re = re.compile("^- ([^:]+): (.*)$")
            matches = line_re.match(line)
            if matches:
                #split related person into fields
                fields = matches.groups()[1].split(" ")
                if fields:
                    (idx,asso_p) = self.parse_person(fields,0,Person.UNKNOWN,None)
                    pref = PersonRef()
                    pref.set_relation(matches.groups()[0])
                    LOG.warning("TODO: Handle association types properly")
                    pref.set_reference_handle(asso_p.get_handle())
                    rel_person.add_person_ref(pref)
                    self.db.commit_person(rel_person,self.trans)
                else:
                    LOG.warning("Invalid name of person in line %d" % self.lineno)
            else:
                LOG.warning("Invalid relationship in line %d" % self.lineno)
                break
        self.current_mode = None
        return None
Ejemplo n.º 9
0
 def __init__(self, dbstate, user, options_class, name, callback=None):
     uistate = user.uistate
     self.dbstate = dbstate
     self.db = dbstate.db
     count = 0
     has_assoc = False
     for person_handle in self.db.get_person_handles():
         person = self.db.get_person_from_handle(person_handle)
         for assoc in person.get_person_ref_list():
             has_assoc = True
             oldRel = assoc.get_relation()
             if oldRel in ASSOC_LOOKUP:
                 associate = self.db.get_person_from_handle(assoc.ref)
                 update = True
                 for assoc_rev in associate.get_person_ref_list():
                     if assoc_rev.get_relation() == ASSOC_LOOKUP.get(
                             assoc.get_relation(
                             )) and assoc_rev.ref == person_handle:
                         update = False
                 if update:
                     newRel = ASSOC_LOOKUP.get(assoc.get_relation())
                     personRef = PersonRef()
                     personRef.set_reference_handle(person_handle)
                     personRef.set_relation(newRel)
                     personRef.merge(assoc)
                     with DbTxn(
                             _('Add %s reciprocal association') %
                             _nd.display(associate), self.db) as self.trans:
                         associate.add_person_ref(personRef)
                         self.db.commit_person(associate, self.trans)
                     count += 1
     if uistate:
         if count > 0:
             OkDialog(_("Sync Associations"),
                      _("{} Reciprocal associations created".format(count)),
                      parent=uistate.window)
         elif has_assoc:
             OkDialog(_("Sync Associations"),
                      _("All reciprocal associations exist, none created"),
                      parent=uistate.window)
         else:
             OkDialog(
                 _("Sync Associations"),
                 _("No existing associations, so no reciprocal ones needed"
                   ),
                 parent=uistate.window)
     else:
         print("{} Reciprocal associations created".format(count))