...
 
Commits (2)
......@@ -3,5 +3,6 @@
!gmb
!requirements.txt
!run
!scripts
!makefile
**/__pycache__
......@@ -15,7 +15,7 @@ class BaseModel(Model):
@classmethod
def _get_all(cls):
items = []
for item in cls._select():
for item in super().select():
items.append(item)
return items
......@@ -27,9 +27,9 @@ class BaseModel(Model):
@classmethod
def _get_entry(cls):
for item in cls._select():
for item in super().select():
return item
return cls._create()
return super().create()
@classmethod
@handle_errors
......@@ -42,10 +42,10 @@ class BaseModel(Model):
# update or create für chat admin list sollte diese Methode nutzen:
# http://docs.peewee-orm.com/en/latest/peewee/api.html#Model.get_or_create
try:
item = cls._get(kwargs[pk_name])
item = super().get(kwargs[pk_name])
item.__data__ = {**kwargs}
except DoesNotExist:
item = cls._create(**kwargs)
item = super().create(**kwargs)
item.save()
return item
......@@ -61,29 +61,17 @@ class BaseModel(Model):
"""
return cls._update_or_create(pk_name, **kwargs)
@classmethod
def _create(cls, **query):
return super().create(**query)
@classmethod
@handle_errors
def create(cls, **query):
return cls._create(**query)
@classmethod
def _select(cls, *fields):
return super().select(*fields)
return super().create(**query)
@classmethod
@handle_errors
def select(cls, *fields):
return cls._select(*fields)
@classmethod
def _get(cls, *query, **filters):
return super().get(*query, **filters)
return super().select(*fields)
@classmethod
@handle_errors
def get(cls, *query, **filters):
return cls._get(*query, **filters)
return super().get(*query, **filters)
......@@ -58,9 +58,12 @@ class W_ChatAdmin(BaseModel):
# update or create für chat admin list sollte diese Methode nutzen:
# http://docs.peewee-orm.com/en/latest/peewee/api.html#Model.get_or_create
try:
item = super()._get(admin=admin, chat=chat)
# TODO https://github.com/palantir/python-language-server/issues/552
get_method = super(BaseModel, cls).get
item = get_method(admin=admin, chat=chat)
except DoesNotExist:
item = super()._create(admin=admin, chat=chat)
create_method = super(BaseModel, cls).create
item = create_method(admin=admin, chat=chat)
return item
@classmethod
......