projectal.entities.note API documentation

# projectal.entities.note

View Source

     1import copy
     2
     3import projectal
     4from projectal.entity import Entity
     5from projectal.linkers import *
     6
     7
     8class Note(Entity, TagLinker):
     9    """
    10    Implementation of the [Note](https://projectal.com/docs/latest/#tag/Note) API.
    11    """
    12
    13    _path = "note"
    14    _name = "note"
    15    _links = [TagLinker]  # TODO: user?
    16
    17    @classmethod
    18    def create(cls, holder, entity):
    19        """Create a Note
    20
    21        `holder`: `uuId` of the owner
    22
    23        `entity`: The fields of the entity to be created
    24        """
    25        holder_id = holder["uuId"] if isinstance(holder, dict) else holder
    26        params = "?holder=" + holder_id
    27        out = super().create(entity, params)
    28        # Notes use "empty linkers" during creation which don't go through our
    29        # usual linker pipeline where the internal list is updated. Do it here
    30        # manually.
    31        if isinstance(holder, Entity):
    32            nl = holder.get("noteList", [])
    33            nl.append(out)
    34            holder.set_readonly("noteList", copy.deepcopy(nl))
    35
    36        # Notes contain references to the objects that made and hold them. We don't get this
    37        # information from the creation api method, but we can insert them ourselves because
    38        # we know what they are.
    39        time = projectal.response_timestamp
    40
    41        def add_fields(obj):
    42            obj.set_readonly("created", time)
    43            obj.set_readonly("modified", time)
    44            obj.set_readonly("author", projectal.api_auth_details.get("name"))
    45            obj.set_readonly("authorRef", projectal.api_auth_details.get("uuId"))
    46            obj.set_readonly("holderRef", holder_id)
    47            tag = None
    48            if isinstance(holder, Entity):
    49                tag = holder._name.upper()
    50            obj.set_readonly("holderTag", tag)
    51
    52        if isinstance(out, dict):
    53            add_fields(out)
    54        if isinstance(out, list):
    55            for obj in out:
    56                add_fields(obj)
    57        return out

class Note(projectal.entity.Entity, projectal.linkers.TagLinker): View Source

     9class Note(Entity, TagLinker):
    10    """
    11    Implementation of the [Note](https://projectal.com/docs/latest/#tag/Note) API.
    12    """
    13
    14    _path = "note"
    15    _name = "note"
    16    _links = [TagLinker]  # TODO: user?
    17
    18    @classmethod
    19    def create(cls, holder, entity):
    20        """Create a Note
    21
    22        `holder`: `uuId` of the owner
    23
    24        `entity`: The fields of the entity to be created
    25        """
    26        holder_id = holder["uuId"] if isinstance(holder, dict) else holder
    27        params = "?holder=" + holder_id
    28        out = super().create(entity, params)
    29        # Notes use "empty linkers" during creation which don't go through our
    30        # usual linker pipeline where the internal list is updated. Do it here
    31        # manually.
    32        if isinstance(holder, Entity):
    33            nl = holder.get("noteList", [])
    34            nl.append(out)
    35            holder.set_readonly("noteList", copy.deepcopy(nl))
    36
    37        # Notes contain references to the objects that made and hold them. We don't get this
    38        # information from the creation api method, but we can insert them ourselves because
    39        # we know what they are.
    40        time = projectal.response_timestamp
    41
    42        def add_fields(obj):
    43            obj.set_readonly("created", time)
    44            obj.set_readonly("modified", time)
    45            obj.set_readonly("author", projectal.api_auth_details.get("name"))
    46            obj.set_readonly("authorRef", projectal.api_auth_details.get("uuId"))
    47            obj.set_readonly("holderRef", holder_id)
    48            tag = None
    49            if isinstance(holder, Entity):
    50                tag = holder._name.upper()
    51            obj.set_readonly("holderTag", tag)
    52
    53        if isinstance(out, dict):
    54            add_fields(out)
    55        if isinstance(out, list):
    56            for obj in out:
    57                add_fields(obj)
    58        return out

Implementation of the Note API.

@classmethod
def create(cls, holder, entity): View Source

    18    @classmethod
    19    def create(cls, holder, entity):
    20        """Create a Note
    21
    22        `holder`: `uuId` of the owner
    23
    24        `entity`: The fields of the entity to be created
    25        """
    26        holder_id = holder["uuId"] if isinstance(holder, dict) else holder
    27        params = "?holder=" + holder_id
    28        out = super().create(entity, params)
    29        # Notes use "empty linkers" during creation which don't go through our
    30        # usual linker pipeline where the internal list is updated. Do it here
    31        # manually.
    32        if isinstance(holder, Entity):
    33            nl = holder.get("noteList", [])
    34            nl.append(out)
    35            holder.set_readonly("noteList", copy.deepcopy(nl))
    36
    37        # Notes contain references to the objects that made and hold them. We don't get this
    38        # information from the creation api method, but we can insert them ourselves because
    39        # we know what they are.
    40        time = projectal.response_timestamp
    41
    42        def add_fields(obj):
    43            obj.set_readonly("created", time)
    44            obj.set_readonly("modified", time)
    45            obj.set_readonly("author", projectal.api_auth_details.get("name"))
    46            obj.set_readonly("authorRef", projectal.api_auth_details.get("uuId"))
    47            obj.set_readonly("holderRef", holder_id)
    48            tag = None
    49            if isinstance(holder, Entity):
    50                tag = holder._name.upper()
    51            obj.set_readonly("holderTag", tag)
    52
    53        if isinstance(out, dict):
    54            add_fields(out)
    55        if isinstance(out, list):
    56            for obj in out:
    57                add_fields(obj)
    58        return out

Create a Note

`holder`: `uuId` of the owner

`entity`: The fields of the entity to be created

##### Inherited Members

projectal.entity.Entity
  get
  update
  delete
  history
  save
  clone
  list
  match
  match_startswith
  match_endswith
  match_one
  match_startswith_one
  match_endswith_one
  search
  query
  profile_get
  profile_set
  changes
  set_readonly
  get_link_definitions
  entity_name
projectal.linkers.TagLinker
  link_tag
  unlink_tag