Skip to content

Commit

Permalink
Hides question menu on budget poll and changes redirect when create
Browse files Browse the repository at this point in the history
  • Loading branch information
decabeza authored and javierm committed Apr 3, 2019
1 parent 431c313 commit fcbb11b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
7 changes: 6 additions & 1 deletion app/controllers/admin/poll/polls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def new
def create
@poll = Poll.new(poll_params.merge(author: current_user))
if @poll.save
redirect_to [:admin, @poll], notice: t("flash.actions.create.poll")
notice = t("flash.actions.create.poll")
if @poll.budget.present?
redirect_to admin_poll_booth_assignments_path(@poll), notice: notice
else
redirect_to [:admin, @poll], notice: notice
end
else
render :new
end
Expand Down
3 changes: 3 additions & 0 deletions app/models/poll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,7 @@ def date_range
end
end

def budget_poll?
budget.present?
end
end
2 changes: 1 addition & 1 deletion app/views/admin/budgets/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</td>
<td class="small">
<% if budget.poll.present? %>
<%= link_to t("admin.budgets.index.admin_ballots"), admin_poll_path(budget.poll) %>
<%= link_to t("admin.budgets.index.admin_ballots"), admin_poll_booth_assignments_path(budget.poll) %>
<% else %>
<%= link_to_create_budget_poll(budget) %>
<% end %>
Expand Down
30 changes: 16 additions & 14 deletions app/views/admin/poll/polls/_subnav.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<ul class="menu simple clear" id="assigned-resources-tabs">
<% if controller_name == "polls" %>
<li class="is-active">
<h2>
<%= t("admin.polls.show.questions_tab") %>
(<%= @poll.questions.count %>)
</h2>
</li>
<% else %>
<li>
<%= link_to admin_poll_path(@poll) do %>
<%= t("admin.polls.show.questions_tab") %>
(<%= @poll.questions.count %>)
<% end %>
</li>
<% unless @poll.budget_poll? %>
<% if controller_name == "polls" %>
<li class="is-active">
<h2>
<%= t("admin.polls.show.questions_tab") %>
(<%= @poll.questions.count %>)
</h2>
</li>
<% else %>
<li>
<%= link_to admin_poll_path(@poll) do %>
<%= t("admin.polls.show.questions_tab") %>
(<%= @poll.questions.count %>)
<% end %>
</li>
<% end %>
<% end %>
<% if controller_name == "booth_assignments" %>
Expand Down

0 comments on commit fcbb11b

Please sign in to comment.