How to use the lino.dd function in lino

To help you get started, we’ve selected a few lino examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lino-framework / lino / lino / modlib / codechanges / models.py View on Github external
#~ frm = inspect.stack()[1]
    #~ m = inspect.getmodule(frm[0])
    #~ app_label = m.__name__.split('.')[-2]
    #~ CHANGES_LIST.append(Issue(app_label,*args,**kw))

#~ def discover():
    #~ if len(CHANGES_LIST) == 0:
        # ~ # similar logic as in django.template.loaders.app_directories
        #~ for app in settings.INSTALLED_APPS:
            #~ mod = import_module(app)
            #~ fn = os.path.join(os.path.dirname(mod.__file__), 'changes.py')
            #~ if os.path.exists(fn):
                #~ import_module(app+'.changes')


class CodeChanges(dd.VirtualTable):

    label = _("Code Changes")

    detail_layout = """
    date module 
    body
    """
    parameters = dict(
        start_date=models.DateField(_("Only changes from"), blank=True),
        end_date=models.DateField(_("until"), blank=True),
        opt_tag=models.BooleanField(_("Optimizations"), default=True),
    )
    params_layout = """
    start_date end_date opt_tag
    """
    #~ params_panel_hidden = False
github lino-framework / lino / obsolete / mails / models.py View on Github external
m.full_clean()
          m.save()
          #~ for t,n,a in elem.get_recipients():
              #~ m.recipient_set.create(type=t,address=a,name=n)
          for t,c in elem.get_mailable_recipients():
              r = Recipient(mail=m,type=t,partner=c)
              r.full_clean()
              r.save()
              #~ m.recipient_set.create(type=t,partner=c)
          a = Attachment(mail=m,owner=elem)
          a.save()
          kw.update(open_url=rr.ui.get_detail_url(m))
          return rr.ui.success(**kw)
          
      
  class Mailable(dd.Model):
      """
      Mixin for models that provide a "Create Email" button.
      Deserves more documentation.
      """

      class Meta:
          abstract = True
          
      #~ time_sent = models.DateTimeField(null=True,editable=False)
      
      @classmethod
      def setup_report(cls,rpt):
          rpt.add_action(CreateMailAction())
          #~ call_optional_super(Mailable,cls,'setup_report',rpt)
          
      def get_print_language(self,pm):
github lino-framework / lino / obsolete / mails / models.py View on Github external
#~ from lino.utils import call_optional_super
from django.conf import settings
#~ from lino import choices_method, simple_choices_method

from lino.modlib.mails.utils import RecipientType

from lino.utils.html2text import html2text
from django.core.mail import EmailMultiAlternatives
from lino.utils.config import find_config_file
from Cheetah.Template import Template as CheetahTemplate


if True:


  class MailType(mixins.PrintableType,dd.BabelNamed):
      "Deserves more documentation."
    
      templates_group = 'mails/Mail'
      
      class Meta:
          verbose_name = _("Mail Type")
          verbose_name_plural = _('Mail Types')

  class MailTypes(dd.Table):
      model = MailType
      column_names = 'name build_method template *'


  class CreateMailAction(dd.RowAction):
      "Deserves more documentation."
github lino-framework / lino / lino / modlib / old / newcomers / models.py View on Github external
from lino import mixins
from django.conf import settings
#~ from lino import choices_method, simple_choices_method
#~ from lino.modlib.contacts import models as contacts
from lino.modlib.users import models as users
from lino.modlib.cal.utils import DurationUnits


from lino.apps.pcsw.models import Person, AllPersons, only_my_persons, PersonsByCoach1, MyActivePersons

def amonthago():
  return DurationUnits.months.add_duration(datetime.date.today(),-1)
        


class Broker(dd.Model):
    """
    A Broker (Vermittler) is an external institution 
    who suggests newcomers.
    """
    class Meta:
        verbose_name = _("Broker")
        verbose_name_plural = _("Brokers")
        
    name = models.CharField(max_length=200)
    
    def __unicode__(self):
        return self.name

