diff --git a/app/assets/javascripts/admin/controllers/admin_groups_controller.js b/app/assets/javascripts/admin/controllers/admin_groups_controller.js index 5ed0fbb31..5578afc09 100644 --- a/app/assets/javascripts/admin/controllers/admin_groups_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_groups_controller.js @@ -33,12 +33,16 @@ Discourse.AdminGroupsController = Ember.Controller.extend({ }, destroy: function(group){ - var list = this.get("model"); - if(group.get("id")){ - group.destroy().then(function(){ - list.removeObject(group); - }); - } + var _this = this; + return bootbox.confirm(I18n.t("admin.groups.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) { + if (result) { + group.destroy().then(function(deleted) { + if (deleted) { + _this.get("model").removeObject(group); + } + }); + } + }); } }); diff --git a/app/assets/javascripts/admin/models/group.js b/app/assets/javascripts/admin/models/group.js index 64e96dfd0..920097a1e 100644 --- a/app/assets/javascripts/admin/models/group.js +++ b/app/assets/javascripts/admin/models/group.js @@ -36,12 +36,18 @@ Discourse.Group = Discourse.Model.extend({ }.property('users'), destroy: function(){ + if(!this.id) return; + var group = this; group.set('disableSave', true); - return Discourse.ajax("/admin/groups/" + this.get("id"), {type: "DELETE"}) + return Discourse.ajax("/admin/groups/" + group.id, {type: "DELETE"}) .then(function(){ + return true; + }, function(jqXHR, status, error) { group.set('disableSave', false); + bootbox.alert(I18n.t("admin.groups.delete_failed")); + return false; }); }, diff --git a/app/assets/javascripts/discourse/components/autocomplete.js b/app/assets/javascripts/discourse/components/autocomplete.js index b46aff2fa..6e282f36a 100644 --- a/app/assets/javascripts/discourse/components/autocomplete.js +++ b/app/assets/javascripts/discourse/components/autocomplete.js @@ -64,7 +64,7 @@ $.fn.autocomplete = function(options) { d.find('a').click(function() { closeAutocomplete(); - inputSelectedItems.splice($.inArray(item), 1); + inputSelectedItems.splice($.inArray(item, inputSelectedItems), 1); $(this).parent().parent().remove(); if (options.single) { me.show(); diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 40026b6d0..908d5f8b1 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -43,7 +43,7 @@ class Admin::GroupsController < Admin::AdminController can_not_modify_automatic else group.destroy - render json: "ok" + render json: success_json end end diff --git a/config/locales/client.cs.yml b/config/locales/client.cs.yml index 7697aa60b..56baa65b8 100644 --- a/config/locales/client.cs.yml +++ b/config/locales/client.cs.yml @@ -1152,6 +1152,9 @@ cs: name_placeholder: "Název skupiny, bez mezer, stejná pravidla jako pro uživatelská jména" about: "Zde můžete upravit názvy skupin a členství" can_not_edit_automatic: "Členství v automatických skupinách se přiděluje samo, administrátoři mohou přidělit další role a důveryhodnost uživatelům" + delete: "Smazat" + delete_confirm: "Smazat toto skupiny?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "API" diff --git a/config/locales/client.da.yml b/config/locales/client.da.yml index 254be5415..49f7f1e1f 100644 --- a/config/locales/client.da.yml +++ b/config/locales/client.da.yml @@ -728,8 +728,29 @@ da: flagged_by: "Flagged by" error: "Something went wrong" + groups: + title: "Groups" + edit: "Edit Groups" + selector_placeholder: "add users" + name_placeholder: "Group name, no spaces, same as username rule" + about: "Edit your group membership and names here" + can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels" + delete: "Delete" + delete_confirm: "Delete this group?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." + + api: + title: "API" + long_title: "API Information" + key: "Key" + generate: "Generate API Key" + regenerate: "Regenerate API Key" + info_html: "Your API key will allow you to create and update topics using JSON calls." + note_html: "Keep this key secret, all users that have it may create arbitrary posts on the forum as any user." + customize: title: "Customize" + long_title: "Site Customizations" header: "Header" css: "Stylesheet" override_default: "Do not include standard style sheet" @@ -741,6 +762,7 @@ da: new_style: "New Style" delete: "Delete" delete_confirm: "Delete this customization?" + about: "Site Customization allow you to modify stylesheets and headers on the site. Choose or add one to start editing." email: title: "Email" diff --git a/config/locales/client.de.yml b/config/locales/client.de.yml index 78b081bf5..4f56fcdca 100644 --- a/config/locales/client.de.yml +++ b/config/locales/client.de.yml @@ -1092,6 +1092,9 @@ de: name_placeholder: "Gruppenname, keine Leerzeichen, gleiche Regel wie beim Benutzernamen" about: "Hier kannst du Gruppenzugehörigkeiten und Gruppennamen bearbeiten." can_not_edit_automatic: "Automatische Gruppenzugehörigkeiten können nicht bearbeitet werden. Bearbeite Benutzer, um Rollen und Vertrauensstufen einzustellen." + delete: "Löschen" + delete_confirm: "Diese gruppe löschen?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "API" diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index e83302dc6..37643e5f2 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1092,6 +1092,9 @@ en: name_placeholder: "Group name, no spaces, same as username rule" about: "Edit your group membership and names here" can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels" + delete: "Delete" + delete_confirm: "Delete this group?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "API" diff --git a/config/locales/client.es.yml b/config/locales/client.es.yml index 645cc66fa..8b4b6e86e 100644 --- a/config/locales/client.es.yml +++ b/config/locales/client.es.yml @@ -815,6 +815,26 @@ es: delete_title: "delete post (if its the first post delete topic)" flagged_by: "Flagged by" + groups: + title: "Groups" + edit: "Edit Groups" + selector_placeholder: "add users" + name_placeholder: "Group name, no spaces, same as username rule" + about: "Edit your group membership and names here" + can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels" + delete: "Delete" + delete_confirm: "Delete this group?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." + + api: + title: "API" + long_title: "API Information" + key: "Key" + generate: "Generate API Key" + regenerate: "Regenerate API Key" + info_html: "Your API key will allow you to create and update topics using JSON calls." + note_html: "Keep this key secret, all users that have it may create arbitrary posts on the forum as any user." + customize: title: "Customize" header: "Header" diff --git a/config/locales/client.fr.yml b/config/locales/client.fr.yml index 3e8d40dae..8850ad698 100644 --- a/config/locales/client.fr.yml +++ b/config/locales/client.fr.yml @@ -207,6 +207,7 @@ fr: taken: "Désolé, ce pseudo est déjà pris" error: "Il y a eu une erreur en changeant votre pseudo." invalid: "Ce pseudo est invalide. Il ne doit être composé que de lettres et de chiffres." + change_email: action: 'changer' title: "Changer d'email" @@ -227,6 +228,7 @@ fr: instructions: "Votre nom complet (pas nécessairement unique)." too_short: "Votre nom est trop court." ok: "Votre nom à l'air sympa !." + username: title: "Pseudo" instructions: "Doit être unique et ne pas contenir d'espace. Les gens pourrons vous mentionner avec @pseudo." @@ -1037,6 +1039,9 @@ fr: name_placeholder: "Nom du groupe, sans espace, mêmes règles que pour les noms d'utilisateurs" about: "Modifier votre adhésion et les noms ici" can_not_edit_automatic: "L'adhésion au groupe est défini automatiquement, les administrateurs assignent des rôles et niveaux de confiance" + delete: "Supprimer" + delete_confirm: "Supprimer ce groupe?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "API" diff --git a/config/locales/client.id.yml b/config/locales/client.id.yml index 28b4f3755..7ddf6242b 100644 --- a/config/locales/client.id.yml +++ b/config/locales/client.id.yml @@ -667,6 +667,26 @@ id: delete_title: "delete post (if its the first post delete topic)" flagged_by: "Flagged by" + groups: + title: "Groups" + edit: "Edit Groups" + selector_placeholder: "add users" + name_placeholder: "Group name, no spaces, same as username rule" + about: "Edit your group membership and names here" + can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels" + delete: "Delete" + delete_confirm: "Delete this group?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." + + api: + title: "API" + long_title: "API Information" + key: "Key" + generate: "Generate API Key" + regenerate: "Regenerate API Key" + info_html: "Your API key will allow you to create and update topics using JSON calls." + note_html: "Keep this key secret, all users that have it may create arbitrary posts on the forum as any user." + customize: title: "Customize" header: "Header" diff --git a/config/locales/client.it.yml b/config/locales/client.it.yml index 8089a8b4a..9e2788d1e 100644 --- a/config/locales/client.it.yml +++ b/config/locales/client.it.yml @@ -958,6 +958,11 @@ it: edit: "Modifica Gruppi" selector_placeholder: "aggiungi utenti" name_placeholder: "Nome gruppo, no spazi, come lo username" + about: "Edit your group membership and names here" + can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels" + delete: "Elimina" + delete_confirm: "Delete this group?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "API" diff --git a/config/locales/client.ko.yml b/config/locales/client.ko.yml index 2731d10ee..538245aaa 100644 --- a/config/locales/client.ko.yml +++ b/config/locales/client.ko.yml @@ -900,9 +900,22 @@ ko: title: "그룹" edit: "Edit 그룹" selector_placeholder: "메뉴 추가" + name_placeholder: "Group name, no spaces, same as username rule" + about: "Edit your group membership and names here" + can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels" + delete: "삭제" + delete_confirm: "이 그룹을 삭제 하시겠습니까?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "API" + long_title: "API Information" + key: "Key" + generate: "Generate API Key" + regenerate: "Regenerate API Key" + info_html: "Your API key will allow you to create and update topics using JSON calls." + note_html: "Keep this key secret, all users that have it may create arbitrary posts on the forum as any user." + customize: title: "사용자 지정" long_title: "사이트 사용자 지정" diff --git a/config/locales/client.nb_NO.yml b/config/locales/client.nb_NO.yml index 77e398cec..152c4a6aa 100644 --- a/config/locales/client.nb_NO.yml +++ b/config/locales/client.nb_NO.yml @@ -979,6 +979,11 @@ nb_NO: edit: "Rediger Grupper" selector_placeholder: "legg til brukere" name_placeholder: "Gruppenavn, ingen mellomrom, samme som reglene for brukernavn" + about: "Edit your group membership and names here" + can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels" + delete: "Slett" + delete_confirm: "Slette denne grupper?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "API" diff --git a/config/locales/client.nl.yml b/config/locales/client.nl.yml index fc0cfcdb7..fb3380f25 100644 --- a/config/locales/client.nl.yml +++ b/config/locales/client.nl.yml @@ -1091,6 +1091,9 @@ nl: name_placeholder: "Groepsnaam, geen spaties, zelfde regels als bij een gebruikersnaam" about: "Wijzig hier je deelname aan groepen en je namen" can_not_edit_automatic: "Automatisch lidmaatschap van groepen wordt automatisch bepaald. Beheer rollen en trust levels van gebruikers" + delete: Verwijder + delete_confirm: Verwijder deze groepen? + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: API diff --git a/config/locales/client.pseudo.yml b/config/locales/client.pseudo.yml index 1566e18e3..fceae06e5 100644 --- a/config/locales/client.pseudo.yml +++ b/config/locales/client.pseudo.yml @@ -1060,6 +1060,9 @@ pseudo: about: '[[ Éďíť ýóůř ǧřóůƿ ɱéɱƀéřšĥíƿ áɳď ɳáɱéš ĥéřé ]]' can_not_edit_automatic: '[[ Áůťóɱáťíč ǧřóůƿ ɱéɱƀéřšĥíƿ íš ďéťéřɱíɳéď áůťóɱáťíčáłłý, áďɱíɳíšťéř ůšéřš ťó áššíǧɳ řółéš áɳď ťřůšť łéνéłš ]]' + delete: '[[ Ďéłéťé ]]' + delete_confirm: '[[ Ďéłéťé ťĥíš ǧřóůƿ? ]]' + delete_failed: '[[ Unable to delete group. If this is an automatic group, it cannot be destroyed. ]]' api: title: '[[ ÁРÍ ]]' long_title: '[[ ÁРÍ Íɳƒóřɱáťíóɳ ]]' diff --git a/config/locales/client.pt.yml b/config/locales/client.pt.yml index 18adc1962..0c6ef73b4 100644 --- a/config/locales/client.pt.yml +++ b/config/locales/client.pt.yml @@ -623,6 +623,26 @@ pt: delete_title: "apagar post (se for o primeiro post, apagar tópico)" flagged_by: "Flagged por" + groups: + title: "Groups" + edit: "Edit Groups" + selector_placeholder: "add users" + name_placeholder: "Group name, no spaces, same as username rule" + about: "Edit your group membership and names here" + can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels" + delete: "Delete" + delete_confirm: "Delete this group?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." + + api: + title: "API" + long_title: "API Information" + key: "Key" + generate: "Generate API Key" + regenerate: "Regenerate API Key" + info_html: "Your API key will allow you to create and update topics using JSON calls." + note_html: "Keep this key secret, all users that have it may create arbitrary posts on the forum as any user." + customize: title: "Personalizar" header: "Cabeçalho" diff --git a/config/locales/client.pt_BR.yml b/config/locales/client.pt_BR.yml index 4a9ea1655..7c336bba7 100644 --- a/config/locales/client.pt_BR.yml +++ b/config/locales/client.pt_BR.yml @@ -968,6 +968,9 @@ pt_BR: name_placeholder: "Nome do grupo, sem espaços, regras iguais ao nome de usuário" about: "Editar participação no grupo e nomes aqui" can_not_edit_automatic: "Participação nos grupos automáticos é determinada automaticamente, gerencie os usuários para determinar papéis e níveis de confiança" + delete: "Apagar" + delete_confirm: "Apagar este grupos?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "API" long_title: "Informações da API" diff --git a/config/locales/client.ru.yml b/config/locales/client.ru.yml index 00f8a6252..f6ef39639 100644 --- a/config/locales/client.ru.yml +++ b/config/locales/client.ru.yml @@ -1096,6 +1096,9 @@ ru: name_placeholder: Название группы, без пробелов, по тем же правилам, что и имя пользователя. about: Здесь можно редактировать группы и имена групп can_not_edit_automatic: Принадлежность пользователя к системным группам определяется автоматически, однако вы можете самостоятельно переназначить группу пользователя и уровень доверия + delete: Удалить + delete_confirm: удалить эту Группы? + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: API long_title: Информация об API diff --git a/config/locales/client.sv.yml b/config/locales/client.sv.yml index e346404db..e76eb10f0 100644 --- a/config/locales/client.sv.yml +++ b/config/locales/client.sv.yml @@ -839,8 +839,26 @@ sv: flagged_by: "Flaggad av" error: "Någonting gick snett" + groups: + title: "Groups" + edit: "Edit Groups" + selector_placeholder: "add users" + name_placeholder: "Group name, no spaces, same as username rule" + about: "Edit your group membership and names here" + can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels" + delete: "Radera" + delete_confirm: "Delete this group?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." + api: title: "API" + long_title: "API Information" + key: "Key" + generate: "Generate API Key" + regenerate: "Regenerate API Key" + info_html: "Your API key will allow you to create and update topics using JSON calls." + note_html: "Keep this key secret, all users that have it may create arbitrary posts on the forum as any user." + customize: title: "Anpassa" header: "Sidhuvud" diff --git a/config/locales/client.zh_CN.yml b/config/locales/client.zh_CN.yml index 70e2271e7..d31655612 100644 --- a/config/locales/client.zh_CN.yml +++ b/config/locales/client.zh_CN.yml @@ -568,10 +568,10 @@ zh_CN: not_found: title: "未找到主题" description: "抱歉,无法找到此主题。有可能它被论坛版主删掉了?" - unread_posts: + unread_posts: one: "此主题中你有一个帖子未阅" other: "此主题中你有 {{unread}} 个帖子未阅" - new_posts: + new_posts: other: "从你最近一次阅读此主题后,又有一个新帖子发表" other: "从你最近一次阅读此主题后,又有 {{new_posts}} 个新帖子发表" @@ -1109,6 +1109,9 @@ zh_CN: name_placeholder: "组名,不能含有空格,与用户名规则一致" about: "在这里编辑群组的名字和成员" can_not_edit_automatic: "这是一个自动划分的群组,管理员用来分配角色和管理用户等级" + delete: "删除" + delete_confirm: "删除这个小组吗?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "应用开发接口(API)" diff --git a/config/locales/client.zh_TW.yml b/config/locales/client.zh_TW.yml index 88e42e81a..e4d25ac14 100644 --- a/config/locales/client.zh_TW.yml +++ b/config/locales/client.zh_TW.yml @@ -958,6 +958,9 @@ zh_TW: edit: "編輯群組" selector_placeholder: "添加用戶" name_placeholder: "組名,不能含有空格,與用戶名規則一致" + delete: "刪除" + delete_confirm: "删除这个小组吗?" + delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed." api: title: "應用開發接口(API)" diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb index 2c21a5fee..056d12f75 100644 --- a/spec/controllers/admin/groups_controller_spec.rb +++ b/spec/controllers/admin/groups_controller_spec.rb @@ -2,14 +2,17 @@ require 'spec_helper' describe Admin::GroupsController do + before do + @admin = log_in(:admin) + end + it "is a subclass of AdminController" do (Admin::GroupsController < Admin::AdminController).should be_true end it "produces valid json for groups" do - admin = log_in(:admin) group = Fabricate.build(:group, name: "test") - group.add(admin) + group.add(@admin) group.save xhr :get, :index @@ -23,28 +26,31 @@ describe Admin::GroupsController do end it "is able to refresh automatic groups" do - admin = log_in(:admin) Group.expects(:refresh_automatic_groups!).returns(true) xhr :post, :refresh_automatic_groups response.status.should == 200 end - it "is able to destroy a group" do - log_in(:admin) - group = Fabricate(:group) + context '.destroy' do + it "returns a 422 if the group is automatic" do + group = Fabricate(:group, automatic: true) + xhr :delete, :destroy, id: group.id + response.status.should == 422 + Group.where(id: group.id).count.should == 1 + end - xhr :delete, :destroy, id: group.id - response.status.should == 200 - - Group.where(id: group.id).count.should == 0 + it "is able to destroy a non-automatic group" do + group = Fabricate(:group) + xhr :delete, :destroy, id: group.id + response.status.should == 200 + Group.where(id: group.id).count.should == 0 + end end it "is able to create a group" do - a = log_in(:admin) - xhr :post, :create, group: { - usernames: a.username, + usernames: @admin.username, name: "bob" } @@ -53,16 +59,14 @@ describe Admin::GroupsController do groups = Group.where(name: "bob").to_a groups.count.should == 1 - groups[0].usernames.should == a.username + groups[0].usernames.should == @admin.username groups[0].name.should == "bob" - end it "is able to update group members" do user1 = Fabricate(:user) user2 = Fabricate(:user) group = Fabricate(:group) - log_in(:admin) xhr :put, :update, id: group.id, name: 'fred', group: { name: 'fred', @@ -72,6 +76,5 @@ describe Admin::GroupsController do group.reload group.users.count.should == 2 group.name.should == 'fred' - end end