コード例 #1
0
ファイル: async_handlers.py プロジェクト: solleks/commcare-hq
 def remove_object(self):
     if len(self.get_linked_objects()
            ) == 1 and self.identity_provider.is_editable:
         raise AsyncHandlerError(
             "At least one admin must be exempt from SSO in case of "
             "failure connecting with an Identity Provider.")
     existing_exempt_user = UserExemptFromSingleSignOn.objects.filter(
         username=self.username,
         email_domain__identity_provider__slug=self.idp_slug)
     if not existing_exempt_user.exists():
         raise AsyncHandlerError(
             f"The user {self.username} was never exempt from SSO with "
             f"this Identity Provider and the {self.email_domain} "
             f"Email Domain.")
     existing_exempt_user.delete()
コード例 #2
0
 def create_response(self):
     if SoftwareProduct.objects.filter(name=self.name).count() > 0:
         raise AsyncHandlerError(
             "Product '%s' already exists, and likely already "
             "in this Software Plan Version." % self.name)
     new_product, _ = SoftwareProduct.objects.get_or_create(
         name=self.name, product_type=self.rate_type)
     return fmt_product_rate_dict(new_product)
コード例 #3
0
ファイル: async_handlers.py プロジェクト: solleks/commcare-hq
 def add_object(self):
     if UserExemptFromSingleSignOn.objects.filter(
             username=self.username).exists():
         raise AsyncHandlerError(
             f"User {self.username} is already exempt from SSO", )
     auth_email_domain = AuthenticatedEmailDomain.objects.filter(
         identity_provider__slug=self.idp_slug,
         email_domain=self.email_domain)
     if not auth_email_domain.exists():
         raise AsyncHandlerError(
             f"Please ensure that '{self.email_domain}' is added as an "
             f"Authenticated Email Domain for this Identity Provider "
             f"before proceeding.")
     UserExemptFromSingleSignOn.objects.create(
         username=self.username,
         email_domain=auth_email_domain.first(),
     )
コード例 #4
0
 def create_response(self):
     if Feature.objects.filter(name=self.name).count() > 0:
         raise AsyncHandlerError("Feature '%s' already exists, and likely already "
                                 "in this Software Plan Version." % self.name)
     new_feature, _ = Feature.objects.get_or_create(
         name=self.name,
         feature_type=self.rate_type,
     )
     return fmt_feature_rate_dict(new_feature)
コード例 #5
0
ファイル: async_handlers.py プロジェクト: solleks/commcare-hq
 def remove_object(self):
     existing_email_domain = AuthenticatedEmailDomain.objects.filter(
         email_domain=self.email_domain,
         identity_provider=self.identity_provider,
     )
     if not existing_email_domain.exists():
         raise AsyncHandlerError(
             f"No email domain exists with the name {self.email_domain}.")
     existing_email_domain.delete()
コード例 #6
0
ファイル: async_handlers.py プロジェクト: solleks/commcare-hq
 def add_object(self):
     if AuthenticatedEmailDomain.objects.filter(
             email_domain=self.email_domain).exists():
         raise AsyncHandlerError(
             f"Email domain {self.email_domain} is already associated"
             f"with an identity provider.")
     AuthenticatedEmailDomain.objects.create(
         identity_provider=self.identity_provider,
         email_domain=self.email_domain,
     )
コード例 #7
0
 def apply_response(self):
     try:
         product = SoftwareProduct.objects.get(id=self.rate_id)
         return fmt_product_rate_dict(product)
     except SoftwareProduct.DoesNotExist:
         raise AsyncHandlerError("could not find an existing product")
コード例 #8
0
 def apply_response(self):
     try:
         feature = Feature.objects.get(id=self.rate_id)
         return fmt_feature_rate_dict(feature)
     except Feature.DoesNotExist:
         raise AsyncHandlerError("could not find an existing feature")
コード例 #9
0
 def create_response(self):
     if SoftwareProductRate.objects.filter(name=self.name).exists():
         raise AsyncHandlerError(
             "Product rate '%s' already exists, and likely already "
             "in this Software Plan Version." % self.name)
     return fmt_product_rate_dict(self.name)
コード例 #10
0
ファイル: async_handlers.py プロジェクト: solleks/commcare-hq
 def email_domain(self):
     email_domain = get_email_domain_from_username(self.username)
     if not email_domain:
         raise AsyncHandlerError("Please enter in a valid email.")
     return email_domain