Example #1
0
 def list_storage_units(self, structural_unit_id=None, ids_only=False):
     """Maybe use for listing which storage_units are placed in
     a given structural unit.
     """
     if structural_unit_id:
         filters = [("structural_unit_id", "=", structural_unit_id)]
     else:
         filters = None
     resp = self._list("storage_unit", filters=filters, ids_only=ids_only)
     return response_handler(resp)
Example #2
0
    def get_structural_unit(self, uuid):
        """Get a structural unit (shelf, drawer, rack...)

        Args:
            uuid (str): uuid of the structural unit (required)
        
        Returns:
            The structural unit in a 'data'-key or an 'error'-key
        """
        resp = self._get("structural_unit", uuid)
        return response_handler(resp)
Example #3
0
    def list_orders(self, user_id=None, storage_unit_id=None, status=None):
        filters = []
        if user_id:
            filters.append(("user_id", "=", user_id))
        if storage_unit_id:
            filters.append(("storage_unit_id", "=", storage_unit_id))
        if status:
            filters.append(("status", "=", status))

        resp = self._list("order", filters=filters)
        return response_handler(resp)
Example #4
0
    def list_structural_units(self, path=[]):
        """List all structural units of a given client

        Args:
            path (list): list of uuid's of parent_units to filter by

        Returns:
            List of structural units in a 'data'-key
        """
        filters = [("path", "=", uuid) for uuid in path] if path else None
        resp = self._list("structural_unit", filters=filters)
        return response_handler(resp)
Example #5
0
    def insert_storage_unit(self, data, username):
        """Insert a storage_unit

        Args:
            data (dict):
                id (str): barcode, unit_id, eg. '91+000923-1'
                type (str): freeform type, eg. "box" or "protokol"
                current_location (str): archive, readingroom, staged...
                structural_unit_id (str): uuid of the closest structural_unit
            username (str): username

        Returns:
            dict with 'status', plus 'data' or 'error'
        """
        resp = self._insert("storage_unit", data, username=username)
        return response_handler(resp)
Example #6
0
    def insert_structural_unit(self, data, username):
        """Insert a structural unit

        Args:
            data (dict):
                id (str): barcode, label or other
                label (str): possible label, eg. "Reol 32"
                type (str): freeform type, eg. "shelf" or "drawer"
                location (str): hierarchical location-string, eg.
                    "Vester Alle 12/Magasin 001"
                path_label (str): hierarchical unit_path, eg.
                    "Reol 11/F*g 4"
                path (list): list of uuid's of all parent structural_units, eg.
                    ["339d0933-d5c6-4e48-9c3b-c8ff0faed824", "132d0933-d5c6-4e48-9c3b-c8ff0faed843"]
            username (str): the user doing the insertion
        Returns:   
            dict with 'status', plus 'data' or 'error'
        """
        # out = []
        # for i, s in enumerate(data.get('path').split('/')):
        #     if i == 0:
        #         out.append(s)
        #     else:
        #         out.append('/'.join([out[i-1], s]))
        # data['path'] = out

        # path_str = data.get('path')
        # path_list = []
        # start = 1
        # while start > 0:
        #     idx = path_str.find('/', start)
        #     if idx > -1:
        #         path_list.append(path_str[0:idx+1])
        #     elif start == 1:
        #         path_list.append(path_str)
        #     start = idx
        # data['path'] = [path_str]

        resp = self._insert("structural_unit", data, username=username)
        return response_handler(resp)
Example #7
0
 def delete_structural_unit(self, uuid, username):
     resp = self._delete("structural_unit", uuid, username=username)
     return response_handler(resp)
Example #8
0
 def update_structural_unit(self, uuid, data, username):
     resp = self._update("structural_unit", uuid, data, username=username)
     return response_handler(resp)
Example #9
0
 def get_order(self, uuid):
     """ """
     resp = self._get("order", uuid)
     return response_handler(resp)
Example #10
0
 def get_storage_unit(self, uuid):
     """Id is a uuid4-string
     """
     resp = self._get("storage_unit", uuid)
     return response_handler(resp)