Class: TaskTypesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/task_types_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#robot?

Instance Method Details

#createObject

POST /task_types POST /task_types.xml



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/controllers/task_types_controller.rb', line 57

def create
  if !(current_user.is_admin? || current_user.is_staff?)
    flash[:error] = "You don't have permission to do this action."
    redirect_to(task_types_url) and return
  end

  @task_type = TaskType.new(params[:task_type])

  respond_to do |format|
    if @task_type.save
      flash[:notice] = 'TaskType was successfully created.'
      format.html { redirect_to(@task_type) }
      format.xml { render :xml => @task_type, :status => :created, :location => @task_type }
    else
      format.html { render :action => "new" }
      format.xml { render :xml => @task_type.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /task_types/1 DELETE /task_types/1.xml



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'app/controllers/task_types_controller.rb', line 101

def destroy
  if !current_user.is_admin?
    flash[:error] = 'You don' 't have permission to do this action.'
    redirect_to(task_types_url) and return
  end

  @task_type = TaskType.find(params[:id])
  @task_type.destroy

  respond_to do |format|
    format.html { redirect_to(task_types_url) }
    format.xml { head :ok }
  end
end

#editObject

GET /task_types/1/edit



46
47
48
49
50
51
52
53
# File 'app/controllers/task_types_controller.rb', line 46

def edit
  if !(current_user.is_admin? || current_user.is_staff?)
    flash[:error] = "You don't have permission to do this action."
    redirect_to(task_type_url) and return
  end

  @task_type = TaskType.find(params[:id])
end

#indexObject

GET /task_types GET /task_types.xml



8
9
10
11
12
13
14
15
16
# File 'app/controllers/task_types_controller.rb', line 8

def index
#    @task_types = TaskType.locate_appropriate_by_user_type
  @task_types = locate_appropriate_by_user_type
  ##
  respond_to do |format|
    format.html # index.html.erb
    format.xml { render :xml => @task_types }
  end
end

#newObject

GET /task_types/new GET /task_types/new.xml



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/task_types_controller.rb', line 31

def new
  if !(current_user.is_admin? || current_user.is_staff?)
    flash[:error] = "You don't have permission to do this action."
    redirect_to(task_types_url) and return
  end

  @task_type = TaskType.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml { render :xml => @task_type }
  end
end

#showObject

GET /task_types/1 GET /task_types/1.xml



20
21
22
23
24
25
26
27
# File 'app/controllers/task_types_controller.rb', line 20

def show
  @task_type = TaskType.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.xml { render :xml => @task_type }
  end
end

#updateObject

PUT /task_types/1 PUT /task_types/1.xml



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'app/controllers/task_types_controller.rb', line 79

def update
  if !(current_user.is_admin? || current_user.is_staff?)
    flash[:error] = "You don't have permission to do this action."
    redirect_to(task_type_url) and return
  end

  @task_type = TaskType.find(params[:id])

  respond_to do |format|
    if @task_type.update_attributes(params[:task_type])
      flash[:notice] = 'TaskType was successfully updated.'
      format.html { redirect_to(@task_type) }
      format.xml { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml { render :xml => @task_type.errors, :status => :unprocessable_entity }
    end
  end
end