Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream #1060

Merged
merged 21 commits into from
Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
56a7c46
adds timestamps to polls
voodoorai2000 Dec 13, 2017
c14f9be
Add 'publication_date' attribute to Budget::Investment::Milestone
aitbw Dec 12, 2017
6d57d76
Admins can add a 'publication date' to milestones
aitbw Dec 13, 2017
03ae14c
End-users will be shown a milestone's publication date if available
aitbw Dec 13, 2017
1e1028d
Adapt existing milestone-related specs to fit the new requirement
aitbw Dec 13, 2017
01a8c55
Make Budget::Investment::Milestone class Documentable.
Dec 14, 2017
ff50dc1
Add feature specs to test new admin features and documents' show in u…
Dec 14, 2017
7399e5f
Update unreleased section of Changelog
bertocq Dec 14, 2017
50b4f50
Merge branch 'master' into aperez-dates-for-milestones
bertocq Dec 14, 2017
2b52d26
refactors notifications into concerns and shared examples
voodoorai2000 Dec 14, 2017
e675cee
Merge branch 'master' into aperez-dates-for-milestones
decabeza Dec 14, 2017
09b5447
Merge pull request #2191 from wairbut-m2c/iagirre-add-documents-to-mi…
decabeza Dec 14, 2017
1737f85
Merge branch 'master' into aperez-dates-for-milestones
decabeza Dec 14, 2017
76a3dd5
Merge branch 'master' into aperez-dates-for-milestones
decabeza Dec 14, 2017
b4782f7
delete unnecessary parenthesis
decabeza Dec 14, 2017
a46863a
Merge pull request #2188 from wairbut-m2c/aperez-dates-for-milestones
decabeza Dec 14, 2017
23eaffc
Merge remote-tracking branch 'upstream/master' into upstream
decabeza Dec 14, 2017
9ba8ca7
Merge pull request #2187 from consul/notifications
voodoorai2000 Dec 14, 2017
3f7484d
fixes conflicts with upstream
voodoorai2000 Dec 14, 2017
bf86eea
Merge branch 'master' into upstream
voodoorai2000 Dec 15, 2017
1e1ab12
Merge pull request #1061 from AyuntamientoMadrid/notifications
voodoorai2000 Dec 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/assets/stylesheets/participation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@
.draft-panels,
.debate-questions,
.communities-show,
.topic-show {
.topic-show,
.milestone-content {

p {
word-wrap: break-word;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def destroy
def milestone_params
params.require(:budget_investment_milestone)
.permit(:title, :description, :budget_investment_id,
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
end

def load_budget_investment
Expand Down
4 changes: 4 additions & 0 deletions app/models/budget/investment/milestone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ class Budget
class Investment
class Milestone < ActiveRecord::Base
include Imageable
include Documentable
documentable max_documents_allowed: 3,
max_file_size: 3.megabytes,
accepted_content_types: [ "application/pdf" ]

belongs_to :investment

Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/budget_investment_milestones/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
<%= f.text_area :description, rows: 5 %>
<%= render 'images/admin_image', imageable: @milestone, f: f %>

<hr>
<div class="documents">
<%= render 'documents/nested_documents', documentable: @milestone, f: f %>
</div>

<%= f.submit nil, class: "button success" %>
<% end %>
11 changes: 11 additions & 0 deletions app/views/admin/budget_investments/_milestones.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<th><%= t("admin.milestones.index.table_title") %></th>
<th><%= t("admin.milestones.index.table_description") %></th>
<th><%= t("admin.milestones.index.image") %></th>
<th><%= t("admin.milestones.index.documents") %></th>
<th><%= t("admin.milestones.index.table_actions") %></th>
</tr>
</thead>
Expand All @@ -24,6 +25,16 @@
<td class="small">
<%= link_to t("admin.milestones.index.show_image"), milestone.image_url(:large), target: :_blank if milestone.image.present? %>
</td>
<td class="small">
<% if milestone.documents.present? %>
<% milestone.documents.each do |document| %>
<%= link_to document.title,
document.attachment.url,
target: "_blank",
rel: "" %><br>
<% end %>
<% end %>
</td>
<td>
<%= link_to t("admin.milestones.index.delete"), admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone),
method: :delete,
Expand Down
14 changes: 14 additions & 0 deletions app/views/budgets/investments/_milestones.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
</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>
<% if milestone.documents.present? %>
<div class="document-link text-center">
<p>
<span class="icon-document"></span>&nbsp;
<strong><%= t('proposals.show.title_external_url') %></strong>
</p>
<% milestone.documents.each do |document| %>
<%= link_to document.title,
document.attachment.url,
target: "_blank",
rel: "" %><br>
<% end %>
</div>
<% end %>
</div>
</li>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ en:
no_milestones: "Don't have defined milestones"
image: "Image"
show_image: "Show image"
documents: "Documents"
new:
creating: Create milestone
edit:
Expand Down
1 change: 1 addition & 0 deletions config/locales/es/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ es:
no_milestones: "No hay hitos definidos"
image: "Imagen"
show_image: "Ver imagen"
documents: "Documentos"
new:
creating: Crear hito
edit:
Expand Down
10 changes: 9 additions & 1 deletion spec/features/admin/budget_investment_milestones_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
context "Index" do
scenario 'Displaying milestones' do
milestone = create(:budget_investment_milestone, investment: @investment)
create(:image, imageable: milestone)
document = create(:document, documentable: milestone)

visit admin_budget_budget_investment_path(@investment.budget, @investment)

expect(page).to have_content("Milestone")
expect(page).to have_content(milestone.title)
expect(page).to have_content(milestone.id)
expect(page).to have_link 'Show image'
expect(page).to have_link document.title
end

scenario 'Displaying no_milestones text' do
Expand Down Expand Up @@ -60,24 +64,28 @@
end

context "Edit" do
scenario "Change title and description" do
scenario "Change title, description and document names" do
milestone = create(:budget_investment_milestone, investment: @investment)
create(:image, imageable: milestone)
document = create(:document, documentable: milestone)

visit admin_budget_budget_investment_path(@investment.budget, @investment)
expect(page).to have_link document.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_description', with: 'Changed description'
fill_in 'budget_investment_milestone_documents_attributes_0_title', with: 'New document title'

click_button 'Update milestone'

expect(page).to have_content 'Changed title'
expect(page).to have_content 'Changed description'
expect(page).to have_link 'Show image'
expect(page).to have_link 'New document title'
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/features/budgets/investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ def investments_order
milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show",
created_at: DateTime.new(2015, 9, 19).utc)
image = create(:image, imageable: milestone)
document = create(:document, documentable: milestone)

login_as(user)
visit budget_investment_path(budget_id: investment.budget.id, id: investment.id)
Expand All @@ -515,6 +516,7 @@ def investments_order
expect(page).to have_content(milestone.description)
expect(page).to have_content("Published 2015-09-19")
expect(page.find("#image_#{milestone.id}")['alt']).to have_content image.title
expect(page).to have_link document.title
end
end

Expand Down