class Brokers(dd.Table):
    """
    List of Brokers on this site.
github lino-framework / lino / lino / modlib / cal / models_calendar.py View on Github external
class Calendars(dd.Table):
    required = dd.required(user_groups='office', user_level='manager')
    model = 'cal.Calendar'

    insert_layout = """
    name
    color
    """
    detail_layout = """
    name color id
    description
    """


class Subscription(dd.UserAuthored):

    """
    A Suscription is when a User subscribes to a Calendar.
    It corresponds to what the extensible CalendarPanel calls "Calendars"
    
    :user: points to the author (recipient) of this subscription
    :other_user: 
    
    """

    class Meta:
        abstract = settings.SITE.is_abstract_model('cal.Subscription')
        verbose_name = _("Subscription")
        verbose_name_plural = _("Subscriptions")

    manager_level_field = 'office_level'
github lino-framework / lino / lino / sandbox / debts / fixtures / demo.py View on Github external
def objects():
    group = Instantiator('debts.AccountGroup').build
    g = group(account_type=AccountType.income, **dd.babel_values('name',
                                                              de=u"Monatliche Einkünfte",
                                                              fr=u"Revenus mensuels",
                                                              en=u"Monthly incomes"
                                                              ))
    yield g
    account = Instantiator('debts.Account', group=g).build
    yield account(required_for_person=True, **dd.babel_values('name',
                                                           de=u"Gehälter",
                                                           fr=u"Salaires",
                                                           en=u"Salaries"
                                                           ))
    yield account(required_for_person=True, **dd.babel_values('name',
                                                           de=u"Renten",
                                                           fr=u"Pension",
                                                           en=u"Pension"
                                                           ))
github lino-framework / lino / lino / modlib / cal / workflows / take.py View on Github external
@dd.receiver(dd.pre_analyze)
def take_workflows(sender=None, **kw):

    site = sender

    site.modules.cal.Event.take = TakeAssignedEvent()
github lino-framework / lino / lino / modlib / old / isip / models.py View on Github external
from django.db import models
#~ from django.db.models import Q
from django.conf import settings
from django.core.exceptions import ValidationError
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_unicode 


from lino import dd
from lino.utils import dblogger
#~ from lino.utils import printable
from lino import mixins
from lino.modlib.contacts import models as contacts
#~ from lino.modlib.notes import models as notes
notes = dd.resolve_app('notes')

#~ from lino.modlib.links import models as links
from lino.modlib.uploads import models as uploads
from lino.utils.choicelists import HowWell
#~ from lino.modlib.properties.utils import KnowledgeField #, StrengthField
#~ from lino.modlib.uploads.models import UploadsByPerson
from lino.core.modeltools import get_field
from lino.core.modeltools import resolve_field
from lino.utils.babel import DEFAULT_LANGUAGE, babelattr, babeldict_getitem, language_choices
from lino.utils.htmlgen import UL
#~ from lino.utils.babel import add_babel_field, DEFAULT_LANGUAGE, babelattr, babeldict_getitem
from lino.utils import babel 
from lino.utils.choosers import chooser
from lino.utils.choicelists import ChoiceList
from lino.utils import mti
from lino.utils.ranges import isrange, overlap, overlap2, encompass, rangefmt
github lino-framework / lino / lino / modlib / old / jobs / models.py View on Github external
if True: # settings.LINO.user_model:
  
    from lino.core.modeltools import resolve_model, UnresolvedModel
    #~ USER_MODEL = resolve_model(settings.LINO.user_model)
    
    class ContractsSearch(Contracts):
        """
        Shows the job contracts owned by this user.
        """
        label = _("Job Contracts Search")
        
        use_as_default_table = False
        
        parameters = dict(
          user = dd.ForeignKey(settings.LINO.user_model,blank=True),
          #~ user = models.ForeignKey(settings.LINO.user_model,blank=True),
          type = models.ForeignKey(ContractType,blank=True,verbose_name=_("Only contracts of type")),
          show_past = models.BooleanField(_("past contracts"),default=True),
          show_active = models.BooleanField(_("active contracts"),default=True),
          show_coming = models.BooleanField(_("coming contracts"),default=True),
          today = models.DateField(_("on"),blank=True,default=datetime.date.today),
        )
        params_layout = """type show_past show_active show_coming today user"""
        #~ params_panel_hidden = False
        
        #~ master_key = 'user'
        #~ group_by = ['type']
        group_by = ['person__group']
        column_names = 'id applies_from applies_until job person person__city person__national_id person__gender user type *'
        
        @classmethod
github lino-framework / lino / lino / modlib / cal / workflows / take.py View on Github external
ar.response.update(refresh=True)
            #~ return kw
        ar.confirm(ok, self.help_text, _("Are you sure?"))


if False:

    class AssignEvent(dd.ChangeStateAction):
        label = _("Assign")
        required = dict(states='suggested draft published', owner=True)

        icon_name = 'flag_blue'
        help_text = _("Assign responsibility of this event to another user.")

        parameters = dict(
            to_user=dd.ForeignKey(settings.SITE.user_model),
            remark=dd.RichTextField(_("Remark"), blank=True),
        )

        params_layout = dd.Panel("""
    to_user
    remark
    """, window_size=(50, 15))

        @dd.chooser()
        #~ def to_user_choices(cls,user):
        def to_user_choices(cls):
            # .exclude(id=user.id)
            return settings.SITE.user_model.objects.exclude(profile='')

        def action_param_defaults(self, ar, obj, **kw):
            kw = super(AssignEvent, self).action_param_defaults(ar, obj, **kw)