0

I am working on a plug-in to extend the file attachment feature of redmine.

For which I need to add a checkbox that is only visible by users with a particular role

I am totally noob on ruby. This is what i came up with after referring some other plug-ins and redmine documentation.

in plugins/myplugin/app/view/attachments/_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 %> 

In plugins/myplugin/app/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

The check box is not getting displayed .

born
  • 265
  • 3
  • 18

1 Answers1

0

You can use disable and readonly property of checkbox depending your condition.

<%= f.check_box :private_attachment, :disabled => true, :readonly => true %>
Ganesh Kunwar
  • 2,643
  • 2
  • 20
  • 36
  • actually I wanted to restrict the "visibility" of the checkbox . ie, some users with "view" permission can see the checkbox others cannot. – born Mar 19 '13 at 07:45
  • if you want to ristrict the visibility then use if condition depending the condition. – Ganesh Kunwar Mar 19 '13 at 07:51
  • oops sorry guys i messed up the "roles and permission " . Actually what i did was correct. Wasted atleast 4 hrs on it! Jeeezzzz. – born Mar 19 '13 at 08:08