add code of user for show in angular

This commit is contained in:
Cayo Puigdefabregas 2021-07-01 12:08:18 +02:00
parent c5234e0fd4
commit 5e8c4a3231
2 changed files with 8 additions and 0 deletions

View File

@ -59,6 +59,13 @@ class User(Thing):
"""The individual associated for this database, or None.""" """The individual associated for this database, or None."""
return next(iter(self.individuals), None) return next(iter(self.individuals), None)
@property
def code(self):
"""Code of phantoms accounts"""
if not self.phantom:
return
return self.email.split('@')[0].split('_')[1]
class UserInventory(db.Model): class UserInventory(db.Model):
"""Relationship between users and their inventories.""" """Relationship between users and their inventories."""

View File

@ -23,6 +23,7 @@ class User(Thing):
description='Use this token in an Authorization header to access the app.' description='Use this token in an Authorization header to access the app.'
'The token can change overtime.') 'The token can change overtime.')
inventories = NestedOn(Inventory, many=True, dump_only=True) inventories = NestedOn(Inventory, many=True, dump_only=True)
code = String(dump_only=True, description='Code of inactive accounts')
def __init__(self, def __init__(self,
only=None, only=None,