def load(self): """Load the form.""" can_use_amazon_s3, reason = get_can_use_amazon_s3() if not can_use_amazon_s3: self.disabled_fields['aws_access_key_id'] = True self.disabled_fields['aws_secret_access_key'] = True self.disabled_fields['aws_s3_bucket_name'] = True self.disabled_fields['aws_calling_format'] = True self.disabled_reasons['aws_access_key_id'] = reason can_use_openstack_swift, reason = get_can_use_openstack_swift() if not can_use_openstack_swift: self.disabled_fields['swift_auth_url'] = True self.disabled_fields['swift_username'] = True self.disabled_fields['swift_key'] = True self.disabled_fields['swift_auth_version'] = True self.disabled_fields['swift_container_name'] = True self.disabled_reasons['swift_auth_url'] = reason can_use_couchdb, reason = get_can_use_couchdb() if not can_use_couchdb: self.disabled_fields['couchdb_default_server'] = True self.disabled_reasons['couchdb_default_server'] = reason super(StorageSettingsForm, self).load()
def __init__(self, *args, **kwargs): """Initialize the subform. If OpenStack Swift support isn't available, the form's fields will be disabled. Args: *args (tuple): Additional positional arguments for the parent class. **kwargs (dict): Additional keyword arguments for the parent class. """ super(SwiftStorageSettingsForm, self).__init__(*args, **kwargs) can_use_openstack_swift, reason = get_can_use_openstack_swift() if not can_use_openstack_swift: self.disabled_fields['swift_auth_url'] = True self.disabled_fields['swift_username'] = True self.disabled_fields['swift_key'] = True self.disabled_fields['swift_auth_version'] = True self.disabled_fields['swift_container_name'] = True self.disabled_reasons['swift_auth_url'] = reason