Modifying Redmine's issue creation form

Submitted by matthew on March 29, 2010 - 8:48pm

I am an avid user of Redmine project management system on all of my freelance websites. I can't imagine how I managed my projects before. IMHO it is single best collaboration tool to use with my clients. There is sum functionality however that I just didn't want my clients to be able to manipulate. For example, when a client creates a new issue, I don't want them to have the ability to assign the ticket to a specific user. More than that, there were other little bits of html I wish I could just hit for clients. So my solution was to hack redmine!!!

Now, I am not a rails developer in the least, and if there is a way to do this other than I am describing, please let me know!

So the first step is create a new "Client" role. Pretty straight forward. The next part is the actual hackery. Not being native to rails apps, it took me a while to find the views folder that outputs the html for the application. I found the output for the issue form in /app/views/issues/_form.rhtml

From there all I need to add is:

<% if != "Client" %>
[html i don't want clients to see]
<% end %>

And when ever a user with the Client role hits that page, that html will not appear! Presto! The actual hidden fields in the _from.rhtml would be:

<% role = User.current.role_for_project(@project) %>
<% if != "Client" %>
<div class="splitcontentleft">
<% if @issue.new_record? || @allowed_statuses.any? %>
<p><%= :status_id, (@allowed_statuses.collect {|p| [,]}), :required => true %></p>
<% else %>
<p><label><%= l(:field_status) %></label> <%= %></p>
<% end %>

<p><%= :priority_id, (@priorities.collect {|p| [,]}), :required => true %></p>
<p><%= :assigned_to_id, (@issue.assignable_users.collect {|m| [,]}), :include_blank => true %></p>
<% unless @project.issue_categories.empty? %>
<p><%= :category_id, (@project.issue_categories.collect {|c| [,]}), :include_blank => true %>
<%= prompt_to_remote(l(:label_issue_category_new),
l(:label_issue_category_new), 'category[name]',
{:controller => 'projects', :action => 'add_issue_category', :id => @project},
:class => 'small', :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p>
<% end %>
<%= content_tag('p',,
(@project.versions.sort.collect {|v| [,]}),
{ :include_blank => true })) unless @project.versions.empty? %>

<div class="splitcontentright">
<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
<p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p>
<p><%= f.text_field :estimated_hours, :size => 3 %> <%= l(:field_hours) %></p>
<p><%= :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
<% end %>

And now the user can't set the assign to, category, start date, end date, hours, or estimated done. Only actual developers and managers should be able to set those.

So there you have it. If you know a better way to override this view without hacking it please let me know.

What is Drupal?

Drupal - a completely free, open source content management system that many organizations are using today to provide for their needs. Drupal's many features and add-ons allow it to be used for a variety of website needs. Drupal is a good choice for today's organizations of any size because it is free, easy, and incredibly flexible.

Copyright ©, 2008-2010. All Rights Reserved Drupal theme by Kiwi Themes.