How to use the lino.api._ 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_noi / lib / tickets / ui.py View on Github external
def param_defaults(self, ar, **kw):
        kw = super(ActiveProjects, self).param_defaults(ar, **kw)
        kw.update(start_date=dd.demo_date())
        kw.update(end_date=dd.demo_date())
        kw.update(observed_event=ProjectEvents.active)
        return kw

    
class ProjectsByParent(Projects):
    master_key = 'parent'
    label = _("Subprojects")
    column_names = "ref name children_summary *"


class TopLevelProjects(Projects):
    label = _("Projects (tree)")
    required_roles = dd.required(dd.SiteStaff)
    order_by = ["ref"]
    column_names = 'ref name parent children_summary *'
    filter = models.Q(parent__isnull=True)
    variable_row_height = True


class ProjectsByType(Projects):
    master_key = 'type'
    column_names = "ref name *"


class ProjectsByCompany(Projects):
    master_key = 'company'
    column_names = "ref name *"
github lino-framework / lino / lino_noi / lib / tickets / choicelists.py View on Github external
# required=dict(states=['new']),
    # action_name=_("Wait for feedback"),
    # help_text=_("Waiting for feedback from partner."))
add('40', _("Ready"), 'ready',
    # help_text=_(
    #     "Has been fixed. Ready for release. Waiting to be tested."),
    active=True,
    button_text="\u2610")  # BALLOT BOX
add('50', _("Done"), 'done',
    button_text="\u2611")  # BALLOT BOX WITH CHECK

# add('50', _("Tested"), 'tested',
#     # required=dict(states=['fixed']),
#     help_text=_("Has been fixed and tested."))
# add('60', _("Refused"), 'refused',
add('60', _("Cancelled"), 'cancelled',
    # required=dict(states="tested new todo callback"),
    # help_text=_("It has been decided that we won't fix this ticket."))
    button_text=u"🗑")  # WASTEBASKET (U+1F5D1)
# add('90', _("Cancelled"), 'cancelled',
#     # required=dict(states=['new todo waiting']),
#     help_text=_("Has been cancelled for some reason."))

"""Difference between Cancelled and Refused was that: Canceled means
that we don't want to talk about this ticket anymore.  Refused makes
sense for tickets which had been asked by a partner. In that case we
still may want to report it.

Also remember this thought: Should we add a new ticket state "dropped"
or "withdrawn" ("Verworfen", "Widerrufen") to indicate that the
*reporter* decided to cancel their plea? This is different from
"refused".  --> Solution seems to rename "refused" to "cancelled"
github lino-framework / lino / lino / modlib / dupable_partners / models.py View on Github external
"""
Database models for `lino.modlib.dupable_partners`.
"""
from builtins import object

from lino.api import dd, _

from lino.mixins.dupable import PhoneticWordBase, SimilarObjects


class Word(PhoneticWordBase):
    """Phonetic words for Partners."""

    class Meta(object):
        verbose_name = _("Phonetic word")
        verbose_name_plural = _("Phonetic words")

    owner = dd.ForeignKey('contacts.Partner', related_name='dupable_words')


class Words(dd.Table):
    model = 'dupable_partners.Word'
    required_roles = dd.required(dd.SiteStaff)


class SimilarPartners(SimilarObjects):
    label = _("Similar partners")
github lino-framework / lino / lino / modlib / cal / ui.py View on Github external
def as_link(cls, ar, today, txt=None):
        if ar is None:
            return ''
        if today is None:
            today = settings.SITE.today()
        if txt is None:
            txt = when_text(today)
        pv = dict(start_date=today)
        # TODO: what to do with events that span multiple days?
        pv.update(end_date=today)
        target = ar.spawn(cls, param_values=pv)
        return ar.href_to_request(target, txt)


class ShowEventsByDay(dd.Action):
    label = _("Today")
    help_text = _("Show all calendar events of the same day.")
    show_in_bbar = True
    sort_index = 60
    icon_name = 'calendar'

    def __init__(self, date_field, **kw):
        self.date_field = date_field
        super(ShowEventsByDay, self).__init__(**kw)

    def run_from_ui(self, ar, **kw):
        obj = ar.selected_rows[0]
        today = getattr(obj, self.date_field)
        pv = dict(start_date=today)
        pv.update(end_date=today)
        sar = ar.spawn(EventsByDay, param_values=pv)
        js = ar.renderer.request_handler(sar)
github lino-framework / lino / lino_noi / lib / tickets / ui.py View on Github external
start_date end_date observed_event topic feasable_by"""

    @classmethod
    def param_defaults(self, ar, **kw):
        kw = super(TicketsToDo, self).param_defaults(ar, **kw)
        kw.update(state=TicketStates.todo)
        kw.update(assigned_to=ar.get_user())
        return kw


class ActiveTickets(Tickets):
    """Active tickets are those which are neither closed nor in standby
    mode.

    """
    label = _("Active tickets")
    required_roles = dd.login_required(Triager)
    order_by = ["-id"]
    # order_by = ["-modified", "id"]
    column_names = 'overview:50 topic:10 reporter:10 project:10 ' \
                   'assigned_to:10 ticket_type:10 workflow_buttons:40 *'

    @classmethod
    def param_defaults(self, ar, **kw):
        kw = super(ActiveTickets, self).param_defaults(ar, **kw)
        kw.update(show_active=dd.YesNo.yes)
        # kw.update(show_closed=dd.YesNo.no)
        # kw.update(show_standby=dd.YesNo.no)
        return kw


