summaryrefslogtreecommitdiff
path: root/opendc/models_old/allowed_object.py
blob: bcadf02590ef5df3c158a971bfa763ea9e4ee29a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from opendc.models_old.model import Model


class AllowedObject(Model):
    JSON_TO_PYTHON_DICT = {'AllowedObject': {'roomType': 'room_type', 'objectType': 'object_type'}}

    COLLECTION_NAME = 'allowed_objects'
    COLUMNS = ['room_type', 'object_type']
    COLUMNS_PRIMARY_KEY = ['room_type', 'object_type']

    def google_id_has_at_least(self, google_id, authorization_level):
        """Return True if the user has at least the given auth level over this AllowedObject."""

        if authorization_level in ['EDIT', 'OWN']:
            return False

        return True

    def to_JSON(self):
        """Return a JSON representation of this AllowedObject."""

        return self.object_type