flaschengeist/flaschengeist
Ferdinand Thiessen 8ac43826dc [Model] Event has userid not user 2020-10-27 13:38:03 +01:00
..
modules [Plugin] Fixed auth_ldap usage of User 2020-10-27 13:36:23 +01:00
system [Model] Event has userid not user 2020-10-27 13:38:03 +01:00
__init__.py Rename AccessToken model to Session, same with controller. 2020-10-19 01:41:54 +02:00
app.py Fixed plugin permissions installation 2020-10-20 19:34:14 +02:00
flaschengeist.example.cfg Only use one plugin system, load auth and "normal" plugins at once. 2020-10-15 21:58:56 +02:00
logging.yml Cleanup. Move old controller, removed unused code. 2020-09-07 18:11:38 +02:00
readme.md Detect version of plugins from setup.py, updated Readme 2020-10-19 13:16:23 +02:00

readme.md

Flaschengeist

Installation

Requirements

  • mysql or mariadb
  • python 3.4+

Install python files

pip3 install --user .

or with ldap support

pip3 install --user ".[ldap]"

Configuration

  1. Rename flaschengeist.example.cfg to flaschengeist.cfg
  2. Move it to either
    1. the module path (where flaschegeist is installed)
    2. ~/.config/
    3. A custom path and set environment variable FLASCHENGEIST_CONF
  3. Change at least the database parameters

Database installation

run_flaschengeist --install

Run

run_flaschengeist

or with debug messages:

run_flaschengeist --debug

Development

Code Style

We enforce you to use PEP 8 code style with a line length of 120 as used by Black. See also Black Code Style.

Code formatting

We use Black as the code formatter.

Installation:

pip install black

Usage:

black -l 120 DIRECTORY_OR_FILE

Misc

Git blame

When using git blame use this to ignore the code formatting commits:

$ git blame FILE.py --ignore-revs-file .git-blame-ignore-revs

Or if you just want to use git blame, configure git like this:

$ git config blame.ignoreRevsFile .git-blame-ignore-revs

Plugin Development

File Structure

flaschengeist-example-plugin
 |> __init__.py
 |> model.py
 |> setup.py

Files

__init__.py

from flask import Blueprint
from flaschengeist.modules import Plugin

    
example_bp = Blueprint("example", __name__, url_prefix="/example")
permissions = {"EXAMPLE_HELLO": "example_hello"}

class PluginExample(Plugin):
    def __init__(self, conf):
        super().__init__(blueprint=example_bp, permissions=permissions)

    def install(self):
        from flaschengeist.system.database import db
        import .model
        db.create_all()
        db.session.commit()


@example_bp.route("/hello", methods=['GET'])
@login_required(roles=['example_hello'])
def __hello(id, **kwargs):
    return "Hello"

model.py

Optional, only needed if you need your own models (database)

from flaschengeist.system.database import db


class ExampleModel(db.Model):
    """Example Model"""
    __tablename__ = 'example'
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(240))

setup.py

from setuptools import setup, find_packages

setup(
    name="flaschengeist-example-plugin",
    version="0.0.0-dev",
    packages=find_packages(),
    install_requires=[
        "flaschengeist >= 2",
    ],
    entry_points={
        "flaschengeist.plugin": [
            "example = flaschengeist-example-plugin:ExampleModel"
        ]
    },
)