2013-03-19 43 views
0

我正在使用插件来扩展redmine的文件附件功能。控制用户复选框的可见性

对于我需要添加一个复选框,只有通过用户与特定角色

可见我对红宝石完全小白。这是我提到一些其他插件和redmine文档后提出的。

在插件

/为myplugin /应用/视图/附件/ _form.html.erb

<% if view_private_attachment = User.current.allowed_to?(:view_private_attachments, @project) %> 
<%= check_box_tag :private_attachment, true, false %> 
<%= label_tag :private_attachment, 'Private Attachment', :style => 'font-weight:bold;' %> 
    <% end %> 

在插件/为myplugin /应用/ init.d中

Redmine::Plugin.register :myplugin do 
    name 'myplugin' 
    author 'njan' 
    description 'This is a plugin for Redmine' 
    version '0.0.1' 
    url 'http://example.com/path/to/plugin' 
    author_url 'http://example.com/about' 


project_module :issue_tracking do 
permission :view_private_attachments, { } 

end 
end 

该复选框没有得到显示。

回答

0

根据您的情况,您可以使用复选框的禁用和只读属性。

<%= f.check_box :private_attachment, :disabled => true, :readonly => true %> 
+0

其实我想限制复选框的“可见性”。即一些具有“查看”权限的用户可以看到其他人不能查看的复选框。 – born 2013-03-19 07:45:25

+0

如果你想提高能见度,那么使用条件取决于条件。 – 2013-03-19 07:51:01

+0

哎呀抱歉,我搞砸了“角色和许可”。其实我做的是正确的。浪费至少4小时! Jeeezzzz。 – born 2013-03-19 08:08:31