how to

Added by Tim Aleinikoff about 15 years ago

Thank you for redmine, guys.
I try to customize different views and actions for stuff and clients.

For example in new_issue dialogue my clients can see only status and date fields.
For this goal I add string

<%if User.current.allowed_to?(:delete_issues, @project) %>
to app/views/issues/_form
Delete_issues used as flag - user is stuff member.
<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 %>
<%if User.current.allowed_to?(:delete_issues, @project) %>
<p><%= :priority_id, (@priorities.collect {|p| [,]}), :required => true %></p>
<p><%= :assigned_to_id, (@issue.assignable_users.collect {|m| [,]}) %></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 %>
<% end %>
<%= content_tag('p',,
(@project.versions.sort.collect {|v| [,]}),
{ :include_blank => true })) unless @project.versions.empty? %>

Help me plz. How to write this construction on Ruby.
"if current_user.boolean_custom_field.value = 1 than"
"case current_user.list_custom_field
1st_value do ...
2nd_value do ..."

Now, i wanna to customize actions with issues.
For example: when current_user=client make New Issue i wanna to assign it to service-manager, but if current_user=stuff, skip default assignment.

Default assigment i have done in app/models/issue

  def after_initialize
    if new_record?
      # set default values for new records only
      self.status ||= IssueStatus.default
      self.priority ||= Enumeration.default('IPRI')
#   if .....
      self.assigned_to ||= User.find_by_id(1)
#   end