Files
edx-platform/lms/djangoapps/branding/models.py
Manjinder Singh a40f1d9bd6 BOM-933: Fix type mismatches in various migrations 2 (#22115)
* Fix type mismatches in track migrations

* Fix type mismatches in oauth_dispatch

* Fix type mismatches in badges migrations

* fix type mismatch in contentserver migrations

* Fix type mismatches in mobile_api migrations

* fix type mismatch in crawlers migrations

* fix type mismatch in dark_lang migrations

* fix type mismatch in branding  migrations
2019-10-23 13:04:36 -04:00

69 lines
1.7 KiB
Python

"""
Model used by Video module for Branding configuration.
Includes:
BrandingInfoConfig: A ConfigurationModel for managing how Video Module will
use Branding.
"""
from __future__ import absolute_import
import json
from config_models.models import ConfigurationModel
from django.core.exceptions import ValidationError
from django.db.models import TextField
class BrandingInfoConfig(ConfigurationModel):
"""
Configuration for Branding.
Example of configuration that must be stored:
{
"CN": {
"url": "http://www.xuetangx.com",
"logo_src": "http://www.xuetangx.com/static/images/logo.png",
"logo_tag": "Video hosted by XuetangX.com"
}
}
.. no_pii:
"""
class Meta(ConfigurationModel.Meta):
app_label = "branding"
configuration = TextField(
help_text=u"JSON data of Configuration for Video Branding."
)
def clean(self):
"""
Validates configuration text field.
"""
try:
json.loads(self.configuration)
except ValueError:
raise ValidationError('Must be valid JSON string.')
@classmethod
def get_config(cls):
"""
Get the Video Branding Configuration.
"""
info = cls.current()
return json.loads(info.configuration) if info.enabled else {}
class BrandingApiConfig(ConfigurationModel):
"""Configure Branding api's
Enable or disable api's functionality.
When this flag is disabled, the api will return 404.
When the flag is enabled, the api will returns the valid reponse.
.. no_pii:
"""
class Meta(ConfigurationModel.Meta):
app_label = "branding"