Merged release v2.4.5

This commit is contained in:
Jeremy Stretch
2018-10-03 11:23:21 -04:00
38 changed files with 249 additions and 125 deletions

View File

@@ -688,9 +688,22 @@ class ConfigContext(models.Model):
def get_absolute_url(self):
return reverse('extras:configcontext', kwargs={'pk': self.pk})
def clean(self):
# Verify that JSON data is provided as an object
if type(self.data) is not dict:
raise ValidationError(
{'data': 'JSON data must be in object form. Example: {"foo": 123}'}
)
class ConfigContextModel(models.Model):
local_context_data = JSONField(
blank=True,
null=True,
)
class Meta:
abstract = True
@@ -704,6 +717,10 @@ class ConfigContextModel(models.Model):
for context in ConfigContext.objects.get_for_object(self):
data.update(context.data)
# If the object has local config context data defined, that data overwrites all rendered data
if self.local_context_data is not None:
data.update(self.local_context_data)
return data