Exemplo n.º 1
0
def overview():
    # user and group stats
    banned_users = User.query.filter(
        Group.banned == True, Group.id == User.primary_group_id).count()
    if not current_app.config["REDIS_ENABLED"]:
        online_users = User.query.filter(User.lastseen >= time_diff()).count()
    else:
        online_users = len(get_online_users())

    stats = {
        # user stats
        "all_users": User.query.count(),
        "banned_users": banned_users,
        "online_users": online_users,
        "all_groups": Group.query.count(),
        # forum stats
        "report_count": Report.query.count(),
        "topic_count": Topic.query.count(),
        "post_count": Post.query.count(),
        # misc stats
        "plugins": get_all_plugins(),
        "python_version": "%s.%s" % (sys.version_info[0], sys.version_info[1]),
        "flask_version": flask_version,
        "flaskbb_version": flaskbb_version
    }

    return render_template("management/overview.html", **stats)
Exemplo n.º 2
0
def overview():
    # user and group stats
    banned_users = User.query.filter(
        Group.banned == True,
        Group.id == User.primary_group_id
    ).count()
    if not current_app.config["REDIS_ENABLED"]:
        online_users = User.query.filter(User.lastseen >= time_diff()).count()
    else:
        online_users = len(get_online_users())

    stats = {
        # user stats
        "all_users": User.query.count(),
        "banned_users": banned_users,
        "online_users": online_users,
        "all_groups": Group.query.count(),
        # forum stats
        "report_count": Report.query.count(),
        "topic_count": Topic.query.count(),
        "post_count": Post.query.count(),
        # misc stats
        "plugins": get_all_plugins(),
        "python_version": "%s.%s" % (sys.version_info[0], sys.version_info[1]),
        "flask_version": flask_version,
        "flaskbb_version": flaskbb_version
    }

    return render_template("management/overview.html", **stats)
Exemplo n.º 3
0
def checkplugins(enabled=True):
    """
    This function is used to populate a multiselect field. It checks which plugins are enabled and disabled
     and generates the output required for the DOM element.
    :param enabled: If true a list of enabled plugins are returned else a list of disabled plugins are returned.
    :return: Output required by DOM element
    """
    plugins = [(plugin.identifier, plugin.name)
               for plugin in get_all_plugins()]
    enabled_plugins = [(plugin.identifier, plugin.name)
                       for plugin in get_enabled_plugins()]
    disabled_plugins = [x for x in plugins if x not in enabled_plugins]

    if plugins:
        if enabled:
            if enabled_plugins:
                p = [plugin for plugin in enabled_plugins]

            else:
                p = [('', 'No active plugins')]

        else:
            if disabled_plugins:
                p = [plugin for plugin in disabled_plugins]

            else:
                p = [('', 'All plugins enabled')]

    else:
        p = [('', 'No plugins detected')]

    return p
Exemplo n.º 4
0
def admin_home():

    enabled_plugins = [x.identifier for x in list(get_enabled_plugins())]

    return render_template("admin.html",
                           status="default",
                           **adminInfo(),
                           plugins=get_all_plugins(),
                           enabled_plugins=enabled_plugins,
                           disable_pwd_section=config.useOIDC())
Exemplo n.º 5
0
def overview():
    # user and group stats
    banned_users = User.query.filter(
        Group.banned == True,
        Group.id == User.primary_group_id
    ).count()
    if not current_app.config["REDIS_ENABLED"]:
        online_users = User.query.filter(User.lastseen >= time_diff()).count()
    else:
        online_users = len(get_online_users())

    unread_reports = Report.query.\
        filter(Report.zapped == None).\
        order_by(Report.id.desc()).\
        count()

    celery_inspect = celery.control.inspect()
    try:
        celery_running = True if celery_inspect.ping() else False
    except Exception:
        # catching Exception is bad, and just catching ConnectionError
        # from redis is also bad because you can run celery with other
        # brokers as well.
        celery_running = False

    python_version = "{}.{}.{}".format(
        sys.version_info[0], sys.version_info[1], sys.version_info[2]
    )

    stats = {
        "current_app": current_app,
        "unread_reports": unread_reports,
        # stats stats
        "all_users": User.query.count(),
        "banned_users": banned_users,
        "online_users": online_users,
        "all_groups": Group.query.count(),
        "report_count": Report.query.count(),
        "topic_count": Topic.query.count(),
        "post_count": Post.query.count(),
        # components
        "python_version": python_version,
        "celery_version": celery_version,
        "celery_running": celery_running,
        "flask_version": flask_version,
        "flaskbb_version": flaskbb_version,
        # plugins
        "plugins": get_all_plugins()
    }

    return render_template("management/overview.html", **stats)
