Merge pull request #2186 from wairbut-m2c/iagirre-add-images-to-milestones
Add Images to Milestones
This commit is contained in:
@@ -314,7 +314,9 @@
|
|||||||
.polls-form,
|
.polls-form,
|
||||||
.poll-question-form,
|
.poll-question-form,
|
||||||
.legislation-process-new,
|
.legislation-process-new,
|
||||||
.legislation-process-edit {
|
.legislation-process-edit,
|
||||||
|
.milestone-new,
|
||||||
|
.milestone-edit {
|
||||||
@include direct-uploads;
|
@include direct-uploads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
|
|||||||
|
|
||||||
def milestone_params
|
def milestone_params
|
||||||
params.require(:budget_investment_milestone)
|
params.require(:budget_investment_milestone)
|
||||||
.permit(:title, :description, :budget_investment_id)
|
.permit(:title, :description, :budget_investment_id,
|
||||||
|
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_budget_investment
|
def load_budget_investment
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
class Budget
|
class Budget
|
||||||
class Investment
|
class Investment
|
||||||
class Milestone < ActiveRecord::Base
|
class Milestone < ActiveRecord::Base
|
||||||
|
include Imageable
|
||||||
|
|
||||||
belongs_to :investment
|
belongs_to :investment
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<%= f.text_field :title, maxlength: Budget::Investment::Milestone.title_max_length %>
|
<%= f.text_field :title, maxlength: Budget::Investment::Milestone.title_max_length %>
|
||||||
<%= f.text_area :description, rows: 5 %>
|
<%= f.text_area :description, rows: 5 %>
|
||||||
|
<%= render 'images/admin_image', imageable: @milestone, f: f %>
|
||||||
|
|
||||||
<%= f.submit nil, class: "button success" %>
|
<%= f.submit nil, class: "button success" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
<h2><%= t("admin.milestones.edit.title") %></h2>
|
<h2><%= t("admin.milestones.edit.title") %></h2>
|
||||||
|
|
||||||
<%= render '/admin/budget_investment_milestones/form' %>
|
<div class="milestone-edit">
|
||||||
|
<%= render '/admin/budget_investment_milestones/form' %>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<th><%= t("admin.milestones.index.table_id") %></th>
|
<th><%= t("admin.milestones.index.table_id") %></th>
|
||||||
<th><%= t("admin.milestones.index.table_title") %></th>
|
<th><%= t("admin.milestones.index.table_title") %></th>
|
||||||
<th><%= t("admin.milestones.index.table_description") %></th>
|
<th><%= t("admin.milestones.index.table_description") %></th>
|
||||||
|
<th><%= t("admin.milestones.index.image") %></th>
|
||||||
<th><%= t("admin.milestones.index.table_actions") %></th>
|
<th><%= t("admin.milestones.index.table_actions") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -20,6 +21,9 @@
|
|||||||
<td class="small">
|
<td class="small">
|
||||||
<%= milestone.description %>
|
<%= milestone.description %>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<%= link_to t("admin.milestones.index.show_image"), milestone.image_url(:large), target: :_blank if milestone.image.present? %>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to t("admin.milestones.index.delete"), admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone),
|
<%= link_to t("admin.milestones.index.delete"), admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone),
|
||||||
method: :delete,
|
method: :delete,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<span class="milestone-date">
|
<span class="milestone-date">
|
||||||
<strong><%= t("budgets.investments.show.milestone_publish_date", publish_date: l(milestone.created_at.to_date)) %></strong>
|
<strong><%= t("budgets.investments.show.milestone_publish_date", publish_date: l(milestone.created_at.to_date)) %></strong>
|
||||||
</span>
|
</span>
|
||||||
|
<%= image_tag(milestone.image_url(:large), {alt: milestone.image.title, class: "margin", id: "image_#{milestone.id}"}) if milestone.image.present? %>
|
||||||
<p><%= milestone.description %></p>
|
<p><%= milestone.description %></p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ en:
|
|||||||
table_actions: "Actions"
|
table_actions: "Actions"
|
||||||
delete: "Delete milestone"
|
delete: "Delete milestone"
|
||||||
no_milestones: "Don't have defined milestones"
|
no_milestones: "Don't have defined milestones"
|
||||||
|
image: "Image"
|
||||||
|
show_image: "Show image"
|
||||||
new:
|
new:
|
||||||
creating: Create milestone
|
creating: Create milestone
|
||||||
edit:
|
edit:
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ es:
|
|||||||
table_actions: "Acciones"
|
table_actions: "Acciones"
|
||||||
delete: "Eliminar hito"
|
delete: "Eliminar hito"
|
||||||
no_milestones: "No hay hitos definidos"
|
no_milestones: "No hay hitos definidos"
|
||||||
|
image: "Imagen"
|
||||||
|
show_image: "Ver imagen"
|
||||||
new:
|
new:
|
||||||
creating: Crear hito
|
creating: Crear hito
|
||||||
edit:
|
edit:
|
||||||
|
|||||||
@@ -62,11 +62,14 @@ feature 'Admin budget investment milestones' do
|
|||||||
context "Edit" do
|
context "Edit" do
|
||||||
scenario "Change title and description" do
|
scenario "Change title and description" do
|
||||||
milestone = create(:budget_investment_milestone, investment: @investment)
|
milestone = create(:budget_investment_milestone, investment: @investment)
|
||||||
|
create(:image, imageable: milestone)
|
||||||
|
|
||||||
visit admin_budget_budget_investment_path(@investment.budget, @investment)
|
visit admin_budget_budget_investment_path(@investment.budget, @investment)
|
||||||
|
|
||||||
click_link milestone.title
|
click_link milestone.title
|
||||||
|
|
||||||
|
expect(page).to have_css("img[alt='#{milestone.image.title}']")
|
||||||
|
|
||||||
fill_in 'budget_investment_milestone_title', with: 'Changed title'
|
fill_in 'budget_investment_milestone_title', with: 'Changed title'
|
||||||
fill_in 'budget_investment_milestone_description', with: 'Changed description'
|
fill_in 'budget_investment_milestone_description', with: 'Changed description'
|
||||||
|
|
||||||
@@ -74,6 +77,7 @@ feature 'Admin budget investment milestones' do
|
|||||||
|
|
||||||
expect(page).to have_content 'Changed title'
|
expect(page).to have_content 'Changed title'
|
||||||
expect(page).to have_content 'Changed description'
|
expect(page).to have_content 'Changed description'
|
||||||
|
expect(page).to have_link 'Show image'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -495,6 +495,7 @@ feature 'Budget Investments' do
|
|||||||
investment = create(:budget_investment)
|
investment = create(:budget_investment)
|
||||||
milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show",
|
milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show",
|
||||||
created_at: DateTime.new(2015, 9, 19).utc)
|
created_at: DateTime.new(2015, 9, 19).utc)
|
||||||
|
image = create(:image, imageable: milestone)
|
||||||
|
|
||||||
login_as(user)
|
login_as(user)
|
||||||
visit budget_investment_path(budget_id: investment.budget.id, id: investment.id)
|
visit budget_investment_path(budget_id: investment.budget.id, id: investment.id)
|
||||||
@@ -505,6 +506,7 @@ feature 'Budget Investments' do
|
|||||||
expect(page).to have_content(milestone.title)
|
expect(page).to have_content(milestone.title)
|
||||||
expect(page).to have_content(milestone.description)
|
expect(page).to have_content(milestone.description)
|
||||||
expect(page).to have_content("Published 2015-09-19")
|
expect(page).to have_content("Published 2015-09-19")
|
||||||
|
expect(page.find("#image_#{milestone.id}")['alt']).to have_content image.title
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user