🔍 Overview

The Employee model links two Users in a master → employee relationship.

It is used for:

  • Admin scoping: a master can view/manage the employee’s objects in most admin screens.
  • Notifications: Telegram notifications can be sent to masters of the affected user.

📑 Fields

FieldTypeDescription
masterForeign Key UserThe managing user (owner of the relationship).
employeeForeign Key UserThe subordinate user.

🧩 Methods

MethodDescription
get_employees(user, with_current=False)Returns a list of employees for the given master user. Optionally includes the master user itself.
get_masters(user, with_current=False)Returns a list of masters for the given employee user. Optionally includes the user itself.
get_master(user)Returns a single master for a user (first by PK) or None if not present.

💡 Meta

  • unique_together = ('master', 'employee') ensures there are no duplicate relationships.