bokos
2018 年10 月 5 日 18:33
1
I noticed my moderators don’t have access to the Staff category. I just installed a fresh discourse locally to test it and it still happens.
I think it’s because my Discourse got installed in German and my Staff group is actually called Team.
So I ran this in console:
staff = Category.find_by(id: SiteSetting.staff_category_id)
staff.group_names = [Group[:staff].name]
staff.save
I hope this doesn’t break anything?
2 个赞
Hmm, no, permissions aren’t set based on the text name of the category.
bokos
2018 年10 月 5 日 21:41
3
I just noticed I have the same issue with the Lounge category.
I think the group_names=(names) method of the Category model should find the correct name of the group? Or change the fixtures?
1 个赞
david
(David Taylor)
2018 年10 月 5 日 22:14
4
Yes, it looks like we localise the group names here:
group.id = id
group.save!
end
# don't allow shoddy localization to break this
localized_name = I18n.t("groups.default_names.#{name}").downcase
validator = UsernameValidator.new(localized_name)
if !Group.where("LOWER(name) = ?", localized_name).exists? && validator.valid_format?
group.name = localized_name
end
# the everyone group is special, it can include non-users so there is no
# way to have the membership in a table
case name
when :everyone
group.visibility_level = Group.visibility_levels[:owners]
group.save!
return group
when :moderators
But then set category permissions using the unlocalised group name here:
unless Rails.env.test?
staff = Category.find_by(id: SiteSetting.staff_category_id)
if staff && !staff.group_ids.include?(Group[:staff].id)
# Add permissions and a description to the Staff category.
Category.transaction do
staff.group_names = ['staff']
unless staff.save
puts staff.errors.full_messages
raise "Failed to set permissions on the Staff category!"
end
if staff.topic_id.nil?
creator = PostCreator.new(Discourse.system_user,
raw: I18n.t('staff_category_description'),
title: I18n.t('category.topic_prefix', category: staff.name),
category: staff.name,
I think this could do with some improvement
8 个赞
Oh dear, I didn’t realize we were using the string names rather than the numeric codes. I wonder why we haven’t seen more complaints about this for Discourse instances in other languages?
4 个赞
zoul
(Tomáš Znamenáček)
2018 年10 月 6 日 06:46
6
I’ve seen the same (or similar?) bug running Discourse in Czech and thought it was a random glitch related just to a single user. It went away after I temporarily turned the moderator into an admin and back IIRC, so I did not bother reporting it.
3 个赞
ErlendMS
(Erlend Markussen Saltnes)
2024 年1 月 20 日 10:42
8
我好像也遇到了同样的问题……?
我安装的是挪威语版本——当我登录到我的管理员账户时,我无法访问 staff 类别。我在“所有类别”中看到了它,但当我点击它时,它一直在加载。
我创建了一个测试用户并将其设置为版主——然后该 用户获得了访问权限。
1 个赞