Exemplo n.º 6
0
    def get(self):
        # user and group stats
        banned_users = User.query.filter(Group.banned == True,
                                         Group.id == User.primary_group_id).count()
        if not current_app.config["REDIS_ENABLED"]:
            online_users = User.query.filter(User.lastseen >= time_diff()).count()
        else:
            online_users = len(get_online_users())

        unread_reports = Report.query.\
            filter(Report.zapped == None).\
            order_by(Report.id.desc()).\
            count()

        celery_inspect = celery.control.inspect()
        try:
            celery_running = True if celery_inspect.ping() else False
        except Exception:
            # catching Exception is bad, and just catching ConnectionError
            # from redis is also bad because you can run celery with other
            # brokers as well.
            celery_running = False

        python_version = "{}.{}.{}".format(
            sys.version_info[0], sys.version_info[1], sys.version_info[2]
        )

        stats = {
            "current_app": current_app,
            "unread_reports": unread_reports,
            # stats stats
            "all_users": User.query.count(),
            "banned_users": banned_users,
            "online_users": online_users,
            "all_groups": Group.query.count(),
            "report_count": Report.query.count(),
            "topic_count": Topic.query.count(),
            "post_count": Post.query.count(),
            # components
            "python_version": python_version,
            "celery_version": celery_version,
            "celery_running": celery_running,
            "flask_version": flask_version,
            "flaskbb_version": flaskbb_version,
            # plugins
            "plugins": get_all_plugins()
        }

        return render_template("management/overview.html", **stats)
Exemplo n.º 7
0
def list_plugins():
    """Lists all installed plugins."""
    click.secho("[+] Listing all installed plugins...", fg="cyan")

    # This is subject to change as I am not happy with the current
    # plugin system
    enabled_plugins = get_enabled_plugins()
    disabled_plugins = set(get_all_plugins()) - set(enabled_plugins)
    if len(enabled_plugins) > 0:
        click.secho("[+] Enabled Plugins:", fg="blue", bold=True)
        for plugin in enabled_plugins:
            click.secho("    - {} (version {})".format(plugin.name,
                                                       plugin.version),
                        bold=True)
    if len(disabled_plugins) > 0:
        click.secho("[+] Disabled Plugins:", fg="yellow", bold=True)
        for plugin in disabled_plugins:
            click.secho("    - {} (version {})".format(plugin.name,
                                                       plugin.version),
                        bold=True)
Exemplo n.º 8
0
def list_plugins():
    """Lists all installed plugins."""
    click.secho("[+] Listing all installed plugins...", fg="cyan")

    # This is subject to change as I am not happy with the current
    # plugin system
    enabled_plugins = get_enabled_plugins()
    disabled_plugins = set(get_all_plugins()) - set(enabled_plugins)
    if len(enabled_plugins) > 0:
        click.secho("[+] Enabled Plugins:", fg="blue", bold=True)
        for plugin in enabled_plugins:
            click.secho("    - {} (version {})".format(
                plugin.name, plugin.version), bold=True
            )
    if len(disabled_plugins) > 0:
        click.secho("[+] Disabled Plugins:", fg="yellow", bold=True)
        for plugin in disabled_plugins:
            click.secho("    - {} (version {})".format(
                plugin.name, plugin.version), bold=True
            )
Exemplo n.º 9
0
    def test_get_all_plugins(self):
        with self.app.test_request_context():
            plugins = get_all_plugins()

        self.assertEquals(len(plugins), 3)
Exemplo n.º 10
0
def plugins():
    plugins = get_all_plugins()
    return render_template("management/plugins.html", plugins=plugins)
Exemplo n.º 11
0
def plugins():
    plugins = get_all_plugins()
    return render_template("management/plugins.html", plugins=plugins)
Exemplo n.º 12
0
    def test_get_all_plugins(self):
        with self.app.test_request_context():
            plugins = get_all_plugins()

        self.assertEquals(len(plugins), 3)