Code cleanup, we only use json as backend.
This commit is contained in:
parent
a7bfbccd99
commit
9903473076
9 changed files with 139 additions and 374 deletions
|
@ -2,85 +2,47 @@ class GroupsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
# GET /groups
|
# GET /groups
|
||||||
# GET /groups.json
|
|
||||||
def index
|
def index
|
||||||
@groups = Group.all
|
@groups = Group.all
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @groups
|
||||||
format.html # index.html.erb
|
|
||||||
format.json { render :json => @groups }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /groups/1
|
# GET /groups/1
|
||||||
# GET /groups/1.json
|
|
||||||
def show
|
def show
|
||||||
@group = Group.find(params[:id])
|
@group = Group.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @group
|
||||||
format.html # show.html.erb
|
|
||||||
format.json { render :json => @group }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /groups/new
|
|
||||||
# GET /groups/new.json
|
|
||||||
def new
|
|
||||||
@group = Group.new
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html # new.html.erb
|
|
||||||
format.json { render :json => @group }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /groups/1/edit
|
|
||||||
def edit
|
|
||||||
@group = Group.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /groups
|
# POST /groups
|
||||||
# POST /groups.json
|
|
||||||
def create
|
def create
|
||||||
@group = Group.new(params[:group])
|
@group = Group.new(params[:group])
|
||||||
@group.created_by_id = current_user.id
|
@group.created_by_id = current_user.id
|
||||||
|
|
||||||
respond_to do |format|
|
if @group.save
|
||||||
if @group.save
|
render :json => @group, :status => :created
|
||||||
format.html { redirect_to @group, :notice => 'Group was successfully created.' }
|
else
|
||||||
format.json { render :json => @group, :status => :created }
|
render :json => @group.errors, :status => :unprocessable_entity
|
||||||
else
|
|
||||||
format.html { render :action => "new" }
|
|
||||||
format.json { render :json => @group.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /groups/1
|
# PUT /groups/1
|
||||||
# PUT /groups/1.json
|
|
||||||
def update
|
def update
|
||||||
@group = Group.find(params[:id])
|
@group = Group.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
if @group.update_attributes(params[:group])
|
||||||
if @group.update_attributes(params[:group])
|
render :json => @group, :status => :ok
|
||||||
format.html { redirect_to @group, :notice => 'Group was successfully updated.' }
|
else
|
||||||
format.json { render :json => @group, :status => :ok }
|
render :json => @group.errors, :status => :unprocessable_entity
|
||||||
else
|
|
||||||
format.html { render :action => "edit" }
|
|
||||||
format.json { render :json => @group.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /groups/1
|
# DELETE /groups/1
|
||||||
# DELETE /groups/1.json
|
|
||||||
def destroy
|
def destroy
|
||||||
@group = Group.find(params[:id])
|
@group = Group.find(params[:id])
|
||||||
@group.destroy
|
@group.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
head :ok
|
||||||
format.html { redirect_to groups_url }
|
|
||||||
format.json { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,85 +2,47 @@ class OrganizationsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
# GET /organizations
|
# GET /organizations
|
||||||
# GET /organizations.json
|
|
||||||
def index
|
def index
|
||||||
@organizations = Organization.all
|
@organizations = Organization.all
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @organizations
|
||||||
format.html # index.html.erb
|
|
||||||
format.json { render :json => @organizations }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /organizations/1
|
# GET /organizations/1
|
||||||
# GET /organizations/1.json
|
|
||||||
def show
|
def show
|
||||||
@organization = Organization.find(params[:id])
|
@organization = Organization.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @organization
|
||||||
format.html # show.html.erb
|
|
||||||
format.json { render :json => @organization }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /organizations/new
|
|
||||||
# GET /organizations/new.json
|
|
||||||
def new
|
|
||||||
@organization = Organization.new
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html # new.html.erb
|
|
||||||
format.json { render :json => @organization }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /organizations/1/edit
|
|
||||||
def edit
|
|
||||||
@organization = Organization.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /organizations
|
# POST /organizations
|
||||||
# POST /organizations.json
|
|
||||||
def create
|
def create
|
||||||
@organization = Organization.new(params[:organization])
|
@organization = Organization.new(params[:organization])
|
||||||
@organization.created_by_id = current_user.id
|
@organization.created_by_id = current_user.id
|
||||||
|
|
||||||
respond_to do |format|
|
if @organization.save
|
||||||
if @organization.save
|
render :json => @organization, :status => :created
|
||||||
format.html { redirect_to @organization, :notice => 'Organization was successfully created.' }
|
else
|
||||||
format.json { render :json => @organization, :status => :created }
|
render :json => @organization.errors, :status => :unprocessable_entity
|
||||||
else
|
|
||||||
format.html { render :action => "new" }
|
|
||||||
format.json { render :json => @organization.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /organizations/1
|
# PUT /organizations/1
|
||||||
# PUT /organizations/1.json
|
|
||||||
def update
|
def update
|
||||||
@organization = Organization.find(params[:id])
|
@organization = Organization.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
if @organization.update_attributes(params[:organization])
|
||||||
if @organization.update_attributes(params[:organization])
|
render :json => @organization, :status => :ok
|
||||||
format.html { redirect_to @organization, :notice => 'Organization was successfully updated.' }
|
else
|
||||||
format.json { render :json => @organization, :status => :ok }
|
render :json => @organization.errors, :status => :unprocessable_entity
|
||||||
else
|
|
||||||
format.html { render :action => "edit" }
|
|
||||||
format.json { render :json => @organization.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /organizations/1
|
# DELETE /organizations/1
|
||||||
# DELETE /organizations/1.json
|
|
||||||
def destroy
|
def destroy
|
||||||
@organization = Organization.find(params[:id])
|
@organization = Organization.find(params[:id])
|
||||||
@organization.destroy
|
@organization.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
head :ok
|
||||||
format.html { redirect_to organizations_url }
|
|
||||||
format.json { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,85 +2,54 @@ class RolesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
# GET /roles
|
# GET /roles
|
||||||
# GET /roles.json
|
|
||||||
def index
|
def index
|
||||||
@roles = Role.all
|
@roles = Role.all
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @roles
|
||||||
format.html # index.html.erb
|
|
||||||
format.json { render :json => @roles }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /roles/1
|
# GET /roles/1
|
||||||
# GET /roles/1.json
|
|
||||||
def show
|
def show
|
||||||
@role = Role.find(params[:id])
|
@role = Role.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @role
|
||||||
format.html # show.html.erb
|
|
||||||
format.json { render :json => @role }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /roles/new
|
# GET /roles/new
|
||||||
# GET /roles/new.json
|
|
||||||
def new
|
def new
|
||||||
@role = Role.new
|
@role = Role.new
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @role
|
||||||
format.html # new.html.erb
|
|
||||||
format.json { render :json => @role }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /roles/1/edit
|
|
||||||
def edit
|
|
||||||
@role = Role.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /roles
|
# POST /roles
|
||||||
# POST /roles.json
|
|
||||||
def create
|
def create
|
||||||
@role = Role.new(params[:role])
|
@role = Role.new(params[:role])
|
||||||
@role.created_by_id = current_user.id
|
@role.created_by_id = current_user.id
|
||||||
|
|
||||||
respond_to do |format|
|
if @role.save
|
||||||
if @role.save
|
render :json => @role, :status => :created
|
||||||
format.html { redirect_to @role, :notice => 'Role was successfully created.' }
|
else
|
||||||
format.json { render :json => @role, :status => :created }
|
render :json => @role.errors, :status => :unprocessable_entity
|
||||||
else
|
|
||||||
format.html { render :action => "new" }
|
|
||||||
format.json { render :json => @role.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /roles/1
|
# PUT /roles/1
|
||||||
# PUT /roles/1.json
|
|
||||||
def update
|
def update
|
||||||
@role = Role.find(params[:id])
|
@role = Role.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
if @role.update_attributes(params[:role])
|
||||||
if @role.update_attributes(params[:role])
|
render :json => @role, :status => :ok
|
||||||
format.html { redirect_to @role, :notice => 'Role was successfully updated.' }
|
else
|
||||||
format.json { render :json => @role, :status => :ok }
|
render :json => @role.errors, :status => :unprocessable_entity
|
||||||
else
|
|
||||||
format.html { render :action => "edit" }
|
|
||||||
format.json { render :json => @role.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /roles/1
|
# DELETE /roles/1
|
||||||
# DELETE /roles/1.json
|
|
||||||
def destroy
|
def destroy
|
||||||
@role = Role.find(params[:id])
|
@role = Role.find(params[:id])
|
||||||
@role.destroy
|
@role.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
head :ok
|
||||||
format.html { redirect_to roles_url }
|
|
||||||
format.json { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,76 +2,46 @@ class SettingsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
# GET /settings
|
# GET /settings
|
||||||
# GET /settings.json
|
|
||||||
def index
|
def index
|
||||||
@settings = Setting.all
|
@settings = Setting.all
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @settings
|
||||||
format.json { render :json => @settings }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /settings/1
|
# GET /settings/1
|
||||||
# GET /settings/1.json
|
|
||||||
def show
|
def show
|
||||||
@setting = Setting.find(params[:id])
|
@setting = Setting.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @setting
|
||||||
format.json { render :json => @setting }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /settings/new
|
|
||||||
# GET /settings/new.json
|
|
||||||
def new
|
|
||||||
@setting = Setting.new
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.json { render :json => @setting }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /settings/1/edit
|
|
||||||
def edit
|
|
||||||
@setting = Setting.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /settings
|
# POST /settings
|
||||||
# POST /settings.json
|
|
||||||
def create
|
def create
|
||||||
@setting = Setting.new(params[:setting])
|
@setting = Setting.new(params[:setting])
|
||||||
|
|
||||||
respond_to do |format|
|
if @setting.save
|
||||||
if @setting.save
|
render :json => @setting, :status => :created
|
||||||
format.json { render :json => @setting, :status => :created }
|
else
|
||||||
else
|
render :json => @setting.errors, :status => :unprocessable_entity
|
||||||
format.json { render :json => @setting.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /settings/1
|
# PUT /settings/1
|
||||||
# PUT /settings/1.json
|
|
||||||
def update
|
def update
|
||||||
@setting = Setting.find(params[:id])
|
@setting = Setting.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
if @setting.update_attributes(params[:setting])
|
||||||
if @setting.update_attributes(params[:setting])
|
render :json => @setting, :status => :ok
|
||||||
format.json { render :json => @setting, :status => :ok }
|
else
|
||||||
else
|
render :json => @setting.errors, :status => :unprocessable_entity
|
||||||
format.json { render :json => @setting.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /settings/1
|
# DELETE /settings/1
|
||||||
# DELETE /settings/1.json
|
|
||||||
def destroy
|
def destroy
|
||||||
@setting = Setting.find(params[:id])
|
@setting = Setting.find(params[:id])
|
||||||
@setting.destroy
|
@setting.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
head :ok
|
||||||
format.json { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,27 +2,20 @@ class TicketArticlesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
# GET /articles
|
# GET /articles
|
||||||
# GET /articles.json
|
|
||||||
def index
|
def index
|
||||||
@articles = Ticket::Article.all
|
@articles = Ticket::Article.all
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @articles
|
||||||
format.json { render :json => @articles }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /articles/1
|
# GET /articles/1
|
||||||
# GET /articles/1.json
|
|
||||||
def show
|
def show
|
||||||
@article = Ticket::Article.find(params[:id])
|
@article = Ticket::Article.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @article
|
||||||
format.json { render :json => @article }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /articles
|
# POST /articles
|
||||||
# POST /articles.json
|
|
||||||
def create
|
def create
|
||||||
@article = Ticket::Article.new(params[:ticket_article])
|
@article = Ticket::Article.new(params[:ticket_article])
|
||||||
@article.created_by_id = current_user.id
|
@article.created_by_id = current_user.id
|
||||||
|
@ -33,43 +26,35 @@ class TicketArticlesController < ApplicationController
|
||||||
:o_id => @article.ticket_id
|
:o_id => @article.ticket_id
|
||||||
)
|
)
|
||||||
|
|
||||||
respond_to do |format|
|
if @article.save
|
||||||
if @article.save
|
render :json => @article, :status => :created
|
||||||
format.json { render :json => @article, :status => :created }
|
|
||||||
|
|
||||||
# remove attachments from upload cache
|
# remove attachments from upload cache
|
||||||
Store.remove(
|
Store.remove(
|
||||||
:object => 'UploadCache::TicketZoom::' + current_user.id.to_s,
|
:object => 'UploadCache::TicketZoom::' + current_user.id.to_s,
|
||||||
:o_id => @article.ticket_id
|
:o_id => @article.ticket_id
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
format.json { render :json => @article.errors, :status => :unprocessable_entity }
|
render :json => @article.errors, :status => :unprocessable_entity
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /articles/1
|
# PUT /articles/1
|
||||||
# PUT /articles/1.json
|
|
||||||
def update
|
def update
|
||||||
@article = Ticket::Article.find(params[:id])
|
@article = Ticket::Article.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
if @article.update_attributes(params[:ticket_article])
|
||||||
if @article.update_attributes(params[:ticket_article])
|
render :json => @article, :status => :ok
|
||||||
format.json { render :json => @article, :status => :ok }
|
else
|
||||||
else
|
render :json => @article.errors, :status => :unprocessable_entity
|
||||||
format.json { render :json => @article.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /articles/1
|
# DELETE /articles/1
|
||||||
# DELETE /articles/1.json
|
|
||||||
def destroy
|
def destroy
|
||||||
@article = Ticket::Article.find(params[:id])
|
@article = Ticket::Article.find(params[:id])
|
||||||
@article.destroy
|
@article.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
head :ok
|
||||||
format.json { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,61 +2,46 @@ class TicketPrioritiesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
# GET /ticket_priorities
|
# GET /ticket_priorities
|
||||||
# GET /ticket_priorities.json
|
|
||||||
def index
|
def index
|
||||||
@ticket_priorities = Ticket::Priority.all
|
@ticket_priorities = Ticket::Priority.all
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @ticket_priorities
|
||||||
format.json { render :json => @ticket_priorities }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /ticket_priorities/1
|
# GET /ticket_priorities/1
|
||||||
# GET /ticket_priorities/1.json
|
|
||||||
def show
|
def show
|
||||||
@ticket_priority = Ticket::Priority.find(params[:id])
|
@ticket_priority = Ticket::Priority.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @ticket_priority
|
||||||
format.json { render :json => @ticket_priority }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /ticket_priorities
|
# POST /ticket_priorities
|
||||||
# POST /ticket_priorities.json
|
|
||||||
def create
|
def create
|
||||||
@ticket_priority = Ticket::Priority.new(params[:ticket_priority])
|
@ticket_priority = Ticket::Priority.new(params[:ticket_priority])
|
||||||
|
|
||||||
respond_to do |format|
|
if @ticket_priority.save
|
||||||
if @ticket_priority.save
|
render :json => @ticket_priority, :status => :created
|
||||||
format.json { render :json => @ticket_priority, :status => :created }
|
else
|
||||||
else
|
render :json => @ticket_priority.errors, :status => :unprocessable_entity
|
||||||
format.json { render :json => @ticket_priority.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /ticket_priorities/1
|
# PUT /ticket_priorities/1
|
||||||
# PUT /ticket_priorities/1.json
|
|
||||||
def update
|
def update
|
||||||
@ticket_priority = Ticket::Priority.find(params[:id])
|
@ticket_priority = Ticket::Priority.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
if @ticket_priority.update_attributes(params[:ticket_priority])
|
||||||
if @ticket_priority.update_attributes(params[:ticket_priority])
|
render :json => @ticket_priority, :status => :ok
|
||||||
format.json { render :json => @ticket_priority, :status => :ok }
|
else
|
||||||
else
|
render :json => @ticket_priority.errors, :status => :unprocessable_entity
|
||||||
format.json { render :json => @ticket_priority.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /ticket_priorities/1
|
# DELETE /ticket_priorities/1
|
||||||
# DELETE /ticket_priorities/1.json
|
|
||||||
def destroy
|
def destroy
|
||||||
@ticket_priority = Ticket::Priority.find(params[:id])
|
@ticket_priority = Ticket::Priority.find(params[:id])
|
||||||
@ticket_priority.destroy
|
@ticket_priority.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
head :ok
|
||||||
format.json { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,61 +2,46 @@ class TicketStatesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
# GET /ticket_states
|
# GET /ticket_states
|
||||||
# GET /ticket_states.json
|
|
||||||
def index
|
def index
|
||||||
@ticket_states = Ticket::State.all
|
@ticket_states = Ticket::State.all
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @ticket_states
|
||||||
format.json { render :json => @ticket_states }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /ticket_states/1
|
# GET /ticket_states/1
|
||||||
# GET /ticket_states/1.json
|
|
||||||
def show
|
def show
|
||||||
@ticket_state = Ticket::State.find(params[:id])
|
@ticket_state = Ticket::State.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @ticket_state
|
||||||
format.json { render :json => @ticket_state }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /ticket_states
|
# POST /ticket_states
|
||||||
# POST /ticket_states.json
|
|
||||||
def create
|
def create
|
||||||
@ticket_state = Ticket::State.new(params[:ticket_state])
|
@ticket_state = Ticket::State.new(params[:ticket_state])
|
||||||
|
|
||||||
respond_to do |format|
|
if @ticket_state.save
|
||||||
if @ticket_state.save
|
render :json => @ticket_state, :status => :created
|
||||||
format.json { render :json => @ticket_state, :status => :created }
|
else
|
||||||
else
|
render :json => @ticket_state.errors, :status => :unprocessable_entity
|
||||||
format.json { render :json => @ticket_state.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /ticket_states/1
|
# PUT /ticket_states/1
|
||||||
# PUT /ticket_states/1.json
|
|
||||||
def update
|
def update
|
||||||
@ticket_state = Ticket::State.find(params[:id])
|
@ticket_state = Ticket::State.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
if @ticket_state.update_attributes(params[:ticket_state])
|
||||||
if @ticket_state.update_attributes(params[:ticket_state])
|
render :json => @ticket_state, :status => :ok
|
||||||
format.json { render :json => @ticket_state, :status => :ok }
|
else
|
||||||
else
|
render :json => @ticket_state.errors, :status => :unprocessable_entity
|
||||||
format.json { render :json => @ticket_state.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /ticket_states/1
|
# DELETE /ticket_states/1
|
||||||
# DELETE /ticket_states/1.json
|
|
||||||
def destroy
|
def destroy
|
||||||
@ticket_state = Ticket::State.find(params[:id])
|
@ticket_state = Ticket::State.find(params[:id])
|
||||||
@ticket_state.destroy
|
@ticket_state.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
head :ok
|
||||||
format.json { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,62 +2,47 @@ class TicketsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
# GET /tickets
|
# GET /tickets
|
||||||
# GET /tickets.json
|
|
||||||
def index
|
def index
|
||||||
@tickets = Ticket.all
|
@tickets = Ticket.all
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @tickets
|
||||||
format.json { render :json => @tickets }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /tickets/1
|
# GET /tickets/1
|
||||||
# GET /tickets/1.json
|
|
||||||
def show
|
def show
|
||||||
@ticket = Ticket.find(params[:id])
|
@ticket = Ticket.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @ticket
|
||||||
format.json { render :json => @ticket }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /tickets
|
# POST /tickets
|
||||||
# POST /tickets.json
|
|
||||||
def create
|
def create
|
||||||
@ticket = Ticket.new(params[:ticket])
|
@ticket = Ticket.new(params[:ticket])
|
||||||
@ticket.created_by_id = current_user.id
|
@ticket.created_by_id = current_user.id
|
||||||
|
|
||||||
respond_to do |format|
|
if @ticket.save
|
||||||
if @ticket.save
|
render :json => @ticket, :status => :created
|
||||||
format.json { render :json => @ticket, :status => :created }
|
else
|
||||||
else
|
render :json => @ticket.errors, :status => :unprocessable_entity
|
||||||
format.json { render :json => @ticket.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /tickets/1
|
# PUT /tickets/1
|
||||||
# PUT /tickets/1.json
|
|
||||||
def update
|
def update
|
||||||
@ticket = Ticket.find(params[:id])
|
@ticket = Ticket.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
if @ticket.update_attributes(params[:ticket])
|
||||||
if @ticket.update_attributes(params[:ticket])
|
render :json => @ticket, :status => :ok
|
||||||
format.json { render :json => @ticket, :status => :ok }
|
else
|
||||||
else
|
render :json => @ticket.errors, :status => :unprocessable_entity
|
||||||
format.json { render :json => @ticket.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /tickets/1
|
# DELETE /tickets/1
|
||||||
# DELETE /tickets/1.json
|
|
||||||
def destroy
|
def destroy
|
||||||
@ticket = Ticket.find(params[:id])
|
@ticket = Ticket.find(params[:id])
|
||||||
@ticket.destroy
|
@ticket.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
head :ok
|
||||||
format.json { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,6 @@ class UsersController < ApplicationController
|
||||||
before_filter :authentication_check, :except => [:create]
|
before_filter :authentication_check, :except => [:create]
|
||||||
|
|
||||||
# GET /users
|
# GET /users
|
||||||
# GET /users.json
|
|
||||||
def index
|
def index
|
||||||
@users = User.all
|
@users = User.all
|
||||||
|
|
||||||
|
@ -17,118 +16,81 @@ class UsersController < ApplicationController
|
||||||
i[:organization_id] = organization_id
|
i[:organization_id] = organization_id
|
||||||
}
|
}
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @users
|
||||||
format.html # index.html.erb
|
|
||||||
format.json { render :json => @users }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /users/1
|
# GET /users/1
|
||||||
# GET /users/1.json
|
|
||||||
def show
|
def show
|
||||||
# @user = User.find(params[:id])
|
# @user = User.find(params[:id])
|
||||||
@user = user_data_full(params[:id])
|
@user = user_data_full(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
render :json => @user
|
||||||
format.html # show.html.erb
|
|
||||||
format.json { render :json => @user }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /users/new
|
|
||||||
# GET /users/new.json
|
|
||||||
def new
|
|
||||||
@user = User.new
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html # new.html.erb
|
|
||||||
format.json { render :json => @user }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /users/1/edit
|
|
||||||
def edit
|
|
||||||
@user = User.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /users
|
# POST /users
|
||||||
# POST /users.json
|
|
||||||
def create
|
def create
|
||||||
@user = User.new(params[:user])
|
@user = User.new(params[:user])
|
||||||
@user.created_by_id = (current_user && current_user.id) || 1
|
@user.created_by_id = (current_user && current_user.id) || 1
|
||||||
respond_to do |format|
|
if @user.save
|
||||||
if @user.save
|
|
||||||
|
|
||||||
# if it's a signup, add user to customer role
|
# if it's a signup, add user to customer role
|
||||||
if @user.created_by_id == 1
|
if @user.created_by_id == 1
|
||||||
|
|
||||||
# check if it's first user
|
# check if it's first user
|
||||||
count = User.all.count()
|
count = User.all.count()
|
||||||
role_ids = []
|
role_ids = []
|
||||||
if count <= 2
|
if count <= 2
|
||||||
role_ids.push Role.where( :name => 'Admin' ).first.id
|
role_ids.push Role.where( :name => 'Admin' ).first.id
|
||||||
role_ids.push Role.where( :name => 'Agent' ).first.id
|
role_ids.push Role.where( :name => 'Agent' ).first.id
|
||||||
else
|
|
||||||
role_ids.push Role.where( :name => 'Customer' ).first.id
|
|
||||||
end
|
|
||||||
@user.role_ids = role_ids
|
|
||||||
|
|
||||||
# else do assignment as defined
|
|
||||||
else
|
else
|
||||||
if params[:role_ids]
|
role_ids.push Role.where( :name => 'Customer' ).first.id
|
||||||
@user.role_ids = params[:role_ids]
|
|
||||||
end
|
|
||||||
if params[:group_ids]
|
|
||||||
@user.group_ids = params[:group_ids]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@user.role_ids = role_ids
|
||||||
|
|
||||||
# send inviteation if needed
|
# else do assignment as defined
|
||||||
if params[:invite]
|
|
||||||
|
|
||||||
# logger.debug('IIIIIIIIIIIIIIIIIIIIIIIIIIIIII')
|
|
||||||
# exit '123'
|
|
||||||
end
|
|
||||||
format.html { redirect_to @user, :notice => 'User was successfully created.' }
|
|
||||||
format.json { render :json => @user, :status => :created }
|
|
||||||
else
|
else
|
||||||
format.html { render :action => "new" }
|
|
||||||
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# PUT /users/1
|
|
||||||
# PUT /users/1.json
|
|
||||||
def update
|
|
||||||
@user = User.find(params[:id])
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
if @user.update_attributes(params[:user])
|
|
||||||
if params[:role_ids]
|
if params[:role_ids]
|
||||||
@user.role_ids = params[:role_ids]
|
@user.role_ids = params[:role_ids]
|
||||||
end
|
end
|
||||||
if params[:group_ids]
|
if params[:group_ids]
|
||||||
@user.group_ids = params[:group_ids]
|
@user.group_ids = params[:group_ids]
|
||||||
end
|
end
|
||||||
format.html { redirect_to @user, :notice => 'User was successfully updated.' }
|
|
||||||
format.json { render :json => @user, :status => :ok }
|
|
||||||
else
|
|
||||||
format.html { render :action => "edit" }
|
|
||||||
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# send inviteation if needed
|
||||||
|
if params[:invite]
|
||||||
|
|
||||||
|
# logger.debug('IIIIIIIIIIIIIIIIIIIIIIIIIIIIII')
|
||||||
|
# exit '123'
|
||||||
|
end
|
||||||
|
render :json => @user, :status => :created
|
||||||
|
else
|
||||||
|
render :json => @user.errors, :status => :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /users/1
|
||||||
|
def update
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
|
||||||
|
if @user.update_attributes(params[:user])
|
||||||
|
if params[:role_ids]
|
||||||
|
@user.role_ids = params[:role_ids]
|
||||||
|
end
|
||||||
|
if params[:group_ids]
|
||||||
|
@user.group_ids = params[:group_ids]
|
||||||
|
end
|
||||||
|
render :json => @user, :status => :ok
|
||||||
|
else
|
||||||
|
render :json => @user.errors, :status => :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /users/1
|
# DELETE /users/1
|
||||||
# DELETE /users/1.json
|
|
||||||
def destroy
|
def destroy
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
@user.destroy
|
@user.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
head :ok
|
||||||
format.html { redirect_to users_url }
|
|
||||||
format.json { head :ok }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue