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)
=============== ===========
 Désignation     Reference
--------------- -----------
 Alfa Romeo
 Audi
 BMW
 Chevrolet
 Chrysler
 Citroen
 Dacia
 Daewoo
 Daihatsu
 Dodge
 Fiat
 Ford
 Honda
 Hyundai
 Isuzu
 Iveco
 Jaguar
 Jeep
 Kia
 Lada
 Lancia
 Land Rover
 Linhai
 MG
 Mazda
 Mercedes-Benz
 Mini
 Mitsubishi
 Nissan
 Opel
 Peugeot
 Plymouth
 Pontiac
 Porsche
 Renault
 Rover
 Saab
 Seat
 Skoda
 Smart
 Ssangyong
 Subaru
 Suzuki
 Toyota
 VW
 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
=============== ============ ======== ============