Class: Tr8n::Admin::TranslationController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/tr8n/admin/translation_controller.rb

Overview

– Copyright © 2010-2011 Michael Berkovich, tr8n.net

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++

Instance Method Summary collapse

Instance Method Details

#deleteObject



36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/tr8n/admin/translation_controller.rb', line 36

def delete
  params[:translations] = [params[:translation_id]] if params[:translation_id]
  if params[:translations]
    params[:translations].each do |translation_id|
      translation = Tr8n::Translation.find_by_id(translation_id)
      translation.destroy if translation
    end  
  end
  redirect_to_source
end

#delete_voteObject



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/tr8n/admin/translation_controller.rb', line 51

def delete_vote
  params[:votes] = [params[:vote_id]] if params[:vote_id]
  if params[:votes]
    params[:votes].each do |vote_id|
      vote = Tr8n::TranslationVote.find_by_id(vote_id)
      translation = vote.translation
      vote.destroy if vote
      translation.reload
      translation.update_rank!
    end  
  end
  redirect_to_source
end

#indexObject



26
27
28
# File 'app/controllers/tr8n/admin/translation_controller.rb', line 26

def index
  @translations = Tr8n::Translation.filter(:params => params, :filter => Tr8n::TranslationFilter)
end

#viewObject



30
31
32
33
34
# File 'app/controllers/tr8n/admin/translation_controller.rb', line 30

def view
  @translation = Tr8n::Translation.find_by_id(params[:translation_id])
  return redirect_to(:action => :index) unless @translation
  @votes = Tr8n::TranslationVote.find(:all, :conditions => ["translation_id = ?", @translation.id], :order => "created_at desc", :limit => 20)
end

#votesObject



47
48
49
# File 'app/controllers/tr8n/admin/translation_controller.rb', line 47

def votes
  @votes = Tr8n::TranslationVote.filter(:params => params, :filter => Tr8n::TranslationVoteFilter)
end