Commit 8c783480acf78b192a57dbefb55a7b0b464c7fce
1 parent
19e29330
Exists in
master
and in
7 other branches
sorry - revert last 3 commits. Merge request is needed
Showing
5 changed files
with
4 additions
and
45 deletions
Show diff stats
db/migrate/20150903210329_add_proposal_discussion_plugin_simplified_abstract_to_tasks.rb
... | ... | @@ -1,9 +0,0 @@ |
1 | -class AddProposalDiscussionPluginSimplifiedAbstractToTasks < ActiveRecord::Migration | |
2 | - def change | |
3 | - add_column :tasks, :proposal_discussion_plugin_simplified_abstract, :text | |
4 | - add_index :tasks, :proposal_discussion_plugin_simplified_abstract | |
5 | - ProposalsDiscussionPlugin::ProposalTask.find_each do |t| | |
6 | - t.update_attribute :proposal_discussion_plugin_simplified_abstract, ProposalsDiscussionPlugin::ProposalTask.simplify(t.abstract) | |
7 | - end | |
8 | - end | |
9 | -end |
lib/proposals_discussion_plugin/api.rb
... | ... | @@ -23,7 +23,7 @@ class ProposalsDiscussionPlugin::API < Grape::API |
23 | 23 | proposal_task.requestor = current_person |
24 | 24 | |
25 | 25 | unless proposal_task.save |
26 | - render_api_errors!(proposal_task.errors) | |
26 | + render_api_errors!(proposal_task.article_object.errors.full_messages) | |
27 | 27 | end |
28 | 28 | {:success => true} |
29 | 29 | #present proposal_task, :with => Entities::Task, :fields => params[:fields] | ... | ... |
lib/proposals_discussion_plugin/proposal_task.rb
1 | 1 | class ProposalsDiscussionPlugin::ProposalTask < Task |
2 | + | |
2 | 3 | has_and_belongs_to_many :categories, |
3 | 4 | class_name: "ProposalsDiscussionPlugin::TaskCategory", |
4 | 5 | join_table: :proposals_discussion_plugin_task_categories, |
... | ... | @@ -9,13 +10,8 @@ class ProposalsDiscussionPlugin::ProposalTask < Task |
9 | 10 | |
10 | 11 | validates_presence_of :requestor_id, :target_id |
11 | 12 | validates_associated :article_object |
12 | - before_save :simplify_abstract | |
13 | -# before_validation :simplify_abstract | |
14 | - validate :require_category | |
15 | - | |
16 | - validate :unique_simplified_abstract? | |
17 | 13 | |
18 | -# validates_uniqueness_of :proposal_discussion_plugin_simplified_abstract, :scope => ['target_id'], :message => _("Cannot create duplicate proposal") | |
14 | + validate :require_category | |
19 | 15 | |
20 | 16 | settings_items :name, :type => String |
21 | 17 | settings_items :ip_address, :type => String |
... | ... | @@ -25,10 +21,6 @@ class ProposalsDiscussionPlugin::ProposalTask < Task |
25 | 21 | settings_items :closing_statment, :article_parent_id |
26 | 22 | |
27 | 23 | |
28 | - def simplify_abstract | |
29 | - self.proposal_discussion_plugin_simplified_abstract = ProposalsDiscussionPlugin::ProposalTask.simplify(self[:data][:article]["abstract"]) | |
30 | - end | |
31 | - | |
32 | 24 | scope :pending_evaluated, lambda { |profile, filter_type, filter_text| |
33 | 25 | self |
34 | 26 | .to(profile) |
... | ... | @@ -266,14 +258,6 @@ class ProposalsDiscussionPlugin::ProposalTask < Task |
266 | 258 | parent.name if parent |
267 | 259 | end |
268 | 260 | |
269 | - def self.simplify(s) | |
270 | - return nil if s.nil? | |
271 | - s=I18n.transliterate(s) | |
272 | - s.gsub!(/(^\s)|([',.?!])|(\s$)/, "") | |
273 | - s.gsub!(/\s{2,}/, " ") | |
274 | - s.downcase | |
275 | - end | |
276 | - | |
277 | 261 | protected |
278 | 262 | |
279 | 263 | def require_category |
... | ... | @@ -282,10 +266,4 @@ class ProposalsDiscussionPlugin::ProposalTask < Task |
282 | 266 | end |
283 | 267 | end |
284 | 268 | |
285 | - def unique_simplified_abstract? | |
286 | - sa = ProposalsDiscussionPlugin::ProposalTask.simplify(self[:data][:article]["abstract"]) | |
287 | - r = ProposalsDiscussionPlugin::ProposalTask.find_by_sql ["SELECT 1 AS one FROM tasks WHERE tasks.type IN ('ProposalsDiscussionPlugin::ProposalTask') AND (tasks.proposal_discussion_plugin_simplified_abstract = ? AND tasks.target_id = ?) LIMIT 1", sa, target_id] | |
288 | - errors.add :base, _('This proposal has been previously registered') unless r.empty? | |
289 | - end | |
290 | - | |
291 | 269 | end | ... | ... |
test/test_helper.rb
test/unit/proposal_task_test.rb
1 | -# encoding: UTF-8 | |
2 | 1 | require_relative '../test_helper' |
3 | 2 | |
4 | 3 | class ProposalTaskTest < ActiveSupport::TestCase |
... | ... | @@ -84,13 +83,4 @@ class ProposalTaskTest < ActiveSupport::TestCase |
84 | 83 | assert task.information.present? |
85 | 84 | end |
86 | 85 | |
87 | - should 'not register duplicate task' do | |
88 | - task = ProposalsDiscussionPlugin::ProposalTask.create!(:requestor => person, :target => profile, :article => {:name => 'proposal 1', :abstract => ' Alô ! ruby é legal a bêçá. seu moÇo, não Acha? '}) | |
89 | - task.categories = [fast_create(ProposalsDiscussionPlugin::TaskCategory)] | |
90 | - task.save! | |
91 | - task = ProposalsDiscussionPlugin::ProposalTask.new(:requestor => person, :target => profile, :article => {:name => 'proposal 1', :abstract => 'alo ruby e legal a beca seu moco nao acha'}) | |
92 | - task.categories = [fast_create(ProposalsDiscussionPlugin::TaskCategory)] | |
93 | - assert !task.valid? | |
94 | - end | |
95 | - | |
96 | 86 | end | ... | ... |