added get_inventory_logs_of_type() to Asset
This commit is contained in:
@@ -23,7 +23,7 @@ def init_api():
|
||||
client_secret = client_secret
|
||||
)
|
||||
break
|
||||
except ConnectionError:
|
||||
except:
|
||||
print("Fehler bei Verbindung mit Server (wahrscheinlich DuckDns) probiere erneut...")
|
||||
|
||||
oauth = OAuth2(client_id=client_id, client=client, token=token)
|
||||
|
||||
@@ -23,6 +23,19 @@ class Asset(jsonapi_requests.orm.ApiModel):
|
||||
break;
|
||||
return related
|
||||
|
||||
def get_inventory_logs_of_type(self, type):
|
||||
if not issubclass(type, Log.Log):
|
||||
raise ValueError("type specified is not a type of log use for example: get_logs_of_type(Log.Harvest)")
|
||||
logs = type.get_list()
|
||||
related = []
|
||||
for log in logs:
|
||||
for quantity in log.quantities:
|
||||
if quantity.inventory_asset:
|
||||
if quantity.inventory_asset.id == self.id:
|
||||
related.append(log)
|
||||
break;
|
||||
return related
|
||||
|
||||
class Land(Asset):
|
||||
class Meta(Asset.Meta):
|
||||
name = 'land'
|
||||
|
||||
Reference in New Issue
Block a user