コード例 #1
0
ファイル: models.py プロジェクト: cuchac/lino
 def address_location_lines(self):
     #~ lines = []
     #~ lines = [self.name]
     if self.addr1:
         yield self.addr1
     if self.street:
         yield join_words(
             self.street_prefix, self.street,
             self.street_no, self.street_box)
     if self.addr2:
         yield self.addr2
     #lines = [self.name,street,self.addr1,self.addr2]
     if self.region:  # format used in Estonia
         if self.city:
             yield unicode(self.city)
         s = join_words(self.zip_code, self.region)
     else:
         s = join_words(self.zip_code, self.city)
     if s:
         yield s
     # ~ foreigner = True # False
     #~ if self.id == 1:
         #~ foreigner = False
     #~ else:
         #~ foreigner = (self.country != self.objects.get(pk=1).country)
     if self.country is not None:
         sc = settings.SITE.site_config  # get_site_config()
         if not sc.site_partner or self.country != sc.site_partner.country:
             # (if self.country != sender's country)
             yield unicode(self.country)
コード例 #2
0
ファイル: models.py プロジェクト: ManuelWeidmann/lino
 def get_city_lines(me, self):
     lines = []
     if self.city:
         city = self.city
         zip_code = self.zip_code or self.city.zip_code
         # Tallinna linnaosade asemel kirjutakse "Tallinn"
         if city.type == PlaceTypes.township and city.parent:
             city = city.parent
         # linna puhul pole vaja maakonda
         if city.type in (PlaceTypes.town, PlaceTypes.city):
             s = join_words(zip_code, city)
         else:
             lines.append(me.format_place(city))
             p = city.parent
             while p and not CountryDrivers.EE.is_region(p):
                 lines.append(me.format_place(p))
                 p = p.parent
             if self.region:
                 s = join_words(zip_code, self.region)
             elif p:
                 s = join_words(zip_code, me.format_place(p))
             elif len(lines) and zip_code:
                 lines[-1] = zip_code + ' ' + lines[-1]
                 s = ''
             else:
                 s = zip_code
     else:
         s = join_words(self.zip_code, self.region)
     if s:
         lines.append(s)
     return lines
コード例 #3
0
ファイル: utils.py プロジェクト: forexblog/xl
 def get_city_lines(me, self):
     lines = []
     if self.city:
         city = self.city
         zip_code = self.zip_code or self.city.zip_code
         # Tallinna linnaosade asemel kirjutakse "Tallinn"
         if city.type == PlaceTypes.township and city.parent:
             city = city.parent
         # linna puhul pole vaja maakonda
         if city.type in (PlaceTypes.town, PlaceTypes.city):
             s = join_words(zip_code, city)
         else:
             lines.append(me.format_place(city))
             p = city.parent
             while p and not CountryDrivers.EE.is_region(p):
                 lines.append(me.format_place(p))
                 p = p.parent
             if self.region:
                 s = join_words(zip_code, self.region)
             elif p:
                 s = join_words(zip_code, me.format_place(p))
             elif len(lines) and zip_code:
                 lines[-1] = zip_code + ' ' + lines[-1]
                 s = ''
             else:
                 s = zip_code
     else:
         s = join_words(self.zip_code, self.region)
     if s:
         lines.append(s)
     return lines
コード例 #4
0
ファイル: models.py プロジェクト: MaxTyutyunnikov/lino
 def get_city_lines(me,self):
     #lines = [self.name,street,self.addr1,self.addr2]
     if self.region: # 
         if self.city:
             join_words(self.zip_code or self.city.zip_code,self.city)
             if self.city_zip_code:
                 yield unicode(self.city)
                 yield unicode(self.city)
         s = join_words(self.zip_code,self.region)
     else: 
         s = join_words(self.zip_code,self.city)
     if s:
         yield s 
コード例 #5
0
ファイル: human.py プロジェクト: DarioGT/lino
    def get_full_name(self, salutation=True, upper=None, **salutation_options):
        """Returns a one-line string composed of salutation,
        :attr:`first_name` and :attr:`last_name`.

        The optional keyword argument `salutation` can be set to
        `False` to suppress salutations.

        The optional keyword argument `upper` can be specified to
        override the Site's default value
        (:attr:`lino.core.site.Site.uppercase_last_name`). `True`
        means to convert the last name to uppercase as is usually done
        in French.

        Any other keyword arguments are forwarded to
        :func:`lino.mixins.human.get_salutation` (see there).

        See :ref:`lino.tutorial.human` for some examples.

        """
        words = []

        if salutation:
            words.append(self.get_salutation(**salutation_options))
        if self.title:
            words.append(self.title)
        words.append(self.first_name)
        if upper is None:
            upper = settings.SITE.uppercase_last_name
        if upper:
            words.append(self.last_name.upper())
        else:
            words.append(self.last_name)
        return join_words(*words)
コード例 #6
0
ファイル: human.py プロジェクト: khchine5/lino
    def get_full_name(self, salutation=True, upper=None, **salutation_options):
        """Returns a one-line string composed of salutation, :attr:`title`,
        :attr:`first_name` and :attr:`last_name`.

        The optional keyword argument `salutation` can be set to
        `False` to suppress salutations.

        The optional keyword argument `upper` can be specified to
        override the Site's default value
        (:attr:`lino.core.site.Site.uppercase_last_name`). `True`
        means to convert the last name to uppercase as is usually done
        in French.

        Any other keyword arguments are forwarded to
        :func:`lino.mixins.human.get_salutation` (see there).

        See :ref:`lino.tutorial.human` for some examples.

        """
        words = []

        if salutation:
            words.append(self.get_salutation(**salutation_options))
        if self.title:
            words.append(self.title)
        words.append(self.first_name)
        if upper is None:
            upper = settings.SITE.uppercase_last_name
        if upper:
            words.append(self.last_name.upper())
        else:
            words.append(self.last_name)
        return join_words(*words)
コード例 #7
0
ファイル: human.py プロジェクト: MaxTyutyunnikov/lino
    def get_full_name(self,salutation=True,upper=None,**salutation_options):
        """Returns a one-line string composed of salutation, first_name and last_name.
        
The optional keyword argument `salutation` can be set to `False` 
to suppress salutations. 
See :func:`lino_welfare.modlib.pcsw.tests.pcsw_tests.test04` 
and
:func:`lino.modlib.contacts.tests.test01` 
for some examples.

Optional `salutation_options` see :func:`get_salutation`.
        """
        #~ print '20120729 PersonMixin.get_full_name`'
        #~ return '%s %s' % (self.first_name, self.last_name.upper())
        words = []
        #~ if salutation is None:
            #~ salutation = SHOW_SALUTATION
        if salutation:
            words.append(self.get_salutation(**salutation_options))
        words.append(self.first_name)
        if upper is None:
            upper = settings.SITE.uppercase_last_name
        if upper:
            words.append(self.last_name.upper())
        else:
            words.append(self.last_name)
        #~ words += [self.first_name, self.last_name.upper()]
        return join_words(*words)
