FIX: Category creation failed when translation was missing

This commit is contained in:
Gerhard Schlager 2014-09-20 22:05:21 +02:00
parent d97548114f
commit a6714e252e
5 changed files with 12 additions and 7 deletions

View File

@ -45,9 +45,15 @@ Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(Discourse.OpenCompos
actions: {
createCategory: function() {
var groups = Discourse.Site.current().groups;
var everyone_group = groups.findBy('id', 0);
var group_names = groups.map(function(group) {
return group.name;
});
Discourse.Route.showModal(this, 'editCategory', Discourse.Category.create({
color: 'AB9364', text_color: 'FFFFFF', group_permissions: [{group_name: I18n.t('category.everyone_permission'), permission_type: 1}],
available_groups: Discourse.Site.current().group_names,
color: 'AB9364', text_color: 'FFFFFF', group_permissions: [{group_name: everyone_group.name, permission_type: 1}],
available_groups: group_names,
allow_badges: true
}));
this.controllerFor('editCategory').set('selectedTab', 'general');

View File

@ -29,8 +29,8 @@ class Site
TrustLevel.all
end
def group_names
@group_name ||= Group.order(:name).pluck(:name)
def groups
@groups ||= Group.order(:name).map { |g| {:id => g.id, :name => g.name}}
end
def categories

View File

@ -3,7 +3,7 @@ class SiteSerializer < ApplicationSerializer
attributes :default_archetype,
:notification_types,
:post_types,
:group_names,
:groups,
:filters,
:periods,
:top_menu_items,

View File

@ -1275,7 +1275,6 @@ en:
allow_badges_label: "Allow badges to be awarded in this category"
edit_permissions: "Edit Permissions"
add_permission: "Add Permission"
everyone_permission: "everyone"
this_year: "this year"
position: "position"
default_position: "Default Position"

File diff suppressed because one or more lines are too long