def get_enterprise_region(self,
                           enterprise_id,
                           region_id,
                           check_status=True):
     region = region_repo.get_region_by_id(enterprise_id, region_id)
     if not region:
         return None
     return self.conver_region_info(region, check_status)
Example #2
0
 def initial(self, request, *args, **kwargs):
     super(BaseOpenAPIView, self).initial(request, *args, **kwargs)
     request.user.is_ = False
     if hasattr(request.user, "enterprise_id"):
         self.enterprise = enterprise_services.get_enterprise_by_id(request.user.enterprise_id)
     if not self.enterprise:
         raise ErrEnterpriseNotFound
     self.region_name = kwargs.get("region_name")
     if not self.region_name:
         self.region_name = kwargs.get("region_id")
     if self.region_name:
         self.region = region_services.get_enterprise_region_by_region_name(
             enterprise_id=self.enterprise.enterprise_id, region_name=self.region_name)
         if not self.region:
             self.region = region_repo.get_region_by_id(self.enterprise.enterprise_id, self.region_name)
     # Temporary logic
     if self.enterprise.ID == 1:
         request.user.is_administrator = True
     self.user = request.user
     self.get_perms()
     self.check_perms(request, *args, **kwargs)