コード例 #8
0
ファイル: demo2.py プロジェクト: forexblog/xl
def objects():

    dist = build_dist(dd.plugins.countries.country_code)

    if dist is None:
        return

    User = rt.models.users.User
    Person = rt.models.contacts.Person

    for p in Person.objects.order_by('id'):
        if User.objects.filter(partner=p).count() > 0:
            # users keep their original name
            pass
        else:
            p.last_name = dist.LAST_NAMES.pop()
            if p.gender == dd.Genders.male:
                p.first_name = dist.MALES.pop()
                dist.FEMALES.pop()
            else:
                p.first_name = dist.FEMALES.pop()
                dist.MALES.pop()
            p.name = join_words(p.last_name, p.first_name)
            dist.before_save(p)
            yield p
コード例 #9
0
ファイル: models.py プロジェクト: lino-framework/xl
    def get_full_name(self, *args, **kwargs):
        """Return a one-line string representing this Partner.  The default
        returns simply the `name`, optionally prefixed by the
        :attr:`prefix`, ignoring any arguments, but
        e.g. :class:`Human` overrides this.

        """
        return join_words(self.prefix, self.name)
コード例 #10
0
    def get_full_name(self, *args, **kwargs):
        """Return a one-line string representing this Partner.  The default
        returns simply the `name`, optionally prefixed by the
        :attr:`prefix`, ignoring any arguments, but
        e.g. :class:`Human` overrides this.

        """
        return join_words(self.prefix, self.name)
コード例 #11
0
ファイル: models.py プロジェクト: ManuelWeidmann/lino
    def full_clean(self, *args, **kw):
        """Set the `name` field of this person.  This field is visible in the
        Partner's detail but not in the Person's detail and serves for
        sorting when selecting a Partner.  It also serves for quick
        search on Persons.

        """
        self.name = join_words(self.last_name, self.first_name)
        super(Person, self).full_clean(*args, **kw)
コード例 #12
0
ファイル: utils.py プロジェクト: TonisPiip/xl
 def get_street_lines(me, self):
     if self.street:
         s = join_words(self.street_prefix, self.street, self.street_no)
         if self.street_box:
             if self.street_box[0] in '/-':
                 s += self.street_box
             else:
                 s += ' ' + self.street_box
         yield s
コード例 #13
0
ファイル: initdb_tim.py プロジェクト: khchine5/welfare
def country2kw(row, kw):
    # for both PAR and ADR

    if row.has_key('PROF'):
        activity = row['PROF']
        if activity:
            try:
                activity = int(activity)
            except ValueError:
                dblogger.debug("Ignored invalid value PROF = %r", activity)
            else:
                if activity:
                    try:
                        activity = Activity.objects.get(pk=activity)
                    except Activity.DoesNotExist:
                        activity = Activity(
                            id=activity, name=unicode(activity))
                        activity.save(force_insert=True)
                    kw.update(activity=activity)

    country = row['PAYS']
    if country:
        try:
            country = Country.objects.get(short_code__exact=country)
        except Country.DoesNotExist:
            country = Country(isocode=country, name=country,
                              short_code=country)
            country.save()
        kw.update(country=country)

    email = row['EMAIL']
    if email and is_valid_email(email):
        kw.update(email=email)
    store(kw,
          phone=row['TEL'],
          fax=row['FAX'],
          )

    kw.update(street2kw(join_words(row['RUE'], row['RUENUM'], row['RUEBTE'])))

    zip_code = row['CP']
    if zip_code:
        kw.update(zip_code=zip_code)
        try:
            city = Place.objects.get(
                country=country,
                zip_code__exact=zip_code,
            )
            kw.update(city=city)
        except Place.DoesNotExist, e:
            city = Place(zip_code=zip_code, name=zip_code, country=country)
            city.save()
            kw.update(city=city)
            #~ dblogger.warning("%s-%s : %s",row['PAYS'],row['CP'],e)
        except Place.MultipleObjectsReturned, e:
            dblogger.warning("%s-%s : %s", row['PAYS'], row['CP'], e)
コード例 #14
0
def country2kw(row, kw):
    # for both PAR and ADR

    if row.has_key('PROF'):
        activity = row['PROF']
        if activity:
            try:
                activity = int(activity)
            except ValueError:
                dblogger.debug("Ignored invalid value PROF = %r", activity)
            else:
                if activity:
                    try:
                        activity = Activity.objects.get(pk=activity)
                    except Activity.DoesNotExist:
                        activity = Activity(id=activity,
                                            name=unicode(activity))
                        activity.save(force_insert=True)
                    kw.update(activity=activity)

    country = row['PAYS']
    if country:
        try:
            country = Country.objects.get(short_code__exact=country)
        except Country.DoesNotExist:
            country = Country(isocode=country,
                              name=country,
                              short_code=country)
            country.save()
        kw.update(country=country)

    store(
        kw,
        phone=row['TEL'],
        fax=row['FAX'],
        email=row['EMAIL'],
    )

    kw.update(street2kw(join_words(row['RUE'], row['RUENUM'], row['RUEBTE'])))

    zip_code = row['CP']
    if zip_code:
        kw.update(zip_code=zip_code)
        try:
            city = Place.objects.get(
                country=country,
                zip_code__exact=zip_code,
            )
            kw.update(city=city)
        except Place.DoesNotExist, e:
            city = Place(zip_code=zip_code, name=zip_code, country=country)
            city.save()
            kw.update(city=city)
            #~ logger.warning("%s-%s : %s",row['PAYS'],row['CP'],e)
        except Place.MultipleObjectsReturned, e:
            dblogger.warning("%s-%s : %s", row['PAYS'], row['CP'], e)
コード例 #15
0
ファイル: models.py プロジェクト: MaxTyutyunnikov/lino
 def address_location_lines(self):
     if self.addr1:
         yield self.addr1
     if self.street:
         yield join_words(self.street_prefix, self.street, self.street_no, self.street_box)
     if self.addr2:
         yield self.addr2
     if self.region:  # format used in Estonia
         if self.city:
             yield unicode(self.city)
         s = join_words(self.zip_code, self.region)
     else:
         s = join_words(self.zip_code, self.city)
     if s:
         yield s
     if self.country is not None:
         sc = get_site_config()
         if not sc.site_company or self.country != sc.site_company.address.country:
             yield unicode(self.country)
