Fix autoupdate of config
This commit is contained in:
parent
2f8138f672
commit
3ae6482863
@ -77,9 +77,10 @@ class ConfigHandler:
|
|||||||
raise ConfigError(e.messages[0])
|
raise ConfigError(e.messages[0])
|
||||||
|
|
||||||
# Save the new value to the database.
|
# Save the new value to the database.
|
||||||
updated_rows = ConfigStore.objects.filter(key=key).update(value=value)
|
config_store, created = ConfigStore.objects.get_or_create(key=key, defaults={'value': value})
|
||||||
if not updated_rows:
|
if not created:
|
||||||
ConfigStore.objects.create(key=key, value=value)
|
config_store.value = value
|
||||||
|
config_store.save()
|
||||||
|
|
||||||
# Update cache.
|
# Update cache.
|
||||||
if hasattr(self, '_cache'):
|
if hasattr(self, '_cache'):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext_noop
|
from django.utils.translation import ugettext_noop
|
||||||
from jsonfield import JSONField
|
from jsonfield import JSONField
|
||||||
@ -198,6 +199,12 @@ class ConfigStore(models.Model):
|
|||||||
permissions = (
|
permissions = (
|
||||||
('can_manage_config', ugettext_noop('Can manage configuration')),)
|
('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):
|
class ChatMessage(RESTModelMixin, models.Model):
|
||||||
"""
|
"""
|
||||||
|
@ -343,6 +343,11 @@ angular.module('OpenSlidesApp.core.site', [
|
|||||||
$scope.key = 'field-' + field.key;
|
$scope.key = 'field-' + field.key;
|
||||||
$scope.value = config.value;
|
$scope.value = config.value;
|
||||||
$scope.help_text = field.help_text;
|
$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>
|
<label>{{ label }}</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<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">
|
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>
|
</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">
|
class="form-control" ng-options="option.value as option.display_name for option in choices">
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<span class="input-group-btn">
|
<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>
|
<i class="fa fa-undo"></i>
|
||||||
<translate>Reset</translate>
|
<translate>Reset</translate>
|
||||||
</button>
|
</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user