Class: TimelogController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- TimelogController
- Includes:
- CustomFieldsHelper, SortHelper, TimelogHelper
- Defined in:
- app/controllers/timelog_controller.rb
Overview
– copyright ChiliProject is a project management system.
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
See doc/COPYRIGHT.rdoc for more details. ++
Constant Summary
Constant Summary
Constants included from ApplicationHelper
ApplicationHelper::HEADING_RE, ApplicationHelper::RELATIVE_LINK_RE, ApplicationHelper::TOC_RE
Instance Method Summary (collapse)
- - (Object) create
- - (Object) destroy
- - (Object) edit
- - (Object) index
- - (Object) new
- - (Object) show
- - (Object) update
Methods included from CustomFieldsHelper
#custom_field_formats_for_select, #custom_field_label_tag, #custom_field_tag, #custom_field_tag_for_bulk_edit, #custom_field_tag_with_label, #custom_fields_tabs, #format_value, #render_api_custom_values, #show_value
Methods included from TimelogHelper
#activity_collection_for_select_options, #entries_to_csv, #format_criteria_value, #options_for_period_select, #render_timelog_breadcrumb, #report_criteria_to_csv, #report_to_csv, #select_hours, #sum_hours, #to_utf8_for_timelogs
Methods included from ApplicationHelper
#accesskey, #api_meta, #authoring, #authorize_for, #avatar, #back_url_hidden_field_tag, #body_css_classes, #breadcrumb, #calendar_for, #check_all_links, #checked_image, #content_for, #context_menu, #context_menu_link, #current_theme, #due_date_distance_in_words, #expand_current_menu, #favicon, #format_activity_day, #format_activity_description, #format_activity_title, #format_version_name, #gravatar, #has_content?, #heads_for_theme, #help_menu_item, #html_hours, #html_title, #image_to_function, #include_in_api_response?, #javascript_heads, #jquery_datepicker_settings, #label_tag_for, #labelled_tabular_form_for, #lang_options_for_select, #link_to_attachment, #link_to_if_authorized, #link_to_issue, #link_to_message, #link_to_project, #link_to_remote_if_authorized, #link_to_revision, #link_to_user, #list_users, #main_top_menu_items, #more_top_menu_items, #other_formats_links, #page_header_title, #pagination_links_full, #parse_headings, #parse_inline_attachments, #parse_non_pre_blocks, #parse_redmine_links, #parse_relative_urls, #parse_wiki_links, #path_to_stylesheet, #per_page_links, #principals_check_box_tags, #progress_bar, #project_nested_ul, #project_tree, #project_tree_options_for_select, #projects_check_box_tags, #prompt_to_remote, #render_flash_messages, #render_page_hierarchy, #render_project_jump_box, #render_tabs, #reorder_links, #replace_toc, #robot_exclusion_tag, #simple_format_without_paragraph, #split_top_menu_into_main_or_more_menus, #stylesheet_path, #syntax_highlight, #textilizable, #time_tag, #to_path_param, #toggle_link, #truncate_lines, #truncate_single_line
Methods included from Redmine::I18n
#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages
Methods included from SortHelper
#sort_clause, #sort_clear, #sort_header_tag, #sort_init, #sort_link, #sort_name, #sort_update
Methods included from Redmine::MenuManager::MenuController
#current_menu_item, included, #menu_items, #redirect_to_project_menu_item
Methods included from Redmine::Search::Controller
#default_search_scope, #default_search_scopes, included
Instance Method Details
- (Object) create
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'app/controllers/timelog_controller.rb', line 107 def create @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today) @time_entry.safe_attributes = params[:time_entry] call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) if @time_entry.save respond_to do |format| format.html { flash[:notice] = l(:notice_successful_update) redirect_back_or_default :action => 'index', :project_id => @time_entry.project } format.api { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) } end else respond_to do |format| format.html { render :action => 'edit' } format.api { render_validation_errors(@time_entry) } end end end |
- (Object) destroy
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'app/controllers/timelog_controller.rb', line 158 def destroy if @time_entry.destroy && @time_entry.destroyed? respond_to do |format| format.html { flash[:notice] = l(:notice_successful_delete) redirect_to :back } format.api { head :ok } end else respond_to do |format| format.html { flash[:error] = l(:notice_unable_delete_time_entry) redirect_to :back } format.api { render_validation_errors(@time_entry) } end end rescue ::ActionController::RedirectBackError redirect_to :action => 'index', :project_id => @time_entry.project end |
- (Object) edit
129 130 131 132 133 |
# File 'app/controllers/timelog_controller.rb', line 129 def edit @time_entry.safe_attributes = params[:time_entry] call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) end |
- (Object) index
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/timelog_controller.rb', line 27 def index sort_init 'spent_on', 'desc' sort_update 'spent_on' => 'spent_on', 'user' => 'user_id', 'activity' => 'activity_id', 'project' => "#{Project.table_name}.name", 'issue' => 'issue_id', 'hours' => 'hours' cond = ARCondition.new if @issue cond << "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}" elsif @project cond << @project.project_condition(Setting.display_subprojects_issues?) end retrieve_date_range cond << ['spent_on BETWEEN ? AND ?', @from, @to] respond_to do |format| format.html { # Paginate results @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions) @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page'] @entries = TimeEntry.visible.find(:all, :include => [:project, :activity, :user, {:issue => :tracker}], :conditions => cond.conditions, :order => sort_clause, :limit => @entry_pages.items_per_page, :offset => @entry_pages.current.offset) @total_hours = TimeEntry.visible.sum(:hours, :include => [:project, :issue], :conditions => cond.conditions).to_f render :layout => !request.xhr? } format.api { @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions) @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page'] @entries = TimeEntry.visible.find(:all, :include => [:project, :activity, :user, {:issue => :tracker}], :conditions => cond.conditions, :order => sort_clause, :limit => @entry_pages.items_per_page, :offset => @entry_pages.current.offset) } format.atom { entries = TimeEntry.visible.find(:all, :include => [:project, :activity, :user, {:issue => :tracker}], :conditions => cond.conditions, :order => "#{TimeEntry.table_name}.created_on DESC", :limit => Setting.feeds_limit.to_i) render_feed(entries, :title => l(:label_spent_time)) } format.csv { # Export all entries @entries = TimeEntry.visible.find(:all, :include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], :conditions => cond.conditions, :order => sort_clause) send_data(entries_to_csv(@entries), :type => 'text/csv; header=present', :filename => 'timelog.csv') } end end |
- (Object) new
98 99 100 101 102 103 104 |
# File 'app/controllers/timelog_controller.rb', line 98 def new @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today) @time_entry.safe_attributes = params[:time_entry] call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) render :action => 'edit' end |
- (Object) show
90 91 92 93 94 95 96 |
# File 'app/controllers/timelog_controller.rb', line 90 def show respond_to do |format| # TODO: Implement html response format.html { render :nothing => true, :status => 406 } format.api end end |
- (Object) update
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'app/controllers/timelog_controller.rb', line 136 def update @time_entry.safe_attributes = params[:time_entry] call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) if @time_entry.save respond_to do |format| format.html { flash[:notice] = l(:notice_successful_update) redirect_back_or_default :action => 'index', :project_id => @time_entry.project } format.api { head :ok } end else respond_to do |format| format.html { render :action => 'edit' } format.api { render_validation_errors(@time_entry) } end end end |