コード例 #16
0
ファイル: garble.py プロジェクト: khchine5/welfare
    def handle(self, *args, **options):

        dbname = settings.DATABASES['default']['NAME']
        if options.get('interactive'):
            if not confirm("This is going to GARBLE your database (%s).\nAre you sure (y/n) ?" % dbname):
                raise CommandError("User abort.")

        contacts = dd.resolve_app('contacts')

        User = dd.resolve_model(settings.SITE.user_model)
        Person = dd.resolve_model('contacts.Person')
        Household = dd.resolve_model('households.Household')
        Member = dd.resolve_model('households.Member')
        Role = dd.resolve_model('households.Role')
        Country = dd.resolve_model('countries.Country')

        for p in Person.objects.order_by('id'):
            if User.objects.filter(partner=p).count() > 0:
                # users keep their original name
                pass
            else:
                p.nationality = Country.objects.get(
                    isocode=NATIONALITIES.pop())
                p.last_name = LAST_NAMES.pop()
                if p.gender == dd.Genders.male:
                    p.first_name = MALES.pop()
                    FEMALES.pop()
                else:
                    p.first_name = FEMALES.pop()
                    MALES.pop()
                #~ dblogger.log_changes(REQUEST,p)
                p.name = join_words(p.last_name, p.first_name)
                p.save()
                dblogger.info("%s from %s", unicode(p), unicode(p.nationality))

        MEN = Cycler(Person.objects.filter(gender=dd.Genders.male)
                     .order_by('id'))
        WOMEN = Cycler(
            Person.objects.filter(gender=dd.Genders.female).order_by('id'))
        for h in Household.objects.all():
            if h.member_set.all().count() == 0:
                he = MEN.pop()
                she = WOMEN.pop()
                h.name = he.last_name + "-" + she.last_name
                Member(household=h, person=he,
                       role=Role.objects.get(pk=1)).save()
                Member(household=h, person=she,
                       role=Role.objects.get(pk=2)).save()
            else:
                h.name = ''
                h.full_clean()
            h.save()
            dblogger.info(unicode(h))

        dblogger.info("GARBLE done on database %s." % dbname)
コード例 #17
0
 def address_location_lines(self):
     if self.addr1:
         yield self.addr1
     if self.street:
         yield join_words(self.street_prefix, self.street, self.street_no,
                          self.street_box)
     if self.addr2:
         yield self.addr2
     if self.region:  # format used in Estonia
         if self.city:
             yield unicode(self.city)
         s = join_words(self.zip_code, self.region)
     else:
         s = join_words(self.zip_code, self.city)
     if s:
         yield s
     if self.country is not None:
         sc = get_site_config()
         if not sc.site_company or self.country != sc.site_company.address.country:
             yield unicode(self.country)
コード例 #18
0
ファイル: utils.py プロジェクト: khchine5/welfare
def cbss2address(obj, **data):
    n = obj.childAtPath("/Basic/DiplomaticPost")
    if n is not None:
        data.update(country=cbss2country(nodetext(n.childAtPath("/CountryCode"))))
        # n.childAtPath('/Post')
        data.update(address=nodetext(n.childAtPath("/AddressPlainText")))
        return data
    n = obj.childAtPath("/Basic/Address")
    if n is not None:
        data.update(country=cbss2country(nodetext(n.childAtPath("/CountryCode"))))
        # country = countries.Country.objects.get(
        # inscode=n.childAtPath('/CountryCode').text)
        addr = ""
        # addr += n.childAtPath('/MunicipalityCode').text
        addr += join_words(
            nodetext(n.childAtPath("/Street")), nodetext(n.childAtPath("/HouseNumber")), nodetext(n.childAtPath("/Box"))
        )
        addr += ", " + join_words(nodetext(n.childAtPath("/PostalCode")), nodetext(n.childAtPath("/Municipality")))
        data.update(address=addr)
    return data
コード例 #19
0
ファイル: models.py プロジェクト: ManuelWeidmann/lino
 def get_street_lines(me, self):
     if self.street:
         s = join_words(
             self.street_prefix, self.street,
             self.street_no)
         if self.street_box:
             if self.street_box[0] in '/-':
                 s += self.street_box
             else:
                 s += ' ' + self.street_box
         yield s
コード例 #20
0
ファイル: human.py プロジェクト: ManuelWeidmann/lino
 def get_full_name(
         self, salutation=True, upper=None, **salutation_options):
     words = []
     if salutation:
         words.append(self.get_salutation(**salutation_options))
     words.append(self.first_name)
     if upper is None:
         upper = settings.SITE.uppercase_last_name
     if upper:
         words.append(self.last_name.upper())
     else:
         words.append(self.last_name)
     return join_words(*words)
コード例 #21
0
ファイル: models.py プロジェクト: lino-framework/xl
    def full_clean(self, *args, **kw):
        """Set the `name` field of this person.  This field is visible in the
        Partner's detail but not in the Person's detail and serves for
        sorting when selecting a Partner.  It also serves for quick
        search on Persons.

        """
        name = join_words(self.last_name, self.first_name)
        if name:
            self.name = name
        else:
            for k, v in list(name2kw(self.name).items()):
                setattr(self, k, v)
            # self.last_name = self.name
        super(Person, self).full_clean(*args, **kw)
コード例 #22
0
ファイル: models.py プロジェクト: TonisPiip/xl
    def full_clean(self, *args, **kw):
        """Set the `name` field of this person.  This field is visible in the
        Partner's detail but not in the Person's detail and serves for
        sorting when selecting a Partner.  It also serves for quick
        search on Persons.

        """
        name = join_words(self.last_name, self.first_name)
        if name:
            self.name = name
        else:
            for k, v in list(name2kw(self.name).items()):
                setattr(self, k, v)
            # self.last_name = self.name
        super(Person, self).full_clean(*args, **kw)
コード例 #23
0
ファイル: models.py プロジェクト: MaxTyutyunnikov/lino
 def address_location_lines(self):
     #~ lines = []
     #~ lines = [self.name]
     if self.addr1:
         yield self.addr1
     if self.street:
         yield join_words(
           self.street_prefix, self.street,
           self.street_no,self.street_box)
     if self.addr2:
         yield self.addr2
        
     af = get_address_formatter(self.country)
     for ln in af.get_city_lines(self):
         yield ln
         
     if self.country is not None:
         sc = settings.SITE.site_config # get_site_config()
         #~ print 20130228, sc.site_company_id
         if sc.site_company is None or self.country != sc.site_company.country: 
             # (if self.country != sender's country)
             yield unicode(self.country)
