Base Legislation::Process model and admin page
This commit is contained in:
5
app/controllers/admin/legislation/base_controller.rb
Normal file
5
app/controllers/admin/legislation/base_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class Admin::Legislation::BaseController < Admin::BaseController
|
||||||
|
include FeatureFlags
|
||||||
|
|
||||||
|
feature_flag :legislation
|
||||||
|
end
|
||||||
54
app/controllers/admin/legislation/processes_controller.rb
Normal file
54
app/controllers/admin/legislation/processes_controller.rb
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
class Admin::Legislation::ProcessesController < Admin::Legislation::BaseController
|
||||||
|
has_filters %w{open next past all}, only: :index
|
||||||
|
|
||||||
|
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||||
|
|
||||||
|
def index
|
||||||
|
@processes = ::Legislation::Process.send(@current_filter).page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@process = ::Legislation::Process.new(process_params)
|
||||||
|
if @process.save
|
||||||
|
redirect_to admin_legislation_processes_path
|
||||||
|
else
|
||||||
|
render :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@process.assign_attributes(process_params)
|
||||||
|
if @process.update(process_params)
|
||||||
|
redirect_to admin_legislation_processes_path
|
||||||
|
else
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@process.destroy
|
||||||
|
redirect_to admin_legislation_processes_path
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def process_params
|
||||||
|
params.require(:legislation_process).permit(
|
||||||
|
:title,
|
||||||
|
:description_summary,
|
||||||
|
:target_summary,
|
||||||
|
:description,
|
||||||
|
:target,
|
||||||
|
:how_to_participate,
|
||||||
|
:additional_info,
|
||||||
|
:start_date,
|
||||||
|
:end_date,
|
||||||
|
:debate_start_date,
|
||||||
|
:debate_end_date,
|
||||||
|
:draft_publication_date,
|
||||||
|
:allegations_start_date,
|
||||||
|
:allegations_end_date,
|
||||||
|
:final_publication_date
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
5
app/controllers/legislation/base_controller.rb
Normal file
5
app/controllers/legislation/base_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class Legislation::BaseController < ApplicationController
|
||||||
|
include FeatureFlags
|
||||||
|
|
||||||
|
feature_flag :legislation
|
||||||
|
end
|
||||||
2
app/controllers/legislation/processes_controller.rb
Normal file
2
app/controllers/legislation/processes_controller.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
class Legislation::ProcessesController < Legislation::BaseController
|
||||||
|
end
|
||||||
@@ -5,7 +5,7 @@ module AdminHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def official_level_options
|
def official_level_options
|
||||||
options = [["", 0]]
|
options = [["",0]]
|
||||||
(1..5).each do |i|
|
(1..5).each do |i|
|
||||||
options << [[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(': '), i]
|
options << [[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(': '), i]
|
||||||
end
|
end
|
||||||
@@ -16,10 +16,14 @@ module AdminHelper
|
|||||||
Administrator.all.order('users.username asc').includes(:user).collect { |v| [ v.name, v.id ] }
|
Administrator.all.order('users.username asc').includes(:user).collect { |v| [ v.name, v.id ] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def admin_submit_action(resource)
|
||||||
|
resource.persisted? ? "edit" : "new"
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def namespace
|
def namespace
|
||||||
controller.class.parent.name.downcase
|
controller.class.parent.name.downcase.gsub("::", "/")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ module Abilities
|
|||||||
|
|
||||||
can [:read, :update, :destroy, :summary], SpendingProposal
|
can [:read, :update, :destroy, :summary], SpendingProposal
|
||||||
can [:search, :edit, :update, :create, :index, :destroy], Banner
|
can [:search, :edit, :update, :create, :index, :destroy], Banner
|
||||||
|
|
||||||
|
can [:manage], ::Legislation::Process
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
5
app/models/legislation.rb
Normal file
5
app/models/legislation.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module Legislation
|
||||||
|
def self.table_name_prefix
|
||||||
|
'legislation_'
|
||||||
|
end
|
||||||
|
end
|
||||||
21
app/models/legislation/process.rb
Normal file
21
app/models/legislation/process.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
class Legislation::Process < ActiveRecord::Base
|
||||||
|
acts_as_paranoid column: :hidden_at
|
||||||
|
include ActsAsParanoidAliases
|
||||||
|
|
||||||
|
validates :title, presence: true
|
||||||
|
validates :description, presence: true
|
||||||
|
validates :target, presence: true
|
||||||
|
validates :how_to_participate, presence: true
|
||||||
|
validates :start_date, presence: true
|
||||||
|
validates :end_date, presence: true
|
||||||
|
validates :debate_start_date, presence: true
|
||||||
|
validates :debate_end_date, presence: true
|
||||||
|
validates :draft_publication_date, presence: true
|
||||||
|
validates :allegations_start_date, presence: true
|
||||||
|
validates :allegations_end_date, presence: true
|
||||||
|
validates :final_publication_date, presence: true
|
||||||
|
|
||||||
|
scope :open, -> {where("start_date <= ? and end_date >= ?", Time.current, Time.current) }
|
||||||
|
scope :next, -> {where("start_date > ?", Time.current) }
|
||||||
|
scope :past, -> {where("end_date < ?", Time.current) }
|
||||||
|
end
|
||||||
@@ -35,6 +35,14 @@
|
|||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if feature?(:legislation) %>
|
||||||
|
<li <%= "class=active" if controller_name == "processes" %>>
|
||||||
|
<%= link_to admin_legislation_processes_path do %>
|
||||||
|
<span class="icon-budget"></span><%= t("admin.menu.legislation") %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<li <%= "class=active" if controller_name == "banners" %>>
|
<li <%= "class=active" if controller_name == "banners" %>>
|
||||||
<%= link_to admin_banners_path do %>
|
<%= link_to admin_banners_path do %>
|
||||||
<span class="icon-eye"></span><%= t("admin.menu.banner") %>
|
<span class="icon-eye"></span><%= t("admin.menu.banner") %>
|
||||||
|
|||||||
1
app/views/admin/legislation/_menu.html.erb
Normal file
1
app/views/admin/legislation/_menu.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<%= render "admin/menu" %>
|
||||||
155
app/views/admin/legislation/processes/_form.html.erb
Normal file
155
app/views/admin/legislation/processes/_form.html.erb
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
<%= form_for [:admin, @process] do |f| %>
|
||||||
|
|
||||||
|
<% if @process.errors.any? %>
|
||||||
|
|
||||||
|
<div id="error_explanation" data-alert class="callout alert" data-closable>
|
||||||
|
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<strong>
|
||||||
|
<%= @process.errors.count %>
|
||||||
|
<%= t("admin.legislation.processes.errors.form.error", count: @process.errors.count) %>
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :title %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_field :title,
|
||||||
|
label: false %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :description %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_area :description,
|
||||||
|
label: false,
|
||||||
|
rows: 5 %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :target %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_area :target,
|
||||||
|
label: false,
|
||||||
|
rows: 5 %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :how_to_participate %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_area :how_to_participate,
|
||||||
|
label: false,
|
||||||
|
rows: 5 %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :additional_info %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_area :additional_info,
|
||||||
|
label: false,
|
||||||
|
rows: 10 %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :start_date %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_field :start_date,
|
||||||
|
label: false,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "start_date" %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :end_date %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_field :end_date,
|
||||||
|
label: false,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "end_date" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :debate_start_date %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_field :debate_start_date,
|
||||||
|
label: false,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "debate_start_date" %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :debate_end_date %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_field :debate_end_date,
|
||||||
|
label: false,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "debate_end_date" %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :draft_publication_date %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_field :draft_publication_date,
|
||||||
|
label: false,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "draft_publication_date" %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :allegations_start_date %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_field :allegations_start_date,
|
||||||
|
label: false,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "allegations_start_date" %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :allegations_end_date %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_field :allegations_end_date,
|
||||||
|
label: false,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "allegations_end_date" %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-4 column">
|
||||||
|
<%= f.label :final_publication_date %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-8 column">
|
||||||
|
<%= f.text_field :final_publication_date,
|
||||||
|
label: false,
|
||||||
|
class: "js-calendar-full",
|
||||||
|
id: "final_publication_date" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="actions small-12 medium-3 column">
|
||||||
|
<%= f.submit(class: "button expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
13
app/views/admin/legislation/processes/edit.html.erb
Normal file
13
app/views/admin/legislation/processes/edit.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="legislation-process-edit row">
|
||||||
|
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= link_to admin_legislation_processes_path, class: "back" do %>
|
||||||
|
<span class="icon-angle-left"></span>
|
||||||
|
<%= t("admin.legislation.processes.edit.back") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<h1><%= @process.title %></h1>
|
||||||
|
|
||||||
|
<%= render "form" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
33
app/views/admin/legislation/processes/index.html.erb
Normal file
33
app/views/admin/legislation/processes/index.html.erb
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<%= link_to t("admin.legislation.processes.index.create"),
|
||||||
|
new_admin_legislation_process_path, class: "button success float-right" %>
|
||||||
|
|
||||||
|
<h2 class="inline-block"><%= t("admin.legislation.processes.index.title") %></h2>
|
||||||
|
|
||||||
|
<%= render 'shared/filter_subnav', i18n_namespace: "admin.legislation.processes.index" %>
|
||||||
|
|
||||||
|
<h3><%= page_entries_info @processes %></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th><%= t("admin.legislation.processes.process.title") %></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
<% @processes.each do |process| %>
|
||||||
|
<tr id="<%= dom_id(process) %>">
|
||||||
|
<td class="small-12 medium-9">
|
||||||
|
<%= link_to process.title, edit_admin_legislation_process_path(process) %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="text-right">
|
||||||
|
<%= link_to t("admin.legislation.processes.index.edit"), edit_admin_legislation_process_path(process),
|
||||||
|
class: 'edit-banner button hollow' %>
|
||||||
|
|
||||||
|
<%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_path(process),
|
||||||
|
method: :delete,
|
||||||
|
class: 'button hollow alert' %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= paginate @processes %>
|
||||||
13
app/views/admin/legislation/processes/new.html.erb
Normal file
13
app/views/admin/legislation/processes/new.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="legislation-process-new row">
|
||||||
|
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= link_to admin_legislation_processes_path, class: "back" do %>
|
||||||
|
<span class="icon-angle-left"></span>
|
||||||
|
<%= t("admin.legislation.processes.new.back") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<h1><%= t("admin.legislation.processes.new.title") %></h1>
|
||||||
|
|
||||||
|
<%= render "form" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -23,6 +23,7 @@ data:
|
|||||||
# - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
|
# - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
|
||||||
- config/locales/%{locale}.yml
|
- config/locales/%{locale}.yml
|
||||||
- config/locales/admin.%{locale}.yml
|
- config/locales/admin.%{locale}.yml
|
||||||
|
- config/locales/admin.legislation.%{locale}.yml
|
||||||
- config/locales/moderation.%{locale}.yml
|
- config/locales/moderation.%{locale}.yml
|
||||||
- config/locales/valuation.%{locale}.yml
|
- config/locales/valuation.%{locale}.yml
|
||||||
- config/locales/management.%{locale}.yml
|
- config/locales/management.%{locale}.yml
|
||||||
@@ -117,6 +118,8 @@ ignore_unused:
|
|||||||
- 'admin.organizations.index.filter*'
|
- 'admin.organizations.index.filter*'
|
||||||
- 'admin.users.index.filter*'
|
- 'admin.users.index.filter*'
|
||||||
- 'admin.activity.show.filter*'
|
- 'admin.activity.show.filter*'
|
||||||
|
- 'admin.legislation.processes.index.filter*'
|
||||||
|
- 'admin.legislation.processes.*.submit_button'
|
||||||
- 'admin.comments.index.hidden_*'
|
- 'admin.comments.index.hidden_*'
|
||||||
- 'admin.settings.index.features.*'
|
- 'admin.settings.index.features.*'
|
||||||
- 'moderation.comments.index.filter*'
|
- 'moderation.comments.index.filter*'
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ en:
|
|||||||
spending_proposal:
|
spending_proposal:
|
||||||
one: "Spending proposal"
|
one: "Spending proposal"
|
||||||
other: "Spending proposals"
|
other: "Spending proposals"
|
||||||
|
legislation/process:
|
||||||
|
one: "Process"
|
||||||
|
other: "Processes"
|
||||||
attributes:
|
attributes:
|
||||||
comment:
|
comment:
|
||||||
body: "Comment"
|
body: "Comment"
|
||||||
@@ -69,6 +72,20 @@ en:
|
|||||||
external_url: "Link to additional documentation"
|
external_url: "Link to additional documentation"
|
||||||
geozone_id: "Scope of operation"
|
geozone_id: "Scope of operation"
|
||||||
title: "Title"
|
title: "Title"
|
||||||
|
legislation/process:
|
||||||
|
title: Process Title
|
||||||
|
description: Description
|
||||||
|
target: Target
|
||||||
|
how_to_participate: How to participate
|
||||||
|
additional_info: Additional info
|
||||||
|
start_date: Start date
|
||||||
|
end_date: End date
|
||||||
|
debate_start_date: Debate start date
|
||||||
|
debate_end_date: Debate end date
|
||||||
|
draft_publication_date: Draft publication date
|
||||||
|
allegations_start_date: Allegations start date
|
||||||
|
allegations_end_date: Allegations end date
|
||||||
|
final_publication_date: Final result publication date
|
||||||
errors:
|
errors:
|
||||||
models:
|
models:
|
||||||
user:
|
user:
|
||||||
@@ -90,4 +107,4 @@ en:
|
|||||||
proposal_notification:
|
proposal_notification:
|
||||||
attributes:
|
attributes:
|
||||||
minimum_interval:
|
minimum_interval:
|
||||||
invalid: "You have to wait a minium of %{interval} days between notifications"
|
invalid: "You have to wait a minium of %{interval} days between notifications"
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ es:
|
|||||||
spending_proposal:
|
spending_proposal:
|
||||||
one: "Propuesta de inversión"
|
one: "Propuesta de inversión"
|
||||||
other: "Propuestas de inversión"
|
other: "Propuestas de inversión"
|
||||||
|
legislation/process:
|
||||||
|
one: "Proceso"
|
||||||
|
other: "Procesos"
|
||||||
attributes:
|
attributes:
|
||||||
comment:
|
comment:
|
||||||
body: "Comentario"
|
body: "Comentario"
|
||||||
@@ -69,6 +72,20 @@ es:
|
|||||||
external_url: "Enlace a documentación adicional"
|
external_url: "Enlace a documentación adicional"
|
||||||
geozone_id: "Ámbito de actuación"
|
geozone_id: "Ámbito de actuación"
|
||||||
title: "Título"
|
title: "Título"
|
||||||
|
legislation/process:
|
||||||
|
title: Título del proceso
|
||||||
|
description: En qué consiste
|
||||||
|
target: A quién afecta
|
||||||
|
how_to_participate: Cómo participar
|
||||||
|
additional_info: Información adicional
|
||||||
|
start_date: Fecha de inicio del proceso
|
||||||
|
end_date: Fecha de fin del proceso
|
||||||
|
debate_start_date: Fecha de inicio del debate
|
||||||
|
debate_end_date: Fecha de fin del debate
|
||||||
|
draft_publication_date: Fecha de publicación del borrador
|
||||||
|
allegations_start_date: Fecha de inicio de alegaciones
|
||||||
|
allegations_end_date: Fecha de fin de alegaciones
|
||||||
|
final_publication_date: Fecha de publicación del resultado final
|
||||||
errors:
|
errors:
|
||||||
models:
|
models:
|
||||||
user:
|
user:
|
||||||
@@ -90,4 +107,4 @@ es:
|
|||||||
proposal_notification:
|
proposal_notification:
|
||||||
attributes:
|
attributes:
|
||||||
minimum_interval:
|
minimum_interval:
|
||||||
invalid: "Debes esperar un mínimo de %{interval} días entre notificaciones"
|
invalid: "Debes esperar un mínimo de %{interval} días entre notificaciones"
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ en:
|
|||||||
settings: Configuration settings
|
settings: Configuration settings
|
||||||
spending_proposals: Spending proposals
|
spending_proposals: Spending proposals
|
||||||
stats: Statistics
|
stats: Statistics
|
||||||
|
legislation: Collaborative Legislation
|
||||||
moderators:
|
moderators:
|
||||||
index:
|
index:
|
||||||
title: Moderators
|
title: Moderators
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ es:
|
|||||||
settings: Configuración global
|
settings: Configuración global
|
||||||
spending_proposals: Propuestas de inversión
|
spending_proposals: Propuestas de inversión
|
||||||
stats: Estadísticas
|
stats: Estadísticas
|
||||||
|
legislation: Legislación colaborativa
|
||||||
moderators:
|
moderators:
|
||||||
index:
|
index:
|
||||||
title: Moderadores
|
title: Moderadores
|
||||||
|
|||||||
27
config/locales/admin.legislation.en.yml
Normal file
27
config/locales/admin.legislation.en.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
en:
|
||||||
|
admin:
|
||||||
|
legislation:
|
||||||
|
processes:
|
||||||
|
edit:
|
||||||
|
back: Back
|
||||||
|
submit_button: Save changes
|
||||||
|
errors:
|
||||||
|
form:
|
||||||
|
error: Error
|
||||||
|
index:
|
||||||
|
create: New process
|
||||||
|
delete: Delete
|
||||||
|
edit: Edit
|
||||||
|
title: Legislation processess
|
||||||
|
filters:
|
||||||
|
open: Open
|
||||||
|
next: Next
|
||||||
|
past: Past
|
||||||
|
all: All
|
||||||
|
new:
|
||||||
|
back: Back
|
||||||
|
title: Create new collaborative legislation process
|
||||||
|
submit_button: Create process
|
||||||
|
process:
|
||||||
|
title: Collaborative legislation process title
|
||||||
27
config/locales/admin.legislation.es.yml
Normal file
27
config/locales/admin.legislation.es.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
es:
|
||||||
|
admin:
|
||||||
|
legislation:
|
||||||
|
processes:
|
||||||
|
edit:
|
||||||
|
back: Volver
|
||||||
|
submit_button: Guardar cambios
|
||||||
|
errors:
|
||||||
|
form:
|
||||||
|
error: Error
|
||||||
|
index:
|
||||||
|
create: Nuevo proceso
|
||||||
|
delete: Borrar
|
||||||
|
edit: Editar
|
||||||
|
title: Procesos de legislación colaborativa
|
||||||
|
filters:
|
||||||
|
open: Abiertos
|
||||||
|
next: Próximamente
|
||||||
|
past: Pasados
|
||||||
|
all: Todos
|
||||||
|
new:
|
||||||
|
back: Volver
|
||||||
|
title: Crear nuevo proceso de legislación colaborativa
|
||||||
|
submit_button: Crear proceso
|
||||||
|
process:
|
||||||
|
title: Título del proceso de legislación colaborativa
|
||||||
@@ -30,3 +30,4 @@ en:
|
|||||||
spending_proposals: Investment projects
|
spending_proposals: Investment projects
|
||||||
spending_proposal_features:
|
spending_proposal_features:
|
||||||
voting_allowed: Voting on investment projects
|
voting_allowed: Voting on investment projects
|
||||||
|
legislation: Legislation
|
||||||
|
|||||||
@@ -29,4 +29,5 @@ es:
|
|||||||
debates: Debates
|
debates: Debates
|
||||||
spending_proposals: Propuestas de inversión
|
spending_proposals: Propuestas de inversión
|
||||||
spending_proposal_features:
|
spending_proposal_features:
|
||||||
voting_allowed: Votaciones sobre propuestas de inversión.
|
voting_allowed: Votaciones sobre propuestas de inversión.
|
||||||
|
legislation: Legislación
|
||||||
|
|||||||
@@ -189,6 +189,10 @@ Rails.application.routes.draw do
|
|||||||
get :direct_messages, on: :collection
|
get :direct_messages, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
namespace :legislation do
|
||||||
|
resources :processes
|
||||||
|
end
|
||||||
|
|
||||||
namespace :api do
|
namespace :api do
|
||||||
resource :stats, only: :show
|
resource :stats, only: :show
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ Setting.create(key: 'feature.spending_proposal_features.voting_allowed', value:
|
|||||||
Setting.create(key: 'feature.twitter_login', value: "true")
|
Setting.create(key: 'feature.twitter_login', value: "true")
|
||||||
Setting.create(key: 'feature.facebook_login', value: "true")
|
Setting.create(key: 'feature.facebook_login', value: "true")
|
||||||
Setting.create(key: 'feature.google_login', value: "true")
|
Setting.create(key: 'feature.google_login', value: "true")
|
||||||
|
Setting.create(key: 'feature.legislation', value: "true")
|
||||||
Setting.create(key: 'per_page_code', value: "")
|
Setting.create(key: 'per_page_code', value: "")
|
||||||
Setting.create(key: 'comments_body_max_length', value: '1000')
|
Setting.create(key: 'comments_body_max_length', value: '1000')
|
||||||
|
|
||||||
|
|||||||
23
db/migrate/20161117135624_create_legislation_processes.rb
Normal file
23
db/migrate/20161117135624_create_legislation_processes.rb
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
class CreateLegislationProcesses < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :legislation_processes do |t|
|
||||||
|
t.string :title
|
||||||
|
t.text :description
|
||||||
|
t.text :target
|
||||||
|
t.text :how_to_participate
|
||||||
|
t.text :additional_info
|
||||||
|
t.date :start_date, index: true
|
||||||
|
t.date :end_date, index: true
|
||||||
|
t.date :debate_start_date, index: true
|
||||||
|
t.date :debate_end_date, index: true
|
||||||
|
t.date :draft_publication_date, index: true
|
||||||
|
t.date :allegations_start_date, index: true
|
||||||
|
t.date :allegations_end_date, index: true
|
||||||
|
t.date :final_publication_date, index: true
|
||||||
|
|
||||||
|
t.datetime :hidden_at, index: true
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
31
db/schema.rb
31
db/schema.rb
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20161117115841) do
|
ActiveRecord::Schema.define(version: 20161117135624) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -228,6 +228,35 @@ ActiveRecord::Schema.define(version: 20161117115841) do
|
|||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "legislation_processes", force: :cascade do |t|
|
||||||
|
t.string "title"
|
||||||
|
t.text "description"
|
||||||
|
t.text "target"
|
||||||
|
t.text "how_to_participate"
|
||||||
|
t.text "additional_info"
|
||||||
|
t.date "start_date"
|
||||||
|
t.date "end_date"
|
||||||
|
t.date "debate_start_date"
|
||||||
|
t.date "debate_end_date"
|
||||||
|
t.date "draft_publication_date"
|
||||||
|
t.date "allegations_start_date"
|
||||||
|
t.date "allegations_end_date"
|
||||||
|
t.date "final_publication_date"
|
||||||
|
t.datetime "hidden_at"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "legislation_processes", ["allegations_end_date"], name: "index_legislation_processes_on_allegations_end_date", using: :btree
|
||||||
|
add_index "legislation_processes", ["allegations_start_date"], name: "index_legislation_processes_on_allegations_start_date", using: :btree
|
||||||
|
add_index "legislation_processes", ["debate_end_date"], name: "index_legislation_processes_on_debate_end_date", using: :btree
|
||||||
|
add_index "legislation_processes", ["debate_start_date"], name: "index_legislation_processes_on_debate_start_date", using: :btree
|
||||||
|
add_index "legislation_processes", ["draft_publication_date"], name: "index_legislation_processes_on_draft_publication_date", using: :btree
|
||||||
|
add_index "legislation_processes", ["end_date"], name: "index_legislation_processes_on_end_date", using: :btree
|
||||||
|
add_index "legislation_processes", ["final_publication_date"], name: "index_legislation_processes_on_final_publication_date", using: :btree
|
||||||
|
add_index "legislation_processes", ["hidden_at"], name: "index_legislation_processes_on_hidden_at", using: :btree
|
||||||
|
add_index "legislation_processes", ["start_date"], name: "index_legislation_processes_on_start_date", using: :btree
|
||||||
|
|
||||||
create_table "locks", force: :cascade do |t|
|
create_table "locks", force: :cascade do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "tries", default: 0
|
t.integer "tries", default: 0
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ Setting['feature.twitter_login'] = true
|
|||||||
Setting['feature.facebook_login'] = true
|
Setting['feature.facebook_login'] = true
|
||||||
Setting['feature.google_login'] = true
|
Setting['feature.google_login'] = true
|
||||||
Setting['feature.public_stats'] = true
|
Setting['feature.public_stats'] = true
|
||||||
|
Setting['feature.legislation'] = true
|
||||||
|
|
||||||
# Spending proposals feature flags
|
# Spending proposals feature flags
|
||||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||||
|
|||||||
@@ -1,4 +1,19 @@
|
|||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
|
factory :legislation_process, class: 'Legislation::Process' do
|
||||||
|
title "A collaborative legislation process"
|
||||||
|
description "Description of the process"
|
||||||
|
target "Who will affected by this law?"
|
||||||
|
how_to_participate "You can participate by answering some questions"
|
||||||
|
start_date "2016-11-16"
|
||||||
|
end_date "2016-11-16"
|
||||||
|
debate_start_date "2016-11-16"
|
||||||
|
debate_end_date "2016-11-16"
|
||||||
|
draft_publication_date "2016-11-16"
|
||||||
|
allegations_start_date "2016-11-16"
|
||||||
|
allegations_end_date "2016-11-16"
|
||||||
|
final_publication_date "2016-11-16"
|
||||||
|
end
|
||||||
|
|
||||||
sequence(:document_number) { |n| "#{n.to_s.rjust(8, '0')}X" }
|
sequence(:document_number) { |n| "#{n.to_s.rjust(8, '0')}X" }
|
||||||
|
|
||||||
factory :user do
|
factory :user do
|
||||||
|
|||||||
62
spec/features/admin/legislation/processes_spec.rb
Normal file
62
spec/features/admin/legislation/processes_spec.rb
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
feature 'Admin legislation processes' do
|
||||||
|
|
||||||
|
background do
|
||||||
|
admin = create(:administrator)
|
||||||
|
login_as(admin.user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Feature flag" do
|
||||||
|
|
||||||
|
scenario 'Disabled with a feature flag' do
|
||||||
|
Setting['feature.legislation'] = nil
|
||||||
|
expect{ visit admin_legislation_processes_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Index" do
|
||||||
|
|
||||||
|
scenario 'Displaying legislation processes' do
|
||||||
|
process = create(:legislation_process)
|
||||||
|
visit admin_legislation_processes_path(filter: 'all')
|
||||||
|
|
||||||
|
expect(page).to have_content(process.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'Create' do
|
||||||
|
scenario 'Valid legislation process' do
|
||||||
|
visit admin_root_path
|
||||||
|
|
||||||
|
within('#side_menu') do
|
||||||
|
click_link "Collaborative Legislation"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to_not have_content 'An example legislation process'
|
||||||
|
|
||||||
|
click_link "New process"
|
||||||
|
|
||||||
|
fill_in 'legislation_process_title', with: 'An example legislation process'
|
||||||
|
fill_in 'legislation_process_description', with: 'Describing the process'
|
||||||
|
fill_in 'legislation_process_target', with: 'This thing affects people'
|
||||||
|
fill_in 'legislation_process_how_to_participate', with: 'You can partipate in this thing by doing...'
|
||||||
|
|
||||||
|
base_date = Date.current
|
||||||
|
fill_in 'start_date', with: base_date.strftime("%d/%m/%Y")
|
||||||
|
fill_in 'end_date', with: (base_date + 5.days).strftime("%d/%m/%Y")
|
||||||
|
|
||||||
|
fill_in 'debate_start_date', with: base_date.strftime("%d/%m/%Y")
|
||||||
|
fill_in 'debate_end_date', with: (base_date + 2.days).strftime("%d/%m/%Y")
|
||||||
|
fill_in 'draft_publication_date', with: (base_date + 3.days).strftime("%d/%m/%Y")
|
||||||
|
fill_in 'allegations_start_date', with: (base_date + 3.days).strftime("%d/%m/%Y")
|
||||||
|
fill_in 'allegations_end_date', with: (base_date + 5.days).strftime("%d/%m/%Y")
|
||||||
|
fill_in 'final_publication_date', with: (base_date + 7.days).strftime("%d/%m/%Y")
|
||||||
|
|
||||||
|
click_button 'Create process'
|
||||||
|
|
||||||
|
expect(page).to have_content 'An example legislation process'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
41
spec/models/legislation/process_spec.rb
Normal file
41
spec/models/legislation/process_spec.rb
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Legislation::Process, type: :model do
|
||||||
|
let(:legislation_process) { build(:legislation_process) }
|
||||||
|
|
||||||
|
it "should be valid" do
|
||||||
|
expect(legislation_process).to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "filter scopes" do
|
||||||
|
before(:each) do
|
||||||
|
@process_1 = create(:legislation_process, start_date: Date.current - 2.days, end_date: Date.current + 1.day)
|
||||||
|
@process_2 = create(:legislation_process, start_date: Date.current + 1.days, end_date: Date.current + 3.days)
|
||||||
|
@process_3 = create(:legislation_process, start_date: Date.current - 4.days, end_date: Date.current - 3.days)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "filter open" do
|
||||||
|
open_processes = ::Legislation::Process.open
|
||||||
|
|
||||||
|
expect(open_processes).to include(@process_1)
|
||||||
|
expect(open_processes).to_not include(@process_2)
|
||||||
|
expect(open_processes).to_not include(@process_3)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "filter next" do
|
||||||
|
next_processes = ::Legislation::Process.next
|
||||||
|
|
||||||
|
expect(next_processes).to include(@process_2)
|
||||||
|
expect(next_processes).to_not include(@process_1)
|
||||||
|
expect(next_processes).to_not include(@process_3)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "filter past" do
|
||||||
|
past_processes = ::Legislation::Process.past
|
||||||
|
|
||||||
|
expect(past_processes).to include(@process_3)
|
||||||
|
expect(past_processes).to_not include(@process_2)
|
||||||
|
expect(past_processes).to_not include(@process_1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user