Skip to content

Commit 2a5cf60

Browse files
committed
news controller reorganized display validation errors
1 parent a2c4e68 commit 2a5cf60

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

app/controllers/redaction/news_controller.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ def reorganize
6565

6666
def reorganized
6767
@news.editor = current_account
68-
@news.reorganize news_params
69-
redirect_to [@news.draft? ? :redaction : :moderation, @news]
68+
if @news.reorganize news_params
69+
redirect_to [@news.draft? ? :redaction : :moderation, @news]
70+
else
71+
load_board
72+
render :reorganize, layout: "chat_n_edit"
73+
end
7074
end
7175

7276
def followup

app/models/news.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,20 @@ def nb_editors
260260
end
261261

262262
def reorganize(params)
263+
reorganized = false
263264
self.transaction do
264265
Paragraph.where(news_id: self.id).delete_all
265266
self.attributes = params
266267
create_parts
267268
# Let commit transaction only if save is successful so version will be well created
268-
raise ActiveRecord::Rollback unless save
269+
if save
270+
reorganized = true
271+
else
272+
raise ActiveRecord::Rollback
273+
end
269274
end
270-
unlock
275+
unlock if reorganized
276+
reorganized
271277
end
272278

273279
### Associated node ###

app/views/redaction/news/reorganize.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
= render 'topbar', news: @news, show_backlink: false
1010

1111
%article
12+
= messages_on_error @news
1213
= form_for @news, url: reorganized_redaction_news_path(@news), method: :put do |form|
1314
%p
1415
= form.label :section_id, "Section"

0 commit comments

Comments
 (0)