Class: Dashboard::BaseController

Inherits:
Xrono::ApplicationController
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper
Defined in:
app/controllers/dashboard/base_controller.rb

Instance Method Summary collapse

Instance Method Details

#calendarObject



37
38
# File 'app/controllers/dashboard/base_controller.rb', line 37

def calendar
end

#clientObject



24
25
26
27
28
29
30
# File 'app/controllers/dashboard/base_controller.rb', line 24

def client
  @projects = Project.order("name").incomplete.for_client_id(params[:id])
  unless admin?
    @projects = @projects.for_user_and_role(current_user, :developer)
  end
  respond_with @projects
end

#indexObject



14
15
16
17
18
19
20
21
22
# File 'app/controllers/dashboard/base_controller.rb', line 14

def index
  @message = {:title => t(:management), :body => t(:enter_time_for_previous_day)} unless current_user.entered_time_yesterday?
  @clients = Client.order("name").active.for_user(current_user)
  @projects = []
  @tickets = []

  # NOTE: The following line is shameful
  @project_report_rows = WorkUnit.for_user(current_user).scheduled_between(Time.zone.now - 2.weeks, Time.zone.now.end_of_day).joins(:ticket => :project).select("projects.name as project_name, projects.id as project_id, SUM(work_units.effective_hours) as total_hours").group("projects.name, projects.id").sort_by{|r| r.total_hours}.reverse # Sort in ruby because I ran into sql problems - should be sorting like 5 rows max so no worries
end

#json_indexObject



7
8
9
10
11
12
# File 'app/controllers/dashboard/base_controller.rb', line 7

def json_index
  bucket = decide_bucket
  bucket = bucket.for_user(current_user) unless params["all"] == "true"
  bucket.order("name")
  render :json => bucket.all
end

#load_work_unitsObject



40
41
42
# File 'app/controllers/dashboard/base_controller.rb', line 40

def load_work_units
  @work_units = current_user.work_units_between(@start_date, @start_date + 6.days)
end

#projectObject



32
33
34
35
# File 'app/controllers/dashboard/base_controller.rb', line 32

def project
  @tickets = Ticket.order("name").incomplete.where("project_id = ?", params[:id])
  respond_with @tickets
end

#update_calendarObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/dashboard/base_controller.rb', line 44

def update_calendar
  respond_to do |format|
    format.js {
      render :json => {
        :success => true,
        :data => render_to_string(
          :partial => 'shared/calendar',
          :locals => {
            :start_date => @start_date,
            :work_units => @work_units,
            :user => current_user
          }
        ),
        :week_pagination => render_to_string(
          :partial => 'dashboard/base/week_pagination',
          :locals => {
            :start_date => @start_date
          }
        )
      }
    }
  end
end