basic proposal voting my managers
This commit is contained in:
@@ -1,18 +1,33 @@
|
||||
class Management::ProposalsController < Management::BaseController
|
||||
skip_before_action :verify_manager
|
||||
include HasOrders
|
||||
|
||||
before_action :set_proposal, only: :vote
|
||||
has_orders %w{hot_score confidence_score created_at most_commented random}, only: :index
|
||||
|
||||
def index
|
||||
@proposals = Proposal.all.limit(10).page(params[:page])
|
||||
@tag_cloud = []
|
||||
set_proposal_votes(@proposals)
|
||||
end
|
||||
|
||||
def vote
|
||||
@proposal.register_vote(current_user, 'yes')
|
||||
redirect_to management_proposals_url, notice: "Succesfully voted"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_proposal
|
||||
@proposal = Proposal.find(params[:id])
|
||||
end
|
||||
|
||||
def set_proposal_votes(proposals)
|
||||
@proposal_votes = current_user ? current_user.proposal_votes(proposals) : {}
|
||||
end
|
||||
|
||||
def current_user
|
||||
#CHANGE ME
|
||||
#Should be user being managed
|
||||
User.first
|
||||
end
|
||||
|
||||
end
|
||||
35
app/views/management/proposals/_proposal.html.erb
Normal file
35
app/views/management/proposals/_proposal.html.erb
Normal file
@@ -0,0 +1,35 @@
|
||||
<div id="<%= dom_id(proposal) %>" class="proposal clear">
|
||||
<div class="panel">
|
||||
<div class="row">
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<div class="proposal-content">
|
||||
<span class="label-proposal left"><%= t("proposals.proposal.proposal") %></span>
|
||||
<i class="icon-proposals"></i>
|
||||
<h3><%= link_to proposal.title, "#" %></h3>
|
||||
|
||||
<p class="proposal-info">
|
||||
<i class="icon-comments"></i>
|
||||
<span class="bullet"> • </span>
|
||||
<%= l proposal.created_at.to_date %>
|
||||
<span class="bullet"> • </span>
|
||||
<span class="author">
|
||||
<%= proposal.try(:author).try(:name) %>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div class="proposal-description">
|
||||
<p><%= proposal.summary %></p>
|
||||
<div class="truncate"></div>
|
||||
</div>
|
||||
|
||||
<%= render "shared/tags", taggable: proposal, limit: 5 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="<%= dom_id(proposal) %>_votes" class="small-12 medium-3 column text-center">
|
||||
<%= render 'votes', proposal: proposal %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
9
app/views/management/proposals/_votes.html.erb
Normal file
9
app/views/management/proposals/_votes.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<div class="supports">
|
||||
<div class="in-favor">
|
||||
<%= link_to vote_management_proposal_path(proposal, value: 'yes'),
|
||||
class: "button button-support tiny radius expand",
|
||||
title: t('proposals.proposal.support_title'), method: "post" do %>
|
||||
<%= t("proposals.proposal.support") %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1 +1,20 @@
|
||||
<%= render template: "proposals/index" %>
|
||||
<section role="main">
|
||||
<div class="wrap row">
|
||||
<div id="proposals" class="proposals-list small-12 medium-9 column">
|
||||
|
||||
<div class="filters">
|
||||
<div class="small-12 medium-7 left">
|
||||
<% if @search_terms %>
|
||||
<h2 class="margin-top">
|
||||
<%= page_entries_info @proposals %>
|
||||
<%= t("proposals.index.search_results", count: @proposals.size, search_term: @search_terms) %>
|
||||
</h2>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= render @proposals %>
|
||||
<%= paginate @proposals %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -169,7 +169,11 @@ Rails.application.routes.draw do
|
||||
get 'sign_in', to: 'sessions#create'
|
||||
|
||||
resources :sessions, only: :create
|
||||
resources :proposals, only: :index
|
||||
resources :proposals, only: :index do
|
||||
member do
|
||||
post :vote
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Example of regular route:
|
||||
|
||||
Reference in New Issue
Block a user