Add can_comment and can_edit_dossier abilities to valuators
This commit is contained in:
@@ -47,7 +47,8 @@ class Admin::ValuatorsController < Admin::BaseController
|
|||||||
|
|
||||||
def valuator_params
|
def valuator_params
|
||||||
params[:valuator][:description] = nil if params[:valuator][:description].blank?
|
params[:valuator][:description] = nil if params[:valuator][:description].blank?
|
||||||
params.require(:valuator).permit(:user_id, :description, :valuator_group_id)
|
params.require(:valuator).permit(:user_id, :description, :valuator_group_id,
|
||||||
|
:can_comment, :can_edit_dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,4 +4,9 @@ module ValuatorsHelper
|
|||||||
truncate([valuator.name, valuator.email, valuator.description].compact.join(" - "), length: 100)
|
truncate([valuator.name, valuator.email, valuator.description].compact.join(" - "), length: 100)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def valuator_abilities(valuator)
|
||||||
|
[ valuator.can_comment ? I18n.t("admin.valuators.index.can_comment") : nil ,
|
||||||
|
valuator.can_edit_dossier ? I18n.t("admin.valuators.index.can_edit_dossier") : nil
|
||||||
|
].compact.join(", ")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ module Abilities
|
|||||||
can [:hide, :update, :toggle_selection], Budget::Investment
|
can [:hide, :update, :toggle_selection], Budget::Investment
|
||||||
can [:valuate, :comment_valuation], Budget::Investment
|
can [:valuate, :comment_valuation], Budget::Investment
|
||||||
can :create, Budget::ValuatorAssignment
|
can :create, Budget::ValuatorAssignment
|
||||||
|
can [:edit_dossier], Budget::Investment
|
||||||
|
|
||||||
can(:read_admin_stats, Budget) { |budget| budget.balloting_or_later? }
|
can(:read_admin_stats, Budget) { |budget| budget.balloting_or_later? }
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,20 @@ module Abilities
|
|||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
valuator = user.valuator
|
valuator = user.valuator
|
||||||
|
assigned_investment_ids = valuator.assigned_investment_ids
|
||||||
|
finished = { phase: "finished" }
|
||||||
|
|
||||||
can [:read, :update, :comment_valuation], Budget::Investment, id: valuator.assigned_investment_ids
|
can [:read, :update], Budget::Investment, id: assigned_investment_ids
|
||||||
can [:valuate], Budget::Investment, { id: valuator.assigned_investment_ids, valuation_finished: false }
|
can [:valuate], Budget::Investment, { id: assigned_investment_ids, valuation_finished: false }
|
||||||
cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: { phase: "finished" }
|
cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: finished
|
||||||
|
|
||||||
|
if valuator.can_edit_dossier?
|
||||||
|
can [:edit_dossier], Budget::Investment, id: assigned_investment_ids
|
||||||
|
end
|
||||||
|
|
||||||
|
if valuator.can_comment?
|
||||||
|
can [:comment_valuation], Budget::Investment, id: assigned_investment_ids
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
14
app/views/admin/valuators/_user_row.html.erb
Normal file
14
app/views/admin/valuators/_user_row.html.erb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<tr>
|
||||||
|
<td><%= link_to user.name, user_path(user), target: "_blank" %></td>
|
||||||
|
<td><%= user.email %></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<%= form_for Valuator.new(user: user), url: admin_valuators_path do |f| %>
|
||||||
|
<%= f.hidden_field :user_id %>
|
||||||
|
<%= f.submit t("admin.valuators.valuator.add"),
|
||||||
|
class: "button success expanded" %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
30
app/views/admin/valuators/_valuator_row.html.erb
Normal file
30
app/views/admin/valuators/_valuator_row.html.erb
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<tr>
|
||||||
|
<td><%= link_to valuator.name, admin_valuator_path(valuator) %></td>
|
||||||
|
<td><%= valuator.email %></td>
|
||||||
|
<td>
|
||||||
|
<% if valuator.description.present? %>
|
||||||
|
<%= valuator.description %>
|
||||||
|
<% else %>
|
||||||
|
<%= t("admin.valuators.index.no_description") %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if valuator.valuator_group.present? %>
|
||||||
|
<%= valuator.valuator_group.try(:name) %>
|
||||||
|
<% else %>
|
||||||
|
<%= t("admin.valuators.index.no_group") %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= valuator_abilities(valuator) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= link_to t("admin.actions.edit"),
|
||||||
|
edit_admin_valuator_path(valuator),
|
||||||
|
class: "button hollow" %>
|
||||||
|
<%= link_to t("admin.valuators.valuator.delete"),
|
||||||
|
admin_valuator_path(valuator),
|
||||||
|
method: :delete,
|
||||||
|
class: "button hollow alert" %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
21
app/views/admin/valuators/_valuators.html.erb
Normal file
21
app/views/admin/valuators/_valuators.html.erb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<th scope="col"><%= t("admin.valuators.index.name") %></th>
|
||||||
|
<th scope="col"><%= t("admin.valuators.index.email") %></th>
|
||||||
|
<th scope="col"><%= t("admin.valuators.index.description") %></th>
|
||||||
|
<th scope="col"><%= t("admin.valuators.index.group") %></th>
|
||||||
|
<th scope="col"><%= t("admin.valuators.index.abilities") %></th>
|
||||||
|
<th scope="col" class="small-3"><%= t("admin.actions.actions") %></th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% valuators.each do |valuator| %>
|
||||||
|
<% if valuator.is_a?(Valuator) %>
|
||||||
|
<%= render partial: 'valuator_row', locals: {valuator: valuator} %>
|
||||||
|
<% elsif valuator.valuator? %>
|
||||||
|
<%= render partial: 'valuator_row', locals: {valuator: valuator.valuator} %>
|
||||||
|
<% else %>
|
||||||
|
<%= render partial: 'user_row', locals: {user: valuator} %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -15,6 +15,12 @@
|
|||||||
@valuator_groups.map {|group| [group.name, group.id] },
|
@valuator_groups.map {|group| [group.name, group.id] },
|
||||||
{ include_blank: true } %>
|
{ include_blank: true } %>
|
||||||
</div>
|
</div>
|
||||||
<%= f.submit t("admin.valuators.form.update"), class: "button success" %>
|
<div>
|
||||||
|
<div class="filter">
|
||||||
|
<%= f.check_box :can_comment %>
|
||||||
|
<%= f.check_box :can_edit_dossier %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= f.submit class: "button success" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,46 +8,7 @@
|
|||||||
<% if @valuators.any? %>
|
<% if @valuators.any? %>
|
||||||
<h3 class="margin"><%= page_entries_info @valuators %></h3>
|
<h3 class="margin"><%= page_entries_info @valuators %></h3>
|
||||||
|
|
||||||
<table>
|
<%= render partial: "valuators", locals: {valuators: @valuators} %>
|
||||||
<thead>
|
|
||||||
<th scope="col"><%= t("admin.valuators.index.name") %></th>
|
|
||||||
<th scope="col"><%= t("admin.valuators.index.email") %></th>
|
|
||||||
<th scope="col"><%= t("admin.valuators.index.description") %></th>
|
|
||||||
<th scope="col"><%= t("admin.valuators.index.group") %></th>
|
|
||||||
<th scope="col" class="small-3"><%= t("admin.actions.actions") %></th>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% @valuators.each do |valuator| %>
|
|
||||||
<tr>
|
|
||||||
<td><%= link_to valuator.name, admin_valuator_path(valuator) %></td>
|
|
||||||
<td><%= valuator.email %></td>
|
|
||||||
<td>
|
|
||||||
<% if valuator.description.present? %>
|
|
||||||
<%= valuator.description %>
|
|
||||||
<% else %>
|
|
||||||
<%= t("admin.valuators.index.no_description") %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<% if valuator.valuator_group.present? %>
|
|
||||||
<%= valuator.valuator_group.try(:name) %>
|
|
||||||
<% else %>
|
|
||||||
<%= t("admin.valuators.index.no_group") %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= link_to t("admin.actions.edit"),
|
|
||||||
edit_admin_valuator_path(valuator),
|
|
||||||
class: "button hollow" %>
|
|
||||||
<%= link_to t("admin.valuators.valuator.delete"),
|
|
||||||
admin_valuator_path(valuator),
|
|
||||||
method: :delete,
|
|
||||||
class: "button hollow alert" %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<%= paginate @valuators %>
|
<%= paginate @valuators %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -5,51 +5,7 @@
|
|||||||
<div id="valuators">
|
<div id="valuators">
|
||||||
<% if @users.any? %>
|
<% if @users.any? %>
|
||||||
<h3 class="margin"><%= page_entries_info @users %></h3>
|
<h3 class="margin"><%= page_entries_info @users %></h3>
|
||||||
|
<%= render partial: "valuators", locals: {valuators: @users} %>
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<th scope="col"><%= t("admin.valuators.index.name") %></th>
|
|
||||||
<th scope="col"><%= t("admin.valuators.index.email") %></th>
|
|
||||||
<th scope="col"><%= t("admin.valuators.index.description") %></th>
|
|
||||||
<th scope="col"><%= t("admin.shared.actions") %></th>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% @users.each do |user| %>
|
|
||||||
<tr>
|
|
||||||
<td><%= user.name %></td>
|
|
||||||
<td><%= user.email %></td>
|
|
||||||
<td>
|
|
||||||
<% if user.valuator? %>
|
|
||||||
<% if user.valuator.description.present? %>
|
|
||||||
<%= user.valuator.description %>
|
|
||||||
<% else %>
|
|
||||||
<%= t("admin.valuators.index.no_description") %>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<%= t("admin.valuators.index.no_description") %>
|
|
||||||
<% end %>
|
|
||||||
<td>
|
|
||||||
<% if user.valuator? %>
|
|
||||||
<%= link_to t("admin.actions.edit"),
|
|
||||||
edit_admin_valuator_path(user.valuator),
|
|
||||||
class: "button hollow" %>
|
|
||||||
|
|
||||||
<%= link_to t("admin.valuators.valuator.delete"),
|
|
||||||
admin_valuator_path(user),
|
|
||||||
method: :delete,
|
|
||||||
class: "button hollow alert expanded" %>
|
|
||||||
<% else %>
|
|
||||||
<%= form_for Valuator.new(user: user), url: admin_valuators_path do |f| %>
|
|
||||||
<%= f.hidden_field :user_id %>
|
|
||||||
<%= f.submit t("admin.valuators.valuator.add"),
|
|
||||||
class: "button success expanded" %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="callout alert margin">
|
<div class="callout alert margin">
|
||||||
<%= t("admin.shared.no_search_results") %>
|
<%= t("admin.shared.no_search_results") %>
|
||||||
|
|||||||
@@ -27,4 +27,13 @@
|
|||||||
<%= t("admin.valuators.show.no_group") %>
|
<%= t("admin.valuators.show.no_group") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<strong><%= t("admin.valuators.show.abilities") %></strong><br>
|
||||||
|
<% if valuator_abilities(@valuator).present? %>
|
||||||
|
<%= valuator_abilities(@valuator) %>
|
||||||
|
<% else %>
|
||||||
|
<%= t("admin.valuators.show.no_abilities") %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<h2><%= t("valuation.budget_investments.valuation_comments") %></h2>
|
<h2><%= t("valuation.budget_investments.valuation_comments") %></h2>
|
||||||
<% unless @comment_tree.nil? %>
|
<% unless @comment_tree.nil? %>
|
||||||
<%= render partial: "/comments/comment_tree", locals: {
|
<% can_comment = (!@budget.finished? && can?(:comment_valuation, @investment)) %>
|
||||||
comment_tree: @comment_tree,
|
|
||||||
|
<%= render partial: "/comments/comment_tree", locals: { comment_tree: @comment_tree,
|
||||||
comment_flags: @comment_flags,
|
comment_flags: @comment_flags,
|
||||||
display_comments_count: false,
|
display_comments_count: false,
|
||||||
valuation: true,
|
valuation: true,
|
||||||
allow_comments: !@budget.finished?,
|
allow_comments: can_comment,
|
||||||
admin_layout: true } %>
|
admin_layout: true } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<h2><%= t("valuation.budget_investments.edit.dossier") %></h2>
|
<h2><%= t("valuation.budget_investments.edit.dossier") %></h2>
|
||||||
<% if can?(:valuate, @investment) %>
|
<% if can?(:valuate, @investment) && can?(:edit_dossier, @investment) %>
|
||||||
<%= render partial: "/valuation/budget_investments/dossier_form", locals: {investment: @investment} %>
|
<%= render partial: "/valuation/budget_investments/dossier_form", locals: {investment: @investment} %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render partial: "/valuation/budget_investments/dossier_detail", locals: {investment: @investment} %>
|
<%= render partial: "/valuation/budget_investments/dossier_detail", locals: {investment: @investment} %>
|
||||||
|
|||||||
@@ -912,7 +912,6 @@ ar:
|
|||||||
cost: التكلفة
|
cost: التكلفة
|
||||||
form:
|
form:
|
||||||
edit_title: "المقيّمون: تعديل المقيّمين"
|
edit_title: "المقيّمون: تعديل المقيّمين"
|
||||||
update: "تحديث المقيّم"
|
|
||||||
updated: "تم تحديث المقيّمين بنجاح"
|
updated: "تم تحديث المقيّمين بنجاح"
|
||||||
show:
|
show:
|
||||||
description: "الوصف"
|
description: "الوصف"
|
||||||
|
|||||||
@@ -787,7 +787,6 @@ de:
|
|||||||
cost: Gesamtkosten
|
cost: Gesamtkosten
|
||||||
form:
|
form:
|
||||||
edit_title: "Begutachter*innen: Begutachter*in bearbeiten"
|
edit_title: "Begutachter*innen: Begutachter*in bearbeiten"
|
||||||
update: "Begutachter*in aktualisieren"
|
|
||||||
updated: "Begutachter*in erfolgreich aktualisiert"
|
updated: "Begutachter*in erfolgreich aktualisiert"
|
||||||
show:
|
show:
|
||||||
description: "Beschreibung"
|
description: "Beschreibung"
|
||||||
|
|||||||
@@ -352,6 +352,11 @@ en:
|
|||||||
link:
|
link:
|
||||||
label: Title
|
label: Title
|
||||||
url: Link
|
url: Link
|
||||||
|
valuator:
|
||||||
|
description: Description
|
||||||
|
valuator_group_id: Valuator group
|
||||||
|
can_comment: Can create comments
|
||||||
|
can_edit_dossier: Can edit dossiers
|
||||||
errors:
|
errors:
|
||||||
models:
|
models:
|
||||||
user:
|
user:
|
||||||
|
|||||||
@@ -903,6 +903,9 @@ en:
|
|||||||
valuator_groups: "Valuator Groups"
|
valuator_groups: "Valuator Groups"
|
||||||
group: "Group"
|
group: "Group"
|
||||||
no_group: "No group"
|
no_group: "No group"
|
||||||
|
abilities: "Abilities"
|
||||||
|
can_comment: "Can comment"
|
||||||
|
can_edit_dossier: "Can edit dossier"
|
||||||
valuator:
|
valuator:
|
||||||
add: Add to valuators
|
add: Add to valuators
|
||||||
delete: Delete
|
delete: Delete
|
||||||
@@ -910,14 +913,15 @@ en:
|
|||||||
title: "Valuators: User search"
|
title: "Valuators: User search"
|
||||||
form:
|
form:
|
||||||
edit_title: "Valuators: Edit valuator"
|
edit_title: "Valuators: Edit valuator"
|
||||||
update: "Update valuator"
|
|
||||||
updated: "Valuator updated successfully"
|
updated: "Valuator updated successfully"
|
||||||
show:
|
show:
|
||||||
description: "Description"
|
description: "Description"
|
||||||
email: "Email"
|
email: "Email"
|
||||||
group: "Group"
|
group: "Group"
|
||||||
|
abilities: "Abilities"
|
||||||
no_description: "Without description"
|
no_description: "Without description"
|
||||||
no_group: "Without group"
|
no_group: "Without group"
|
||||||
|
no_abilities: "Without abilities"
|
||||||
valuator_groups:
|
valuator_groups:
|
||||||
index:
|
index:
|
||||||
title: "Valuator groups"
|
title: "Valuator groups"
|
||||||
|
|||||||
@@ -354,6 +354,11 @@ es:
|
|||||||
link:
|
link:
|
||||||
label: Título
|
label: Título
|
||||||
url: Enlace
|
url: Enlace
|
||||||
|
valuator:
|
||||||
|
description: Descripción
|
||||||
|
valuator_group_id: Grupo de evaluación
|
||||||
|
can_comment: Puede comentar
|
||||||
|
can_edit_dossier: Puede editar informes
|
||||||
errors:
|
errors:
|
||||||
models:
|
models:
|
||||||
user:
|
user:
|
||||||
|
|||||||
@@ -902,6 +902,9 @@ es:
|
|||||||
valuator_groups: "Grupo de evaluadores"
|
valuator_groups: "Grupo de evaluadores"
|
||||||
group: "Grupo"
|
group: "Grupo"
|
||||||
no_group: "Sin grupo"
|
no_group: "Sin grupo"
|
||||||
|
abilities: "Habilidades"
|
||||||
|
can_comment: "Puede comentar"
|
||||||
|
can_edit_dossier: "Puede editar informes"
|
||||||
valuator:
|
valuator:
|
||||||
add: Añadir como evaluador
|
add: Añadir como evaluador
|
||||||
delete: Borrar
|
delete: Borrar
|
||||||
@@ -909,14 +912,15 @@ es:
|
|||||||
title: "Evaluadores: Búsqueda de usuarios"
|
title: "Evaluadores: Búsqueda de usuarios"
|
||||||
form:
|
form:
|
||||||
edit_title: "Evaluadores: Editar evaluador"
|
edit_title: "Evaluadores: Editar evaluador"
|
||||||
update: "Actualizar evaluador"
|
|
||||||
updated: "Evaluador actualizado correctamente"
|
updated: "Evaluador actualizado correctamente"
|
||||||
show:
|
show:
|
||||||
description: "Descripción"
|
description: "Descripción"
|
||||||
email: "Email"
|
email: "Email"
|
||||||
group: "Grupo"
|
group: "Grupo"
|
||||||
|
abilities: "Habilidades"
|
||||||
no_description: "Sin descripción"
|
no_description: "Sin descripción"
|
||||||
no_group: "Sin grupo"
|
no_group: "Sin grupo"
|
||||||
|
no_abilities: "Sin habilidades"
|
||||||
valuator_groups:
|
valuator_groups:
|
||||||
index:
|
index:
|
||||||
title: "Grupos de evaluadores"
|
title: "Grupos de evaluadores"
|
||||||
|
|||||||
@@ -630,7 +630,6 @@ fa:
|
|||||||
cost: "هزینه\n"
|
cost: "هزینه\n"
|
||||||
form:
|
form:
|
||||||
edit_title: "ارزیابی کنندگان: ویرایش ارزیاب"
|
edit_title: "ارزیابی کنندگان: ویرایش ارزیاب"
|
||||||
update: "به روزرسانی ارزیابی "
|
|
||||||
updated: " ارزیابی با موفقیت به روز رسانی شده"
|
updated: " ارزیابی با موفقیت به روز رسانی شده"
|
||||||
show:
|
show:
|
||||||
description: "توضیحات"
|
description: "توضیحات"
|
||||||
|
|||||||
@@ -868,7 +868,6 @@ fr:
|
|||||||
cost: Coût
|
cost: Coût
|
||||||
form:
|
form:
|
||||||
edit_title: "Évaluateurs : modifier l'évaluateur"
|
edit_title: "Évaluateurs : modifier l'évaluateur"
|
||||||
update: "Modifier l'évaluateur"
|
|
||||||
updated: "L'évaluateur a bien été modifié"
|
updated: "L'évaluateur a bien été modifié"
|
||||||
show:
|
show:
|
||||||
description: "Description"
|
description: "Description"
|
||||||
|
|||||||
@@ -798,7 +798,6 @@ gl:
|
|||||||
cost: Custo total
|
cost: Custo total
|
||||||
form:
|
form:
|
||||||
edit_title: "Avaliadores: Editar avaliador"
|
edit_title: "Avaliadores: Editar avaliador"
|
||||||
update: "Actualizar avaliador"
|
|
||||||
updated: "Avaliador actualizado correctamente"
|
updated: "Avaliador actualizado correctamente"
|
||||||
show:
|
show:
|
||||||
description: "Descrición"
|
description: "Descrición"
|
||||||
|
|||||||
@@ -710,7 +710,6 @@ it:
|
|||||||
cost: Costi
|
cost: Costi
|
||||||
form:
|
form:
|
||||||
edit_title: "Stimatori: Modificare stimatore"
|
edit_title: "Stimatori: Modificare stimatore"
|
||||||
update: "Aggiorna stimatore"
|
|
||||||
updated: "Stimatore aggiornato con successo"
|
updated: "Stimatore aggiornato con successo"
|
||||||
show:
|
show:
|
||||||
description: "Descrizione"
|
description: "Descrizione"
|
||||||
|
|||||||
@@ -826,7 +826,6 @@ nl:
|
|||||||
cost: Kosten
|
cost: Kosten
|
||||||
form:
|
form:
|
||||||
edit_title: "Beoordelaars: Bewerk Beoordelaar"
|
edit_title: "Beoordelaars: Bewerk Beoordelaar"
|
||||||
update: "Sla op"
|
|
||||||
updated: "Beoordelaar aangepast"
|
updated: "Beoordelaar aangepast"
|
||||||
show:
|
show:
|
||||||
description: "Beschrijving"
|
description: "Beschrijving"
|
||||||
|
|||||||
@@ -823,7 +823,6 @@ pl:
|
|||||||
cost: Koszt
|
cost: Koszt
|
||||||
form:
|
form:
|
||||||
edit_title: "Wyceniający: Edytuj wyceniającego"
|
edit_title: "Wyceniający: Edytuj wyceniającego"
|
||||||
update: "Aktualizuj wyceniającego"
|
|
||||||
updated: "Wyceniający zaktualizowany pomyślnie"
|
updated: "Wyceniający zaktualizowany pomyślnie"
|
||||||
show:
|
show:
|
||||||
description: "Opis"
|
description: "Opis"
|
||||||
|
|||||||
@@ -709,7 +709,6 @@ pt-BR:
|
|||||||
cost: Custo
|
cost: Custo
|
||||||
form:
|
form:
|
||||||
edit_title: "Avaliadores: editar avaliador"
|
edit_title: "Avaliadores: editar avaliador"
|
||||||
update: "Atualizar avaliador"
|
|
||||||
updated: "Avalaiador atualizado com sucesso"
|
updated: "Avalaiador atualizado com sucesso"
|
||||||
show:
|
show:
|
||||||
description: "Descrição"
|
description: "Descrição"
|
||||||
|
|||||||
@@ -826,7 +826,6 @@ ru:
|
|||||||
cost: Стоимость
|
cost: Стоимость
|
||||||
form:
|
form:
|
||||||
edit_title: "Оценщики: Редактировать оценщика"
|
edit_title: "Оценщики: Редактировать оценщика"
|
||||||
update: "Обновить оценщика"
|
|
||||||
updated: "Оценщик обновлен успешно"
|
updated: "Оценщик обновлен успешно"
|
||||||
show:
|
show:
|
||||||
description: "Описание"
|
description: "Описание"
|
||||||
|
|||||||
@@ -525,7 +525,6 @@ sl:
|
|||||||
cost: Cena
|
cost: Cena
|
||||||
form:
|
form:
|
||||||
edit_title: "Cenilci: Uredi cenilce"
|
edit_title: "Cenilci: Uredi cenilce"
|
||||||
update: "Posodobi cenilca"
|
|
||||||
updated: "Cenilec uspešno posodobljen"
|
updated: "Cenilec uspešno posodobljen"
|
||||||
show:
|
show:
|
||||||
description: "Opis"
|
description: "Opis"
|
||||||
|
|||||||
@@ -715,7 +715,6 @@ so:
|
|||||||
cost: Kharashaad
|
cost: Kharashaad
|
||||||
form:
|
form:
|
||||||
edit_title: "Qiimeeyayaasha: Tafatiraha qiimeeyaha"
|
edit_title: "Qiimeeyayaasha: Tafatiraha qiimeeyaha"
|
||||||
update: "Cusboneysi Qimeeyaha"
|
|
||||||
updated: "Siguula ayaa loo cusboneysiyey"
|
updated: "Siguula ayaa loo cusboneysiyey"
|
||||||
show:
|
show:
|
||||||
description: "Sharaxaad"
|
description: "Sharaxaad"
|
||||||
|
|||||||
@@ -717,7 +717,6 @@ sq:
|
|||||||
cost: Kosto
|
cost: Kosto
|
||||||
form:
|
form:
|
||||||
edit_title: "Vlerësuesit: Ndrysho vlerësuesin"
|
edit_title: "Vlerësuesit: Ndrysho vlerësuesin"
|
||||||
update: "Përditëso vlerësuesin"
|
|
||||||
updated: "Vlerësuesi u përditësua me sukses"
|
updated: "Vlerësuesi u përditësua me sukses"
|
||||||
show:
|
show:
|
||||||
description: "Përshkrimi"
|
description: "Përshkrimi"
|
||||||
|
|||||||
@@ -764,7 +764,6 @@ val:
|
|||||||
cost: Cost total
|
cost: Cost total
|
||||||
form:
|
form:
|
||||||
edit_title: "Avaluadors: Editar avaluador"
|
edit_title: "Avaluadors: Editar avaluador"
|
||||||
update: "Actualitzar avaluador"
|
|
||||||
updated: "Avaluador actualitzat correctament"
|
updated: "Avaluador actualitzat correctament"
|
||||||
show:
|
show:
|
||||||
description: "Descripció"
|
description: "Descripció"
|
||||||
|
|||||||
@@ -718,7 +718,6 @@ zh-CN:
|
|||||||
cost: 成本
|
cost: 成本
|
||||||
form:
|
form:
|
||||||
edit_title: "评估员:编辑评估员"
|
edit_title: "评估员:编辑评估员"
|
||||||
update: "更新评估员"
|
|
||||||
updated: "评估员已成功更新"
|
updated: "评估员已成功更新"
|
||||||
show:
|
show:
|
||||||
description: "说明"
|
description: "说明"
|
||||||
|
|||||||
@@ -708,7 +708,6 @@ zh-TW:
|
|||||||
cost: 成本
|
cost: 成本
|
||||||
form:
|
form:
|
||||||
edit_title: "評估員:編輯評估員"
|
edit_title: "評估員:編輯評估員"
|
||||||
update: "更新評估員"
|
|
||||||
updated: "評估員已成功更新"
|
updated: "評估員已成功更新"
|
||||||
show:
|
show:
|
||||||
description: "描述"
|
description: "描述"
|
||||||
|
|||||||
6
db/migrate/20190408083819_add_actions_to_valuators.rb
Normal file
6
db/migrate/20190408083819_add_actions_to_valuators.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
class AddActionsToValuators < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :valuators, :can_comment, :boolean, default: true
|
||||||
|
add_column :valuators, :can_edit_dossier, :boolean, default: true
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1487,6 +1487,8 @@ ActiveRecord::Schema.define(version: 20190607160900) do
|
|||||||
t.string "description"
|
t.string "description"
|
||||||
t.integer "budget_investments_count", default: 0
|
t.integer "budget_investments_count", default: 0
|
||||||
t.integer "valuator_group_id"
|
t.integer "valuator_group_id"
|
||||||
|
t.boolean "can_comment", default: true
|
||||||
|
t.boolean "can_edit_dossier", default: true
|
||||||
t.index ["user_id"], name: "index_valuators_on_user_id", using: :btree
|
t.index ["user_id"], name: "index_valuators_on_user_id", using: :btree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ describe "Valuator groups" do
|
|||||||
visit edit_admin_valuator_path(valuator)
|
visit edit_admin_valuator_path(valuator)
|
||||||
|
|
||||||
select "Health", from: "valuator_valuator_group_id"
|
select "Health", from: "valuator_valuator_group_id"
|
||||||
click_button "Update valuator"
|
click_button "Update Valuator"
|
||||||
|
|
||||||
expect(page).to have_content "Valuator updated successfully"
|
expect(page).to have_content "Valuator updated successfully"
|
||||||
expect(page).to have_content "Health"
|
expect(page).to have_content "Health"
|
||||||
@@ -102,7 +102,7 @@ describe "Valuator groups" do
|
|||||||
|
|
||||||
visit edit_admin_valuator_path(valuator)
|
visit edit_admin_valuator_path(valuator)
|
||||||
select "Economy", from: "valuator_valuator_group_id"
|
select "Economy", from: "valuator_valuator_group_id"
|
||||||
click_button "Update valuator"
|
click_button "Update Valuator"
|
||||||
|
|
||||||
expect(page).to have_content "Valuator updated successfully"
|
expect(page).to have_content "Valuator updated successfully"
|
||||||
expect(page).to have_content "Economy"
|
expect(page).to have_content "Economy"
|
||||||
@@ -115,7 +115,7 @@ describe "Valuator groups" do
|
|||||||
|
|
||||||
visit edit_admin_valuator_path(valuator)
|
visit edit_admin_valuator_path(valuator)
|
||||||
select "", from: "valuator_valuator_group_id"
|
select "", from: "valuator_valuator_group_id"
|
||||||
click_button "Update valuator"
|
click_button "Update Valuator"
|
||||||
|
|
||||||
expect(page).to have_content "Valuator updated successfully"
|
expect(page).to have_content "Valuator updated successfully"
|
||||||
expect(page).not_to have_content "Health"
|
expect(page).not_to have_content "Health"
|
||||||
|
|||||||
@@ -2,104 +2,112 @@ require "rails_helper"
|
|||||||
|
|
||||||
describe "Admin valuators" do
|
describe "Admin valuators" do
|
||||||
|
|
||||||
|
let(:admin) { create(:administrator) }
|
||||||
|
let!(:user) { create(:user, username: "Jose Luis Balbin") }
|
||||||
|
let!(:valuator) { create(:valuator) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@admin = create(:administrator)
|
login_as(admin.user)
|
||||||
@user = create(:user, username: "Jose Luis Balbin")
|
|
||||||
@valuator = create(:valuator)
|
|
||||||
login_as(@admin.user)
|
|
||||||
visit admin_valuators_path
|
visit admin_valuators_path
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Show" do
|
scenario "Show" do
|
||||||
visit admin_valuator_path(@valuator)
|
visit admin_valuator_path(valuator)
|
||||||
|
|
||||||
expect(page).to have_content @valuator.name
|
expect(page).to have_content valuator.name
|
||||||
expect(page).to have_content @valuator.description
|
expect(page).to have_content valuator.description
|
||||||
expect(page).to have_content @valuator.email
|
expect(page).to have_content valuator.email
|
||||||
|
expect(page).to have_content "Can comment, Can edit dossier"
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Index" do
|
scenario "Index" do
|
||||||
expect(page).to have_content(@valuator.name)
|
expect(page).to have_content(valuator.name)
|
||||||
expect(page).to have_content(@valuator.email)
|
expect(page).to have_content(valuator.email)
|
||||||
expect(page).not_to have_content(@user.name)
|
expect(page).not_to have_content(user.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Create", :js do
|
scenario "Create", :js do
|
||||||
fill_in "name_or_email", with: @user.email
|
fill_in "name_or_email", with: user.email
|
||||||
click_button "Search"
|
click_button "Search"
|
||||||
|
|
||||||
expect(page).to have_content(@user.name)
|
expect(page).to have_content(user.name)
|
||||||
click_button "Add to valuators"
|
click_button "Add to valuators"
|
||||||
|
|
||||||
within("#valuators") do
|
within("#valuators") do
|
||||||
expect(page).to have_content(@user.name)
|
expect(page).to have_content(user.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Edit" do
|
scenario "Edit" do
|
||||||
visit edit_admin_valuator_path(@valuator)
|
visit edit_admin_valuator_path(valuator)
|
||||||
|
|
||||||
|
expect(page).to have_field("Can create comments", checked: true)
|
||||||
|
expect(page).to have_field("Can edit dossiers", checked: true)
|
||||||
|
|
||||||
fill_in "valuator_description", with: "Valuator for health"
|
fill_in "valuator_description", with: "Valuator for health"
|
||||||
click_button "Update valuator"
|
uncheck "Can edit dossiers"
|
||||||
|
click_button "Update Valuator"
|
||||||
|
|
||||||
expect(page).to have_content "Valuator updated successfully"
|
expect(page).to have_content "Valuator updated successfully"
|
||||||
expect(page).to have_content @valuator.email
|
expect(page).to have_content valuator.email
|
||||||
expect(page).to have_content "Valuator for health"
|
expect(page).to have_content "Valuator for health"
|
||||||
|
expect(page).to have_content "Can comment"
|
||||||
|
expect(page).not_to have_content "Can edit dossier"
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Destroy" do
|
scenario "Destroy" do
|
||||||
click_link "Delete"
|
click_link "Delete"
|
||||||
|
|
||||||
within("#valuators") do
|
within("#valuators") do
|
||||||
expect(page).not_to have_content(@valuator.name)
|
expect(page).not_to have_content(valuator.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Search" do
|
context "Search" do
|
||||||
|
let!(:user1) { create(:user, username: "David Foster Wallace", email: "david@wallace.com") }
|
||||||
|
let!(:user2) { create(:user, username: "Steven Erikson", email: "steven@erikson.com") }
|
||||||
|
let!(:valuator1) { create(:valuator, user: user1) }
|
||||||
|
let!(:valuator2) { create(:valuator, user: user2) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
user = create(:user, username: "David Foster Wallace", email: "david@wallace.com")
|
|
||||||
user2 = create(:user, username: "Steven Erikson", email: "steven@erikson.com")
|
|
||||||
@valuator1 = create(:valuator, user: user)
|
|
||||||
@valuator2 = create(:valuator, user: user2)
|
|
||||||
visit admin_valuators_path
|
visit admin_valuators_path
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "returns no results if search term is empty" do
|
scenario "returns no results if search term is empty" do
|
||||||
expect(page).to have_content(@valuator1.name)
|
expect(page).to have_content(valuator1.name)
|
||||||
expect(page).to have_content(@valuator2.name)
|
expect(page).to have_content(valuator2.name)
|
||||||
|
|
||||||
fill_in "name_or_email", with: " "
|
fill_in "name_or_email", with: " "
|
||||||
click_button "Search"
|
click_button "Search"
|
||||||
|
|
||||||
expect(page).to have_content("Valuators: User search")
|
expect(page).to have_content("Valuators: User search")
|
||||||
expect(page).to have_content("No results found")
|
expect(page).to have_content("No results found")
|
||||||
expect(page).not_to have_content(@valuator1.name)
|
expect(page).not_to have_content(valuator1.name)
|
||||||
expect(page).not_to have_content(@valuator2.name)
|
expect(page).not_to have_content(valuator2.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "search by name" do
|
scenario "search by name" do
|
||||||
expect(page).to have_content(@valuator1.name)
|
expect(page).to have_content(valuator1.name)
|
||||||
expect(page).to have_content(@valuator2.name)
|
expect(page).to have_content(valuator2.name)
|
||||||
|
|
||||||
fill_in "name_or_email", with: "Foster"
|
fill_in "name_or_email", with: "Foster"
|
||||||
click_button "Search"
|
click_button "Search"
|
||||||
|
|
||||||
expect(page).to have_content("Valuators: User search")
|
expect(page).to have_content("Valuators: User search")
|
||||||
expect(page).to have_content(@valuator1.name)
|
expect(page).to have_content(valuator1.name)
|
||||||
expect(page).not_to have_content(@valuator2.name)
|
expect(page).not_to have_content(valuator2.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "search by email" do
|
scenario "search by email" do
|
||||||
expect(page).to have_content(@valuator1.email)
|
expect(page).to have_content(valuator1.email)
|
||||||
expect(page).to have_content(@valuator2.email)
|
expect(page).to have_content(valuator2.email)
|
||||||
|
|
||||||
fill_in "name_or_email", with: @valuator2.email
|
fill_in "name_or_email", with: valuator2.email
|
||||||
click_button "Search"
|
click_button "Search"
|
||||||
|
|
||||||
expect(page).to have_content("Valuators: User search")
|
expect(page).to have_content("Valuators: User search")
|
||||||
expect(page).to have_content(@valuator2.email)
|
expect(page).to have_content(valuator2.email)
|
||||||
expect(page).not_to have_content(@valuator1.email)
|
expect(page).not_to have_content(valuator1.email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -44,4 +44,18 @@ describe Abilities::Valuator do
|
|||||||
|
|
||||||
it { should_not be_able_to(:update, finished_assigned_investment) }
|
it { should_not be_able_to(:update, finished_assigned_investment) }
|
||||||
it { should_not be_able_to(:valuate, finished_assigned_investment) }
|
it { should_not be_able_to(:valuate, finished_assigned_investment) }
|
||||||
|
|
||||||
|
it "can update dossier information if not set can_edit_dossier attribute" do
|
||||||
|
should be_able_to(:edit_dossier, assigned_investment)
|
||||||
|
allow(valuator).to receive(:can_edit_dossier?).and_return(false)
|
||||||
|
ability = Ability.new(user)
|
||||||
|
expect(ability.can?(:edit_dossier, assigned_investment)).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
it "cannot create valuation comments if not set not can_comment attribute" do
|
||||||
|
should be_able_to(:comment_valuation, assigned_investment)
|
||||||
|
allow(valuator).to receive(:can_comment?).and_return(false)
|
||||||
|
ability = Ability.new(user)
|
||||||
|
expect(ability.can?(:comment_valuation, assigned_investment)).to be_falsey
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,4 +50,13 @@ describe Valuator do
|
|||||||
expect(assigned_investment_ids).not_to include investment3.id
|
expect(assigned_investment_ids).not_to include investment3.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "abilities" do
|
||||||
|
context "by default" do
|
||||||
|
let(:valuator) { Valuator.new }
|
||||||
|
it { expect(valuator.can_comment).to be_truthy }
|
||||||
|
it { expect(valuator.can_edit_dossier).to be_truthy }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user