Changeset 469

Show
Ignore:
Timestamp:
01/23/07 14:43:00 (2 years ago)
Author:
timo
Message:
  • Searched and replaced all (=most) instances of "WorkOrder?"/"work_order" with "Task"/"task".
  • Updated the migrations to rename "work_order" to "task" in table and column names.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/workorder_report_rename/app/controllers/application.rb

    r464 r469  
    8383  protected_page_group :asset_edit, 'asset', ['edit'], 'edit_protector' 
    8484  protected_page_group :asset_change_type, 'asset', ['change_type'], 'change_type_protector' 
    85   protected_page_group :work_order_edit, 'work_order', ['edit'], 'edit_protector' 
     85  protected_page_group :task_edit, 'task', ['edit'], 'edit_protector' 
    8686  protected_page_group :form_edit, 'form', ['edit'], 'edit_protector' 
    8787  protected_page_group :form_type_wizard, 'form_type', [  'create_step1', 
     
    300300    # Matches for the base of the url 
    301301    form_url_match = url_for(:controller => 'form', :action => 'view') 
    302     work_order_url_match = url_for(:controller => 'work_order', :action => 'view') 
     302    task_url_match = url_for(:controller => 'task', :action => 'view') 
    303303    attachment_url_match = url_for(:controller => 'attachment', :action => 'view') 
    304304    type_attachment_url_match = url_for(:controller => 'type_attachment', :action => 'view') 
     
    311311    output = text.gsub(/#{form_url_match}\/#{params_match}/) { |m| "[#{$~[1]}]" } 
    312312    # Work orders 
    313     output = output.gsub(/#{work_order_url_match}\/#{params_match}/) { |m| "{#{$~[1]}}" } 
     313    output = output.gsub(/#{task_url_match}\/#{params_match}/) { |m| "{#{$~[1]}}" } 
    314314    # Attachments 
    315315    output = output.gsub(/#{attachment_url_match}\/#{params_match}/) { |m| "<#{$~[1]}>" } 
  • branches/workorder_report_rename/app/controllers/asset_permission_controller.rb

    r455 r469  
    159159    @form_available_groups = (all_user_groups - @form_permission_profiles.map {|p| p.user_group }).map {|g| [g.name, g.id] } 
    160160    @form_permission_profiles << FormPermissionProfile.new(:other => true) if @form_permission_profiles.select { |profile| profile.other }.empty? 
    161     @work_order_permission_profiles = @assets_user_group.work_order_permission_profiles.find(:all, :readonly => true) 
    162     @work_order_available_groups = (all_user_groups - @work_order_permission_profiles.map {|p| p.user_group }).map {|g| [g.name, g.id] } 
    163     @work_order_permission_profiles << WorkOrderPermissionProfile.new(:other => true) if @work_order_permission_profiles.select { |profile| profile.other }.empty? 
     161    @task_permission_profiles = @assets_user_group.task_permission_profiles.find(:all, :readonly => true) 
     162    @task_available_groups = (all_user_groups - @task_permission_profiles.map {|p| p.user_group }).map {|g| [g.name, g.id] } 
     163    @task_permission_profiles << TaskPermissionProfile.new(:other => true) if @task_permission_profiles.select { |profile| profile.other }.empty? 
    164164    @attachment_permission_profiles = @assets_user_group.attachment_permission_profiles.find(:all, :readonly => true) 
    165165    @attachment_available_groups = (all_user_groups - @attachment_permission_profiles.map {|p| p.user_group }).map {|g| [g.name, g.id] } 
     
    207207    return unless authorized_to_edit_assets_permissions(asset) 
    208208 
    209     assets_user_group.update_permission_profiles(params[:profile], params[:form], params[:work_order], params[:attachment]) 
     209    assets_user_group.update_permission_profiles(params[:profile], params[:form], params[:task], params[:attachment]) 
    210210 
    211211    flash[:notice] = msg_changes_saved 
  • branches/workorder_report_rename/app/controllers/asset_tree_controller.rb

    r464 r469  
    113113    # redirect to the appropriate list page. 
    114114    return redirect_to(:controller => 'form', :action=> 'list') if request.env['HTTP_REFERER'] =~ /form\/.*$/x 
    115     return redirect_to(:controller => 'work_order', :action=> 'list') if request.env['HTTP_REFERER'] =~ /work_order\/.*$/x 
     115    return redirect_to(:controller => 'task', :action=> 'list') if request.env['HTTP_REFERER'] =~ /task\/.*$/x 
    116116    return redirect_to(:controller => 'attachment', :action=> 'list') if request.env['HTTP_REFERER'] =~ /attachment\/.*$/x 
    117117 
  • branches/workorder_report_rename/app/controllers/data_permission_controller.rb

    r455 r469  
    4646        redirect_with_error_message(msg_unauthorized_operation(_('read'), _('[%d]', @object.id)), 
    4747                                    :controller => 'form', :action => 'index') 
    48       when 'WorkOrder
     48      when 'Task
    4949        redirect_with_error_message(msg_unauthorized_operation(_('read'), _('{%d}', @object.id)), 
    50                                     :controller => 'work_order', :action => 'list') 
     50                                    :controller => 'task', :action => 'list') 
    5151      when 'Attachment' 
    5252        redirect_with_error_message(msg_unauthorized_operation(_('read'), _('<%d>', @object.id)), 
     
    6767 
    6868    case params[:datatype] 
    69       when 'Attachment', 'Form', 'WorkOrder
     69      when 'Attachment', 'Form', 'Task
    7070        protector = Asset.find params[:id] 
    7171      when 'TypeAttachment' 
     
    116116 
    117117  def find_object(datatype, id) 
    118     raise "Invalid datatype" unless ['Form', 'WorkOrder', 'Attachment', 'TypeAttachment'].include?(datatype) 
     118    raise "Invalid datatype" unless ['Form', 'Task', 'Attachment', 'TypeAttachment'].include?(datatype) 
    119119    @object = Object.const_get(datatype).find(id) 
    120120  end 
  • branches/workorder_report_rename/app/controllers/form_controller.rb

    r452 r469  
    5050    end 
    5151 
    52     redirect_to(:action => 'create', :id => params[:form_type][:id], :cause_work_order_id => params[:cause_work_order_id]) and return if request.post? 
     52    redirect_to(:action => 'create', :id => params[:form_type][:id], :cause_task_id => params[:cause_task_id]) and return if request.post? 
    5353 
    5454    @title = _('Select form type to create') 
     
    5959    redirect_with_message(_('No form types defined.'), :back) and return if form_types.empty? 
    6060 
    61     @hidden_fields = [ ['cause_work_order_id', params[:cause_work_order_id].to_i] ] if params[:cause_work_order_id] 
     61    @hidden_fields = [ ['cause_task_id', params[:cause_task_id].to_i] ] if params[:cause_task_id] 
    6262    @fields = [ [_('Form type'), 'form_type', 'id', form_types.collect { |type| [type.name, type.id] }] ] 
    6363    render(:partial => 'shared/select', :layout => 'mainlevel', 
     
    7676    @form = @form_type.create_empty_form(@selected_asset) 
    7777    @form.creator = session[:user] 
    78     @cause_work_order_id = params[:cause_work_order_id] if  params[:cause_work_order_id] 
     78    @cause_task_id = params[:cause_task_id] if  params[:cause_task_id] 
    7979    # Form cookies are used to match image field values in the session 
    8080    # to specific form creation / edit form. 
     
    9797      end 
    9898 
    99       @form.cause_work_order_id = @cause_work_order_id if @cause_work_order_id 
     99      @form.cause_task_id = @cause_task_id if @cause_task_id 
    100100 
    101101      if @form.validate_fields and @form.valid? 
  • branches/workorder_report_rename/app/controllers/overview_controller.rb

    r464 r469  
    2626      when 'forms_by_type' 
    2727        image = generate_forms_by_type_chart 
    28       when 'work_orders_by_status' 
    29         image = generate_work_orders_by_status_chart 
     28      when 'tasks_by_status' 
     29        image = generate_tasks_by_status_chart 
    3030      when 'resource_usage' 
    3131        image = generate_resource_usage_graph  
    32       when 'time_spent_on_work_orders' 
    33         image = generate_time_spent_on_work_orders_chart 
     32      when 'time_spent_on_tasks' 
     33        image = generate_time_spent_on_tasks_chart 
    3434      else 
    3535        image = pie(300, 200, [1, 1], ['Empty', 'Empty']) 
     
    5151  end 
    5252 
    53   def generate_work_orders_by_status_chart 
     53  def generate_tasks_by_status_chart 
    5454    find_selected_assets 
    55     work_order_counts = [WorkOrder.NEW, WorkOrder.ASSIGNED, WorkOrder.ACCEPTED].collect { |state| 
    56       WorkOrder.count_authorized_to(:read, [@selected_assets_condition[0] + ' AND state = ?'] + [@selected_assets_condition[1], state]) 
     55    task_counts = [Task.NEW, Task.ASSIGNED, Task.ACCEPTED].collect { |state| 
     56      Task.count_authorized_to(:read, [@selected_assets_condition[0] + ' AND state = ?'] + [@selected_assets_condition[1], state]) 
    5757    } 
    5858 
    59     return pie(300, 200, work_order_counts, [_('New'), _('Assigned'), _('Accepted')]) 
     59    return pie(300, 200, task_counts, [_('New'), _('Assigned'), _('Accepted')]) 
    6060  end 
    6161 
    62   def generate_time_spent_on_work_orders_chart 
     62  def generate_time_spent_on_tasks_chart 
    6363    find_selected_assets 
    64     times = WorkOrder.average_times_from_open_state(@selected_assets_condition) 
     64    times = Task.average_times_from_open_state(@selected_assets_condition) 
    6565    return bar(300, 200, times, [_('Assigned'), _('Accepted'), _('Closed')]) 
    6666  end 
     
    6868  def generate_resource_usage_graph 
    6969    find_selected_assets 
    70     resource_usage = WorkOrder.calculate_resource_usage(@selected_assets_condition, 2.days, 30.minutes) 
     70    resource_usage = Task.calculate_resource_usage(@selected_assets_condition, 2.days, 30.minutes) 
    7171    return line(300, 200, [resource_usage], [_('Resource usage')]) 
    7272  end 
  • branches/workorder_report_rename/app/controllers/search_controller.rb

    r455 r469  
    3333    search_string.scan(/\{([[:digit:]]+)/) { |id| 
    3434      id = id.first.to_i 
    35       unless WorkOrder.find_in_authorized_assets(:all, :conditions => ['id = ?', id], :readonly => true).empty? 
    36         redirect_to :controller => 'work_order', :action => 'view', :id => id 
     35      unless Task.find_in_authorized_assets(:all, :conditions => ['id = ?', id], :readonly => true).empty? 
     36        redirect_to :controller => 'task', :action => 'view', :id => id 
    3737        return 
    3838      else 
  • branches/workorder_report_rename/app/controllers/timeline_controller.rb

    r464 r469  
    4343    id_conditions = [] 
    4444 
    45     for klass in [Form, WorkOrder, Attachment] 
     45    for klass in [Form, Task, Attachment] 
    4646      ids = klass.find_authorized_to_read(:all, :select => select, :conditions => @selected_assets_condition).collect { |r| r.id } 
    4747      next if ids.empty? 
  • branches/workorder_report_rename/app/controllers/user_controller.rb

    r464 r469  
    132132  def remove 
    133133    common_remove(User, 'login', :action => 'list') { |instance| 
    134       unless instance.work_orders.empty? 
    135         _('Unable to remove user %s, because there are work_orders assigned to this user.', instance.login) 
     134      unless instance.tasks.empty? 
     135        _('Unable to remove user %s, because there are tasks assigned to this user.', instance.login) 
    136136      end 
    137137    } 
  • branches/workorder_report_rename/app/helpers/application_helper.rb

    r464 r469  
    431431  end 
    432432 
    433   # Function: link_to_work_order 
     433  # Function: link_to_task 
    434434  # ============================ 
    435435  # 
     
    438438  # Parameters: 
    439439  # ----------- 
    440   # work_order - Work order to link to 
     440  # task - Work order to link to 
    441441  # link_only  - If true, the 'Work order' text is not displayed. 
    442442  # show_type - If true, the work order's type will be displayed 
    443   def link_to_work_order(work_order, link_only = false, show_type = true) 
    444     return '' unless work_order 
    445  
    446     link_text = work_order.to_s 
    447     link_text += " (#{work_order.work_order_type.name})" if show_type 
    448  
    449     link = link_to(h(link_text), {:controller => 'work_order', :action => 'view', :id => work_order.id}, :class => 'work_order') 
    450     #link_title = h("#{work_order.to_s} (#{work_order.work_order_type.name})") 
    451     #link = "<a href=\"/work_order/view/#{work_order.id}\" class=\"work_order\">#{link_title}</a>" 
     443  def link_to_task(task, link_only = false, show_type = true) 
     444    return '' unless task 
     445 
     446    link_text = task.to_s 
     447    link_text += " (#{task.task_type.name})" if show_type 
     448 
     449    link = link_to(h(link_text), {:controller => 'task', :action => 'view', :id => task.id}, :class => 'task') 
     450    #link_title = h("#{task.to_s} (#{task.task_type.name})") 
     451    #link = "<a href=\"/task/view/#{task.id}\" class=\"task\">#{link_title}</a>" 
    452452    return link if link_only 
    453453    return _('Work order') + ' ' + link 
     
    549549  def from_markup(src) 
    550550    asset_url_prefix = url_for(:controller=>'/asset', :action=>'view', :full_code=>'') 
    551     work_order_url_prefix = url_for(:controller=>'work_order', :action=>'view', :id=>'') 
     551    task_url_prefix = url_for(:controller=>'task', :action=>'view', :id=>'') 
    552552    form_url_prefix = url_for(:controller=>'form', :action=>'view', :id=>'') 
    553553    attachment_url_prefix = url_for(:controller=>'attachment', :action=>'view', :id=>'') 
    554554    type_attachment_url_prefix = url_for(:controller=>'type_attachment', :action=>'view', :id=>'') 
    555     return CMMSMarkup.new(src, asset_url_prefix, work_order_url_prefix, form_url_prefix, attachment_url_prefix, type_attachment_url_prefix).to_html 
     555    return CMMSMarkup.new(src, asset_url_prefix, task_url_prefix, form_url_prefix, attachment_url_prefix, type_attachment_url_prefix).to_html 
    556556  end 
    557557 
  • branches/workorder_report_rename/app/helpers/asset_helper.rb

    r454 r469  
    6464          when 'Form' 
    6565            link_to_form(item, true) 
    66           when 'WorkOrder
    67             link_to_work_order(item, true) 
     66          when 'Task
     67            link_to_task(item, true) 
    6868          when 'Attachment' 
    6969            link_to_attachment(item, true) 
  • branches/workorder_report_rename/app/models/asset.rb

    r464 r469  
    2525  belongs_to :asset_type 
    2626  has_many :forms 
    27   has_many :work_order
     27  has_many :task
    2828  has_many :attachments 
    2929  has_many :assets_user_groups, :dependent => :destroy, :order => 'user_group_id' 
     
    104104  # ----------- 
    105105  # operation - Symbol defining which permission is checked. Possible operations 
    106   #             are :edit, :create_form, :create_work_order, :attach_file, 
     106  #             are :edit, :create_form, :create_task, :attach_file, 
    107107  #             :create_subasset, :edit_permissions, :remove. 
    108108  # 
     
    116116      when :read 
    117117        where_sql = sanitize_sql(['user_group_id IN (?)', group_ids]) 
    118       when :edit, :create_subasset, :edit_permissions, :remove, :create_form, :create_work_order, :attach_file 
     118      when :edit, :create_subasset, :edit_permissions, :remove, :create_form, :create_task, :attach_file 
    119119        where_sql = sanitize_sql(["user_group_id IN (?) AND #{operation} = ?", group_ids, true]) 
    120120      else 
     
    266266  end 
    267267 
    268   # Function: authorized_to_create_work_order
     268  # Function: authorized_to_create_task
    269269  # ========================================== 
    270270  # 
    271   # Returns true if the user is authorized to create work_orders to this asset 
    272   def authorized_to_create_work_order
    273     authorized_to(:create_work_order
     271  # Returns true if the user is authorized to create tasks to this asset 
     272  def authorized_to_create_task
     273    authorized_to(:create_task
    274274  end 
    275275 
     
    351351      when 'Form' 
    352352        return authorized_to_create_form? 
    353       when 'WorkOrder
    354         return authorized_to_create_work_order
     353      when 'Task
     354        return authorized_to_create_task
    355355      when 'Attachment' 
    356356        return authorized_to_attach_file? 
     
    461461        create_permission = 'create_form' 
    462462        permission_profiles = :form_permission_profiles 
    463       when 'WorkOrder
    464         create_permission = 'create_work_order
    465         permission_profiles = :work_order_permission_profiles 
     463      when 'Task
     464        create_permission = 'create_task
     465        permission_profiles = :task_permission_profiles 
    466466      when 'Attachment' 
    467467        create_permission = 'attach_file' 
     
    567567  # ----------- 
    568568  # operation - Symbol defining which permission is checked. Possible operations 
    569   #             are :edit, :create_form, :create_work_order, :attach_file, 
     569  #             are :edit, :create_form, :create_task, :attach_file, 
    570570  #             :create_subasset, :edit_permissions, :remove. 
    571571  def authorized_to(operation) 
     
    584584  # ----------- 
    585585  # operation - Symbol defining which permission is checked. Possible operations 
    586   #             are :edit, :create_form, :create_work_order, :attach_file, 
     586  #             are :edit, :create_form, :create_task, :attach_file, 
    587587  #             :create_subasset, :edit_permissions, :remove. 
    588588  def branch_authorized_to(operation) 
  • branches/workorder_report_rename/app/models/asset_condition_analysis.rb

    r454 r469  
    99  def analyse_service_request_chain 
    1010    result = {} 
    11     cause_form_tag, work_order_tag, effect_form_tag = DataTypeTag.find DataTypeTag::CHAIN['Service request'] 
     11    cause_form_tag, task_tag, effect_form_tag = DataTypeTag.find DataTypeTag::CHAIN['Service request'] 
    1212    cause_form_type_ids = cause_form_tag.form_types.map {|t| t.id } 
    13     work_order_type_ids = work_order_tag.work_order_types.map {|t| t.id } 
     13    task_type_ids = task_tag.task_types.map {|t| t.id } 
    1414    effect_form_type_ids = effect_form_tag.form_types.map {|t| t.id } 
    1515 
    16     unless work_order_type_ids.empty? 
     16    unless task_type_ids.empty? 
    1717      # Find "Service request" forms which haven't led to work orders. 
    1818      unless cause_form_type_ids.empty? 
    1919        # First find ids of forms which have led to work orders. 
    20         cause_form_ids = WorkOrder.find(:all, :select => 'cause_form_id,' + WorkOrder.minimal_select, :conditions => ['asset_id = ? AND work_order_type_id IN (?) AND cause_form_id IS NOT NULL', self.id, work_order_type_ids]).map {|w| w.cause_form_id } 
     20        cause_form_ids = Task.find(:all, :select => 'cause_form_id,' + Task.minimal_select, :conditions => ['asset_id = ? AND task_type_id IN (?) AND cause_form_id IS NOT NULL', self.id, task_type_ids]).map {|w| w.cause_form_id } 
    2121        conditions = ['asset_id = ? AND form_type_id IN (?)', self.id, cause_form_type_ids] 
    2222        unless cause_form_ids.empty? 
     
    2929 
    3030      # Find new "Service" work orders. 
    31       found = WorkOrder.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND work_order_type_id IN (?) AND state = ?', self.id, work_order_type_ids, WorkOrder.NEW], :readonly => true) 
    32       result[:new_works] = [work_order_tag.name, found] unless found.empty? 
     31      found = Task.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND task_type_id IN (?) AND state = ?', self.id, task_type_ids, Task.NEW], :readonly => true) 
     32      result[:new_works] = [task_tag.name, found] unless found.empty? 
    3333 
    3434      # Find "Service" work orders which have been assigned or accepted. 
    35       found = WorkOrder.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND work_order_type_id IN (?) AND state IN (?)', self.id, work_order_type_ids, [WorkOrder.ASSIGNED, WorkOrder.ACCEPTED]], :readonly => true) 
    36       result[:assigned_works] = [work_order_tag.name, found] unless found.empty? 
     35      found = Task.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND task_type_id IN (?) AND state IN (?)', self.id, task_type_ids, [Task.ASSIGNED, Task.ACCEPTED]], :readonly => true) 
     36      result[:assigned_works] = [task_tag.name, found] unless found.empty? 
    3737 
    3838      # Find closed "Service" work orders, which haven't led to "Condition" forms. 
    3939      unless effect_form_type_ids.empty? 
    4040        # First find ids of work orders which have led to forms. 
    41         cause_work_order_ids = Form.find(:all, :select => 'cause_work_order_id,' + Form.minimal_select, :conditions => ['asset_id = ? AND form_type_id IN (?) AND cause_work_order_id IS NOT NULL', self.id, effect_form_type_ids]).map {|w| w.cause_work_order_id } 
    42         conditions = ['asset_id = ? AND work_order_type_id IN (?) AND work_orders.state = ?', self.id, work_order_type_ids, WorkOrder.CLOSED] 
    43         unless cause_work_order_ids.empty? 
    44           conditions[0] += ' AND  work_orders.id NOT IN (?)' 
    45           conditions.push cause_work_order_ids 
    46         end 
    47         found = WorkOrder.find_authorized_to_read(:all, :conditions => conditions, :readonly => true) 
    48         result[:unknown_condition] = [[work_order_tag.name, effect_form_tag.name], found] unless found.empty? 
     41        cause_task_ids = Form.find(:all, :select => 'cause_task_id,' + Form.minimal_select, :conditions => ['asset_id = ? AND form_type_id IN (?) AND cause_task_id IS NOT NULL', self.id, effect_form_type_ids]).map {|w| w.cause_task_id } 
     42        conditions = ['asset_id = ? AND task_type_id IN (?) AND tasks.state = ?', self.id, task_type_ids, Task.CLOSED] 
     43        unless cause_task_ids.empty? 
     44          conditions[0] += ' AND  tasks.id NOT IN (?)' 
     45          conditions.push cause_task_ids 
     46        end 
     47        found = Task.find_authorized_to_read(:all, :conditions => conditions, :readonly => true) 
     48        result[:unknown_condition] = [[task_tag.name, effect_form_tag.name], found] unless found.empty? 
    4949      end 
    5050    end 
     
    6363  def analyse_maintenance_chain 
    6464    result = {} 
    65     cause_work_order_tag, effect_form_tag = DataTypeTag.find DataTypeTag::CHAIN['Maintenance'] 
    66     cause_work_order_type_ids = cause_work_order_tag.work_order_types.map {|t| t.id } 
     65    cause_task_tag, effect_form_tag = DataTypeTag.find DataTypeTag::CHAIN['Maintenance'] 
     66    cause_task_type_ids = cause_task_tag.task_types.map {|t| t.id } 
    6767    effect_form_type_ids = effect_form_tag.form_types.map {|t| t.id } 
    6868 
    69     unless cause_work_order_type_ids.empty? 
     69    unless cause_task_type_ids.empty? 
    7070      # Find new "Maintenance" work orders 
    71       found = WorkOrder.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND work_order_type_id IN (?) AND state = ?', self.id, cause_work_order_type_ids, WorkOrder.NEW]) 
    72       result[:new_works] = [cause_work_order_tag.name, found] unless found.empty? 
     71      found = Task.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND task_type_id IN (?) AND state = ?', self.id, cause_task_type_ids, Task.NEW]) 
     72      result[:new_works] = [cause_task_tag.name, found] unless found.empty? 
    7373 
    7474      # Find "Maintenance" work orders which have been assigned or accepted. 
    75       found = WorkOrder.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND work_order_type_id IN (?) AND state IN (?)', self.id, cause_work_order_type_ids, [WorkOrder.ASSIGNED, WorkOrder.ACCEPTED]]) 
    76       result[:assigned_works] = [cause_work_order_tag.name, found] unless found.empty? 
     75      found = Task.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND task_type_id IN (?) AND state IN (?)', self.id, cause_task_type_ids, [Task.ASSIGNED, Task.ACCEPTED]]) 
     76      result[:assigned_works] = [cause_task_tag.name, found] unless found.empty? 
    7777 
    7878      # Find closed "Maintenance" work orders, which haven't led to "Maintenance" forms. 
    7979      unless effect_form_type_ids.empty? 
    8080        # First find ids of work orders which have led to forms. 
    81         cause_work_order_ids = Form.find(:all, :select => 'cause_work_order_id,' + Form.minimal_select, :conditions => ['asset_id = ? AND form_type_id IN (?) AND cause_work_order_id IS NOT NULL', self.id, effect_form_type_ids]).map {|w| w.cause_work_order_id } 
    82         conditions = ['asset_id = ? AND work_order_type_id IN (?) AND work_orders.state = ?', self.id, cause_work_order_type_ids, WorkOrder.CLOSED] 
    83         unless cause_work_order_ids.empty? 
    84           conditions[0] += ' AND  work_orders.id NOT IN (?)' 
    85           conditions.push cause_work_order_ids 
    86         end 
    87         found = WorkOrder.find_authorized_to_read(:all, :conditions => conditions, :readonly => true) 
    88         result[:unknown_condition] = [[cause_work_order_tag.name, effect_form_tag.name], found] unless found.empty? 
     81        cause_task_ids = Form.find(:all, :select => 'cause_task_id,' + Form.minimal_select, :conditions => ['asset_id = ? AND form_type_id IN (?) AND cause_task_id IS NOT NULL', self.id, effect_form_type_ids]).map {|w| w.cause_task_id } 
     82        conditions = ['asset_id = ? AND task_type_id IN (?) AND tasks.state = ?', self.id, cause_task_type_ids, Task.CLOSED] 
     83        unless cause_task_ids.empty? 
     84          conditions[0] += ' AND  tasks.id NOT IN (?)' 
     85          conditions.push cause_task_ids 
     86        end 
     87        found = Task.find_authorized_to_read(:all, :conditions => conditions, :readonly => true) 
     88        result[:unknown_condition] = [[cause_task_tag.name, effect_form_tag.name], found] unless found.empty? 
    8989      end 
    9090    end 
  • branches/workorder_report_rename/app/models/assets_user_group.rb

    r441 r469  
    2828  has_many :data_permission_profiles, :dependent => :delete_all 
    2929  has_many :form_permission_profiles, :order => 'other', :dependent => :delete_all 
    30   has_many :work_order_permission_profiles, :order => 'other', :dependent => :delete_all 
     30  has_many :task_permission_profiles, :order => 'other', :dependent => :delete_all 
    3131  has_many :attachment_permission_profiles, :order => 'other', :dependent => :delete_all 
    3232 
     
    4343    return true if self.attributes == original_attributes 
    4444 
    45     original_create_form, original_create_work_order, original_attach_file = original_attributes.values_at('create_form', 'create_work_order', 'attach_file') 
     45    original_create_form, original_create_task, original_attach_file = original_attributes.values_at('create_form', 'create_task', 'attach_file') 
    4646 
    4747    begin 
     
    5757          end 
    5858          # For Work orders 
    59           if original_create_work_order == false and self.create_work_order == true 
    60             self.work_order_permission_profiles.create(:user_group_id => self.user_group_id, :group_read => true) 
    61           elsif original_create_work_order == true and self.create_work_order == false 
    62             self.work_order_permission_profiles.clear 
     59          if original_create_task == false and self.create_task == true 
     60            self.task_permission_profiles.create(:user_group_id => self.user_group_id, :group_read => true) 
     61          elsif original_create_task == true and self.create_task == false 
     62            self.task_permission_profiles.clear 
    6363          end 
    6464          # For Attachments 
     
    8383    # If needed update attributes 
    8484    if self.create_form != object.create_form or 
    85         self.create_work_order != object.create_work_order or 
     85        self.create_task != object.create_task or 
    8686        self.attach_file != object.attach_file 
    8787 
    8888      self.attributes = { 
    8989        :create_form => object.create_form, 
    90         :create_work_order => object.create_work_order
     90        :create_task => object.create_task
    9191        :attach_file => object.attach_file 
    9292      } 
     
    152152  # are given, then new other permission profile(s) will be created with 
    153153  # attributes given in hashes +new_*_other_profile+. 
    154   def update_permission_profiles(profiles, new_form_other_profile = nil, new_work_order_other_profile = nil, new_attachment_other_profile = nil) 
     154  def update_permission_profiles(profiles, new_form_other_profile = nil, new_task_other_profile = nil, new_attachment_other_profile = nil) 
    155155    raise("Unauthorized to edit asset #{self.asset.full_code}'s permissions") unless authorized_to_edit? 
    156156 
     
    170170 
    171171      # Create new other profiles if needed. Only use group_* attributes from new_*_other_profile. 
    172       [new_form_other_profile, new_work_order_other_profile, new_attachment_other_profile].each { |attrs| 
     172      [new_form_other_profile, new_task_other_profile, new_attachment_other_profile].each { |attrs| 
    173173        next if attrs.nil? 
    174174        tmp_attrs = attrs.symbolize_keys 
     
    180180      } 
    181181      FormPermissionProfile.create(new_form_other_profile) if new_form_other_profile 
    182       WorkOrderPermissionProfile.create(new_work_order_other_profile) if new_work_order_other_profile 
     182      TaskPermissionProfile.create(new_task_other_profile) if new_task_other_profile 
    183183      AttachmentPermissionProfile.create(new_attachment_other_profile) if new_attachment_other_profile 
    184184    end 
     
    190190  # Returns true if none of the permission profiles for data +data+ has permission to +operation+ true. 
    191191  # +operation+:: defines which permission is checked. Choices are :read, :change_state and :edit. 
    192   # +data+:: defines data type of profiles. Choices are :forms, :work_orders and :attachments. 
     192  # +data+:: defines data type of profiles. Choices are :forms, :tasks and :attachments. 
    193193  # 
    194194  # Example: object.none_can(:read, :forms) 
     
    213213        end 
    214214      } 
    215     when :work_order
    216       self.work_order_permission_profiles.each { |p| 
     215    when :task
     216      self.task_permission_profiles.each { |p| 
    217217        if p.send(attribute) 
    218218          return false 
     
    299299      if childs_group.update_attributes(:edit => self.edit, 
    300300                                           :create_form => self.create_form, 
    301                                            :create_work_order => self.create_work_order
     301                                           :create_task => self.create_task
    302302                                           :attach_file => self.attach_file, 
    303303                                           :create_subasset => self.create_subasset, 
  • branches/workorder_report_rename/app/models/form.rb

    r452 r469  
    1010  # Associations 
    1111  belongs_to :form_type 
    12   belongs_to :cause_work_order, :class_name => 'WorkOrder', :foreign_key => 'cause_work_order_id' # work order which caused this form 
    13   has_one :effect_work_order, :class_name => 'WorkOrder', :foreign_key => 'cause_form_id' # work order which was caused by this form 
     12  belongs_to :cause_task, :class_name => 'Task', :foreign_key => 'cause_task_id' # work order which caused this form 
     13  has_one :effect_task, :class_name => 'Task', :foreign_key => 'cause_form_id' # work order which was caused by this form 
    1414  has_many :form_field_values, :dependent => :delete_all 
    1515  has_many :form_events, :dependent => :delete_all 
  • branches/workorder_report_rename/app/models/form_tag.rb

    r452 r469  
    77  # Callbacks 
    88  # Associations 
    9   belongs_to :cause_work_order_tag, :class_name => 'WorkOrderTag', :foreign_key => 'cause_tag_id' 
    10   has_one :effect_work_order_tag, :class_name => 'WorkOrderTag', :foreign_key => 'cause_tag_id' 
     9  belongs_to :cause_task_tag, :class_name => 'TaskTag', :foreign_key => 'cause_tag_id' 
     10  has_one :effect_task_tag, :class_name => 'TaskTag', :foreign_key => 'cause_tag_id' 
    1111  has_many :form_categories 
    1212  has_many :form_types, :through => :form_categories 
  • branches/workorder_report_rename/app/models/user.rb

    r464 r469  
    2929  has_and_belongs_to_many :keyrings, :uniq => true, :order => 'name' 
    3030  has_and_belongs_to_many :user_groups, :uniq => true, :order => 'name' 
    31   has_and_belongs_to_many :work_order
     31  has_and_belongs_to_many :task
    3232  has_many :received_messages, :foreign_key => 'receiver_user_id', :order => 'created_at', :class_name => 'Message', :dependent => :delete_all 
    3333  has_many :sent_messages, :foreign_key => 'sender_user_id', :order => 'created_at', :class_name => 'Message', :dependent => :delete_all 
     
    100100  end 
    101101 
    102   # WorkOrders assigned to the user 
    103   def work_order
    104     return WorkOrder.find_all_by_responsible_user_id(self.id) 
     102  # Tasks assigned to the user 
     103  def task
     104    return Task.find_all_by_responsible_user_id(self.id) 
    105105  end 
    106106 
  • branches/workorder_report_rename/app/models/user_group.rb

    r441 r469  
    1717  has_many :form_permissions, :dependent => :delete_all 
    1818#  has_many :forms, :through => :form_permissions 
    19   has_many :work_order_permissions, :dependent => :delete_all 
    20 #  has_many :work_orders, :through => :work_order_permissions 
     19  has_many :task_permissions, :dependent => :delete_all 
     20#  has_many :tasks, :through => :task_permissions 
    2121  has_many :attachment_permissions, :dependent => :delete_all 
    2222#  has_many :attachments, :through => :attachment_permissions 
  • branches/workorder_report_rename/app/views/asset_permission/edit.rhtml

    r465 r469  
    1717    <tr> 
    1818      <th><%= _('Create work orders') %></th> 
    19       <td><%= check_box(:assets_user_group, :create_work_order) %></td> 
     19      <td><%= check_box(:assets_user_group, :create_task) %></td> 
    2020    </tr> 
    2121    <tr> 
     
    4141<%= end_form_tag %> 
    4242 
    43 <% if @assets_user_group.create_form or @assets_user_group.create_work_order or @assets_user_group.attach_file -%> 
     43<% if @assets_user_group.create_form or @assets_user_group.create_task or @assets_user_group.attach_file -%> 
    4444  <% if @assets_user_group.create_form -%> 
    4545    <h3><%= _('Default permissions for forms created by user group "%s"', h(@user_group.name)) %></h3> 
     
    5151                           :object_name => 'form'}) %> 
    5252  <% end -%> 
    53   <% if @assets_user_group.create_work_order -%> 
     53  <% if @assets_user_group.create_task -%> 
    5454    <h3><%= _('Default permissions for work orders created by user group "%s"', h(@user_group.name)) %></h3> 
    55     <%= render(:partial => 'profiles', :object => @work_order_permission_profiles, 
    56                :locals => {:type => 'WorkOrderPermissionProfile', 
    57                            :available_groups => @work_order_available_groups, 
     55    <%= render(:partial => 'profiles', :object => @task_permission_profiles, 
     56               :locals => {:type => 'TaskPermissionProfile', 
     57                           :available_groups => @task_available_groups, 
    5858                           :view_text => _('View work order'), 
    5959                           :edit_text => _('Edit work order'), 
    6060          &