How to use the lino.api.dd.Table 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 / users / desktop.py View on Github external
# """


class UserInsertLayout(dd.InsertLayout):

    window_size = (60, 'auto')

    main = """
    username email
    first_name last_name
    partner
    language user_type
    """


class Users(dd.Table):
    #~ debug_actions  = True
    model = 'users.User'
    #~ order_by = "last_name first_name".split()
    order_by = ["username"]
    active_fields = 'partner'
    abstract = True
    required_roles = dd.login_required(SiteAdmin)

    parameters = dict(
        user_type=UserTypes.field(blank=True))

    simple_parameters = ['user_type']

    #~ column_names = 'username first_name last_name is_active is_staff is_expert is_superuser *'
    column_names = 'username user_type first_name last_name *'
    detail_layout = 'users.UserDetail'
github lino-framework / lino / lino / modlib / checkdata / models.py View on Github external
    @classmethod
    def get_simple_parameters(cls):
        for p in super(Problem, cls).get_simple_parameters():
            yield p
        # yield 'user'
        yield 'checker'

dd.update_field(Problem, 'user', verbose_name=_("Responsible"))
Problem.set_widget_options('checker', width=10)
Problem.set_widget_options('user', width=10)
Problem.set_widget_options('message', width=50)
Problem.update_controller_field(verbose_name = _('Database object'))


class Problems(dd.Table):
    "The base table for :class:`Problem` objects."
    model = 'checkdata.Problem'
    column_names = "user owner message #fixable checker *"
    auto_fit_column_widths = True
    editable = False
    cell_edit = False
    # parameters = dict(
    #     # user=models.ForeignKey(
    #     #     'users.User', blank=True, null=True,
    #     #     verbose_name=_("Responsible"),
    #     #     help_text=_("""Only problems for this responsible.""")),
    #     )
    params_layout = "user checker"

    # simple_parameters = ('user', 'checker')
    detail_layout = dd.DetailLayout("""
github lino-framework / lino / lino / modlib / tickets / ui.py View on Github external
kw.update(interesting_for=u.user_site)
        kw.update(end_date=dd.today())
        kw.update(observed_event=TicketEvents.todo)
        return kw

    @classmethod
    def get_welcome_messages(cls, ar, **kw):
        sar = ar.spawn(cls)
        count = sar.get_total_count()
        if count > 0:
            msg = _("There are {0} known problems for {1}.")
            msg = msg.format(count, ar.get_user().user_site)
            yield ar.href_to_request(sar, msg)


class Milestones(dd.Table):
    """
    .. attribute:: show_closed
    """
    order_by = ['-id']
    # order_by = ['label', '-id']
    model = 'tickets.Milestone'
    detail_layout = """
    site id label expected reached changes_since printed closed
    description
    #TicketsFixed
    TicketsReported DeploymentsByMilestone
    #clocking.OtherTicketsByMilestone
    """
    insert_layout = dd.InsertLayout("""
    site label
    description
github lino-framework / lino / lino_noi / lib / tickets / ui.py View on Github external
workflow_buttons assigned_to waiting_for
    """

    more = dd.Panel("""
    more1 DuplicatesByTicket:20
    description:40 upgrade_notes:20 LinksByTicket:20
    """, label=_("More"))

    more1 = """
    #nickname:10 created modified reported_for #fixed_for ticket_type:10
    state duplicate_of planned_time priority
    # standby feedback closed
    """


class Tickets(dd.Table):
    """Global list of all tickets.

    .. attribute:: site

        Select a site if you want to see only tickets for this site.

    .. attribute:: show_private

        Show only (or hide) tickets that are marked private.

    .. attribute:: show_active

        Show only (or hide) tickets which are active (i.e. state is Talk
        or ToDo).

    .. attribute:: show_assigned
github lino-framework / lino / lino / modlib / cal / ui.py View on Github external
class Calendars(dd.Table):
    required_roles = dd.required(OfficeStaff)
    model = 'cal.Calendar'

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


class Subscriptions(dd.Table):
    required_roles = dd.required(OfficeStaff)
    model = 'cal.Subscription'
    order_by = ['calendar__name']
    #~ insert_layout = """
    #~ label
    #~ event_type
    #~ """
    #~ detail_layout = """
    #~ label user color
    #~ event_type team other_user room
    #~ description
    #~ """

#~ class MySubscriptions(Subscriptions, ByUser):
    #~ pass
github lino-framework / lino / lino / modlib / comments / ui.py View on Github external
master_key = 'reply_to'
    display_mode = "list"
    stay_in_grid = True
    borderless_list_mode = True
    title = _("Replies")
    simple_slavegrid_header = True

    paginator_template = "PrevPageLink NextPageLink"
    hide_if_empty = True


def comments_by_owner(obj):
    return CommentsByRFC.request(master_instance=obj)


class Mentions(dd.Table):
    required_roles = dd.login_required(CommentsStaff)
    model = "comments.Mention"
    column_names = "comment owner created *"
    detail_layout = """
    id comment owner created
    """


class MentionsByOwner(Mentions):
    master_key = "owner"
github lino-framework / lino / lino / sandbox / contacts / models.py View on Github external
#~ class AddressType(mixins.BabelNamed):
    #~ class Meta:
        #~ verbose_name = _("Address Type")
        #~ verbose_name_plural = _("Address Types")
#~ class AddressTypes(dd.Table):
    #~ model = AddressType
    #~ column_names = 'name *'
class Role(mixins.BabelNamed):

    class Meta:
        verbose_name = _("Role")
        verbose_name_plural = _("Roles")


class Roles(dd.Table):
    model = Role
    column_names = 'name *'


class Address(CountryCity):

    class Meta:
        abstract = settings.SITE.abstract_address
        verbose_name = _("Address")
        verbose_name_plural = _("Addresses")

    addr1 = models.CharField(_("Address line before street"),
                             max_length=200, blank=True)

    street_prefix = models.CharField(
        _("Street prefix"), max_length=200, blank=True,
github lino-framework / lino / lino / modlib / sales / models.py View on Github external
class ShippingMode(mixins.BabelNamed):
    """
    Represents a possible method of how the items described in a
    :class:`SalesDocument` are to be transferred from us to our customer.

    .. attribute:: price

    """
    class Meta:
        verbose_name = _("Shipping Mode")
        verbose_name_plural = _("Shipping Modes")

    price = dd.PriceField(blank=True, null=True)


class ShippingModes(dd.Table):

    model = 'sales.ShippingMode'


class SalesDocument(VatDocument, Certifiable):
    """Common base class for `orders.Order` and :class:`VatProductInvoice`.

    Subclasses must either add themselves a `date` field (as does
    Order) or inherit it from Voucher (as does VatProductInvoice)

    """

    auto_compute_totals = True

    class Meta:
        abstract = True
github lino-framework / lino / lino / modlib / boards / models.py View on Github external
verbose_name_plural = _("Boards")

    def full_clean(self, *args, **kw):
        if not self.start_date:
            self.start_date = dd.today()
        super(Board, self).full_clean(*args, **kw)


dd.update_field(
    Board, 'start_date',
    verbose_name=_("Works since"),
    null=False)
dd.update_field(Board, 'end_date', verbose_name=_("Worked until"))


class Boards(dd.Table):
    model = 'boards.Board'
    required_roles = dd.required(dd.SiteStaff, OfficeUser)
    column_names = 'name *'
    order_by = ["name"]

    insert_layout = """
    name
    """

    detail_layout = """
    id name
    boards.MembersByBoard
    """


class Member(dd.Model):
github lino-framework / lino / lino / modlib / accounts / models.py View on Github external
self.ref = str(qs.count() + 1)
            if not self.name:
                self.name = self.group.name
            #~ if not self.type:
            self.type = self.group.account_type
            #~ if not self.chart:
                #~ self.chart = self.group.chart
        super(Account, self).full_clean(*args, **kw)

    def __unicode__(self):
        return "(%(ref)s) %(title)s" % dict(
            ref=self.ref,
            title=settings.SITE.babelattr(self, 'name'))


class Accounts(dd.Table):
    model = 'accounts.Account'
    required_roles = dd.required(SiteStaff)
    order_by = ['ref']
    column_names = "ref name group *"
    insert_layout = """
    ref group type
    name
    """
    detail_layout = """
    ref name
    group type
    # help_text
    """


class AccountsByGroup(Accounts):