def show_complexity_factors(self): self.analyze() items = [] items.append("{0} plugins".format(len(dd.plugins))) items.append("{0} models".format(len(get_models()))) items.append("{0} views".format(len(actors.actors_list))) items.append("{0} user types".format(len(UserTypes.objects()))) dialog_actions = [ ba for ba in analyzer.custom_actions + analyzer.window_actions if ba.action.parameters ] items.append("{0} dialog actions".format(len(dialog_actions))) return rstgen.ul(items)
def get_complexity_factors(self, today=None): self.analyze() yield "{0} plugins".format(len(dd.plugins)) yield "{0} models".format(len(get_models())) User = settings.SITE.user_model if today and User: qs = User.objects.filter(username__isnull=False) qs = PeriodEvents.active.add_filter(qs, today) yield "{0} users".format(qs.count()) yield "{0} user roles".format(len(settings.SITE.user_roles)) yield "{0} user types".format(len(UserTypes.objects())) yield "{0} views".format(len( [a for a in actors.actors_list if not a.abstract])) dialog_actions = [ba for ba in analyzer.custom_actions + analyzer.window_actions if ba.action.parameters] yield "{0} dialog actions".format(len(dialog_actions))
def visible_for(ba): """Shows a list of user profiles for which this action is visible.""" if ba is None: return "N/A" visible = [] hidden = [] for p in UserTypes.objects(): name = p.name or p.value if ba.get_view_permission(p): visible.append(name) else: hidden.append(name) if len(hidden) == 0: return "all" if len(visible) == 0: return "nobody" # if len(hidden) < len(visible): # if len(hidden) <= 3: # return "all except %s" % ', '.join(hidden) return ' '.join(visible)
def build_site_cache(self, force=False): """ Build the site cache files under `/media/cache`, especially the :xfile:`lino*.js` files, one per user user_type and language. """ # if not self.is_prepared: # self.prepare_layouts() # self.is_prepared = True if settings.SITE.never_build_site_cache: logger.debug( "Not building site cache because `settings.SITE.never_build_site_cache` is True" ) return if not os.path.isdir(settings.MEDIA_ROOT): logger.debug( "Not building site cache because " + "directory '%s' (settings.MEDIA_ROOT) does not exist.", settings.STATIC_ROOT) return started = time.time() # logger.info("20140401 build_site_cache started") settings.SITE.on_each_app('setup_site_cache', force) settings.SITE.makedirs_if_missing( os.path.join(settings.MEDIA_ROOT, 'upload')) settings.SITE.makedirs_if_missing( os.path.join(settings.MEDIA_ROOT, 'webdav')) if force or settings.SITE.build_js_cache_on_startup: count = 0 for lng in settings.SITE.languages: with translation.override(lng.django_code): for user_type in UserTypes.objects(): count += with_user_profile(user_type, self.build_js_cache, force) logger.info("%d lino*.js files have been built in %s seconds.", count, time.time() - started)
def get_complexity_factors(self, today=None): """ Yield a series of plain text lines that describe the complexity factors of this application. """ self.analyze() yield "{0} plugins".format(len(dd.plugins)) yield "{0} models".format(len(get_models())) User = settings.SITE.user_model if today and User: qs = User.objects.filter(username__isnull=False) qs = PeriodEvents.active.add_filter(qs, today) yield "{0} users".format(qs.count()) # yield "{0} user roles".format(len(settings.SITE.user_roles)) yield "{0} user types".format(len(UserTypes.objects())) yield "{0} views".format( len([a for a in actors.actors_list if not a.abstract])) dialog_actions = [ ba for ba in analyzer.custom_actions + analyzer.window_actions if ba.action.parameters and not ba.action.no_params_window ] yield "{0} dialog actions".format(len(dialog_actions))
def build_site_cache(self, force=False): """ Build the site cache files under `/media/cache`, especially the :xfile:`lino*.js` files, one per user user_type and language. """ # if not self.is_prepared: # self.prepare_layouts() # self.is_prepared = True if settings.SITE.never_build_site_cache: logger.debug( "Not building site cache because `settings.SITE.never_build_site_cache` is True") return if not os.path.isdir(settings.MEDIA_ROOT): logger.debug( "Not building site cache because " + "directory '%s' (settings.MEDIA_ROOT) does not exist.", settings.STATIC_ROOT) return started = time.time() # logger.info("20140401 build_site_cache started") settings.SITE.on_each_app('setup_site_cache', force) settings.SITE.makedirs_if_missing( os.path.join(settings.MEDIA_ROOT, 'upload')) settings.SITE.makedirs_if_missing( os.path.join(settings.MEDIA_ROOT, 'webdav')) if force or settings.SITE.build_js_cache_on_startup: count = 0 for lng in settings.SITE.languages: with translation.override(lng.django_code): for user_type in UserTypes.objects(): count += with_user_profile( user_type, self.build_js_cache, force) logger.info("%d lino*.js files have been built in %s seconds.", count, time.time() - started)