コード例 #24
0
    def handle(self, *args, **options):

        dbname = settings.DATABASES['default']['NAME']
        if options.get('interactive'):
            if not confirm("This is going to GARBLE your database (%s).\n"
                           "Are you sure (y/n) ?" % dbname):
                raise CommandError("User abort.")

        def build_dist(k):
            k = k.upper()
            if k == 'BE':
                return BelgianDistribution()
            if k == 'EE':
                return EstonianDistribution()
            raise CommandError("Invalid distribution key %r." % k)

        dist = build_dist(options.get('distribution'))

        User = dd.resolve_model(settings.SITE.user_model)
        Person = rt.models.contacts.Person

        for p in Person.objects.order_by('id'):
            if User.objects.filter(partner=p).count() > 0:
                # users keep their original name
                pass
            else:
                p.last_name = dist.LAST_NAMES.pop()
                if p.gender == dd.Genders.male:
                    p.first_name = dist.MALES.pop()
                    dist.FEMALES.pop()
                else:
                    p.first_name = dist.FEMALES.pop()
                    dist.MALES.pop()
                p.name = join_words(p.last_name, p.first_name)
                dist.before_save(p)
                p.save()
                dblogger.info(p.get_address(', '))
コード例 #25
0
ファイル: models.py プロジェクト: cuchac/lino
 def get_full_name(self, salutation=True, **salutation_options):
     """Deserves more documentation."""
     #~ print '20120729 Organisation.get_full_name`'
     if self.type:
         return join_words(self.type.abbr, self.name)
     return self.name
コード例 #26
0
ファイル: utils.py プロジェクト: forexblog/xl
 def get_city_lines(me, self):
     if self.city is not None:
         s = join_words(self.zip_code or self.city.zip_code, self.city)
         if s:
             yield s
コード例 #27
0
    def get_full_name(self, salutation=True, **salutation_options):
        """Overrides
        :meth:`lino_xl.lib.contacts.models.Partner.get_full_name`.

        """
        return join_words(self.prefix, self.name)
コード例 #28
0
ファイル: models.py プロジェクト: cuchac/lino
 def get_partner_name(self):
     return join_words(self.last_name, self.first_name)
コード例 #29
0
ファイル: beid.py プロジェクト: MaxTyutyunnikov/lino
    def card2client(cls,data):
        "does the actual conversion"
        kw = dict()
        #~ assert not settings.SITE.use_eid_jslib
        #~ assert not settings.SITE.has_plugin(BeIdJsLibPlugin):
        data = data['card_data']
        if not '\n' in data:
            raise Warning(data)
        #~ print cd
        data = AttrDict(yaml.load(data))
        #~ raise Exception("20131108 cool: %s" % cd)
        
        
        kw.update(national_id=ssin.format_ssin(str(data.nationalNumber)))
        kw.update(first_name=join_words(
            data.firstName,
            data.middleName))
        kw.update(last_name=data.name)
        
        card_number = str(data.cardNumber)
        
        if data.photo:
            fn = card_number_to_picture_file(card_number)
            if os.path.exists(fn):
                logger.warning("Overwriting existing image file %s.",fn)
            fp = file(fn,'wb')
            fp.write(base64.b64decode(data.photo))
            fp.close()
            #~ print 20121117, repr(data['picture'])
            #~ kw.update(picture_data_encoded=data['picture'])
        
        if isinstance(data.dateOfBirth,basestring):
            data.dateOfBirth = IncompleteDate(*data.dateOfBirth.split('-'))
        kw.update(birth_date=data.dateOfBirth)
        kw.update(card_valid_from=data.cardValidityDateBegin)
        kw.update(card_valid_until=data.cardValidityDateEnd)
        
        kw.update(card_number=card_number)
        kw.update(card_issuer=data.cardDeliveryMunicipality)
        if data.nobleCondition:
            kw.update(noble_condition=data.nobleCondition)
        kw.update(street=data.streetAndNumber)
        #~ kw.update(street_no=data['streetNumber'])
        #~ kw.update(street_box=data['boxNumber'])
        if True: # kw['street'] and not (kw['street_no'] or kw['street_box']):
            kw = street2kw(kw['street'],**kw)
        kw.update(zip_code=str(data.zip))
        if data.placeOfBirth:
            kw.update(birth_place=data.placeOfBirth)
        pk = data.reader.upper()
        
        msg1 = "BeIdReadCardToClientAction %s" % kw.get('national_id')

        #~ try:
        country = countries.Country.objects.get(isocode=pk)
        kw.update(country=country)
        #~ except countries.Country.DoesNotExist,e:
        #~ except Exception,e:
            #~ logger.warning("%s : no country with code %r",msg1,pk)
        #~ BE = countries.Country.objects.get(isocode='BE')
        #~ fld = countries.City._meta.get_field()
        kw.update(city=countries.City.lookup_or_create(
            'name',data.municipality,country=country))
        def sex2gender(sex):
            if sex == 'MALE' : return dd.Genders.male
            if sex == 'FEMALE' : return dd.Genders.female
            logger.warning("%s : invalid gender code %r",msg1,sex)
        kw.update(gender=sex2gender(data.gender))
        
        def doctype2cardtype(dt):
            #~ if dt == 1: return BeIdCardTypes.get_by_value("1")
            rv = BeIdCardTypes.get_by_value(str(dt))
            logger.info("20130103 documentType %r --> %r",dt,rv)
            return rv
        kw.update(card_type=doctype2cardtype(data.documentType))
        return kw
