Making API more uniform

This commit is contained in:
Xavier Bustamante Talavera 2018-12-30 12:43:29 +01:00
parent a1c312edcd
commit 710432ef12
5 changed files with 14 additions and 1 deletions

View file

@ -489,7 +489,10 @@ class DataStorage(JoinedComponentTableMixin, Component):
@property @property
def privacy(self): def privacy(self):
"""Returns the privacy compliance state of the data storage.""" """Returns the privacy compliance state of the data storage.
This is, the last erasure performed to the data storage.
"""
from ereuse_devicehub.resources.event.models import EraseBasic from ereuse_devicehub.resources.event.models import EraseBasic
try: try:
ev = self.last_event_of(EraseBasic) ev = self.last_event_of(EraseBasic)

View file

@ -62,6 +62,7 @@ class Filters(query.Query):
class Sorting(query.Sort): class Sorting(query.Sort):
id = query.SortField(Device.id) id = query.SortField(Device.id)
created = query.SortField(Device.created) created = query.SortField(Device.created)
updated = query.SortField(Device.updated)
class DeviceView(View): class DeviceView(View):

View file

@ -75,6 +75,7 @@ class Deallocate(EventWithMultipleDevices):
class EraseBasic(EventWithOneDevice): class EraseBasic(EventWithOneDevice):
steps = NestedOn('Step', many=True) steps = NestedOn('Step', many=True)
standards = f.List(EnumField(enums.ErasureStandards), dump_only=True) standards = f.List(EnumField(enums.ErasureStandards), dump_only=True)
certificate = URL(dump_only=True)
class EraseSectors(EraseBasic): class EraseSectors(EraseBasic):

View file

@ -75,6 +75,10 @@ class Lot(Thing):
super().__init__(id=uuid.uuid4(), name=name, closed=closed, description=description) super().__init__(id=uuid.uuid4(), name=name, closed=closed, description=description)
Path(self) # Lots have always one edge per default. Path(self) # Lots have always one edge per default.
@property
def type(self) -> str:
return self.__class__.__name__
@property @property
def url(self) -> urlutils.URL: def url(self) -> urlutils.URL:
"""The URL where to GET this event.""" """The URL where to GET this event."""

View file

@ -89,6 +89,10 @@ class Tag(Thing):
UniqueConstraint(secondary, org_id, name='one secondary tag per organization') UniqueConstraint(secondary, org_id, name='one secondary tag per organization')
) )
@property
def type(self) -> str:
return self.__class__.__name__
def __repr__(self) -> str: def __repr__(self) -> str:
return '<Tag {0.id} org:{0.org_id} device:{0.device_id}>'.format(self) return '<Tag {0.id} org:{0.org_id} device:{0.device_id}>'.format(self)