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

# Copyright 2009-2015 Luc Saffre 

# License: BSD (see file COPYING for details) 

 

"""Database models for `lino.modlib.system`. 

 

""" 

from builtins import object 

 

import logging 

logger = logging.getLogger(__name__) 

 

 

from django.db import models 

from django.utils.translation import ugettext_lazy as _ 

 

from lino.modlib.users.mixins import UserAuthored, ByUser 

from lino.modlib.office.roles import OfficeUser 

from lino.api import dd 

 

 

@dd.python_2_unicode_compatible 

class TextFieldTemplate(UserAuthored): 

 

    """A reusable block of text that can be selected from a text editor to 

    be inserted into the text being edited. 

 

    """ 

 

    class Meta(object): 

        verbose_name = _("Text Field Template") 

        verbose_name_plural = _("Text Field Templates") 

 

    name = models.CharField(_("Designation"), max_length=200) 

    description = dd.RichTextField(_("Description"), 

                                   blank=True, null=True, format='plain') 

        #~ blank=True,null=True,format='html') 

    # team = dd.ForeignKey( 

    #     'users.Team', blank=True, null=True, 

    #     help_text=_("If not empty, then this template " 

    #                 "is reserved to members of this team.")) 

    text = dd.RichTextField(_("Template Text"), 

                            blank=True, null=True, format='html') 

 

    def __str__(self): 

        return self.name 

 

 

class TextFieldTemplates(dd.Table): 

    model = TextFieldTemplate 

    required_roles = dd.required(dd.SiteStaff, OfficeUser) 

    insert_layout = dd.FormLayout(""" 

    name 

    user #team 

    """, window_size=(60, 'auto')) 

 

    detail_layout = """ 

    id name user #team 

    description 

    text 

    """ 

 

 

class MyTextFieldTemplates(TextFieldTemplates, ByUser): 

    required_roles = dd.required(OfficeUser)