def get_rst(self): user_type = UserTypes.get_by_value('900') with translation.override(self.language): #~ set_language(lng) actor_names = ' '.join(self.content).split() items = [] for an in actor_names: cls = settings.SITE.models.resolve(an) if not isinstance(cls, type): raise Exception("%s is not an actor." % self.content[0]) desc = "**{0}** (:class:`{1} <{2}>`)".format( force_text(cls.label), cls.__name__, cls.__module__ + '.' + cls.__name__ ) mi = user_type.find_menu_item(cls.default_action) if mi is not None: desc += _(" (Menu %s)") % menuselection(mi) #~ print(str(mi.label).strip()) if cls.help_text: desc += " : " + force_text(cls.help_text).strip() # items.append("%s : %s" % (actor_ref(cls), cls.help_text or '')) items.append(desc) return rstgen.ul(items)
def menupath_role(typ, rawtext, text, *args, **kwargs): a = resolve_action(text) user_type = UserTypes.get_by_value('900') mi = user_type.find_menu_item(a) if mi is None: raise Exception("Unknown menu descriptor %s" % text) text = menuselection_text(mi) rawtext = menuselection(mi) return menusel_role('menuselection', rawtext, text, *args, **kwargs)
def instance(cls): if cls._instance is None: # Call startup() to fill UserTypes also in a # multi-threaded environment: settings.SITE.startup() cls._instance = AnonymousUser() from lino.modlib.users.choicelists import UserTypes cls._instance.profile = UserTypes.get_by_value( settings.SITE.anonymous_user_type, None) if cls._instance.profile is None: raise Exception( "Invalid value %r for `SITE.anonymous_user_type`. " "Must be one of %s" % ( settings.SITE.anonymous_user_type, [i.value for i in list(UserTypes.items())])) return cls._instance
def actors_overview_ul(model_reports): user_type = UserTypes.get_by_value('900') # deprecated items = [] for tb in model_reports: desc = actor_ref(tb) #~ label = str(tb.title or tb.label) #~ desc += " (%s)" % str(tb) desc += " (%s)" % typeref(tb) # mi = find_menu_item(tb.default_action) mi = user_type.find_menu_item(tb.default_action) if mi is not None: desc += _(" (Menu %s)") % menuselection(mi) #~ print(unicode(mi.label).strip()) if tb.help_text: desc += " -- " + str(tb.help_text).strip() items.append(desc) return rstgen.ul(items)