Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

# Copyright 2008-2015 Luc Saffre 

# License: BSD (see file COPYING for details) 

 

"""Adds functionality for managing contacts. 

 

.. autosummary:: 

   :toctree: 

 

    roles 

    models 

    utils 

    mixins 

    dummy 

    fixtures.std 

    fixtures.demo 

    fixtures.demo_ee 

    fixtures.demo_fr 

 

This plugin is being extended by :ref:`welfare` in 

:mod:`lino_welfare.modlib.contacts` or by :ref:`voga` in 

:mod:`lino_voga.modlib.contacts`. 

 

 

Lino differentiates the following subclasses of Partner: 

 

.. django2rst:: contacts.Partner.print_subclasses_graph() 

 

 

The default database comes with the following list of 

:class:`RoleType`: 

 

.. django2rst:: rt.show(contacts.RoleTypes) 

     

 

""" 

 

from lino.api import ad, _ 

 

 

class Plugin(ad.Plugin): 

    "See :class:`lino.core.plugin.Plugin`." 

 

    verbose_name = _("Contacts") 

 

    needs_plugins = ['lino.modlib.countries', 'lino.modlib.system'] 

 

    ## settings 

    hide_region = False 

    """Whether to hide the `region` field in postal addresses.  Set this 

    to `True` if you live in a country like Belgium.  Belgium is 

    --despite their constant language disputes-- obviously a very 

    united country since they don't need a `region` field when 

    entering a postal address.  In Belgium, when you write a letter, 

    you just say the zip code and name of the city.  In many other 

    countries there is a mandatory intermediate field. 

 

    """ 

 

    region_label = _('Region') 

    """The `verbose_name` of the `region` field.""" 

 

    def before_analyze(self): 

        super(Plugin, self).before_analyze() 

        contacts = self.site.modules.contacts 

        if self.hide_region: 

            for m in (contacts.Person, contacts.Company): 

                m.hide_elements('region') 

 

        if False:  # see tickets/90 

            from lino.api import dd 

            for m in (contacts.Person, contacts.Company): 

                m.define_action(merge_row=dd.MergeAction(m)) 

 

    def setup_main_menu(self, site, profile, m): 

        m = m.add_menu(self.app_label, self.verbose_name) 

        # We use the string representations and not the classes because 

        # other installed applications may want to override these tables. 

        for a in ('contacts.Persons', 'contacts.Companies', 

                  'contacts.Partners'): 

            m.add_action(a) 

 

    def setup_config_menu(self, site, profile, m): 

        m = m.add_menu(self.app_label, self.verbose_name) 

        m.add_action('contacts.CompanyTypes') 

        m.add_action('contacts.RoleTypes') 

 

    def setup_explorer_menu(self, site, profile, m): 

        m = m.add_menu(self.app_label, self.verbose_name) 

        m.add_action('contacts.Roles') 

 

 

 

 

# @dd.when_prepared('contacts.Person', 'contacts.Company') 

# def hide_region(model): 

#     model.hide_elements('region')