Merge pull request #1814 from ostcar/fix_config
Fix autoupdate of config
This commit is contained in:
commit
f375f4b45a
@ -77,9 +77,10 @@ class ConfigHandler:
|
||||
raise ConfigError(e.messages[0])
|
||||
|
||||
# Save the new value to the database.
|
||||
updated_rows = ConfigStore.objects.filter(key=key).update(value=value)
|
||||
if not updated_rows:
|
||||
ConfigStore.objects.create(key=key, value=value)
|
||||
config_store, created = ConfigStore.objects.get_or_create(key=key, defaults={'value': value})
|
||||
if not created:
|
||||
config_store.value = value
|
||||
config_store.save()
|
||||
|
||||
# Update cache.
|
||||
if hasattr(self, '_cache'):
|
||||
|
@ -1,5 +1,6 @@
|
||||
from django.conf import settings
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_noop
|
||||
from jsonfield import JSONField
|
||||
@ -198,6 +199,12 @@ class ConfigStore(models.Model):
|
||||
permissions = (
|
||||
('can_manage_config', ugettext_noop('Can manage configuration')),)
|
||||
|
||||
def get_root_rest_url(self):
|
||||
"""
|
||||
Returns the detail url of config value.
|
||||
"""
|
||||
return reverse('config-detail', args=[str(self.key)])
|
||||
|
||||
|
||||
class ChatMessage(RESTModelMixin, models.Model):
|
||||
"""
|
||||
|
@ -343,6 +343,11 @@ angular.module('OpenSlidesApp.core.site', [
|
||||
$scope.key = 'field-' + field.key;
|
||||
$scope.value = config.value;
|
||||
$scope.help_text = field.help_text;
|
||||
$scope.default_value = field.default_value;
|
||||
$scope.reset = function () {
|
||||
$scope.value = $scope.default_value;
|
||||
$scope.save(field.key, $scope.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
|
@ -2,18 +2,27 @@
|
||||
<label>{{ label }}</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input ng-if="type != 'choice' && type != 'textarea'" ng-model="value" ng-change="save(configOption.key, value)" id="{{ key }}"
|
||||
<input ng-if="type != 'choice' && type != 'textarea'"
|
||||
ng-model="$parent.value"
|
||||
ng-change="save(configOption.key, $parent.value)"
|
||||
id="{{ key }}"
|
||||
type="{{ type }}" class="form-control">
|
||||
|
||||
<textarea ng-if="type == 'textarea'" ng-model="value" ng-change="save(configOption.key, value)" id="{{ key }}" class="form-control">
|
||||
<textarea ng-if="type == 'textarea'"
|
||||
ng-model="$parent.value"
|
||||
ng-change="save(configOption.key, $parent.value)"
|
||||
id="{{ key }}" class="form-control">
|
||||
</textarea>
|
||||
|
||||
<select ng-if="type == 'choice'" ng-model="value" ng-change="save(configOption.key, value)" id="{{ key }}"
|
||||
<select ng-if="type == 'choice'"
|
||||
ng-model="$parent.value"
|
||||
ng-change="save(configOption.key, $parent.value)"
|
||||
id="{{ key }}"
|
||||
class="form-control" ng-options="option.value as option.display_name for option in choices">
|
||||
</select>
|
||||
|
||||
<span class="input-group-btn">
|
||||
<button ng-click="value=configOption.default_value; save(configOption.key, configOption.default_value)" class="btn btn-default" translate>
|
||||
<button ng-click="reset()" class="btn btn-default" title="{{ default_value }}" translate>
|
||||
<i class="fa fa-undo"></i>
|
||||
<translate>Reset</translate>
|
||||
</button>
|
||||
|
Loading…
Reference in New Issue
Block a user