Skip to content

Organization Onboarding

zaven edited this page Oct 8, 2020 · 5 revisions

Creating entity records for new planters

Planter records are created in the planter table each time a new planter identifier (email or phone number) is used to log into the app. Every planter record needs to be linked to an existing or newly created entity record with person type. Often this needs to be done when planters belonging to a particular planting organizing join the platform, and need to be connected to their parent organization.

  1. Check in entity table for existing entity with matching identifier used by planter record
  2. If not matching entity exists, create new entity
  • Use type = 'p' for 'person'
  • copy first name, last name, and email or phone number from planter record
  1. Assign planter.person_id to the id of this entity

Connecting new person records to correct parent organization by inserting into entity_relationship table

The entity_relationship table stores organizational hierarchies used by various systems. We want to assign a given entity to the correct parent organization by creating a record in this table.

  1. Find id of child entity (for instance a planter)
  2. Find id of parent entity (this will be identified on a per planter basis by operations team or special data about the planter records)
  3. Insert new record into entity_relationship table
  • type will be indicated by operations team. type describes a group of hierarchical relationships and must be shared between all records describing a hierarchy to link the tiers in that particularly organizational structure.
  • role is the particular role of the child with respect to the parent for each entry in entity_relationship

Creating new admin_role descriptions when necessary

The admin_role table gives admin users different kinds of access to features and data in the admin panel. Features are controlled by named policies that are assigned to the role in the policies JSON field. This field also has an optional organization key that is used to restrict access to just data belonging to extended child relationships to the organization id. The organization id is the entity id (primary key of entity table) for the organization corresponding to the role.

The following JSON policy enables four data access methods and filters that access for only a single organization.

{
  "policies":[
      {"name":"list_tree","description":"Can view trees"},
      {"name":"approve_tree","description":"Can approve/reject trees"},
      {"name":"list_planter","description":"Can view planters"},
      {"name":"manage_planter","description":"Can modify planter information"}
  ],
  "organization":{"name":"$organization_entity_name","id":$organization_entity_id}}