NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

corporations.py (2364B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\common\lib\corporations.py
      2 from ccp_exceptions import UserError
      3 import appConst as const
      4 
      5 def IsAccountantOrJuniorAccountantRole(role):
      6     return role & (const.corpRoleAccountant | const.corpRoleJuniorAccountant)
      7 
      8 
      9 def ValidateAccountantRole(role):
     10     if not role & const.corpRoleAccountant:
     11         raise UserError('CrpAccessDenied', {'reason': (const.UE_LOC, 'UI/Corporations/AccessRestrictions/NotFullAccountant')})
     12 
     13 
     14 def ValidateAccountantOrJuniorAccountantRole(role):
     15     if not IsAccountantOrJuniorAccountantRole(role):
     16         raise UserError('CrpAccessDenied', {'reason': (const.UE_LOC, 'UI/Corporations/AccessRestrictions/NotAccountant')})
     17 
     18 
     19 def ValidateAccountantOrTraderRole(role):
     20     if not role & (const.corpRoleAccountant | const.corpRoleJuniorAccountant):
     21         raise UserError('CrpAccessDenied', {'reason': (const.UE_LOC, 'UI/Corporations/AccessRestrictions/NoAccountantOrTrader')})
     22 
     23 
     24 _CORP_WALLET_DIVISION_ROLES = {1000: const.corpRoleAccountCanTake1,
     25  1001: const.corpRoleAccountCanTake2,
     26  1002: const.corpRoleAccountCanTake3,
     27  1003: const.corpRoleAccountCanTake4,
     28  1004: const.corpRoleAccountCanTake5,
     29  1005: const.corpRoleAccountCanTake6,
     30  1006: const.corpRoleAccountCanTake7,
     31  10000: const.corpRoleAccountant}
     32 
     33 def ValidateCorpWalletDivisionAccess(role, key):
     34     if key is None:
     35         raise UserError('CrpAccessDenied', {'reason': (const.UE_LOC, 'UI/Corporations/AccessRestrictions/NoAccessToWalletDivision')})
     36     if _CORP_WALLET_DIVISION_ROLES[key] & role == 0:
     37         raise UserError('CrpAccessDenied', {'reason': (const.UE_LOC, 'UI/Corporations/AccessRestrictions/NoAccessToWalletDivision')})
     38 
     39 
     40 def ValidateCorpWalletDivisionReadAccess(role, key):
     41     if IsAccountantOrJuniorAccountantRole(role):
     42         return
     43     if key is None:
     44         raise UserError('CrpAccessDenied', {'reason': (const.UE_LOC, 'UI/Corporations/AccessRestrictions/NoAccessToWalletDivision')})
     45     if _CORP_WALLET_DIVISION_ROLES[key] & role == 0:
     46         raise UserError('CrpAccessDenied', {'reason': (const.UE_LOC, 'UI/Corporations/AccessRestrictions/NoAccessToWalletDivision')})
     47 
     48 
     49 def ValidateDirectorRole(role):
     50     if not role & const.corpRoleDirector:
     51         raise UserError('CrpAccessDenied', {'reason': (const.UE_LOC, 'UI/Corporations/AccessRestrictions/NotDirector')})