Welcome | Get started | Dive into Lino | Contribute | Topics | Reference | More

cosi_ee : A Lino Così for Estonia

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

This page is a tested document and the following instructions are used for initialization:

>>> import lino
>>> lino.startup('lino_book.projects.cosi_ee.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 </#/api/countries/PlacesByPlace/968>`__        Vald
 `Järvakandi </#/api/countries/PlacesByPlace/967>`__   Vald
 `Kaiu </#/api/countries/PlacesByPlace/983>`__         Vald
 `Kehtna </#/api/countries/PlacesByPlace/842>`__       Vald
 `Kohila </#/api/countries/PlacesByPlace/1005>`__      Vald
 `Käru </#/api/countries/PlacesByPlace/996>`__         Vald
 `Märjamaa </#/api/countries/PlacesByPlace/889>`__     Vald
 `Raikküla </#/api/countries/PlacesByPlace/1029>`__    Vald
 `Rapla </#/api/countries/PlacesByPlace/801>`__        Linn
 `Vigala </#/api/countries/PlacesByPlace/774>`__       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 </#/api/countries/PlacesByPlace/975>`__      Küla        79403
 `Helda </#/api/countries/PlacesByPlace/978>`__     Küla        79417
 `Härgla </#/api/countries/PlacesByPlace/974>`__    Küla        79404
 `Hõreda </#/api/countries/PlacesByPlace/973>`__    Küla        79010
 `Jaluse </#/api/countries/PlacesByPlace/981>`__    Küla        79410
 `Juuru </#/api/countries/PlacesByPlace/969>`__     Alevik
 `Järlepa </#/api/countries/PlacesByPlace/970>`__   Küla
 `Kalda </#/api/countries/PlacesByPlace/979>`__     Küla        79418
 `Lõiuse </#/api/countries/PlacesByPlace/982>`__    Küla        79405
 `Mahtra </#/api/countries/PlacesByPlace/976>`__    Küla        79407
 `Orguse </#/api/countries/PlacesByPlace/972>`__    Küla
 `Pirgu </#/api/countries/PlacesByPlace/971>`__     Küla
 `Sadala </#/api/countries/PlacesByPlace/980>`__    Küla        79419
 `Vankse </#/api/countries/PlacesByPlace/977>`__    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