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
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
try:
ev = self.last_event_of(EraseBasic)

View File

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

View File

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

View File

@ -75,6 +75,10 @@ class Lot(Thing):
super().__init__(id=uuid.uuid4(), name=name, closed=closed, description=description)
Path(self) # Lots have always one edge per default.
@property
def type(self) -> str:
return self.__class__.__name__
@property
def url(self) -> urlutils.URL:
"""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')
)
@property
def type(self) -> str:
return self.__class__.__name__
def __repr__(self) -> str:
return '<Tag {0.id} org:{0.org_id} device:{0.device_id}>'.format(self)