Commit 96f820534a55db9ebf6f263011751ebd8c9bc738
Committed by
Antonio Terceiro
1 parent
24a8cc1e
Exists in
master
and in
29 other branches
Publish event creates a copy of the event
* Instead of creating a PublishedArticle, a copy of the event is created. PS: depends of cba6c4326. (ActionItem1648)
Showing
6 changed files
with
48 additions
and
20 deletions
Show diff stats
app/models/approve_article.rb
@@ -64,7 +64,11 @@ class ApproveArticle < Task | @@ -64,7 +64,11 @@ class ApproveArticle < Task | ||
64 | end | 64 | end |
65 | 65 | ||
66 | def perform | 66 | def perform |
67 | - PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted, :source => article.source) | 67 | + if article.event? |
68 | + article.copy(:name => name, :profile => target, :reference_article => article) | ||
69 | + else | ||
70 | + PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted, :source => article.source) | ||
71 | + end | ||
68 | end | 72 | end |
69 | 73 | ||
70 | def target_notification_message | 74 | def target_notification_message |
app/models/article.rb
@@ -274,7 +274,7 @@ class Article < ActiveRecord::Base | @@ -274,7 +274,7 @@ class Article < ActiveRecord::Base | ||
274 | end | 274 | end |
275 | 275 | ||
276 | 276 | ||
277 | - def copy(options) | 277 | + def copy(options = {}) |
278 | attrs = attributes.reject! { |key, value| ATTRIBUTES_NOT_COPIED.include?(key.to_sym) } | 278 | attrs = attributes.reject! { |key, value| ATTRIBUTES_NOT_COPIED.include?(key.to_sym) } |
279 | attrs.merge!(options) | 279 | attrs.merge!(options) |
280 | self.class.create(attrs) | 280 | self.class.create(attrs) |
@@ -317,6 +317,10 @@ class Article < ActiveRecord::Base | @@ -317,6 +317,10 @@ class Article < ActiveRecord::Base | ||
317 | false | 317 | false |
318 | end | 318 | end |
319 | 319 | ||
320 | + def event? | ||
321 | + false | ||
322 | + end | ||
323 | + | ||
320 | def display_as_gallery? | 324 | def display_as_gallery? |
321 | false | 325 | false |
322 | end | 326 | end |
app/models/event.rb
@@ -127,6 +127,10 @@ class Event < Article | @@ -127,6 +127,10 @@ class Event < Article | ||
127 | maybe_add_http(self.body[:link]) | 127 | maybe_add_http(self.body[:link]) |
128 | end | 128 | end |
129 | 129 | ||
130 | + def event? | ||
131 | + true | ||
132 | + end | ||
133 | + | ||
130 | include MaybeAddHttp | 134 | include MaybeAddHttp |
131 | 135 | ||
132 | end | 136 | end |
app/views/cms/publish.rhtml
@@ -14,24 +14,15 @@ | @@ -14,24 +14,15 @@ | ||
14 | </div> | 14 | </div> |
15 | <% end %> | 15 | <% end %> |
16 | 16 | ||
17 | +<% form_tag do%> | ||
18 | + <%= hidden_field_tag :back_to, @back_to %> | ||
19 | + <% @groups.each do |group| %> | ||
20 | + <%= labelled_check_box group.name, "marked_groups[#{group.id}][group_id]", group.id, @marked_groups.include?(group) %><br /> | ||
21 | + <%= labelled_text_field _('Title') + ': ', "marked_groups[#{group.id}][name]", @article.name, :style => 'width: 100%' %> | ||
22 | + <hr /> | ||
23 | + <% end %> | ||
17 | 24 | ||
18 | -<!-- Workaroud while the publish feature isn't ready for Events --> | ||
19 | -<% unless @article.is_a?(Event) %> | ||
20 | - <% form_tag do%> | ||
21 | - <%= hidden_field_tag :back_to, @back_to %> | ||
22 | - <% @groups.each do |group| %> | ||
23 | - <%= labelled_check_box group.name, "marked_groups[#{group.id}][group_id]", group.id, @marked_groups.include?(group) %><br /> | ||
24 | - <%= labelled_text_field _('Title') + ': ', "marked_groups[#{group.id}][name]", @article.name, :style => 'width: 100%' %> | ||
25 | - <hr /> | ||
26 | - <% end %> | ||
27 | - | ||
28 | - <% button_bar do %> | ||
29 | - <%= submit_button 'spread', _('Spread this'), :cancel => @back_to %> | ||
30 | - <% end %> | 25 | + <% button_bar do %> |
26 | + <%= submit_button 'spread', _('Spread this'), :cancel => @back_to %> | ||
31 | <% end %> | 27 | <% end %> |
32 | -<% else %> | ||
33 | - <div class='atention'> | ||
34 | - <%= _("This option is temporarily disabled.") %> | ||
35 | - </div> | ||
36 | <% end %> | 28 | <% end %> |
37 | - |
features/events.feature
@@ -170,3 +170,18 @@ Feature: events | @@ -170,3 +170,18 @@ Feature: events | ||
170 | Scenario: display environment name in global agenda | 170 | Scenario: display environment name in global agenda |
171 | When I am on /assets/events | 171 | When I am on /assets/events |
172 | Then I should see "Colivre.net's events" | 172 | Then I should see "Colivre.net's events" |
173 | + | ||
174 | + Scenario: published events should be listed in the agenda too | ||
175 | + Given the following community | ||
176 | + | identifier | name | | ||
177 | + | sample-community | Sample Community | | ||
178 | + And I am logged in as "josesilva" | ||
179 | + And "josesilva" is a member of "Sample Community" | ||
180 | + And I am on josesilva's control panel | ||
181 | + And I follow "Manage content" | ||
182 | + And I follow "Another Conference" | ||
183 | + And I follow "Spread" | ||
184 | + And I check "Sample Community" | ||
185 | + And I press "Spread this" | ||
186 | + And I am on /profile/sample-community/events/2009/10/24 | ||
187 | + Then I should see "Another Conference" |
test/functional/cms_controller_test.rb
@@ -684,6 +684,16 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -684,6 +684,16 @@ class CmsControllerTest < Test::Unit::TestCase | ||
684 | end | 684 | end |
685 | end | 685 | end |
686 | 686 | ||
687 | + should 'create a new event after publishing an event' do | ||
688 | + c = fast_create(Community) | ||
689 | + c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) | ||
690 | + a = Event.create!(:name => "Some event", :profile => profile, :start_date => Date.today) | ||
691 | + | ||
692 | + assert_difference Event, :count do | ||
693 | + post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}} | ||
694 | + end | ||
695 | + end | ||
696 | + | ||
687 | should "not crash if there is a post and no portal community defined" do | 697 | should "not crash if there is a post and no portal community defined" do |
688 | Environment.any_instance.stubs(:portal_community).returns(nil) | 698 | Environment.any_instance.stubs(:portal_community).returns(nil) |
689 | article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | 699 | article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') |