Class: Api::V1::WorkUnitsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/api/v1/work_units_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/api/v1/work_units_controller.rb', line 13

def create
  @work_unit = WorkUnit.new(params[:work_unit])
  @work_unit.user = current_user
  if @work_unit.save
    render :json => {:success => true} and return
  else
    Rails.logger.warn @work_unit.errors.full_messages.to_sentence
    render :json => {:succes => false, :errors => @work_unit.errors.full_messages.to_sentence} and return
  end
end

#indexObject



2
3
4
5
6
7
8
9
10
11
# File 'app/controllers/api/v1/work_units_controller.rb', line 2

def index
  get_calendar_details
  bucket = WorkUnit.scheduled_between(@start_date, @start_date + 6.days)
  if params[:external_only]
    client = SiteSettings.first.try(:client)
    bucket = bucket.except_client(client)
  end
  @work_units = bucket.all
  render :json => @work_units
end