Commit b46d3e4aa20b2c633c2c5d36d88ee4936aa7e87c
1 parent
b6e26e93
Exists in
master
and in
4 other branches
Added link to show reponses of proposals in content manager
Showing
8 changed files
with
84 additions
and
8 deletions
Show diff stats
lib/cms_helper.rb
@@ -10,7 +10,11 @@ module CmsHelper | @@ -10,7 +10,11 @@ module CmsHelper | ||
10 | image_tag(icon_for_article(article)) + link_to(article_name, article.url) | 10 | image_tag(icon_for_article(article)) + link_to(article_name, article.url) |
11 | else | 11 | else |
12 | if "ProposalsDiscussionPlugin::Proposal".eql? article.type | 12 | if "ProposalsDiscussionPlugin::Proposal".eql? article.type |
13 | - link_to article.abstract, article.url, :class => icon_for_article(article) | 13 | + if article.children_count > 0 |
14 | + link_to article.abstract, {:action => 'view', :id => article.id}, :class => 'icon icon-replyied-article' | ||
15 | + else | ||
16 | + link_to article.abstract, article.url, :class => icon_for_article(article) | ||
17 | + end | ||
14 | else | 18 | else |
15 | link_to article_name, article.url, :class => icon_for_article(article) | 19 | link_to article_name, article.url, :class => icon_for_article(article) |
16 | end | 20 | end |
lib/proposals_discussion_plugin/api_new_relic_instrumenter.rb
0 → 100644
@@ -0,0 +1,46 @@ | @@ -0,0 +1,46 @@ | ||
1 | +class ProposalsDiscussionPlugin::ApiNewRelicInstrumenter < Grape::Middleware::Base | ||
2 | + include NewRelic::Agent::Instrumentation::ControllerInstrumentation | ||
3 | + | ||
4 | + def call_with_newrelic(&block) | ||
5 | + trace_options = { | ||
6 | + :category => :rack, | ||
7 | + :path => "#{route_path}\##{route_method}", | ||
8 | + :request => Grape::Request.new(@env) | ||
9 | + } | ||
10 | + | ||
11 | + perform_action_with_newrelic_trace(trace_options) do | ||
12 | + result = yield | ||
13 | + MetricFrame.abort_transaction! if result.first == 404 # ignore cascaded calls | ||
14 | + result | ||
15 | + end | ||
16 | + end | ||
17 | + | ||
18 | + def call(env) | ||
19 | + @env = env | ||
20 | + if ENV['NEW_RELIC_ID'] | ||
21 | + call_with_newrelic do | ||
22 | + super | ||
23 | + end | ||
24 | + else | ||
25 | + super | ||
26 | + end | ||
27 | + end | ||
28 | + | ||
29 | + def env | ||
30 | + @env | ||
31 | + end | ||
32 | + | ||
33 | + def route | ||
34 | + env['api.endpoint'].routes.first | ||
35 | + end | ||
36 | + | ||
37 | + def route_method | ||
38 | + route.route_method.downcase | ||
39 | + end | ||
40 | + | ||
41 | + def route_path | ||
42 | + path = route.route_path.gsub(/^.+:version\/|^\/|:|\(.+\)/, '').tr('/', '-') | ||
43 | + "api.#{route.route_version}.#{path}" | ||
44 | + end | ||
45 | + | ||
46 | +end |
lib/proposals_discussion_plugin/response.rb
@@ -12,16 +12,16 @@ class ProposalsDiscussionPlugin::Response < TinyMceArticle | @@ -12,16 +12,16 @@ class ProposalsDiscussionPlugin::Response < TinyMceArticle | ||
12 | _("The response of a Proposal") | 12 | _("The response of a Proposal") |
13 | end | 13 | end |
14 | 14 | ||
15 | + def icon_name | ||
16 | + 'response' | ||
17 | + end | ||
18 | + | ||
15 | protected | 19 | protected |
16 | 20 | ||
17 | def check_parent_type | 21 | def check_parent_type |
18 | unless parent.is_a? ProposalsDiscussionPlugin::Proposal | 22 | unless parent.is_a? ProposalsDiscussionPlugin::Proposal |
19 | errors.add(:parent, N_('of Response needs be a Proposal')) | 23 | errors.add(:parent, N_('of Response needs be a Proposal')) |
20 | end | 24 | end |
21 | - | ||
22 | - # if self.body_changed? && (self.changed & attrs_validators).any? | ||
23 | - # errors.add(:response, N_('only have "body" field')) | ||
24 | - # end | ||
25 | end | 25 | end |
26 | 26 | ||
27 | end | 27 | end |
743 Bytes
291 Bytes
public/style.css
@@ -406,3 +406,11 @@ div.confirm_evaluation_button a.disabled { | @@ -406,3 +406,11 @@ div.confirm_evaluation_button a.disabled { | ||
406 | .icon-child-article { | 406 | .icon-child-article { |
407 | background-image: url('/plugins/proposals_discussion/images/reply.png'); | 407 | background-image: url('/plugins/proposals_discussion/images/reply.png'); |
408 | } | 408 | } |
409 | + | ||
410 | +.icon-response { | ||
411 | + background: url('/plugins/proposals_discussion/images/response-article.png') no-repeat; | ||
412 | +} | ||
413 | + | ||
414 | +.icon-replyied-article { | ||
415 | + background: url('/plugins/proposals_discussion/images/replyied-article.png') no-repeat; | ||
416 | +} |
test/unit/proposal_test.rb
@@ -156,4 +156,20 @@ class ProposalTest < ActiveSupport::TestCase | @@ -156,4 +156,20 @@ class ProposalTest < ActiveSupport::TestCase | ||
156 | assert_match "Body can't be blank", err.message | 156 | assert_match "Body can't be blank", err.message |
157 | end | 157 | end |
158 | 158 | ||
159 | + should 'not add a response to a article that isnt a proposal' do | ||
160 | + article = create(Article, :name => 'test article', :profile => @profile) | ||
161 | + data = { | ||
162 | + :name => 'Response', | ||
163 | + :abstract => 'Test', | ||
164 | + :parent => article, | ||
165 | + :profile => profile | ||
166 | + } | ||
167 | + | ||
168 | + err = assert_raises ActiveRecord::RecordInvalid do | ||
169 | + response = create(ProposalsDiscussionPlugin::Response, data) | ||
170 | + end | ||
171 | + | ||
172 | + assert_match "Parent of Response needs be a Proposal", err.message | ||
173 | + end | ||
174 | + | ||
159 | end | 175 | end |
views/cms/proposals_discussion_plugin/_response.html.erb
@@ -10,14 +10,16 @@ | @@ -10,14 +10,16 @@ | ||
10 | <div class="title"> | 10 | <div class="title"> |
11 | <%= required labelled_form_field _('Title'), limited_text_area(:article, :name, title_limit, 'title_textarea', :rows => 1) %> | 11 | <%= required labelled_form_field _('Title'), limited_text_area(:article, :name, title_limit, 'title_textarea', :rows => 1) %> |
12 | </div> | 12 | </div> |
13 | - | ||
14 | - <%= select_profile_folder(_('Parent folder:'), 'article[parent_id]', profile, @article.parent_id, {},{},{},:include_articles => true) %> | 13 | + <% if @article.parent_id.nil? %> |
14 | + <%= select_profile_folder(_('Parent folder:'), 'article[parent_id]', profile, @article.parent_id, {},{},{},:include_articles => true) %> | ||
15 | + <% else %> | ||
16 | + <%= hidden_field(:article, :parent_id) %> | ||
17 | + <% end %> | ||
15 | 18 | ||
16 | <div class="body"> | 19 | <div class="body"> |
17 | <%= labelled_form_field(_('Response'), text_area(:article, :body, :class => 'mceEditor')) %> | 20 | <%= labelled_form_field(_('Response'), text_area(:article, :body, :class => 'mceEditor')) %> |
18 | </div> | 21 | </div> |
19 | 22 | ||
20 | - <%= hidden_field(:article, :parent_id) %> | ||
21 | </div> | 23 | </div> |
22 | 24 | ||
23 | <script> | 25 | <script> |