[chore] Minor cleanup
This commit is contained in:
parent
466efcf9e7
commit
900b5efff5
|
@ -14,8 +14,11 @@ class ModelSerializeMixin:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
import typing
|
import typing
|
||||||
if typing.get_origin(self.__class__.__annotations__[param]) is typing.Union and \
|
|
||||||
typing.get_args(self.__class__.__annotations__[param])[1] is None:
|
if (
|
||||||
|
typing.get_origin(self.__class__.__annotations__[param]) is typing.Union
|
||||||
|
and isinstance(typing.get_args(self.__class__.__annotations__[param])[1], type(None))
|
||||||
|
):
|
||||||
return getattr(self, param) is None
|
return getattr(self, param) is None
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
|
|
|
@ -62,9 +62,11 @@ class Plugin:
|
||||||
Value stored in database (native python)
|
Value stored in database (native python)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
setting = _PluginSetting.query\
|
setting = (
|
||||||
.filter(_PluginSetting.plugin == self._plugin_name)\
|
_PluginSetting.query.filter(_PluginSetting.plugin == self._plugin_name)
|
||||||
.filter(_PluginSetting.name == name).one()
|
.filter(_PluginSetting.name == name)
|
||||||
|
.one()
|
||||||
|
)
|
||||||
return setting.value
|
return setting.value
|
||||||
except sqlalchemy.orm.exc.NoResultFound:
|
except sqlalchemy.orm.exc.NoResultFound:
|
||||||
if "default" in kwargs:
|
if "default" in kwargs:
|
||||||
|
@ -78,9 +80,11 @@ class Plugin:
|
||||||
name: String identifying the setting
|
name: String identifying the setting
|
||||||
value: Value to be stored
|
value: Value to be stored
|
||||||
"""
|
"""
|
||||||
setting = _PluginSetting.query \
|
setting = (
|
||||||
.filter(_PluginSetting.plugin == self._plugin_name) \
|
_PluginSetting.query.filter(_PluginSetting.plugin == self._plugin_name)
|
||||||
.filter(_PluginSetting.name == name).one_or_none()
|
.filter(_PluginSetting.name == name)
|
||||||
|
.one_or_none()
|
||||||
|
)
|
||||||
if setting is not None:
|
if setting is not None:
|
||||||
setting.value = value
|
setting.value = value
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -23,10 +23,12 @@ class AuthPlain(AuthPlugin):
|
||||||
self.modify_user(admin, None, "admin")
|
self.modify_user(admin, None, "admin")
|
||||||
db.session.add(admin)
|
db.session.add(admin)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
logger.warning("New administrator user was added, please change the password or remove it before going into"
|
logger.warning(
|
||||||
|
"New administrator user was added, please change the password or remove it before going into"
|
||||||
"production mode. Initial credentials:\n"
|
"production mode. Initial credentials:\n"
|
||||||
"name: admin\n"
|
"name: admin\n"
|
||||||
"password: admin")
|
"password: admin"
|
||||||
|
)
|
||||||
|
|
||||||
def login(self, user: User, password: str):
|
def login(self, user: User, password: str):
|
||||||
if user.has_attribute("password"):
|
if user.has_attribute("password"):
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info < (3, 7):
|
||||||
from backports.datetime_fromisoformat import MonkeyPatch
|
from backports.datetime_fromisoformat import MonkeyPatch
|
||||||
|
|
||||||
MonkeyPatch.patch_fromisoformat()
|
MonkeyPatch.patch_fromisoformat()
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -10,7 +10,7 @@ setup(
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
package_data={"": ["*.toml"]},
|
package_data={"": ["*.toml"]},
|
||||||
scripts=["run_flaschengeist"],
|
scripts=["run_flaschengeist"],
|
||||||
python_requires=">=3.6",
|
python_requires=">=3.7",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"Flask >= 1.1",
|
"Flask >= 1.1",
|
||||||
"toml",
|
"toml",
|
||||||
|
@ -19,8 +19,6 @@ setup(
|
||||||
"flask_sqlalchemy",
|
"flask_sqlalchemy",
|
||||||
"flask_cors",
|
"flask_cors",
|
||||||
"werkzeug",
|
"werkzeug",
|
||||||
# Needed for python < 3.7
|
|
||||||
"backports-datetime-fromisoformat",
|
|
||||||
],
|
],
|
||||||
extras_require={"ldap": ["flask_ldapconn", "ldap3"], "test": ["pytest", "coverage"]},
|
extras_require={"ldap": ["flask_ldapconn", "ldap3"], "test": ["pytest", "coverage"]},
|
||||||
entry_points={
|
entry_points={
|
||||||
|
|
Loading…
Reference in New Issue