def create(self, validated_data): lti_config = validated_data.pop('lti_config', None) instance = LtiConfiguration() instance.version = 'lti_1p1' for key, value in validated_data.items(): if key in set(self.Meta.fields).difference(self.Meta.read_only): setattr(instance, key, value) pii_sharing_allowed = self.context.get('pii_sharing_allowed', False) instance.lti_config = { "pii_share_username": pii_sharing_allowed, "pii_share_email": pii_sharing_allowed, "additional_parameters": lti_config['additional_parameters'] } instance.save() return instance
def create(self, validated_data): lti_config = validated_data.pop('lti_config', None) instance = LtiConfiguration() instance.version = 'lti_1p1' instance.config_store = LtiConfiguration.CONFIG_ON_DB for key, value in validated_data.items(): if key in set(self.Meta.fields).difference(self.Meta.read_only): setattr(instance, key, value) share_email, share_username = self.pii_sharing_allowed() instance.lti_config = { "pii_share_username": share_username, "pii_share_email": share_email, "additional_parameters": lti_config['additional_parameters'] } instance.save() return instance