diff --git a/ereuse_devicehub/resources/tag/model.py b/ereuse_devicehub/resources/tag/model.py index c52cdf8a..92c8d5d4 100644 --- a/ereuse_devicehub/resources/tag/model.py +++ b/ereuse_devicehub/resources/tag/model.py @@ -15,7 +15,7 @@ from ereuse_devicehub.resources.agent.models import Organization from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.models import Thing from ereuse_devicehub.resources.user.models import User -from ereuse_devicehub.resources.utils import hascode +from ereuse_devicehub.resources.utils import hashcode class Tags(Set['Tag']): @@ -134,7 +134,7 @@ class Tag(Thing): @property def code(self) -> str: - return hascode.encode(self.internal_id) + return hashcode.encode(self.internal_id) def delete(self): """Deletes the tag. diff --git a/ereuse_devicehub/resources/tag/view.py b/ereuse_devicehub/resources/tag/view.py index 5416fd2a..6d61304e 100644 --- a/ereuse_devicehub/resources/tag/view.py +++ b/ereuse_devicehub/resources/tag/view.py @@ -6,7 +6,7 @@ from teal.resource import View, url_for_resource from ereuse_devicehub import auth from ereuse_devicehub.db import db from ereuse_devicehub.query import things_response -from ereuse_devicehub.resources.utils import hascode +from ereuse_devicehub.resources.utils import hashcode from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.tag import Tag @@ -14,7 +14,7 @@ from ereuse_devicehub.resources.tag import Tag class TagView(View): def one(self, code): """Gets the device from the named tag, /tags/namedtag.""" - internal_id = hascode.decode(code.upper()) or -1 + internal_id = hashcode.decode(code.upper()) or -1 tag = Tag.query.filter_by(internal_id=internal_id).one() # type: Tag if not tag.device: raise TagNotLinked(tag.id) diff --git a/ereuse_devicehub/resources/utils.py b/ereuse_devicehub/resources/utils.py index 1ac37b51..3d02d610 100644 --- a/ereuse_devicehub/resources/utils.py +++ b/ereuse_devicehub/resources/utils.py @@ -3,7 +3,4 @@ from decouple import config ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' SECRET = config('TAG_HASH', '') -hascode = Hashids(SECRET, min_length=5, alphabet=ALPHABET) - -def hashids(id): - return hascode.encode(id) +hashcode = Hashids(SECRET, min_length=5, alphabet=ALPHABET)