コード例 #30
0
ファイル: mixins.py プロジェクト: cuchac/lino
    def card2client(self, data):
        "does the actual conversion"

        countries = dd.resolve_app('countries', strict=True)

        kw = dict()
        raw_data = data['card_data']
        if not '\n' in raw_data:
            # a one-line string means that some error occured (e.g. no
            # card in reader). of course we want to show this to the
            # user.
            raise Warning(raw_data)

        #~ print cd
        data = AttrDict(yaml.load(raw_data))
        #~ raise Exception("20131108 cool: %s" % cd)

        kw.update(national_id=ssin.format_ssin(str(data.nationalNumber)))
        kw.update(first_name=join_words(
            data.firstName,
            data.middleName))
        kw.update(last_name=data.name)

        card_number = str(data.cardNumber)

        if data.photo:
            fn = config.card_number_to_picture_file(card_number)
            if os.path.exists(fn):
                logger.warning("Overwriting existing image file %s.", fn)
            fp = file(fn, 'wb')
            fp.write(base64.b64decode(data.photo))
            fp.close()
            #~ print 20121117, repr(data['picture'])
            #~ kw.update(picture_data_encoded=data['picture'])

        if isinstance(data.dateOfBirth, basestring):
            data.dateOfBirth = IncompleteDate(*data.dateOfBirth.split('-'))
        kw.update(birth_date=data.dateOfBirth)
        kw.update(card_valid_from=data.cardValidityDateBegin)
        kw.update(card_valid_until=data.cardValidityDateEnd)

        kw.update(card_number=card_number)
        kw.update(card_issuer=data.cardDeliveryMunicipality)
        if data.nobleCondition:
            kw.update(noble_condition=data.nobleCondition)
        kw.update(street=data.streetAndNumber)
        #~ kw.update(street_no=data['streetNumber'])
        #~ kw.update(street_box=data['boxNumber'])
        if True:  # kw['street'] and not (kw['street_no'] or kw['street_box']):
            kw = street2kw(kw['street'], **kw)
        kw.update(zip_code=str(data.zip))
        if data.placeOfBirth:
            kw.update(birth_place=data.placeOfBirth)
        pk = data.reader.upper()

        msg1 = "BeIdReadCardToClientAction %s" % kw.get('national_id')

        #~ try:
        country = countries.Country.objects.get(isocode=pk)
        kw.update(country=country)
        #~ except countries.Country.DoesNotExist,e:
        #~ except Exception,e:
            #~ logger.warning("%s : no country with code %r",msg1,pk)
        #~ BE = countries.Country.objects.get(isocode='BE')
        #~ fld = countries.Place._meta.get_field()
        kw.update(city=countries.Place.lookup_or_create(
            'name', data.municipality, country=country))

        def sex2gender(sex):
            if sex == 'MALE':
                return dd.Genders.male
            if sex == 'FEMALE':
                return dd.Genders.female
            logger.warning("%s : invalid gender code %r", msg1, sex)
        kw.update(gender=sex2gender(data.gender))

        def doctype2cardtype(dt):
            #~ if dt == 1: return BeIdCardTypes.get_by_value("1")
            rv = BeIdCardTypes.get_by_value(str(dt))
            # logger.info("20130103 documentType %r --> %r", dt, rv)
            return rv
        kw.update(card_type=doctype2cardtype(data.documentType))

        if config.data_collector_dir:
            fn = os.path.join(
                config.data_collector_dir,
                card_number + '.txt')
            file(fn, "w").write(raw_data)
            logger.info("Wrote eid card data to file %s", fn)

        return kw
コード例 #31
0
ファイル: mixins.py プロジェクト: ManuelWeidmann/lino
    def run_from_ui(self, ar, **kw):
        attrs = self.card2client(ar.request.POST)
        qs = holder_model().objects.filter(national_id=attrs['national_id'])
        if qs.count() > 1:
            msg = self.sorry_msg % (
                _("There is more than one client with national "
                  "id %(national_id)s in our database.") % attrs)

            raise Exception(msg)  # this is impossible because
                                  # national_id is unique
            return ar.error(msg)
        if qs.count() == 0:
            fkw = dict()
            for k in NAMES:
                v = attrs[k]
                if v:
                    fkw[k+'__iexact'] = v
            # fkw = dict(last_name__iexact=attrs['last_name'],
            #            middle_name__iexact=attrs['middle_name'],
            #            first_name__iexact=attrs['first_name'])

            full_name = join_words(
                attrs['first_name'],
                attrs['middle_name'],
                attrs['last_name'])

            # If a Person with same full_name exists, the user cannot
            # (automatically) create a new Client from eid card.

            #~ fkw.update(national_id__isnull=True)
            contacts = rt.modules.contacts
            pqs = contacts.Person.objects.filter(**fkw)
            if pqs.count() == 0:
                def yes(ar2):
                    obj = holder_model()(**attrs)
                    obj.full_clean()
                    obj.save()
                    objects, diffs = obj.get_beid_diffs(attrs)
                    for o in objects:
                        o.full_clean()
                        o.save()
                    #~ changes.log_create(ar.request,obj)
                    dd.pre_ui_create.send(obj, request=ar2.request)
                    return self.goto_client_response(
                        ar2, obj, _("New client %s has been created") % obj)
                return ar.confirm(
                    yes,
                    _("Create new client %s : Are you sure?") % full_name)
            elif pqs.count() == 1:
                return ar.error(
                    self.sorry_msg % _(
                        "Cannot create new client because "
                        "there is already a person named "
                        "%s in our database.")
                    % full_name, alert=_("Oops!"))
            else:
                return ar.error(
                    self.sorry_msg % _(
                        "Cannot create new client because "
                        "there is more than one person named "
                        "%s in our database.")
                    % full_name, alert=_("Oops!"))

        assert qs.count() == 1
        row = qs[0]
        return self.process_row(ar, row, attrs)
コード例 #32
0
ファイル: models.py プロジェクト: MaxTyutyunnikov/lino
 def get_city_lines(me,self):
     if self.city is not None:
         s = join_words(self.zip_code or self.city.zip_code,self.city)
         if s:
             yield s 
コード例 #33
0
ファイル: watch_tim.py プロジェクト: khchine5/welfare
                city = Place(zip_code=zip_code, name=zip_code, country=country)
                city.save()
                kw.update(city=city)
                # ~ dblogger.warning("%s-%s : %s",row['PAYS'],row['CP'],e)
            except Place.MultipleObjectsReturned, e:
                dblogger.warning("%s-%s : %s", row["PAYS"], row["CP"], e)

    email = row["EMAIL"]
    if email:
        if is_valid_email(email):
            kw.update(email=email)
        else:
            dblogger.warning("Ignoring invalid email address %s", email)
    store(kw, phone=row["TEL"], fax=row["FAX"])

    kw.update(street2kw(join_words(row["RUE"], row["RUENUM"], row["RUEBTE"])))


# ~ def is_company(data):
def PAR_model(data):
    """
    - wer eine SSIN oder Gesdos-Nr hat ist ein Klient, selbst wenn er auch eine Mwst-Nummer hat.
    - Neuzugänge (Attribut N) sind ebenfalls immer Klienten
    
    """
    has_first_name = len(data.get("FIRME", "").split()) > 1
    if has_first_name:
        nb2 = data.get("NB2", False)
        if nb2:  # SSIN
            if nb2.strip() == "0":
                data["NB2"] = ""
