예제 #1
0
 def add_user_to_team(self, request, tenant, user_ids, identitys):
     enterprise = enterprise_services.get_enterprise_by_enterprise_id(
         enterprise_id=tenant.enterprise_id)
     if enterprise:
         user = request.user
         user_perms = team_services.get_user_perm_identitys_in_permtenant(
             user_id=user.user_id, tenant_name=tenant.tenant_name)
         user_ids = [int(r) for r in list(set(user_ids))]
         exist_team_user = PermRelTenant.objects.filter(
             tenant_id=tenant.ID, user_id__in=user_ids).all()
         remove_ids = list()
         exist = []
         for user in exist_team_user:
             exist.append(user.user_id)
         new_user_list = list()
         if ('admin' in user_perms) or ('owner' in user_perms):
             for user_id in user_ids:
                 if user_id not in exist:
                     for identity in identitys:
                         new_user_list.append(
                             PermRelTenant(user_id=user_id,
                                           tenant_id=tenant.pk,
                                           identity=identity,
                                           enterprise_id=enterprise.ID))
         if new_user_list:
             try:
                 PermRelTenant.objects.bulk_create(new_user_list)
             except Exception as e:
                 logging.exception(e)
             finally:
                 return remove_ids
     else:
         return None
예제 #2
0
 def change_tenant_identity(self, user_id, tenant_name, new_identitys):
     tenant = self.get_tenant_by_tenant_name(tenant_name=tenant_name)
     enterprise = enterprise_services.get_enterprise_by_enterprise_id(enterprise_id=tenant.enterprise_id)
     team_repo.delete_user_perms_in_permtenant(user_id=user_id, tenant_id=tenant.ID)
     new_perm_list = list()
     for identity in new_identitys:
         new_perm_list.append(
             PermRelTenant(user_id=user_id, tenant_id=tenant.pk, identity=identity, enterprise_id=enterprise.ID))
     if new_perm_list:
         try:
             PermRelTenant.objects.bulk_create(new_perm_list)
         except Exception as e:
             logging.exception(e)
예제 #3
0
 def add_user_tenant_perm(self, perm_info):
     perm_re_tenant = PermRelTenant(**perm_info)
     perm_re_tenant.save()
     return perm_re_tenant
예제 #4
0
 def init(self):
     self.sources = [
         Tenants(),
         TenantRegionInfo(),
         TenantRegionResource(),
         ServiceInfo(),
         TenantServiceInfo(),
         TenantServiceInfoDelete(),
         TenantServiceLog(),
         TenantServiceRelation(),
         TenantServiceEnv(),
         TenantServiceAuth(),
         TenantServiceExtendMethod(),
         ServiceDomain(),
         ServiceDomainCertificate(),
         PermRelService(),
         PermRelTenant(),
         PhoneCode(),
         TenantServiceL7Info(),
         TenantServiceEnvVar(),
         TenantServicesPort(),
         TenantServiceMountRelation(),
         TenantServiceVolume(),
         TenantServiceConfigurationFile(),
         ServiceGroup(),
         ServiceGroupRelation(),
         ImageServiceRelation(),
         ComposeServiceRelation(),
         ServiceRule(),
         ServiceRuleHistory(),
         ServiceCreateStep(),
         ServiceProbe(),
         ConsoleConfig(),
         TenantEnterprise(),
         TenantEnterpriseToken(),
         TenantServiceGroup(),
         ServiceTcpDomain(),
         ThirdPartyServiceEndpoints(),
         ServiceWebhooks(),
         GatewayCustomConfiguration(),
         ConsoleSysConfig(),
         RainbondCenterApp(),
         RainbondCenterAppInherit(),
         RainbondCenterPlugin(),
         ServiceShareRecord(),
         EnterpriseUserPerm(),
         TenantUserRole(),
         TenantUserPermission(),
         TenantUserRolePermission(),
         PermGroup(),
         ServiceRelPerms(),
         AppExportRecord(),
         UserMessage(),
         AppImportRecord(),
         GroupAppBackupRecord(),
         GroupAppMigrateRecord(),
         GroupAppBackupImportRecord(),
         Applicants(),
         DeployRelation(),
         ServiceBuildSource(),
         TenantServiceBackup(),
         AppUpgradeRecord(),
         ServiceUpgradeRecord(),
         RegionConfig(),
         CloundBangImages(),
         Announcement(),
     ]