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 1 commit
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
Prev Previous commit
Next Next commit
Admins can add a 'publication date' to milestones
  • Loading branch information
aitbw committed Dec 14, 2017
commit 6d57d7607135642ae04b5012b3632dc381743527
16 changes: 9 additions & 7 deletions app/controllers/admin/budget_investment_milestones_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def create
@milestone = Budget::Investment::Milestone.new(milestone_params)
@milestone.investment = @investment
if @milestone.save
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.create.notice')
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment),
notice: t('admin.milestones.create.notice')
else
render :new
end
Expand All @@ -25,32 +26,33 @@ def edit

def update
if @milestone.update(milestone_params)
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.update.notice')
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment),
notice: t('admin.milestones.update.notice')
else
render :edit
end
end

def destroy
@milestone.destroy
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.delete.notice')
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment),
notice: t('admin.milestones.delete.notice')
end

private

def milestone_params
params.require(:budget_investment_milestone)
.permit(:title, :description, :budget_investment_id,
.permit(:title, :description, :publication_date, :budget_investment_id,
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
end

def load_budget_investment
@investment = Budget::Investment.find params[:budget_investment_id]
@investment = Budget::Investment.find(params[:budget_investment_id])
end

def load_budget_investment_milestone
@milestone = Budget::Investment::Milestone.find params[:id]
@milestone = Budget::Investment::Milestone.find(params[:id])
end


end
1 change: 1 addition & 0 deletions app/models/budget/investment/milestone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Milestone < ActiveRecord::Base

validates :title, presence: true
validates :investment, presence: true
validates :publication_date, presence: true

def self.title_max_length
80
Expand Down
4 changes: 4 additions & 0 deletions app/views/admin/budget_investment_milestones/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

<%= f.text_field :title, maxlength: Budget::Investment::Milestone.title_max_length %>
<%= f.text_area :description, rows: 5 %>
<%= f.text_field :publication_date,
value: @milestone.publication_date.present? ? l(@milestone.publication_date.to_date) : nil,
class: "js-calendar-full" %>

<%= render 'images/admin_image', imageable: @milestone, f: f %>

<%= f.submit nil, class: "button success" %>
Expand Down
32 changes: 19 additions & 13 deletions app/views/admin/budget_investments/_milestones.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,42 @@
<th><%= t("admin.milestones.index.table_id") %></th>
<th><%= t("admin.milestones.index.table_title") %></th>
<th><%= t("admin.milestones.index.table_description") %></th>
<th><%= t("admin.milestones.index.table_publication_date") %></th>
<th><%= t("admin.milestones.index.image") %></th>
<th><%= t("admin.milestones.index.table_actions") %></th>
</tr>
</thead>
<tbody>
<% @investment.milestones.each do |milestone| %>
<tr id="<%= dom_id(milestone) %>" class="milestone">
<td><%= milestone.id %></td>
<td>
<%= milestone.id %>
</td>
<td>
<%= link_to milestone.title, edit_admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone) %>
</td>
<td class="small">
<%= milestone.description %>
<%= link_to milestone.title,
edit_admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget,
@investment,
milestone) %>
</td>
<td class="small"><%= milestone.description %></td>
<% if milestone.publication_date.present? %>
<td class="small"><%= l(milestone.publication_date.to_date) %></td>
<% end %>
<td class="small">
<%= link_to t("admin.milestones.index.show_image"), milestone.image_url(:large), target: :_blank if milestone.image.present? %>
<%= link_to t("admin.milestones.index.show_image"),
milestone.image_url(:large),
target: :_blank if milestone.image.present? %>
</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,
class: 'button hollow alert expanded' %>
class: "button hollow alert expanded" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p>
<%= t('admin.milestones.index.no_milestones') %>
</p>
<p><%= t("admin.milestones.index.no_milestones") %></p>
<% end %>
1 change: 1 addition & 0 deletions config/locales/en/activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ en:
budget/investment/milestone:
title: "Title"
description: "Description"
publication_date: "Publication date"
comment:
body: "Comment"
user: "User"
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ en:
table_id: "ID"
table_title: "Title"
table_description: "Description"
table_publication_date: "Publication date"
table_actions: "Actions"
delete: "Delete milestone"
no_milestones: "Don't have defined milestones"
Expand Down Expand Up @@ -1078,4 +1079,4 @@ en:
updated_at: Updated at
status_draft: Draft
status_published: Published
locale: Language
locale: Language
3 changes: 2 additions & 1 deletion config/locales/es/activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ es:
budget/investment/milestone:
title: "Título"
description: "Descripción"
publication_date: "Fecha de publicación"
comment:
body: "Comentario"
user: "Usuario"
Expand Down Expand Up @@ -287,4 +288,4 @@ es:
record_invalid: "La validación falló: %{errors}"
restrict_dependent_destroy:
has_one: No se puede eliminar el registro porque existe un %{record} dependiente
has_many: No se puede eliminar el registro porque existen %{record} dependientes
has_many: No se puede eliminar el registro porque existen %{record} dependientes
1 change: 1 addition & 0 deletions config/locales/es/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ es:
table_id: "ID"
table_title: "Título"
table_description: "Descripción"
table_publication_date: "Fecha de publicación"
table_actions: "Acciones"
delete: "Eliminar hito"
no_milestones: "No hay hitos definidos"
Expand Down