How to use the lino.mixins 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 / cal / mixins.py View on Github external
ar.success(**kw)
        n = 0
        for obj in ar.selected_rows:
            if not ar.response.get('success'):
                ar.info("Aborting remaining rows")
                break
            ar.info("Updating reminders for %s...", unicode(obj))
            n += obj.update_reminders(ar)
            ar.response.update(refresh_all=True)

        msg = _("%d reminder(s) have been updated.") % n
        ar.info(msg)
        #~ ar.success(msg,**kw)


class EventGenerator(mixins.UserAuthored):

    """
    Base class for things that generate a suite of events.
    Examples
    :class:`isip.Contract`,     :class:`jobs.Contract`,
    :class:`schools.Course`.

    """

    class Meta:
        abstract = True

    do_update_reminders = UpdateReminders()
    #~ holiday_calendar = dd.ForeignKey('cal.Calendar',
        #~ verbose_name=_("Holiday calendar"),
        #~ related_name="%(app_label)s_%(class)s_set_by_event_generator",
github lino-framework / lino / lino / modlib / partners / models.py View on Github external
def save(self, *args, **kw):
        if self.partner_id is None:
            assert self.id is None
            p = Partner()
            p.save()
            self.id = p.id
            self.partner = p
            f = self._meta.get_field('partner')
            setattr(p, self.__class__.__name__.lower(), self)
        self.partner.name = self.get_partner_name()
        self.partner.save()
        super(ConcretePartner, self).save(*args, **kw)


class PersonMixin(mixins.Human):

    """
    Can be used also for Persons that are no Partners
    """
    class Meta:
        abstract = True

    title = models.CharField(max_length=200, blank=True,
                             verbose_name=_('Title'))
    """Text to print as part of the first address line in front of first_name."""


class Person(ConcretePartner, Addressable, PersonMixin):

    """
    Mixin for models that represent a physical person. 
github lino-framework / lino / lino_noi / lib / tickets / models.py View on Github external
class TicketType(mixins.BabelNamed):
    """The type of a :class:`Ticket`."""

    class Meta:
        app_label = 'tickets'
        verbose_name = _("Ticket type")
        verbose_name_plural = _('Ticket types')


#~ class Repository(UserAuthored):
    #~ class Meta:
        #~ verbose_name = _("Repository")
        #~ verbose_name_plural = _('Repositories')


class Project(mixins.DatePeriod, TimeInvestment,
              mixins.Hierarchical, mixins.Referrable,
              ContactRelated):
    """A **project** is something on which several users work together.

    .. attribute:: name

    .. attribute:: parent

    .. attribute:: assign_to

        The user to whom new tickets will be assigned.
        See :attr:`Ticket.assigned_to`.

    """
    class Meta:
        app_label = 'tickets'
github lino-framework / lino / lino / modlib / cal / mixins.py View on Github external
def after_state_change(self, ar, old, target_state):
        super(Reservation, self).after_state_change(ar, old, target_state)
        self.update_reminders(ar)

    #~ def after_ui_save(self,ar):
        #~ super(Reservation,self).after_ui_save(ar)
        #~ if self.state.editable:
            #~ self.update_reminders(ar)


class Component(StartedSummaryDescription,
                mixins.ProjectRelated,
                UserAuthored,
                Controllable,
                mixins.CreatedModified):

    """
    Abstract base class for :class:`Event` and :class:`Task`.

    """
    workflow_state_field = 'state'
    manager_roles_required = dd.login_required(OfficeStaff)

    class Meta(object):
        abstract = True

    access_class = AccessClasses.field(blank=True, help_text=_("""\
