Compare commits

..

No commits in common. "22fbb526bb2f2bf5912dbd31dc8f1029b1732c9b" and "b8ac6eb462366074a4dbffa50c7e21c56eb8d053" have entirely different histories.

6 changed files with 8 additions and 36 deletions

View File

@ -1,4 +1,8 @@
"""Flaschengeist"""
""" Server-package
Initialize app, CORS, database and add it to the application.
"""
import logging
import pkg_resources
from pathlib import Path
@ -6,7 +10,5 @@ from werkzeug.local import LocalProxy
__version__ = pkg_resources.get_distribution("flaschengeist").version
_module_path = Path(__file__).parent
__pdoc__ = {}
logger: logging.Logger = LocalProxy(lambda: logging.getLogger(__name__))
__pdoc__["logger"] = "Flaschengeist's logger instance (`werkzeug.local.LocalProxy`)"

View File

@ -1 +0,0 @@
"""Basic controllers for interaction with the Flaschengeist core"""

View File

@ -99,7 +99,7 @@ def set_roles(user: User, roles: list[str], create=False):
roles: List of role names
create: If set to true, create not existing roles
Raises:
BadRequest if invalid arguments given or not all roles found while *create* is set to false
BadRequest if invalid arguments given or not all roles found while `create` is set to false
"""
from roleController import create_role

View File

@ -54,21 +54,10 @@ class Plugin:
If your class uses custom models add a static property called ``models``"""
blueprint = None # You have to override
"""Override with a `flask.blueprint` if the plugin uses custom routes"""
permissions = [] # You have to override
"""Override to add custom permissions used by the plugin
A good style is to name the permissions with a prefix related to the plugin name,
to prevent clashes with other plugins. E. g. instead of *delete* use *plugin_delete*.
"""
id = "dev.flaschengeist.plugin" # You have to override
"""Override with the unique ID of the plugin (Hint: FQN)"""
name = "plugin" # You have to override
"""Override with human readable name of the plugin"""
models = None # You have to override
"""Override with models module"""
migrations_path = None # Override this with the location of your db migrations directory
"""Override with path to migration files, if custome db tables are used"""
def __init__(self, config=None):
"""Constructor called by create_app
@ -79,21 +68,17 @@ class Plugin:
def install(self):
"""Installation routine
Is always called with Flask application context
"""
pass
def get_setting(self, name: str, **kwargs):
"""Get plugin setting from database
Args:
name: string identifying the setting
default: Default value
Returns:
Value stored in database (native python)
Raises:
`KeyError` if no such setting exists in the database
"""
try:
setting = (
@ -110,7 +95,6 @@ class Plugin:
def set_setting(self, name: str, value):
"""Save setting in database
Args:
name: String identifying the setting
value: Value to be stored
@ -130,22 +114,10 @@ class Plugin:
db.session.commit()
def notify(self, user, text: str, data=None):
"""Create a new notification for an user
Args:
user: `flaschengeist.models.user.User` to notify
text: Visibile notification text
data: Optional data passed to the notificaton
Returns:
ID of the created `flaschengeist.models.notification.Notification`
Hint: use the data for frontend actions.
"""
if not user.deleted:
n = Notification(text=text, data=data, plugin=self.id, user_=user)
db.session.add(n)
db.session.commit()
return n.id
def serialize(self):
"""Serialize a plugin into a dict

View File

@ -40,7 +40,7 @@ class Transaction(db.Model, ModelSerializeMixin):
@sender_id.expression
def sender_id(cls):
return db.select([User.userid]).where(cls._sender_id == User.id_).scalar_subquery()
return db.select([User.userid]).where(cls._sender_id == User.id_).as_scalar()
@hybrid_property
def receiver_id(self):
@ -48,7 +48,7 @@ class Transaction(db.Model, ModelSerializeMixin):
@receiver_id.expression
def receiver_id(cls):
return db.select([User.userid]).where(cls._receiver_id == User.id_).scalar_subquery()
return db.select([User.userid]).where(cls._receiver_id == User.id_).as_scalar()
@property
def author_id(self):

View File

@ -1 +0,0 @@
"""Common utilities"""