Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

cosi3 : A Lino Così for Estonia

The Estonian version of Lino Così imports every place in Estonia from commondata.ee.

Side note: Code snippets (lines starting with >>>) in this document get tested as part of our development workflow. The following initialization snippet tells you which demo project is being used in this document.

>>> import lino
>>> lino.startup('lino_book.projects.cosi3.settings')
>>> from lino.api.doctest import *
>>> ses = rt.login("rando")
>>> dd.translation.activate('et')

The Estonian Wikipedia says:

Rapla maakonnas on 10 omavalitsusüksust (valda):

Juuru vald - Järvakandi vald - Kaiu vald - Kehtna vald - Kohila vald - Käru vald - Märjamaa vald - Raikküla vald - Rapla vald - Vigala vald

Lino and commondata.ee agree with this:

>>> raplamaa = countries.Place.objects.get(
...    name="Rapla", type=countries.PlaceTypes.county)
>>> ses.show("countries.PlacesByPlace", raplamaa)
==================== =========== ==========
 Asum                 Asumiliik   zip code
-------------------- ----------- ----------
 `Juuru <…>`__        Vald
 `Järvakandi <…>`__   Vald
 `Kaiu <…>`__         Vald
 `Kehtna <…>`__       Vald
 `Kohila <…>`__       Vald
 `Käru <…>`__         Vald
 `Märjamaa <…>`__     Vald
 `Raikküla <…>`__     Vald
 `Rapla <…>`__        Linn
 `Vigala <…>`__       Vald
==================== =========== ==========

Another test is the municipality of Juuru for which Wikipedia announces one small borough and 14 villages:

Juuru vallas on üks alevik (Juuru, elanikke 597) ja 14 küla: Atla (91), Helda, Hõreda (80), Härgla (84), Jaluse (40), Järlepa (235), Kalda, Lõiuse (103), Mahtra (99), Maidla (124), Orguse (43), Pirgu (102), Sadala ja Vankse (30).

Lino and commondata again agree with this:

>>> juuru = countries.Place.objects.get(name="Juuru",
...    type=countries.PlaceTypes.municipality)
>>> ses.show("countries.PlacesByPlace", juuru)
================= =========== ==========
 Asum              Asumiliik   zip code
----------------- ----------- ----------
 `Atla <…>`__      Küla        79403
 `Helda <…>`__     Küla        79417
 `Härgla <…>`__    Küla        79404
 `Hõreda <…>`__    Küla        79010
 `Jaluse <…>`__    Küla        79410
 `Juuru <…>`__     Alevik
 `Järlepa <…>`__   Küla
 `Kalda <…>`__     Küla        79418
 `Lõiuse <…>`__    Küla        79405
 `Mahtra <…>`__    Küla        79407
 `Orguse <…>`__    Küla
 `Pirgu <…>`__     Küla
 `Sadala <…>`__    Küla        79419
 `Vankse <…>`__    Küla        79406
================= =========== ==========

Formatting postal addresses

The country is being printed in the address, depends on the country_code setting.

>>> rmu(dd.plugins.countries.country_code)
'EE'
>>> dd.plugins.countries.get_my_country()
Country #EE ('Eesti')
>>> eesti = countries.Country.objects.get(isocode="EE")
>>> sindi = countries.Place.objects.get(name="Sindi")
>>> p = contacts.Person(first_name="Malle", last_name="Mets",
...     street="Männi tn", street_no="5", street_box="-6",
...     zip_code="86705", country=eesti, city=sindi)
>>> print(p.address)
Malle Mets
Männi tn 5-6
86705 Sindi

Townships in Estonia get special handling: their name is replaced by the town’s name when a zip code is known:

>>> city = countries.Place.objects.get(name="Kesklinn")
>>> print(city)
Kesklinn
>>> city.type
<countries.PlaceTypes.township:55>
>>> p = contacts.Person(first_name="Kati", last_name="Kask",
...     street="Tartu mnt", street_no="71", street_box="-5",
...     zip_code="10115", country=eesti, city=city)
>>> print(p.address)
Kati Kask
Tartu mnt 71-5
10115 Tallinn

And yet another rule for countryside addresses:

>>> city = countries.Place.objects.get(name="Vana-Vigala")
>>> city.type
<countries.PlaceTypes.village:70>
>>> p = contacts.Person(first_name="Kati", last_name="Kask",
...     street="Hirvepargi", street_no="123",
...     zip_code="78003", country=eesti, city=city)
>>> print(p.address)
Kati Kask
Hirvepargi 123
Vana-Vigala küla
Vigala vald
78003 Rapla maakond