Whether this is private, public or between."""))  # iCal:CLASS
    sequence = models.IntegerField(_("Revision"), default=0)
    auto_type = models.IntegerField(null=True, blank=True, editable=False)
github lino-framework / lino / lino / modlib / old / newcomers / models.py View on Github external
class CompetencesByUser(Competences):
    #~ required = dict(user_groups=['newcomers'])
    required = dict()
    #~ required_user_level = None
    master_key = 'user'
    column_names = 'seqno faculty *'
    order_by = ["seqno"]

class CompetencesByFaculty(Competences):
    master_key = 'faculty'
    column_names = 'user *'
    order_by = ["user"]


class MyCompetences(mixins.ByUser,CompetencesByUser):
    pass

    
class Newcomers(AllPersons):
    """
    Persons who have the "Newcomer" checkbox on.
    """
    required = dict(user_groups=['newcomers'])
    #~ required_user_groups = ['newcomers']
    
    #~ filter = dict(newcomer=True)
    known_values = dict(newcomer=True)
    #~ use_as_default_table = False
    column_names = "name_column broker faculty address_column *"
    
    #~ @classmethod
github lino-framework / lino / lino / modlib / old / jobs / models.py View on Github external
column_names = 'person applies_from applies_until user type *'
    master_key = 'job'

class ContractsByRegime(Contracts):
    """
    Shows Job Contracts for a given Regime.
    Used as slave grid in Regimes detail.
    """
    master_key = 'regime'
    column_names = 'job applies_from applies_until user type *'

class ContractsBySchedule(Contracts):
    master_key = 'schedule'
    column_names = 'job applies_from applies_until user type *'

class MyContracts(Contracts,mixins.ByUser):
    column_names = "applies_from person job *"
    #~ label = _("My contracts")
    #~ order_by = "reminder_date"
    #~ column_names = "reminder_date person company *"
    order_by = ["applies_from"]
    #~ filter = dict(reminder_date__isnull=False)




class JobType(mixins.Sequenced):
    """
    The list of Job Types is used for statistical analysis, 
    e.g. in :class:``
    """
github lino-framework / lino / lino / modlib / cal / models_guest.py View on Github external
help_text = _("""A guest is a partner invited to an event. """)
    model = 'cal.Guest'
    required_roles = dd.required(dd.SiteStaff, OfficeUser)
    column_names = 'partner role workflow_buttons remark event *'
    detail_layout = """
    event partner role
    state remark workflow_buttons
    # outbox.MailsByController
    """
    insert_layout = dd.FormLayout("""
    event
    partner
    role
    """, window_size=(60, 'auto'))

    parameters = mixins.ObservedPeriod(
        user=dd.ForeignKey(settings.SITE.user_model,
                           verbose_name=_("Responsible user"),
                           blank=True, null=True,
                           help_text=_("Only rows managed by this user.")),
        project=dd.ForeignKey(settings.SITE.project_model,
                              blank=True, null=True),
        partner=dd.ForeignKey('contacts.Partner',
                              blank=True, null=True),
        event_state=EventStates.field(
            blank=True,
            verbose_name=_("Event state"),
            help_text=_("Only rows having this event state.")),
        guest_state=GuestStates.field(
            blank=True,
            verbose_name=_("Guest state"),
            help_text=_("Only rows having this guest state.")),
github lino-framework / lino / lino / modlib / households / models.py View on Github external
#         ))


# class Roles(dd.Table):
#     model = Role
#     required = dd.required(user_level='admin')
#     detail_layout = """
#     name name_giving
#     #male
#     #female
#     MembersByRole
#     """


@dd.python_2_unicode_compatible
class Member(mixins.DatePeriod):
    """A **household membership** represents the fact that a given person
    is (or has been) part of a given household.

    .. attribute:: start_date

        Since when this membership exists. This is usually empty.

    .. attribute:: end_date

        Until when this membership exists.


    """

    class Meta(object):
        app_label = 'households'
github lino-framework / lino / lino / modlib / old / isip / models.py View on Github external
#~ def contract_contact_choices(company):
    #~ return links.Link.objects.filter(
        #~ type__use_in_contracts=True,
        #~ a_id=company.pk)

def contract_contact_choices(company):
    return contacts.Role.objects.filter(
        type__use_in_contracts=True,
        company=company)
        #~ company__id=company.pk)




class ContractBase(mixins.DiffingMixin,mixins.TypedPrintable,cal.EventGenerator):
    """Abstract base class for 
    :class:`lino.modlib.jobs.models.Contract`
    and
    :class:`lino.modlib.isip.models.Contract`
    """
    
    TASKTYPE_CONTRACT_APPLIES_UNTIL = 1
    
    class Meta:
        abstract = True
        
    #~ eventgenerator = models.OneToOneField(cal.EventGenerator,
        #~ related_name="%(app_label)s_%(class)s_ptr",
        #~ parent_link=True)
  
    person = models.ForeignKey(settings.LINO.person_model,
github lino-framework / lino / lino / modlib / languages / models.py View on Github external
"""Defines the :class:`Language` model.

"""
from builtins import object


from django.db import models

from lino.api import dd
from lino import mixins
from django.utils.translation import ugettext_lazy as _

from lino.modlib.office.roles import OfficeStaff


class Language(mixins.BabelNamed):

    class Meta(object):
        verbose_name = _("Language")
        verbose_name_plural = _("Languages")
        ordering = ['name']

    id = models.CharField(max_length=3, primary_key=True)
    iso2 = models.CharField(max_length=2, blank=True)  # ,null=True)


class Languages(dd.Table):
    model = 'languages.Language'
    required_roles = dd.login_required(OfficeStaff)