コード例 #34
0
ファイル: models.py プロジェクト: khchine5/book
 def __str__(self):
     words = []
     words.append(self.first_name)
     words.append(self.last_name)
     return join_words(*words)
コード例 #35
0
ファイル: models.py プロジェクト: khchine5/amici
 def __str__(self):
     words = []
     words.append(self.first_name)
     words.append(self.last_name)
     return join_words(*words)
コード例 #36
0
ファイル: demo.py プロジェクト: forexblog/avanti
def objects():

    Person = rt.models.contacts.Person
    Company = rt.models.contacts.Company
    Client = rt.models.avanti.Client
    ClientContact = rt.models.clients.ClientContact
    ClientContactType = rt.models.clients.ClientContactType
    TranslatorTypes = rt.models.avanti.TranslatorTypes
    ClientStates = rt.models.avanti.ClientStates
    EndingReason = rt.models.avanti.EndingReason
    Category = rt.models.avanti.Category
    LanguageKnowledge = rt.models.cv.LanguageKnowledge

    yield babeld(EndingReason, _("Successfully ended"), id=1)
    yield babeld(EndingReason, _("Health problems"), id=2)
    yield babeld(EndingReason, _("Familiar reasons"), id=3)
    yield babeld(EndingReason, _("Missing motivation"), id=4)
    yield babeld(EndingReason, _("Return to home country"), id=5)
    yield babeld(EndingReason, _("Other"), id=9)

    yield babeld(Category, _("Language course"))
    yield babeld(Category, _("Integration course"))
    yield babeld(Category, _("Language & integration course"))
    yield babeld(Category, _("External course"))
    yield babeld(Category, _("Justified interruption"))
    yield babeld(Category, _("Successfully terminated"))

    # yield named(ClientContactType, _("Health insurance"))
    # yield named(ClientContactType, _("School"))
    # yield named(ClientContactType, _("Pharmacy"))
    # yield named(ClientContactType, _("GSS"))
    # yield named(ClientContactType, _("ISS"))
    for i in KnownContactTypes.get_list_items():
        yield i.create_object()

    yield named(ClientContactType, _("Other"))

    TRTYPES = Cycler(TranslatorTypes.objects())
    POLICIES = Cycler(rt.models.cal.EventPolicy.objects.all())
    CCTYPES = Cycler(ClientContactType.objects.all())

    for cct in ClientContactType.objects.all():
        yield Company(
            name="Favourite {}".format(cct), client_contact_type=cct)
        yield Company(
            name="Best {}".format(cct), client_contact_type=cct)

    CCT2COMPANIES = dict()
    for cct in ClientContactType.objects.all():
        CCT2COMPANIES[cct] = Cycler(Company.objects.filter(
            client_contact_type=cct))

    count = 0
    for person in Person.objects.all():
        count += 1
        if count % 7 and person.gender and not person.birth_date:
            # most persons, but not those from humanlinks and those
            # with empty gender field, become clients and receive a
            # new exotic name. Youngest client is 16; 170 days between
            # each client
            birth_date = settings.SITE.demo_date(-170 * count - 16 * 365)
            national_id = generate_ssin(birth_date, person.gender)

            client = mtichild(
                person, Client,
                national_id=national_id,
                birth_date=birth_date)

            if count % 2:
                client.client_state = ClientStates.coached
                client.event_policy = POLICIES.pop()
            # elif count % 5:
            #     client.client_state = ClientStates.newcomer
            else:
                client.client_state = ClientStates.former

            # Dorothée is three times in our database
            if client.first_name == "Dorothée":
                client.national_id = None
                client.birth_date = ''
            else:
                p = client
                p.last_name = LAST_NAMES.pop()
                if p.gender == dd.Genders.male:
                    p.first_name = MALES.pop()
                    FEMALES.pop()
                else:
                    p.first_name = FEMALES.pop()
                    MALES.pop()
                p.first_name = p.first_name.replace('a', 'á')
                p.name = join_words(p.last_name, p.first_name)


            if count % 4:
                client.translator_type = TRTYPES.pop()

            # client.full_clean()
            # client.save()
            yield client

        else:
            pass
            # yield mtichild(
            #     person, Translator, translator_type=TT.pop())

    CefLevel = rt.models.cv.CefLevel
    LANGUAGES = Cycler(rt.models.languages.Language.objects.all())
    HOW_WELL = Cycler(rt.models.cv.HowWell.get_list_items())
    CEF_LEVELS = Cycler(CefLevel.get_list_items())
    LK_COUNTS = Cycler(1, 2, 3, 2, 1, 4)

    def language_knowledge(person, offset, language, native, **kwargs):
        kwargs.update(entry_date=dd.today(offset))
        kwargs.update(language=language, native=native)
        if not native:
            kwargs.update(
                spoken=HOW_WELL.pop(),
                written=HOW_WELL.pop(),
                spoken_passively=HOW_WELL.pop(),
                written_passively=HOW_WELL.pop(),
                cef_level=CEF_LEVELS.pop())
            kwargs.update(has_certificate=person.id % 2)
        return LanguageKnowledge(person=person, **kwargs)

    for i, obj in enumerate(Client.objects.all()):
        for j in range(i % 2):
            cct = CCTYPES.pop()
            company = CCT2COMPANIES[cct].pop()
            yield ClientContact(type=cct, client=obj, company=company)

        if obj.client_state == ClientStates.coached:
            for i in range(LK_COUNTS.pop()):
                yield language_knowledge(obj, -400, LANGUAGES.pop(), i==0)
            lk = LanguageKnowledge.objects.filter(person=obj, native=False).first()
            if lk:
                better = next_choice(CefLevel, lk.cef_level)
                if better:
                    # raise Exception("okay")
                    new_lk = language_knowledge(obj, -10, lk.language, False)
                    new_lk.cef_level = better
                    yield new_lk
コード例 #37
0
ファイル: models.py プロジェクト: MaxTyutyunnikov/lino
 def get_full_name(self, salutation=True, **salutation_options):
     """Deserves more documentation."""
     # ~ if self.prefix:
     return join_words(self.prefix, self.name)
