mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
automatic groups should not allow you to muck with the listed users in the group
This commit is contained in:
parent
7c73140674
commit
b97d186cb5
7 changed files with 38 additions and 14 deletions
|
@ -1,4 +1,3 @@
|
||||||
<!-- work in progress, please ignore -->
|
|
||||||
<div class='row groups'>
|
<div class='row groups'>
|
||||||
<div class='content-list span6'>
|
<div class='content-list span6'>
|
||||||
<h3>{{i18n admin.groups.edit}}</h3>
|
<h3>{{i18n admin.groups.edit}}</h3>
|
||||||
|
@ -25,7 +24,7 @@
|
||||||
{{textField value=name placeholderKey="admin.groups.name_placeholder"}}
|
{{textField value=name placeholderKey="admin.groups.name_placeholder"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{userSelector usernames=usernames id="group-users" placeholderKey="admin.groups.selector_placeholder" tabindex="1"}}
|
{{userSelector usernames=usernames id="group-users" placeholderKey="admin.groups.selector_placeholder" tabindex="1" disabledBinding="automatic"}}
|
||||||
<div class='controls'>
|
<div class='controls'>
|
||||||
<button {{action save this}} {{bindAttr disabled="disableSave"}} class='btn'>{{i18n admin.customize.save}}</button>
|
<button {{action save this}} {{bindAttr disabled="disableSave"}} class='btn'>{{i18n admin.customize.save}}</button>
|
||||||
{{#unless automatic}}
|
{{#unless automatic}}
|
||||||
|
|
|
@ -18,6 +18,7 @@ $.fn.autocomplete = function(options) {
|
||||||
alert("only supporting one matcher at the moment");
|
alert("only supporting one matcher at the moment");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var disabled = options && options.disabled;
|
||||||
var wrap = null;
|
var wrap = null;
|
||||||
var autocompleteOptions = null;
|
var autocompleteOptions = null;
|
||||||
var selectedOption = null;
|
var selectedOption = null;
|
||||||
|
@ -87,7 +88,7 @@ $.fn.autocomplete = function(options) {
|
||||||
if (isInput) {
|
if (isInput) {
|
||||||
var width = this.width();
|
var width = this.width();
|
||||||
var height = this.height();
|
var height = this.height();
|
||||||
wrap = this.wrap("<div class='ac-wrap clearfix'/>").parent();
|
wrap = this.wrap("<div class='ac-wrap clearfix" + (disabled ? " disabled": "") + "'/>").parent();
|
||||||
wrap.width(width);
|
wrap.width(width);
|
||||||
this.width(150);
|
this.width(150);
|
||||||
this.attr('name', this.attr('name') + "-renamed");
|
this.attr('name', this.attr('name') + "-renamed");
|
||||||
|
|
|
@ -8,6 +8,8 @@ Discourse.UserSelector = Discourse.TextField.extend({
|
||||||
$(this.get('element')).val(this.get('usernames')).autocomplete({
|
$(this.get('element')).val(this.get('usernames')).autocomplete({
|
||||||
template: Discourse.UserSelector.templateFunction(),
|
template: Discourse.UserSelector.templateFunction(),
|
||||||
|
|
||||||
|
disabled: this.get('disabled'),
|
||||||
|
|
||||||
dataSource: function(term) {
|
dataSource: function(term) {
|
||||||
var exclude = selected;
|
var exclude = selected;
|
||||||
if (userSelectorView.get('excludeCurrentUser')){
|
if (userSelectorView.get('excludeCurrentUser')){
|
||||||
|
|
|
@ -342,15 +342,24 @@
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.ac-wrap.disabled {
|
||||||
|
input {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
.item a {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
div.ac-wrap {
|
div.ac-wrap {
|
||||||
background-color: $white;
|
background-color: $white;
|
||||||
border: 1px solid #cccccc;
|
border: 1px solid #cccccc;
|
||||||
padding: 4px 10px;
|
padding: 5px 10px 0;
|
||||||
@include border-radius-all(3px);
|
@include border-radius-all(3px);
|
||||||
div.item {
|
div.item {
|
||||||
float: left;
|
float: left;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
margin-bottom: 5px;
|
||||||
span {
|
span {
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
|
|
|
@ -16,12 +16,15 @@ class Admin::GroupsController < Admin::AdminController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
group = Group.find(params[:id].to_i)
|
group = Group.find(params[:id].to_i)
|
||||||
render_json_error if group.automatic
|
if group.automatic
|
||||||
|
can_not_modify_automatic
|
||||||
|
else
|
||||||
group.usernames = params[:group][:usernames]
|
group.usernames = params[:group][:usernames]
|
||||||
group.name = params[:group][:name] if params[:name]
|
group.name = params[:group][:name] if params[:name]
|
||||||
group.save!
|
group.save!
|
||||||
render json: "ok"
|
render json: "ok"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
group = Group.new
|
group = Group.new
|
||||||
|
@ -33,8 +36,17 @@ class Admin::GroupsController < Admin::AdminController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
group = Group.find(params[:id].to_i)
|
group = Group.find(params[:id].to_i)
|
||||||
render_json_error if group.automatic
|
if group.automatic
|
||||||
|
can_not_modify_automatic
|
||||||
|
else
|
||||||
group.destroy
|
group.destroy
|
||||||
render json: "ok"
|
render json: "ok"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def can_not_modify_automatic
|
||||||
|
render json: {errors: I18n.t('groups.errors.can_not_modify_automatic')}, status: 422
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -195,7 +195,6 @@ class ApplicationController < ActionController::Base
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def render_json_error(obj)
|
def render_json_error(obj)
|
||||||
|
|
|
@ -56,6 +56,8 @@ en:
|
||||||
private_message_abbrev: "PM"
|
private_message_abbrev: "PM"
|
||||||
|
|
||||||
groups:
|
groups:
|
||||||
|
errors:
|
||||||
|
can_not_modify_automatic: "You can not modify an automatic group"
|
||||||
default_names:
|
default_names:
|
||||||
admins: "admins"
|
admins: "admins"
|
||||||
moderators: "moderators"
|
moderators: "moderators"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue