Merge branch 'master' into feature/2275#destroy_budgets

This commit is contained in:
BertoCQ
2018-01-09 11:03:51 +01:00
committed by GitHub
19 changed files with 182 additions and 49 deletions

View File

@@ -27,7 +27,7 @@ class Admin::BudgetsController < Admin::BaseController
def update
if @budget.update(budget_params)
redirect_to admin_budget_path(@budget), notice: t('admin.budgets.update.notice')
redirect_to admin_budgets_path, notice: t('admin.budgets.update.notice')
else
render :edit
end

View File

@@ -1,5 +1,6 @@
class BudgetsController < ApplicationController
include FeatureFlags
include BudgetsHelper
feature_flag :budgets
load_and_authorize_resource
@@ -9,6 +10,7 @@ class BudgetsController < ApplicationController
respond_to :html, :js
def show
raise ActionController::RoutingError, 'Not Found' unless budget_published?(@budget)
end
def index

View File

@@ -42,4 +42,9 @@ module BudgetsHelper
def investment_tags_select_options
Budget::Investment.tags_on(:valuation).order(:name).select(:name).distinct
end
def budget_published?(budget)
!budget.drafting? || current_user&.administrator?
end
end

View File

@@ -3,7 +3,8 @@ class Budget < ActiveRecord::Base
include Measurable
include Sluggable
PHASES = %w(accepting reviewing selecting valuating balloting reviewing_ballots finished).freeze
PHASES = %w(drafting accepting reviewing selecting valuating balloting
reviewing_ballots finished).freeze
CURRENCY_SYMBOLS = %w(€ $ £ ¥).freeze
validates :name, presence: true, uniqueness: true
@@ -19,6 +20,7 @@ class Budget < ActiveRecord::Base
before_validation :sanitize_descriptions
scope :on_hold, -> { where(phase: %w(reviewing valuating reviewing_ballots")) }
scope :drafting, -> { where(phase: "drafting") }
scope :accepting, -> { where(phase: "accepting") }
scope :reviewing, -> { where(phase: "reviewing") }
scope :selecting, -> { where(phase: "selecting") }
@@ -41,6 +43,10 @@ class Budget < ActiveRecord::Base
80
end
def drafting?
phase == "drafting"
end
def accepting?
phase == "accepting"
end

View File

@@ -16,14 +16,16 @@
</thead>
<tbody>
<% @budgets.each do |budget| %>
<tr>
<td>
<%= link_to budget.name, budget %>
</td>
<td>
<%= budget.translated_phase %>
</td>
</tr>
<% if budget_published?(budget) %>
<tr>
<td>
<%= link_to budget.name, budget %>
</td>
<td>
<%= budget.translated_phase %>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>

View File

@@ -1,3 +1,12 @@
<% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags",
social_url: budget_investments_path(investment),
social_title: investment.title,
social_description: investment.description,
twitter_image_url: (investment.image.present? ? investment.image_url(:thumb) : nil),
og_image_url: (investment.image.present? ? investment.image_url(:thumb) : nil) %>
<% end %>
<section class="budget-investment-show" id="<%= dom_id(investment) %>">
<div class="row">

View File

@@ -4,7 +4,9 @@
<%= render "shared/social_media_meta_tags",
social_url: proposal_url(@proposal),
social_title: @proposal.title,
social_description: @proposal.summary %>
social_description: @proposal.summary,
twitter_image_url: (@proposal.image.present? ? @proposal.image_url(:thumb) : nil),
og_image_url: (@proposal.image.present? ? @proposal.image_url(:thumb) : nil) %>
<% end %>
<% content_for :canonical do %>
<%= render "shared/canonical", href: proposal_url(@proposal) %>