Removed acts_as_paranoid. Implemented own version.
This commit is contained in:
parent
8bafb3f4b2
commit
07581b7ecf
25 changed files with 93 additions and 57 deletions
|
|
@ -3,7 +3,7 @@ class Admin::OrdergroupsController < Admin::BaseController
|
|||
inherit_resources
|
||||
|
||||
def index
|
||||
@ordergroups = Ordergroup.order('name ASC')
|
||||
@ordergroups = Ordergroup.undeleted.order('name ASC')
|
||||
|
||||
# if somebody uses the search field:
|
||||
unless params[:query].blank?
|
||||
|
|
@ -15,7 +15,7 @@ class Admin::OrdergroupsController < Admin::BaseController
|
|||
|
||||
def destroy
|
||||
@ordergroup = Ordergroup.find(params[:id])
|
||||
@ordergroup.destroy
|
||||
@ordergroup.mark_as_deleted
|
||||
redirect_to admin_ordergroups_url, :notice => "Bestellgruppe wurde gelöscht"
|
||||
rescue => error
|
||||
redirect_to admin_ordergroups_url, :alert => "Bestellgruppe konnte nicht gelöscht werden: #{error}"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class ArticlesController < ApplicationController
|
|||
sort = "article_categories.name, articles.name"
|
||||
end
|
||||
|
||||
@articles = Article.where(supplier_id: @supplier, :type => nil).includes(:article_category).order(sort)
|
||||
@articles = Article.undeleted.where(supplier_id: @supplier, :type => nil).includes(:article_category).order(sort)
|
||||
@articles = @articles.where('articles.name LIKE ?', "%#{params[:query]}%") unless params[:query].nil?
|
||||
|
||||
@articles = @articles.page(params[:page]).per(@per_page)
|
||||
|
|
@ -64,13 +64,13 @@ class ArticlesController < ApplicationController
|
|||
# Deletes article from database. send error msg, if article is used in a current order
|
||||
def destroy
|
||||
@article = Article.find(params[:id])
|
||||
@article.destroy unless @order = @article.in_open_order # If article is in an active Order, the Order will be returned
|
||||
@article.mark_as_deleted unless @order = @article.in_open_order # If article is in an active Order, the Order will be returned
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
# Renders a form for editing all articles from a supplier
|
||||
def edit_all
|
||||
@articles = @supplier.articles
|
||||
@articles = @supplier.articles.undeleted
|
||||
end
|
||||
|
||||
# Updates all article of specific supplier
|
||||
|
|
@ -114,23 +114,24 @@ class ArticlesController < ApplicationController
|
|||
def update_selected
|
||||
raise 'Du hast keine Artikel ausgewählt' if params[:selected_articles].nil?
|
||||
articles = Article.find(params[:selected_articles])
|
||||
|
||||
case params[:selected_action]
|
||||
when 'destroy'
|
||||
articles.each {|a| a.destroy }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden gelöscht'
|
||||
when 'setNotAvailable'
|
||||
articles.each {|a| a.update_attribute(:availability, false) }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt'
|
||||
when 'setAvailable'
|
||||
articles.each {|a| a.update_attribute(:availability, true) }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt'
|
||||
else
|
||||
flash[:alert] = 'Keine Aktion ausgewählt!'
|
||||
Article.transaction do
|
||||
case params[:selected_action]
|
||||
when 'destroy'
|
||||
articles.each(&:mark_as_deleted)
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden gelöscht'
|
||||
when 'setNotAvailable'
|
||||
articles.each {|a| a.update_attribute(:availability, false) }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt'
|
||||
when 'setAvailable'
|
||||
articles.each {|a| a.update_attribute(:availability, true) }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt'
|
||||
else
|
||||
flash[:alert] = 'Keine Aktion ausgewählt!'
|
||||
end
|
||||
end
|
||||
# action succeded
|
||||
redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page])
|
||||
|
||||
|
||||
rescue => error
|
||||
redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page]),
|
||||
:alert => "Ein Fehler ist aufgetreten: #{error}"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Finance::OrdergroupsController < Finance::BaseController
|
|||
sort = "name"
|
||||
end
|
||||
|
||||
@ordergroups = Ordergroup.order(sort)
|
||||
@ordergroups = Ordergroup.undeleted.order(sort)
|
||||
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:query]}%") unless params[:query].nil?
|
||||
|
||||
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class Foodcoop::OrdergroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
@ordergroups = Ordergroup.order('name DESC')
|
||||
@ordergroups = Ordergroup.undeleted.order('name DESC')
|
||||
|
||||
unless params[:name].blank? # Search by name
|
||||
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:name]}%")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class StockitController < ApplicationController
|
||||
|
||||
def index
|
||||
@stock_articles = StockArticle.includes(:supplier, :article_category).
|
||||
@stock_articles = StockArticle.undeleted.includes(:supplier, :article_category).
|
||||
order('suppliers.name, article_categories.name, articles.name')
|
||||
end
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ class StockitController < ApplicationController
|
|||
|
||||
def destroy
|
||||
@article = StockArticle.find(params[:id])
|
||||
@article.destroy
|
||||
@article.mark_as_deleted
|
||||
render :layout => false
|
||||
rescue => error
|
||||
render :partial => "destroy_fail", :layout => false,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class SuppliersController < ApplicationController
|
|||
helper :deliveries
|
||||
|
||||
def index
|
||||
@suppliers = Supplier.order(:name)
|
||||
@suppliers = Supplier.undeleted.order(:name)
|
||||
@deliveries = Delivery.recent
|
||||
end
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ class SuppliersController < ApplicationController
|
|||
|
||||
def destroy
|
||||
@supplier = Supplier.find(params[:id])
|
||||
@supplier.destroy
|
||||
@supplier.mark_as_deleted
|
||||
flash[:notice] = "Lieferant wurde gelöscht"
|
||||
redirect_to suppliers_path
|
||||
rescue => e
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue