How to use the lino.api.rt.modules 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 / noi / fixtures / linotickets.py View on Github external
def objects():

    Project = rt.modules.tickets.Project
    Ticket = rt.modules.tickets.Ticket
    TicketStates = rt.modules.tickets.TicketStates

    prj = Project(name="Lino")
    yield prj

    settings.SITE.loading_from_dump = True

    for ln in TICKETS.splitlines():
        ln = ln.strip()
        if ln:
            a = ln.split(':')
            state = TicketStates.accepted
            a2 = []
            for i in a:
                if '[closed]' in i:
github lino-framework / lino / lino / modlib / finan / mixins.py View on Github external
def set_grouper(self, suggestions):
        # not tested
        Grouper = rt.modules.finan.Grouper
        GrouperItem = rt.modules.finan.GrouperItem
        fkw = dict(partner=self.partner)
        fkw.update(state__in=VoucherStates.get_editable_states())
        try:
            Grouper.objects.get(**fkw)
        except Grouper.DoesNotExist:
            pass
        else:
            msg = _("There is already an open grouper for {0}")
            raise Warning(msg.format(self.partner))
        jnl = self.voucher.journal.grouper_journal
        grouper = jnl.create_voucher()
        for match in suggestions:
            gi = GrouperItem(voucher=grouper)
            gi.fill_suggestion(match)
            gi.full_clean()
github lino-framework / lino / lino / modlib / tickets / fixtures / demo.py View on Github external
def objects():
    User = rt.modules.users.User
    # Company = rt.modules.contacts.Company
    Product = rt.modules.products.Product
    TT = rt.modules.tickets.TicketType
    Ticket = rt.modules.tickets.Ticket
    Interest = rt.modules.tickets.Interest
    Milestone = rt.modules.tickets.Milestone
    Project = rt.modules.tickets.Project
    Site = rt.modules.tickets.Site
    Link = rt.modules.tickets.Link
    LinkTypes = rt.modules.tickets.LinkTypes

    cons = rt.modules.users.UserProfiles.consultant
    dev = rt.modules.users.UserProfiles.developer
    yield User(username="mathieu", profile=cons)
    yield User(username="marc", profile=cons)
    yield User(username="luc", profile=dev)
    yield User(username="jean", profile=rt.modules.users.UserProfiles.senior)

    USERS = Cycler(User.objects.all())
github lino-framework / lino / lino / modlib / clocking / models.py View on Github external
def run_from_ui(self, ar, **kw):
        me = ar.get_user()
        obj = ar.selected_rows[0]

        ses = rt.modules.clocking.Session(ticket=obj, user=me)
        ses.full_clean()
        ses.save()
        ar.set_response(refresh=True)
github lino-framework / lino / lino / modlib / tickets / fixtures / tractickets.py View on Github external
def makeuser(username):
    User = rt.modules.users.User
    u, created = User.objects.get_or_create(username=username.strip())
    if created:
        # u.profile = rt.modules.users.UserProfiles.admin
        # u.set_password('1234')
        # u.modified = datetime.datetime.now()
        u.full_clean()
        u.save()
    return u
github lino-framework / lino / lino / modlib / reception / models.py View on Github external
Create a "prompt event".
    """
    ekw = dict(project=project)
    today = settings.SITE.today()
    ekw.update(start_date=today)
    ekw.update(end_date=today)
    ekw.update(event_type=settings.SITE.site_config.prompt_calendar)
    ekw.update(state=EventStates.published)
    ekw.update(user=user)
    if summary:
        ekw.update(summary=summary)
    event = rt.modules.cal.Event(**ekw)
    event.save()
    if now is None:
        now = timezone.now()
    rt.modules.cal.Guest(
        event=event,
        partner=partner,
        state=rt.modules.cal.GuestStates.waiting,
        role=guest_role,
        #~ role=settings.SITE.site_config.client_guestrole,
        waiting_since=now
    ).save()
    #~ event.full_clean()
    #~ print 20130722, ekw, ar.action_param_values.user, ar.get_user()
    return event
github lino-framework / lino / lino / modlib / notes / fixtures / demo.py View on Github external
def objects():
    User = rt.modules.users.User
    Note = rt.modules.notes.Note
    NoteType = rt.modules.notes.NoteType

    USERS = Cycler(User.objects.all())
    if settings.SITE.project_model is not None:
        Project = settings.SITE.project_model
        qs = Project.objects.all()
        if qs.count() > 10:
            qs = qs[:10]
        PROJECTS = Cycler(qs)
    NTYPES = Cycler(NoteType.objects.all())

    notetype = Instantiator('notes.NoteType').build
    tel = notetype(name="phone report")
    yield tel
    yield notetype(name="todo")
github lino-framework / lino / lino / modlib / ledger / mixins.py View on Github external
def get_match_choices(cls, journal, partner):
        """This is the general algorithm.
        """
        matchable_accounts = rt.modules.accounts.Account.objects.filter(
            matchrule__journal=journal)
        fkw = dict(account__in=matchable_accounts)
        fkw.update(satisfied=False)
        if partner:
            fkw.update(partner=partner)
        qs = rt.modules.ledger.Movement.objects.filter(**fkw)
        qs = qs.order_by('voucher__date')
        #~ qs = qs.distinct('match')
        return qs
        # return qs.values_list('match', flat=True)
github lino-framework / lino / lino / modlib / tickets / fixtures / demo.py View on Github external
def objects():
    User = rt.modules.users.User
    # Company = rt.modules.contacts.Company
    Product = rt.modules.products.Product
    TT = rt.modules.tickets.TicketType
    Ticket = rt.modules.tickets.Ticket
    Interest = rt.modules.tickets.Interest
    Milestone = rt.modules.tickets.Milestone
    Project = rt.modules.tickets.Project
    Site = rt.modules.tickets.Site
    Link = rt.modules.tickets.Link
    LinkTypes = rt.modules.tickets.LinkTypes

    cons = rt.modules.users.UserProfiles.consultant
    dev = rt.modules.users.UserProfiles.developer
    yield User(username="mathieu", profile=cons)
    yield User(username="marc", profile=cons)
    yield User(username="luc", profile=dev)
github lino-framework / lino / lino / modlib / cal / ui.py View on Github external
def check_subscription(user, calendar):
    "Check whether the given subscription exists. If not, create it."
    Subscription = rt.modules.cal.Subscription
    if calendar is None:
        return
    try:
        Subscription.objects.get(user=user, calendar=calendar)
    except Subscription.DoesNotExist:
        sub = Subscription(user=user, calendar=calendar)
        sub.full_clean()
        sub.save()