class MyTickets(My, Tickets):
github lino-framework / lino / lino / modlib / cal / models.py View on Github external
_("Event is an appointment"), default=True)
    all_rooms = models.BooleanField(_("Locks all rooms"), default=False)
    locks_user = models.BooleanField(
        _("Locks the user"),
        help_text=_(
            "Whether events of this type make the user unavailable "
            "for other locking events at the same time."),
        default=False)

    start_date = models.DateField(
        verbose_name=_("Start date"),
        blank=True, null=True)
    event_label = dd.BabelCharField(
        _("Event label"),
        max_length=200, blank=True,
        help_text=_("Default text for summary of new events."))
    # , default=_("Calendar entry"))
    # default values for a Babelfield don't work as expected

    max_conflicting = models.PositiveIntegerField(
        _("Simultaneous events"),
        help_text=_("How many conflicting events should be tolerated."),
        default=1)

    def __str__(self):
        # when selecting an Event.event_type it is more natural to
        # have the event_label. It seems that the current `name` field
        # is actually never used.
        return settings.SITE.babelattr(self, 'event_label') \
            or settings.SITE.babelattr(self, 'name')
github lino-framework / lino / lino / modlib / beid / choicelists.py View on Github external
- Johan: A document type of 7 is used for bootstrap cards ? What
      is a bootstrap card (maybe some kind of test card?)  Danny: A
      bootstrap card was an eID card that was used in the early start
      of the eID card introduction to bootstrap the computers at the
      administration. This type is no longer issued.
    
    - Johan: A document type of 8 is used for a
      "habilitation/machtigings" card ? Is this for refugees or asylum
      seekers? Danny: A habilitation/machtigings card was aimed at
      civil servants. This type is also no longer used.
    
    """

    required_roles = dd.required(dd.SiteStaff)
    verbose_name = _("eID card type")
    verbose_name_plural = _("eID card types")

add = BeIdCardTypes.add_item
add('1', _("Belgian citizen"), "belgian_citizen")
# ,de=u"Belgischer Staatsbürger",fr=u"Citoyen belge"),
add('6', _("Kids card (< 12 year)"), "kids_card")
#,de=u"Kind unter 12 Jahren"),

#~ add('8', _("Habilitation"))
#,fr=u"Habilitation",nl=u"Machtiging")

add('11', _("Foreigner card A"), "foreigner_a")
        #~ nl=u"Bewijs van inschrijving in het vreemdelingenregister - Tijdelijk verblijf",
        #~ fr=u"Certificat d'inscription au registre des étrangers - Séjour temporaire",
        #~ de=u"Ausländerkarte A Bescheinigung der Eintragung im Ausländerregister - Vorübergehender Aufenthalt",
add('12', _("Foreigner card B"), "foreigner_b")
github lino-framework / lino / lino / modlib / ipdict / models.py View on Github external
    @dd.displayfield(_("Login failures"))
    def login_failures(self, obj, ar):
        return obj.login_failures
github lino-framework / lino / lino / modlib / tickets / ui.py View on Github external
'workflow_buttons:30 reporter:10 project:10 *'
    detail_layout = TicketDetail()
    insert_layout = """
    reporter #product
    summary
    """

    detail_html_template = "tickets/Ticket/detail.html"

    parameters = mixins.ObservedPeriod(
        observed_event=TicketEvents.field(blank=True),
        reporter=dd.ForeignKey(
            settings.SITE.user_model,
            verbose_name=_("Reporter"),
            blank=True, null=True,
            help_text=_("Only rows reporter by this user.")),
        assigned_to=dd.ForeignKey(
            settings.SITE.user_model,
            verbose_name=_("Assigned to"),
            blank=True, null=True,
            help_text=_("Only tickets assigned to this user.")),
        interesting_for=dd.ForeignKey(
            'tickets.Site',
            verbose_name=_("Interesting for"),
            blank=True, null=True,
            help_text=_("Only tickets interesting for this site.")),
        project=dd.ForeignKey(
            'tickets.Project',
            blank=True, null=True),
        state=TicketStates.field(
            blank=True, help_text=_("Only rows having this state.")),
        show_assigned=dd.YesNo.field(
github lino-framework / lino / lino / modlib / addresses / choicelists.py View on Github external
# Copyright 2014-2015 Luc Saffre
# License: BSD (see file COPYING for details)

from lino.api import dd, _
from lino.modlib.office.roles import OfficeStaff


class AddressType(dd.Choice):
    living_text = _("living at")


class AddressTypes(dd.ChoiceList):
    required_roles = dd.login_required(OfficeStaff)
    verbose_name = _("Address type")
    verbose_name_plural = _("Address types")
    item_class = AddressType

add = AddressTypes.add_item
add('01', _("Official address"), 'official')  # IT020
add('02', _("Unverified address"), 'unverified')  # IT042
add('03', _("Declared address"), 'declared')  # IT214
add('04', _("Reference address"), 'reference')
add('98', _("Obsolete"), 'obsolete')
add('99', _("Other"), 'other')