コード例 #38
0
ファイル: __init__.py プロジェクト: lino-framework/xl
    def card2client(cls, data):
        "does the actual conversion"

        self = cls

        from lino.utils import ssin
        from lino.api import dd, rt
        from lino.mixins.beid import BeIdCardTypes
        from lino.utils import join_words
        from lino.utils import IncompleteDate
        from lino_xl.lib.contacts.utils import street2kw

        countries = dd.resolve_app('countries', strict=True)

        kw = dict()
        #~ def func(fldname,qname):
            #~ kw[fldname] = data[qname]
        kw.update(national_id=ssin.format_ssin(data['nationalNumber']))
        kw.update(first_name=join_words(
            data['firstName1'],
            data['firstName2'],
            data['firstName3']))
        #~ func('first_name','firstName1')
        kw.update(last_name=data['surname'])

        card_number = data['cardNumber']

        if 'picture' in data:
            fn = self.card_number_to_picture_file(card_number)
            if os.path.exists(fn):
                logger.warning("Overwriting existing image file %s.", fn)
            fp = file(fn, 'wb')
            fp.write(base64.b64decode(data['picture']))
            fp.close()
            #~ print 20121117, repr(data['picture'])
            #~ kw.update(picture_data_encoded=data['picture'])

        #~ func('card_valid_from','validityBeginDate')
        #~ func('card_valid_until','validityEndDate')
        #~ func('birth_date','birthDate')
        kw.update(birth_date=IncompleteDate(
            *settings.SITE.parse_date(data['birthDate'])))
        kw.update(card_valid_from=datetime.date(
            *settings.SITE.parse_date(data['validityBeginDate'])))
        kw.update(card_valid_until=datetime.date(
            *settings.SITE.parse_date(data['validityEndDate'])))
        kw.update(card_number=card_number)
        kw.update(card_issuer=data['issuingMunicipality'])
        kw.update(noble_condition=data['nobleCondition'])
        kw.update(street=data['street'])
        kw.update(street_no=data['streetNumber'])
        kw.update(street_box=data['boxNumber'])
        if kw['street'] and not (kw['street_no'] or kw['street_box']):
            kw = street2kw(kw['street'], **kw)
        kw.update(zip_code=data['zipCode'])
        kw.update(birth_place=data['birthLocation'])
        pk = data['country'].upper()

        msg1 = "BeIdReadCardToClientAction %s" % kw.get('national_id')

        #~ try:
        country = countries.Country.objects.get(isocode=pk)
        kw.update(country=country)
        #~ except countries.Country.DoesNotExist,e:
        #~ except Exception,e:
            #~ logger.warning("%s : no country with code %r",msg1,pk)
        #~ BE = countries.Country.objects.get(isocode='BE')
        #~ fld = countries.Place._meta.get_field()
        kw.update(city=countries.Place.lookup_or_create(
            'name', data['municipality'], country=country))

        def sex2gender(sex):
            if sex == 'M':
                return dd.Genders.male
            if sex in 'FVW':
                return dd.Genders.female
            logger.warning("%s : invalid gender code %r", msg1, sex)
        kw.update(gender=sex2gender(data['sex']))

        if False:
            def nationality2country(nationality):
                try:
                    return countries.Country.objects.get(
                        nationalities__icontains=nationality)
                except countries.Country.DoesNotExist, e:
                    logger.warning("%s : no country for nationality %r",
                                   msg1, nationality)
                except MultipleObjectsReturned, e:
                    logger.warning(
                        "%s : found more than one country for nationality %r",
                        msg1, nationality)
コード例 #39
0
ファイル: models.py プロジェクト: lino-framework/xl
    def get_full_name(self, salutation=True, **salutation_options):
        """Overrides
        :meth:`lino_xl.lib.contacts.models.Partner.get_full_name`.

        """
        return join_words(self.prefix, self.name)
コード例 #40
0
ファイル: models.py プロジェクト: TonisPiip/xl
 def get_full_name(self, salutation=True, **salutation_options):
     """Deserves more documentation."""
     #~ print '20120729 Company.get_full_name`'
     if self.type:
         return join_words(self.prefix, self.type.abbr, self.name)
     return join_words(self.prefix, self.name)
コード例 #41
0
    def card2client(cls, data):
        "does the actual conversion"

        self = cls

        from lino.utils import ssin
        from lino.api import dd, rt
        from lino.mixins.beid import BeIdCardTypes
        from lino.utils import join_words
        from lino.utils import IncompleteDate
        from lino_xl.lib.contacts.utils import street2kw

        countries = dd.resolve_app('countries', strict=True)

        kw = dict()
        #~ def func(fldname,qname):
        #~ kw[fldname] = data[qname]
        kw.update(national_id=ssin.format_ssin(data['nationalNumber']))
        kw.update(first_name=join_words(data['firstName1'], data['firstName2'],
                                        data['firstName3']))
        #~ func('first_name','firstName1')
        kw.update(last_name=data['surname'])

        card_number = data['cardNumber']

        if 'picture' in data:
            fn = self.card_number_to_picture_file(card_number)
            if os.path.exists(fn):
                logger.warning("Overwriting existing image file %s.", fn)
            fp = file(fn, 'wb')
            fp.write(base64.b64decode(data['picture']))
            fp.close()
            #~ print 20121117, repr(data['picture'])
            #~ kw.update(picture_data_encoded=data['picture'])

        #~ func('card_valid_from','validityBeginDate')
        #~ func('card_valid_until','validityEndDate')
        #~ func('birth_date','birthDate')
        kw.update(birth_date=IncompleteDate(
            *settings.SITE.parse_date(data['birthDate'])))
        kw.update(card_valid_from=datetime.date(
            *settings.SITE.parse_date(data['validityBeginDate'])))
        kw.update(card_valid_until=datetime.date(
            *settings.SITE.parse_date(data['validityEndDate'])))
        kw.update(card_number=card_number)
        kw.update(card_issuer=data['issuingMunicipality'])
        kw.update(noble_condition=data['nobleCondition'])
        kw.update(street=data['street'])
        kw.update(street_no=data['streetNumber'])
        kw.update(street_box=data['boxNumber'])
        if kw['street'] and not (kw['street_no'] or kw['street_box']):
            kw = street2kw(kw['street'], **kw)
        kw.update(zip_code=data['zipCode'])
        kw.update(birth_place=data['birthLocation'])
        pk = data['country'].upper()

        msg1 = "BeIdReadCardToClientAction %s" % kw.get('national_id')

        #~ try:
        country = countries.Country.objects.get(isocode=pk)
        kw.update(country=country)
        #~ except countries.Country.DoesNotExist,e:
        #~ except Exception,e:
        #~ logger.warning("%s : no country with code %r",msg1,pk)
        #~ BE = countries.Country.objects.get(isocode='BE')
        #~ fld = countries.Place._meta.get_field()
        kw.update(city=countries.Place.lookup_or_create(
            'name', data['municipality'], country=country))

        def sex2gender(sex):
            if sex == 'M':
                return dd.Genders.male
            if sex in 'FVW':
                return dd.Genders.female
            logger.warning("%s : invalid gender code %r", msg1, sex)

        kw.update(gender=sex2gender(data['sex']))

        if False:

            def nationality2country(nationality):
                try:
                    return countries.Country.objects.get(
                        nationalities__icontains=nationality)
                except countries.Country.DoesNotExist, e:
                    logger.warning("%s : no country for nationality %r", msg1,
                                   nationality)
                except MultipleObjectsReturned, e:
                    logger.warning(
                        "%s : found more than one country for nationality %r",
                        msg1, nationality)
