def create(self, request): """Create a new user.""" try: validator = Validator(email=unicode, display_name=unicode, password=unicode, _optional=('display_name', 'password')) arguments = validator(request) except ValueError as error: return http.bad_request([], str(error)) # We can't pass the 'password' argument to the user creation method, # so strip that out (if it exists), then create the user, adding the # password after the fact if successful. password = arguments.pop('password', None) try: user = getUtility(IUserManager).create_user(**arguments) except ExistingAddressError as error: return http.bad_request([], b'Address already exists {0}'.format( error.email)) if password is None: # This will have to be reset since it cannot be retrieved. password = generate(int(config.passwords.password_length)) scheme = lookup(config.passwords.password_scheme.upper()) user.password = make_secret(password, scheme) location = path_to('users/{0}'.format(user.user_id.int)) return http.created(location, [], None)
def join(self, fqdn_listname, subscriber, display_name=None, delivery_mode=DeliveryMode.regular, role=MemberRole.member): """See `ISubscriptionService`.""" mlist = getUtility(IListManager).get(fqdn_listname) if mlist is None: raise NoSuchListError(fqdn_listname) # Is the subscriber an email address or user id? if isinstance(subscriber, basestring): # It's an email address, so we'll want a real name. Make sure # it's a valid email address, and let InvalidEmailAddressError # propagate up. getUtility(IEmailValidator).validate(subscriber) if display_name is None: display_name, at, domain = subscriber.partition('@') # Because we want to keep the REST API simple, there is no # password or language given to us. We'll use the system's # default language for the user's default language. We'll set the # password to a system default. This will have to get reset since # it can't be retrieved. Note that none of these are used unless # the address is completely new to us. password = generate(int(config.passwords.password_length)) return add_member(mlist, subscriber, display_name, password, delivery_mode, system_preferences.preferred_language, role) else: # We have to assume it's a UUID. assert isinstance(subscriber, UUID), 'Not a UUID' user = getUtility(IUserManager).get_user_by_id(subscriber) if user is None: raise MissingUserError(subscriber) return mlist.subscribe(user, role)
def add_members(self, mlist, args): """Add the members in a file to a mailing list. :param mlist: The mailing list to operate on. :type mlist: `IMailingList` :param args: The command line arguments. :type args: `argparse.Namespace` """ if args.input_filename == '-': fp = sys.stdin else: fp = codecs.open(args.input_filename, 'r', 'utf-8') try: for line in fp: # Ignore blank lines and lines that start with a '#'. if line.startswith('#') or len(line.strip()) == 0: continue # Parse the line and ensure that the values are unicodes. display_name, email = parseaddr(line) display_name = display_name.decode(fp.encoding) email = email.decode(fp.encoding) # Give the user a default, user-friendly password. password = generate(int(config.passwords.password_length)) try: add_member(mlist, email, display_name, password, DeliveryMode.regular, mlist.preferred_language.code) except AlreadySubscribedError: # It's okay if the address is already subscribed, just # print a warning and continue. print('Already subscribed (skipping):', email, display_name) finally: if fp is not sys.stdin: fp.close()
def authenticate(self, credential=None): """Authenticate against a Facebook access token.""" if not credential.invalid: http = httplib2.Http() http = credential.authorize(http) response_headers, response_body = http.request("https://www.googleapis.com/oauth2/v1/userinfo?alt=json") response_body = json.loads(response_body) if not response_headers["status"] == "200": raise Exception(_("An error occurred with the Request to Google")) if not response_body["verified_email"]: raise Exception(_("Email address is not verified")) try: google_plus_user = models.GooglePlusUser.objects.get(google_user_id=response_body["id"]) google_plus_user.update_access_token( credential.access_token, credential.token_expiry, credential.refresh_token, credential.id_token, credential.token_response, ) user = google_plus_user.user except models.GooglePlusUser.DoesNotExist: # Create a new user. user, created = get_user_model().objects.get_or_create( email=response_body["email"], defaults={ "username": response_body["email"], "is_regular_user": False, "is_active": True, "first_name": response_body["given_name"], "last_name": response_body["family_name"], }, ) if created: user.set_password(generate(10)) user.save() google_plus_user = models.GooglePlusUser(user=user, google_user_id=response_body["id"]) google_plus_user.update_access_token( credential.access_token, credential.token_expiry, credential.refresh_token, credential.id_token, credential.token_response, ) return user return None
def authenticate(self, twitter_oauth_token=None, twitter_oauth_token_secret=None): """Ensure authentication with Twitter's access tokens.""" twitter = Twython( settings.TWITTER_APP_KEY, settings.TWITTER_APP_SECRET, twitter_oauth_token, twitter_oauth_token_secret ) verification_details = twitter.verify_credentials() if verification_details: try: twitter_user = models.TwitterUser.objects.get( screen_name=verification_details['screen_name'] ) twitter_user.update_oauth_token( twitter_oauth_token, twitter_oauth_token_secret ) user = twitter_user.user except models.TwitterUser.DoesNotExist: # Create a new user. first_name = verification_details['name'].split(' ')[0] last_name = ' '.join( verification_details['name'].split(' ')[1:] ) user = get_user_model().objects.create( username=verification_details['screen_name'], is_regular_user=False, is_active=True, first_name=first_name, last_name=last_name, city=verification_details['location'] \ if 'location' in verification_details else None ) user.set_password(generate(10)) user.save() twitter_user = models.TwitterUser( user=user, screen_name=verification_details['screen_name'] ) twitter_user.update_oauth_token( twitter_oauth_token, twitter_oauth_token_secret ) return user return None
def save(self, *args, **kwargs): if not self.id: automatic_emails.email_product_evaluation_initial.delay(self.user_id) if self.status == constants.PRODUCT_EVALUATION_STATUS_APPROVED: user_actions.action_product_evaluation_request_approved(self.user) automatic_emails.email_product_evaluation_started.delay(self.user_id) SFTPUser.objects.create(user=self.user, username=('%s%s' % (self.user.first_name, self.user.last_name)).lower(), password=generate(10)) if self.log_file_sample: automatic_emails.email_static_page_uploaded.delay(self.user_id, self.log_file_sample) self.user.profile.role = constants.ROLE_CHOICE_PRODUCT_OWNER self.user.profile.save() return super(ProductEvaluation, self).save(*args, **kwargs)
def authenticate(self, access_token=None, access_token_expiry_seconds=None): """ If the users access token is valid, update their token in the database. """ token_valid, user_id = utils.validate_access_token(access_token) if token_valid: try: facebook_user = models.FacebookUser.objects.get(facebook_user_id=str(user_id)) facebook_user.update_access_token(access_token, access_token_expiry_seconds) user = facebook_user.user except models.FacebookUser.DoesNotExist: # Create a new user. api = facebook.GraphAPI(access_token) api_data = api.get_object("me") user, created = get_user_model().objects.get_or_create( email=api_data["email"], defaults={ "username": api_data["username"], "is_regular_user": False, "is_active": True, "first_name": api_data["first_name"], "last_name": api_data["last_name"], "city": api_data["location"]["name"] if "location" in api_data else None, }, ) if created: user.set_password(generate(10)) user.save() facebook_user = models.FacebookUser(user=user, facebook_user_id=str(user_id)) facebook_user.update_access_token(access_token, access_token_expiry_seconds) return user return None
def save(self, *args, **kwargs): if not self.id: automatic_emails.email_product_evaluation_initial.delay( self.user_id) if self.status == constants.PRODUCT_EVALUATION_STATUS_APPROVED: user_actions.action_product_evaluation_request_approved(self.user) automatic_emails.email_product_evaluation_started.delay( self.user_id) SFTPUser.objects.create( user=self.user, username=('%s%s' % (self.user.first_name, self.user.last_name)).lower(), password=generate(10)) if self.log_file_sample: automatic_emails.email_static_page_uploaded.delay( self.user_id, self.log_file_sample) self.user.profile.role = constants.ROLE_CHOICE_PRODUCT_OWNER self.user.profile.save() return super(ProductEvaluation, self).save(*args, **kwargs)
def save(self, request, *args, **kwargs): update_count = 0 create_count = 0 for obj in self.cleaned_data["source"]: created = False if obj["email"]: try: user = models.Profile.objects.get(username=obj["email"]) except models.Profile.DoesNotExist: user = None if user is None and self.cleaned_data["create"]: user = models.Profile.objects.create( username=obj["email"], email=obj["email"], email_notifications=False ) password = generate(10) user.set_password(password) created = True create_count += 1 if created or self.cleaned_data["update"]: # Set simple fields. if obj["name"]: user.first_name = obj["name"][:30] user.save() partnership, created = models.Partnership.objects.get_or_create( user=user.user, type=constants.PARTNER_TYPE_TECHNOLOGY, defaults={"status": constants.PARTNERSHIP_REQUEST_STATUS_APPROVED}, ) if not created: partnership.status = constants.PARTNERSHIP_REQUEST_STATUS_APPROVED partnership.save() self.cloud_service_provider, _ = models.CloudServiceProvider.objects.get_or_create( partnership=partnership ) if obj["url"]: self.cloud_service_provider.url = obj["url"] if obj["category"]: self.cloud_service_provider.category = unobase_utils.get_choice_value( obj["category"], constants.CSP_CATEGORY_CHOICES ) if obj["csp_id"]: self.cloud_service_provider.csp_id = int(obj["csp_id"]) self.cloud_service_provider.save() if obj["data_sharing_support"]: self.create_csp_attribute(1, obj["data_sharing_support"]) if obj["data_capacity"]: self.create_csp_attribute(2, obj["data_capacity"]) if obj["data_encryption_at_rest"]: self.create_csp_attribute(3, obj["data_encryption_at_rest"]) if obj["data_encryption_in_transit"]: self.create_csp_attribute(4, obj["data_encryption_in_transit"]) if obj["data_multi_tenancy"]: self.create_csp_attribute(5, obj["data_multi_tenancy"]) if obj["data_mingling"]: self.create_csp_attribute(6, obj["data_mingling"]) if obj["data_retention_on_termination"]: self.create_csp_attribute(7, obj["data_retention_on_termination"]) if obj["auto_sync_data"]: self.create_csp_attribute(8, obj["auto_sync_data"]) if obj["encryption_strength"]: self.create_csp_attribute(9, obj["encryption_strength"]) if obj["password_policy_strength"]: self.create_csp_attribute(10, obj["password_policy_strength"]) if obj["anonymous_use"]: self.create_csp_attribute(11, obj["anonymous_use"]) if obj["multi_factor_authentication"]: self.create_csp_attribute(12, obj["multi_factor_authentication"]) if obj["jail_broken_app"]: self.create_csp_attribute(13, obj["jail_broken_app"]) if obj["mobile_app_support"]: self.create_csp_attribute(14, obj["mobile_app_support"]) if obj["identity_federation_method"]: self.create_csp_attribute(15, obj["identity_federation_method"]) if obj["enterprise_identity"]: self.create_csp_attribute(16, obj["enterprise_identity"]) if obj["sso"]: self.create_csp_attribute(17, obj["sso"]) if obj["recent_vulnerabilities"]: self.create_csp_attribute(18, obj["recent_vulnerabilities"]) if obj["csrf"]: self.create_csp_attribute(19, obj["csrf"]) if obj["sqli"]: self.create_csp_attribute(20, obj["sqli"]) if obj["xss"]: self.create_csp_attribute(21, obj["xss"]) if obj["pentesting"]: self.create_csp_attribute(22, obj["pentesting"]) if obj["api_supported"]: self.create_csp_attribute(23, obj["api_supported"]) if obj["api_url"]: self.create_csp_attribute(24, obj["api_url"]) if obj["ip_filtering_support"]: self.create_csp_attribute(25, obj["ip_filtering_support"]) if obj["malware_site_use"]: self.create_csp_attribute(26, obj["malware_site_use"]) if obj["api_authentication"]: self.create_csp_attribute(27, obj["api_authentication"]) if obj["service_hosting_locations"]: self.create_csp_attribute(28, obj["service_hosting_locations"]) if obj["compliance_certifications"]: self.create_csp_attribute(29, obj["compliance_certifications"]) if obj["service_address"]: self.create_csp_attribute(30, obj["service_address"]) if obj["pricing_model"]: self.create_csp_attribute(31, obj["pricing_model"]) if obj["price"]: self.create_csp_attribute(32, obj["price"]) if obj["infrastructure_status_reporting"]: self.create_csp_attribute(33, obj["infrastructure_status_reporting"]) if obj["business_hq"]: self.create_csp_attribute(34, obj["business_hq"]) if obj["admin_audit_logging"]: self.create_csp_attribute(35, obj["admin_audit_logging"]) if obj["user_activity_logging"]: self.create_csp_attribute(36, obj["user_activity_logging"]) if obj["data_access_logging"]: self.create_csp_attribute(37, obj["data_access_logging"]) if obj["terms_of_use"]: self.create_csp_attribute(38, obj["terms_of_use"]) if obj["data_residency"]: self.create_csp_attribute(39, obj["data_residency"]) if obj["service_not_in_itar_list"]: self.create_csp_attribute(40, obj["service_not_in_itar_list"]) if obj["account_termination"]: self.create_csp_attribute(41, obj["account_termination"]) if obj["ip_ownership"]: self.create_csp_attribute(42, obj["ip_ownership"]) if obj["privacy_policy"]: self.create_csp_attribute(43, obj["privacy_policy"]) if obj["impacted_by_compliance"]: self.create_csp_attribute(44, obj["impacted_by_compliance"]) if obj["dispute_resolution"]: self.create_csp_attribute(45, obj["dispute_resolution"]) if obj["jurisdictional_location"]: self.create_csp_attribute(46, obj["jurisdictional_location"]) if obj["indemnity"]: self.create_csp_attribute(47, obj["indemnity"]) if obj["copyright_controls"]: self.create_csp_attribute(48, obj["copyright_controls"]) if obj["statute_of_limitations"]: self.create_csp_attribute(49, obj["statute_of_limitations"]) if not created: update_count += 1 if created: if self.cleaned_data["email"] and obj["email"]: automatic_emails.email_existing_csp_activation.delay(user.user.id) messages.success(request, "Thank you! Your import completed successfully.")
def save(self, request, *args, **kwargs): update_count = 0 create_count = 0 for obj in self.cleaned_data["source"]: created = False try: user = models.Profile.objects.get(username=obj["email"]) except models.Profile.DoesNotExist: user = None if user is None and self.cleaned_data["create"]: user = models.Profile.objects.create(username=obj["email"], email=obj["email"]) password = generate(10) user.set_password(password) created = True create_count += 1 if created or self.cleaned_data["update"]: # Set simple fields. if obj["address"]: user.address = obj["address"] if obj["city"]: user.city = obj["city"] if obj["first_name"]: user.first_name = obj["first_name"] if obj["job_title"]: user.job_title = obj["job_title"] if obj["last_name"]: user.last_name = obj["last_name"] if obj["mobile_number"]: user.mobile_number = obj["mobile_number"] if obj["phone_number"]: user.phone_number = obj["phone_number"] if obj["timezone"]: user.timezone = obj["timezone"] if obj["zip_postal_code"]: user.zip_postal_code = obj["zip_postal_code"] # Ensure user is published/not 'deleted'. # Set complex fields. if obj["country"]: user.country = models.Country.objects.get_or_create(name=obj["country"])[0] user.save() if obj["evaluator"]: product_evaluation, created = models.ProductEvaluation.objects.get_or_create( user=user.user, defaults={"status": constants.PRODUCT_EVALUATION_STATUS_APPROVED} ) if not created: product_evaluation.status = constants.PRODUCT_EVALUATION_STATUS_APPROVED product_evaluation.save() if obj["channel_partner"]: partnership, created = models.Partnership.objects.get_or_create( user=user.user, type=constants.PARTNER_TYPE_CHANNEL, defaults={"status": constants.PARTNERSHIP_REQUEST_STATUS_APPROVED}, ) if not created: partnership.status = constants.PARTNERSHIP_REQUEST_STATUS_APPROVED partnership.save() if object["distributor"]: distributor, _ = models.Distributor.objects.get_or_create(partnership=partnership) elif object["reseller"]: reseller, _ = models.Reseller.objects.get_or_create(partnership=partnership) elif obj["technical_partner"]: partnership, created = models.Partnership.objects.get_or_create( user=user.user, type=constants.PARTNER_TYPE_TECHNOLOGY, defaults={"status": constants.PARTNERSHIP_REQUEST_STATUS_APPROVED}, ) if not created: partnership.status = constants.PARTNERSHIP_REQUEST_STATUS_APPROVED partnership.save() if obj["cloud_service_provider"]: cloud_service_provider, _ = models.CloudServiceProvider.objects.get_or_create( partnership=partnership ) if not created: update_count += 1 if created: if self.cleaned_data["email"] and obj["email"]: automatic_emails.email_successful_account_activation.delay(user.user.id) messages.success(request, "Thank you! Your import completed successfully.")
def save(self, request, *args, **kwargs): update_count = 0 create_count = 0 for obj in self.cleaned_data['source']: created = False if obj['email']: try: user = models.Profile.objects.get(username=obj['email']) except models.Profile.DoesNotExist: user = None if user is None and self.cleaned_data['create']: user = models.Profile.objects.create( username=obj['email'], email=obj['email'], email_notifications=False ) password = generate(10) user.set_password(password) created = True create_count += 1 if created or self.cleaned_data['update']: # Set simple fields. if obj['name']: user.first_name = obj['name'][:30] user.save() partnership, created = models.Partnership.objects.get_or_create(user=user.user, type=constants.PARTNER_TYPE_TECHNOLOGY, defaults={'status': constants.PARTNERSHIP_REQUEST_STATUS_APPROVED}) if not created: partnership.status = constants.PARTNERSHIP_REQUEST_STATUS_APPROVED partnership.save() self.cloud_service_provider, _ = models.CloudServiceProvider.objects.get_or_create(partnership=partnership) if obj['url']: self.cloud_service_provider.url = obj['url'] if obj['category']: self.cloud_service_provider.category = unobase_utils.get_choice_value(obj['category'], constants.CSP_CATEGORY_CHOICES) if obj['csp_id']: self.cloud_service_provider.csp_id = int(obj['csp_id']) self.cloud_service_provider.save() if obj['data_sharing_support']: self.create_csp_attribute(1, obj['data_sharing_support']) if obj['data_capacity']: self.create_csp_attribute(2, obj['data_capacity']) if obj['data_encryption_at_rest']: self.create_csp_attribute(3, obj['data_encryption_at_rest']) if obj['data_encryption_in_transit']: self.create_csp_attribute(4, obj['data_encryption_in_transit']) if obj['data_multi_tenancy']: self.create_csp_attribute(5, obj['data_multi_tenancy']) if obj['data_mingling']: self.create_csp_attribute(6, obj['data_mingling']) if obj['data_retention_on_termination']: self.create_csp_attribute(7, obj['data_retention_on_termination']) if obj['auto_sync_data']: self.create_csp_attribute(8, obj['auto_sync_data']) if obj['encryption_strength']: self.create_csp_attribute(9, obj['encryption_strength']) if obj['password_policy_strength']: self.create_csp_attribute(10, obj['password_policy_strength']) if obj['anonymous_use']: self.create_csp_attribute(11, obj['anonymous_use']) if obj['multi_factor_authentication']: self.create_csp_attribute(12, obj['multi_factor_authentication']) if obj['jail_broken_app']: self.create_csp_attribute(13, obj['jail_broken_app']) if obj['mobile_app_support']: self.create_csp_attribute(14, obj['mobile_app_support']) if obj['identity_federation_method']: self.create_csp_attribute(15, obj['identity_federation_method']) if obj['enterprise_identity']: self.create_csp_attribute(16, obj['enterprise_identity']) if obj['sso']: self.create_csp_attribute(17, obj['sso']) if obj['recent_vulnerabilities']: self.create_csp_attribute(18, obj['recent_vulnerabilities']) if obj['csrf']: self.create_csp_attribute(19, obj['csrf']) if obj['sqli']: self.create_csp_attribute(20, obj['sqli']) if obj['xss']: self.create_csp_attribute(21, obj['xss']) if obj['pentesting']: self.create_csp_attribute(22, obj['pentesting']) if obj['api_supported']: self.create_csp_attribute(23, obj['api_supported']) if obj['api_url']: self.create_csp_attribute(24, obj['api_url']) if obj['ip_filtering_support']: self.create_csp_attribute(25, obj['ip_filtering_support']) if obj['malware_site_use']: self.create_csp_attribute(26, obj['malware_site_use']) if obj['api_authentication']: self.create_csp_attribute(27, obj['api_authentication']) if obj['service_hosting_locations']: self.create_csp_attribute(28, obj['service_hosting_locations']) if obj['compliance_certifications']: self.create_csp_attribute(29, obj['compliance_certifications']) if obj['service_address']: self.create_csp_attribute(30, obj['service_address']) if obj['pricing_model']: self.create_csp_attribute(31, obj['pricing_model']) if obj['price']: self.create_csp_attribute(32, obj['price']) if obj['infrastructure_status_reporting']: self.create_csp_attribute(33, obj['infrastructure_status_reporting']) if obj['business_hq']: self.create_csp_attribute(34, obj['business_hq']) if obj['admin_audit_logging']: self.create_csp_attribute(35, obj['admin_audit_logging']) if obj['user_activity_logging']: self.create_csp_attribute(36, obj['user_activity_logging']) if obj['data_access_logging']: self.create_csp_attribute(37, obj['data_access_logging']) if obj['terms_of_use']: self.create_csp_attribute(38, obj['terms_of_use']) if obj['data_residency']: self.create_csp_attribute(39, obj['data_residency']) if obj['service_not_in_itar_list']: self.create_csp_attribute(40, obj['service_not_in_itar_list']) if obj['account_termination']: self.create_csp_attribute(41, obj['account_termination']) if obj['ip_ownership']: self.create_csp_attribute(42, obj['ip_ownership']) if obj['privacy_policy']: self.create_csp_attribute(43, obj['privacy_policy']) if obj['impacted_by_compliance']: self.create_csp_attribute(44, obj['impacted_by_compliance']) if obj['dispute_resolution']: self.create_csp_attribute(45, obj['dispute_resolution']) if obj['jurisdictional_location']: self.create_csp_attribute(46, obj['jurisdictional_location']) if obj['indemnity']: self.create_csp_attribute(47, obj['indemnity']) if obj['copyright_controls']: self.create_csp_attribute(48, obj['copyright_controls']) if obj['statute_of_limitations']: self.create_csp_attribute(49, obj['statute_of_limitations']) if not created: update_count += 1 if created: if self.cleaned_data['email'] and obj['email']: automatic_emails.email_existing_csp_activation.delay(user.user.id) messages.success( request, "Thank you! Your import completed successfully." )
def save(self, request, *args, **kwargs): update_count = 0 create_count = 0 for obj in self.cleaned_data['source']: created = False try: user = models.Profile.objects.get(username=obj['email']) except models.Profile.DoesNotExist: user = None if user is None and self.cleaned_data['create']: user = models.Profile.objects.create( username=obj['email'], email=obj['email'] ) password = generate(10) user.set_password(password) created = True create_count += 1 if created or self.cleaned_data['update']: # Set simple fields. if obj['address']: user.address = obj['address'] if obj['city']: user.city = obj['city'] if obj['first_name']: user.first_name = obj['first_name'] if obj['job_title']: user.job_title = obj['job_title'] if obj['last_name']: user.last_name = obj['last_name'] if obj['mobile_number']: user.mobile_number = obj['mobile_number'] if obj['phone_number']: user.phone_number = obj['phone_number'] if obj['timezone']: user.timezone = obj['timezone'] if obj['zip_postal_code']: user.zip_postal_code = obj['zip_postal_code'] # Ensure user is published/not 'deleted'. # Set complex fields. if obj['country']: user.country = models.Country.objects.get_or_create(name=obj['country'])[0] user.save() if obj['evaluator']: product_evaluation, created = models.ProductEvaluation.objects.get_or_create(user=user.user, defaults={'status': constants.PRODUCT_EVALUATION_STATUS_APPROVED}) if not created: product_evaluation.status = constants.PRODUCT_EVALUATION_STATUS_APPROVED product_evaluation.save() if obj['channel_partner']: partnership, created = models.Partnership.objects.get_or_create(user=user.user, type=constants.PARTNER_TYPE_CHANNEL, defaults={'status': constants.PARTNERSHIP_REQUEST_STATUS_APPROVED}) if not created: partnership.status = constants.PARTNERSHIP_REQUEST_STATUS_APPROVED partnership.save() if object['distributor']: distributor, _ = models.Distributor.objects.get_or_create(partnership=partnership) elif object['reseller']: reseller, _ = models.Reseller.objects.get_or_create(partnership=partnership) elif obj['technical_partner']: partnership, created = models.Partnership.objects.get_or_create(user=user.user, type=constants.PARTNER_TYPE_TECHNOLOGY, defaults={'status': constants.PARTNERSHIP_REQUEST_STATUS_APPROVED}) if not created: partnership.status = constants.PARTNERSHIP_REQUEST_STATUS_APPROVED partnership.save() if obj['cloud_service_provider']: cloud_service_provider, _ = models.CloudServiceProvider.objects.get_or_create(partnership=partnership) if not created: update_count += 1 if created: if self.cleaned_data['email'] and obj['email']: automatic_emails.email_successful_account_activation.delay(user.user.id) messages.success( request, "Thank you! Your import completed successfully." )