old_contents: import redis
  import json
  import functools
  
  from enum import Enum
  
  
  
  from typing import Dict
  
  
  @functools.total_ordering
  class OrderedEnum(Enum):
      @classmethod
      @functools.lru_cache(None)
      def _member_list(cls):
          return list(cls)
  
      def __lt__(self, other):
          if self.__class__ is other.__class__:
              member_list = self.__class__._member_list()
              return member_list.index(self) < member_list.index(other)
          return NotImplemented
  
  
  
  
  
  def get_user_membership(conn: redis.Redis, user_id: str,
                          group_id: str) -> Dict:
      """Return a dictionary that indicates whether the `user_id` is a
      member or admin of `group_id`.
  
      Args:
        - conn: a Redis Connection with the responses decoded.
        - user_id: a user's unique id
          e.g. '8ad942fe-490d-453e-bd37-56f252e41603'
        - group_id: a group's unique id
        e.g. '7fa95d07-0e2d-4bc5-b47c-448fdc1260b2'
  
      Returns:
        A dict indicating whether the user is an admin or a member of
        the group: {"member": True, "admin": False}
  
      """
      results = {"member": False, "admin": False}
      for key, value in conn.hgetall('groups').items():
          if key == group_id:
              group_info = json.loads(value)
              if user_id in group_info.get("admins"):
                  results["admin"] = True
              if user_id in group_info.get("members"):
                  results["member"] = True
              break
      return results
      admin_status = check_owner_or_admin(resource_id=resource_id)
  
new_contents: import redis
  import json
  import functools
  
  from enum import Enum, unique
  
  
  
  from typing import Dict
  
  
  @functools.total_ordering
  class OrderedEnum(Enum):
      @classmethod
      @functools.lru_cache(None)
      def _member_list(cls):
          return list(cls)
  
      def __lt__(self, other):
          if self.__class__ is other.__class__:
              member_list = self.__class__._member_list()
              return member_list.index(self) < member_list.index(other)
          return NotImplemented
  
  
  @unique
  class DataRole(OrderedEnum):
      NO_ACCESS = "no-access"
      VIEW = "view"
      EDIT = "edit"
  
  
  @unique
  class AdminRole(OrderedEnum):
      NOT_ADMIN = "not-admin"
      EDIT_ACCESS = "edit-access"
      EDIT_ADMINS = "edit-admins"
  
  def get_user_membership(conn: redis.Redis, user_id: str,
                          group_id: str) -> Dict:
      """Return a dictionary that indicates whether the `user_id` is a
      member or admin of `group_id`.
  
      Args:
        - conn: a Redis Connection with the responses decoded.
        - user_id: a user's unique id
          e.g. '8ad942fe-490d-453e-bd37-56f252e41603'
        - group_id: a group's unique id
        e.g. '7fa95d07-0e2d-4bc5-b47c-448fdc1260b2'
  
      Returns:
        A dict indicating whether the user is an admin or a member of
        the group: {"member": True, "admin": False}
  
      """
      results = {"member": False, "admin": False}
      for key, value in conn.hgetall('groups').items():
          if key == group_id:
              group_info = json.loads(value)
              if user_id in group_info.get("admins"):
                  results["admin"] = True
              if user_id in group_info.get("members"):
                  results["member"] = True
              break
      return results
      admin_status = check_owner_or_admin(resource_id=resource_id)
  
subject: Add immutable data structures for admin and data access roles