コード例 #42
0
    def run_from_ui(self, ar, **kw):
        # if settings.SITE.beid_protocol:
        if dd.plugins.beid.urlhandler_prefix:
            uuid = ar.request.POST['uuid']
            data = load_card_data(uuid)
            # print("20180518", data)
            attrs = self.card2client(data)
        else:
            raise Exception("No longer maintained")
            data = yaml2dict(ar.request.POST)
            attrs = self.card2client_java(data)
        holder_model = dd.plugins.beid.holder_model
        qs = holder_model.objects.filter(national_id=attrs['national_id'])
        if qs.count() > 1:
            msg = self.sorry_msg % (
                _("There is more than one client with national "
                  "id %(national_id)s in our database.") % attrs)

            raise Exception(msg)  # this is impossible because
            # national_id is unique
            return ar.error(msg)
        if qs.count() == 0:
            fkw = dict()
            for k in NAMES:
                v = attrs[k]
                if v:
                    fkw[k + '__iexact'] = v
            # fkw = dict(last_name__iexact=attrs['last_name'],
            #            middle_name__iexact=attrs['middle_name'],
            #            first_name__iexact=attrs['first_name'])

            full_name = join_words(attrs['first_name'], attrs['middle_name'],
                                   attrs['last_name'])

            # If a Person with same full_name exists, the user cannot
            # (automatically) create a new Client from eid card.

            #~ fkw.update(national_id__isnull=True)
            Person = rt.models.contacts.Person
            pqs = Person.objects.filter(**fkw)
            if pqs.count() == 0:

                def yes(ar2):
                    obj = holder_model(**attrs)
                    msg = _("New client %s has been created") % obj
                    if dd.plugins.beid.read_only_simulate:
                        msg = simulate_wrap(msg)
                        return ar2.warning(msg)
                    obj.full_clean()
                    obj.save()
                    objects, diffs = obj.get_beid_diffs(attrs)
                    for o in objects:
                        o.full_clean()
                        o.save()
                    #~ changes.log_create(ar.request,obj)
                    dd.on_ui_created.send(obj, request=ar2.request)
                    msg = _("New client %s has been created") % obj
                    return self.goto_client_response(ar2, obj, msg)

                msg = _("Create new client %s : Are you sure?") % full_name
                msg = simulate_wrap(msg)
                return ar.confirm(yes, msg)
            elif pqs.count() == 1:
                return ar.error(self.sorry_msg %
                                _("Cannot create new client because "
                                  "there is already a person named "
                                  "%s in our database.") % full_name,
                                alert=_("Oops!"))
            else:
                return ar.error(self.sorry_msg %
                                _("Cannot create new client because "
                                  "there is more than one person named "
                                  "%s in our database.") % full_name,
                                alert=_("Oops!"))

        assert qs.count() == 1
        row = qs[0]
        return self.process_row(ar, row, attrs)
コード例 #43
0
ファイル: actions.py プロジェクト: khchine5/xl
    def run_from_ui(self, ar, **kw):
        if settings.SITE.beid_protocol:
            data = load_card_data(ar.request.POST['uuid'])
            data = AttrDict(data)

            # quick hack to fix #2393. a better solution would be to
            # make eidreader not POST every key-value using requests
            # but to send a single field card_data which would be a
            # json encoded dict.
            # if isinstance(data.success, six.string_types):
            #     data.success = parse_boolean(data.success.lower())
            if not data.success:
                raise Warning(_("No card data found: {}").format(
                    data.message))
            # print("20180518", data)
            attrs = self.card2client(data)
        else:
            data = yaml2dict(ar.request.POST)
            attrs = self.card2client_java(data)
        holder_model = dd.plugins.beid.holder_model
        qs = holder_model.objects.filter(national_id=attrs['national_id'])
        if qs.count() > 1:
            msg = self.sorry_msg % (
                _("There is more than one client with national "
                  "id %(national_id)s in our database.") % attrs)

            raise Exception(msg)  # this is impossible because
                                  # national_id is unique
            return ar.error(msg)
        if qs.count() == 0:
            fkw = dict()
            for k in NAMES:
                v = attrs[k]
                if v:
                    fkw[k+'__iexact'] = v
            # fkw = dict(last_name__iexact=attrs['last_name'],
            #            middle_name__iexact=attrs['middle_name'],
            #            first_name__iexact=attrs['first_name'])

            full_name = join_words(
                attrs['first_name'],
                attrs['middle_name'],
                attrs['last_name'])

            # If a Person with same full_name exists, the user cannot
            # (automatically) create a new Client from eid card.

            #~ fkw.update(national_id__isnull=True)
            Person = rt.models.contacts.Person
            pqs = Person.objects.filter(**fkw)
            if pqs.count() == 0:
                def yes(ar2):
                    obj = holder_model(**attrs)
                    msg = _("New client %s has been created") % obj
                    if dd.plugins.beid.read_only_simulate:
                        msg = simulate_wrap(msg)
                        return ar2.warning(msg)
                    obj.full_clean()
                    obj.save()
                    objects, diffs = obj.get_beid_diffs(attrs)
                    for o in objects:
                        o.full_clean()
                        o.save()
                    #~ changes.log_create(ar.request,obj)
                    dd.on_ui_created.send(obj, request=ar2.request)
                    msg = _("New client %s has been created") % obj
                    return self.goto_client_response(ar2, obj, msg)
                msg = _("Create new client %s : Are you sure?") % full_name
                msg = simulate_wrap(msg)
                return ar.confirm(yes, msg)
            elif pqs.count() == 1:
                return ar.error(
                    self.sorry_msg % _(
                        "Cannot create new client because "
                        "there is already a person named "
                        "%s in our database.")
                    % full_name, alert=_("Oops!"))
            else:
                return ar.error(
                    self.sorry_msg % _(
                        "Cannot create new client because "
                        "there is more than one person named "
                        "%s in our database.")
                    % full_name, alert=_("Oops!"))

        assert qs.count() == 1
        row = qs[0]
        return self.process_row(ar, row, attrs)