Sha256: e3282c860e0279dd4a0bf597428cf66f161f2d6a8d2c398c204551616eec1bdb
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
module Api module V1 class TicketTasksController < ApplicationController before_filter :api_authenticate! before_filter :find_project_and_ticket before_filter :find_task, only: [:update, :destroy] skip_before_filter :verify_authenticity_token attr_reader :project, :ticket, :task rescue_from ActiveRecord::RecordNotFound do head 404 end def index authorize! :read, Task render json: ticket.tasks.map { |task| present_task(task) } end def create task = ticket.tasks.build params.slice(:description, :effort) authorize! :create, task task.updated_by = current_user if task.save render json: present_task(task), status: :created else render json: {errors: task.errors.full_messages}, status: :unprocessable_entity end end def update authorize! :update, task task.attributes = params.slice(:description, :effort) task.updated_by = current_user if task.save head :ok else render json: {errors: task.errors.full_messages}, status: :unprocessable_entity end end def destroy authorize! :destroy, task task.destroy head :ok end private def present_task(task) { id: task.id, number: task.number, letter: task.letter, description: task.description, effort: task.effort, committedAt: task.first_commit_at, releasedAt: task.first_release_at, completedAt: task.completed_at } end def find_project_and_ticket @project = Project.find_by_slug! params[:slug] @ticket = project.tickets.find_by_number! params[:number] end def find_task @task = ticket.tasks.find params[:id] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
houston-core-0.5.0.beta1 | app/controllers/api/v1/ticket_tasks_controller.rb |