Skip to content
This repository was archived by the owner on Apr 25, 2019. It is now read-only.

Commit d16768f

Browse files
committed
destroy competition form in separate partial
1 parent 3397971 commit d16768f

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

app/policies/competition_policy.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def apply?
2727
end
2828

2929
def destroy?
30-
# record.id && user && record.author == user && record.users.none?
31-
true
30+
record.id && user && record.author == user && record.users.none?
3231
end
3332
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% if policy(competition).destroy? %>
2+
<div class="panel panel-danger marged-mini">
3+
<div class="panel-heading">
4+
<strong><%= t('competitions.show.destroy.panel') %></strong>
5+
</div>
6+
<div class="panel-body">
7+
<p><strong><%= t('competitions.show.destroy.title') %></strong></p>
8+
<%= link_to t('competitions.show.destroy.title'), competition_path(competition), method: 'delete', class: "btn btn-danger pull-right" %>
9+
<p><%= t('competitions.show.destroy.text') %></p>
10+
</div>
11+
</div>
12+
<% end %>

app/views/competitions/_form.html.erb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,3 @@
211211

212212
<%= f.button :submit, class: "btn btn-primary" %> <%= link_to t('cancel'), :back, class: "btn" %>
213213
<% end %>
214-
215-
<% if policy(competition).destroy? %>
216-
<div class="panel panel-danger marged-mini">
217-
<div class="panel-heading">
218-
<strong><%= t('competitions.show.destroy.panel') %></strong>
219-
</div>
220-
<div class="panel-body">
221-
<p><strong><%= t('competitions.show.destroy.title') %></strong></p>
222-
<%= link_to t('competitions.show.destroy.title'), competition_path(competition), method: 'delete', class: "btn btn-danger pull-right" %>
223-
<p><%= t('competitions.show.destroy.text') %></p>
224-
</div>
225-
</div>
226-
<% end %>

app/views/competitions/edit.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<h3><%= t('.title') %></h3>
1313

1414
<%= render 'form', competition: @form %>
15+
<%= render 'destroy_form', competition: @competition %>
1516
</div>
1617
</div>
1718
</div>

app/views/competitions/show.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
</div>
9797
<div role="tabpanel" class="tab-pane" id="settings">
9898
<%= render 'form', competition: @form %>
99+
<%= render 'destroy_form', competition: @competition %>
99100
</div>
100101
<% end %>
101102
</div>

0 commit comments

Comments
 (0)