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

cars : Managing cars

This is the developer reference about the lino_xl.lib.cars plugin, which adds functionality for managing cars and similar vehicles.

This page contains code snippets (lines starting with >>>), which are being tested during our development workflow. The following snippet initializes the demo project used throughout this page.

>>> from lino_book.projects.cosi2.startup import *
>>> ses = rt.login('robin')

The cars plugin is being used by the lino_book.projects.cosi2 demo project. The Car model is declared as lino_xl.lib.trading.project_model.

class lino_xl.lib.cars.Car

Django model used to represent a car.

class lino_xl.lib.cars.Brand

Django model used to represent a brand.

Configuration options

You can activate this plugin by overriding your Site’s lino.core.site.Site.get_installed_plugins() method like this:

def get_installed_plugins(self):
    yield super().get_installed_plugins()
    yield 'lino_xl.lib.cars'

Usage

As a site manager you can see all cars by selecting Cars ‣ Cars. Cars ‣ Brands.

>>> show_menu_path(cars.Cars)
Cars --> Cars
>>> show_menu_path(cars.Brands)
Cars --> Car brands
>>> rt.show(cars.Brands)
==== ===============
 ID   Désignation
---- ---------------
 1    Alfa Romeo
 2    Audi
 3    BMW
 4    Chevrolet
 5    Chrysler
 6    Citroen
 8    Dacia
 7    Daewoo
 9    Daihatsu
 10   Dodge
 11   Fiat
 12   Ford
 13   Honda
 14   Hyundai
 15   Isuzu
 16   Iveco
 17   Jaguar
 18   Jeep
 19   Kia
 20   Lada
 21   Lancia
 23   Land Rover
 22   Linhai
 26   MG
 24   Mazda
 25   Mercedes-Benz
 27   Mini
 28   Mitsubishi
 29   Nissan
 30   Opel
 31   Peugeot
 32   Plymouth
 33   Pontiac
 34   Porsche
 35   Renault
 36   Rover
 37   Saab
 38   Seat
 39   Skoda
 40   Smart
 41   Ssangyong
 42   Subaru
 43   Suzuki
 44   Toyota
 46   VW
 45   Volvo
==== ===============
>>> rt.show(cars.Cars)
===================== =============== ============ ======== ============
 Partenaire            License plate   Car brand    Modèle   Vehicle ID
--------------------- --------------- ------------ -------- ------------
 Bestbank              ABC123          Alfa Romeo
 Rumma & Ko OÜ         ABC456          Audi
 Bäckerei Ausdemwald   DEF123          BMW
 Bäckerei Mießen       DEF789          Chevrolet
 Bäckerei Schmitz      GHI123          Chrysler
 Garage Mergelsberg    GHI789          Citroen
===================== =============== ============ ======== ============
>>> rt.show(cars.CarsByBrand, cars.Brand.objects.get(name="Audi"))
======== =============== =============== ============
 Modèle   Partenaire      License plate   Vehicle ID
-------- --------------- --------------- ------------
          Rumma & Ko OÜ   ABC456
======== =============== =============== ============
>>> obj = contacts.Company.objects.get(name="Bestbank")
>>> rt.show(cars.CarsByPartner, obj)
=============== ============ ======== ============
 License plate   Car brand    Modèle   Vehicle ID
--------------- ------------ -------- ------------
 ABC123          Alfa Romeo
=============== ============ ======== ============