Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
74434d559e
4 changed files with 95 additions and 0 deletions
56
app/controllers/taskbar_controller.rb
Normal file
56
app/controllers/taskbar_controller.rb
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
class TaskbarController < ApplicationController
|
||||||
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
def index
|
||||||
|
|
||||||
|
current_user_tasks = Taskbar.where(:user_id=>current_user.id)
|
||||||
|
model_index_render_result(current_user_tasks)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
taskbar = Taskbar.find(params[:id])
|
||||||
|
|
||||||
|
if taskbar.user_id != current_user.id
|
||||||
|
render :json => { :error => 'Not allowed to show this task.' }, :status => :unprocessable_entity
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
model_show_render_item(taskbar)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
|
||||||
|
params[:user_id] = current_user.id
|
||||||
|
model_create_render(Taskbar,params)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
params[:user_id] = current_user.id
|
||||||
|
taskbar = Taskbar.find(params[:id])
|
||||||
|
|
||||||
|
if taskbar.user_id != current_user.id
|
||||||
|
render :json => { :error => 'Not allowed to update this task.' }, :status => :unprocessable_entity
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
model_update_render_item(taskbar)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
|
||||||
|
params[:user_id] = current_user.id
|
||||||
|
taskbar = Taskbar.find(params[:id])
|
||||||
|
|
||||||
|
if taskbar.user_id != current_user.id
|
||||||
|
render :json => { :error => 'Not allowed to delete this task.' }, :status => :unprocessable_entity
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
model_destory_render_item()
|
||||||
|
taskbar.destroy
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
12
app/models/taskbar.rb
Normal file
12
app/models/taskbar.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class Taskbar < ApplicationModel
|
||||||
|
|
||||||
|
store :state
|
||||||
|
store :params
|
||||||
|
before_create :update_last_contact
|
||||||
|
before_update :update_last_contact
|
||||||
|
|
||||||
|
private
|
||||||
|
def update_last_contact
|
||||||
|
self.last_contact = Time.now
|
||||||
|
end
|
||||||
|
end
|
10
config/routes/taskbar.rb
Normal file
10
config/routes/taskbar.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
module ExtraRoutes
|
||||||
|
def add(map)
|
||||||
|
map.match '/api/taskbar', :to => 'taskbar#index', :via => :get
|
||||||
|
map.match '/api/taskbar/:id', :to => 'taskbar#show', :via => :get
|
||||||
|
map.match '/api/taskbar', :to => 'taskbar#create', :via => :post
|
||||||
|
map.match '/api/taskbar/:id', :to => 'taskbar#update', :via => :put
|
||||||
|
map.match '/api/taskbar/:id', :to => 'taskbar#destroy', :via => :delete
|
||||||
|
end
|
||||||
|
module_function :add
|
||||||
|
end
|
17
db/migrate/20130529124443_taskbar.rb
Normal file
17
db/migrate/20130529124443_taskbar.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
class Taskbar < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
create_table :taskbars do |t|
|
||||||
|
t.column :user_id, :integer, :null => false
|
||||||
|
t.column :last_contact, :datetime, :null => false
|
||||||
|
t.column :client_id, :string, :null => false
|
||||||
|
t.column :state, :string, :limit => 8000,:null => true
|
||||||
|
t.column :params, :string, :limit => 2000,:null => true
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
drop_table :taskbars
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue