1
0
forked from erp-dev/erp
This commit is contained in:
2026-07-05 13:53:17 +08:00
parent 4538e51ad5
commit e1cc6df122
24 changed files with 3030 additions and 495 deletions

26
api_core/permissions.py Normal file
View File

@@ -0,0 +1,26 @@
from rest_framework.permissions import BasePermission
class IsCoreSuperAdmin(BasePermission):
"""
Core APIs are reserved for Django superusers with a bound Employee merchant.
"""
message = "需要 superadmin 权限并绑定有效员工商户"
def has_permission(self, request, view):
user = request.user
if not user or not user.is_authenticated:
return False
if not user.is_superuser:
return False
employee = getattr(user, "employee", None)
if employee is None:
return False
if getattr(employee, "merchant_id", None) is None:
return False
request.core_merchant = employee.merchant
return True