Class: Tr8n::TranslatorReport
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Tr8n::TranslatorReport
- Defined in:
- app/models/tr8n/translator_report.rb
Overview
– Copyright © 2010-2012 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. ++
– Tr8n::TranslatorReport Schema Information
Table name: tr8n_translator_reports
id INTEGER not null, primary key
translator_id integer
state varchar(255)
object_id integer
object_type varchar(255)
reason varchar(255)
comment text
created_at datetime
updated_at datetime
Indexes
index_tr8n_translator_reports_on_translator_id (translator_id)
++
Class Method Summary collapse
- .default_reasons_for(object) ⇒ Object
- .find_or_create(translator, object) ⇒ Object
- .report_for(translator, object) ⇒ Object
- .submit(translator, object, reason, comment) ⇒ Object
- .title_for(object) ⇒ Object
Class Method Details
.default_reasons_for(object) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/models/tr8n/translator_report.rb', line 65 def self.default_reasons_for(object) if object.is_a?(Tr8n::TranslationKey) return ['Bad Grammar', 'Bad Tokens', 'Premature Lock', 'Other:'] end if object.is_a?(Tr8n::Translation) return ['Inappropriate Language', 'Bad Tokens', 'Spam', 'Vandalism', 'Other:'] end if object.is_a?(Tr8n::Translator) return ['Spammer', 'Vandalist', 'Bully', 'Other:'] end if object.is_a?(Tr8n::LanguageForumMessage) return ['Inappropriate Language', 'Bad Tokens', 'Spam', 'Vandalism', 'Other:'] end if object.is_a?(Tr8n::LanguageForumTopic) return ['Inappropriate Language', 'Bad Tokens', 'Spam', 'Vandalism', 'Other:'] end if object.is_a?(Tr8n::TranslationKeyComment) return ['Inappropriate Language', 'Spam', 'Vandalism', 'Other:'] end ['Inappropriate Language'] end |
.find_or_create(translator, object) ⇒ Object
53 54 55 |
# File 'app/models/tr8n/translator_report.rb', line 53 def self.find_or_create(translator, object) report_for(translator, object) || create(:translator => translator, :object => object) end |
.report_for(translator, object) ⇒ Object
57 58 59 |
# File 'app/models/tr8n/translator_report.rb', line 57 def self.report_for(translator, object) self.where("translator_id = ? and object_type = ? and object_id = ?", translator.id, object.class.name, object.id).first end |
.submit(translator, object, reason, comment) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/models/tr8n/translator_report.rb', line 93 def self.submit(translator, object, reason, comment) report = find_or_create(translator, object) report.update_attributes(:reason => reason, :comment => comment) if object.is_a?(Tr8n::Translation) object.vote!(translator, -100) submit(translator, object.translator, "bad translation #{object.id}", comment) elsif object.is_a?(Tr8n::LanguageForumMessage) submit(translator, object.translator, "bad message #{object.id}", comment) end end |
.title_for(object) ⇒ Object
61 62 63 |
# File 'app/models/tr8n/translator_report.rb', line 61 def self.title_for(object) object.class.name.underscore.split('_').collect{|item| item.capitalize}.join(' ') end |