diff --git a/app/controllers/legislation/draft_versions_controller.rb b/app/controllers/legislation/draft_versions_controller.rb
new file mode 100644
index 000000000..6956f11b6
--- /dev/null
+++ b/app/controllers/legislation/draft_versions_controller.rb
@@ -0,0 +1,14 @@
+class Legislation::DraftVersionsController < Legislation::BaseController
+ load_and_authorize_resource :process
+ load_and_authorize_resource :draft_version, through: :process
+
+ def index
+ end
+
+ def show
+ end
+
+ def changes
+ @draft_version = @process.draft_versions.find(params[:draft_version_id])
+ end
+end
diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb
index 75ca3f5dd..a444f151e 100644
--- a/app/controllers/legislation/processes_controller.rb
+++ b/app/controllers/legislation/processes_controller.rb
@@ -1,2 +1,9 @@
class Legislation::ProcessesController < Legislation::BaseController
+ load_and_authorize_resource
+
+ def index
+ end
+
+ def show
+ end
end
diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb
index 867bc3df6..88eccd00a 100644
--- a/app/models/abilities/everyone.rb
+++ b/app/models/abilities/everyone.rb
@@ -11,6 +11,8 @@ module Abilities
can :read, User
can [:search, :read], Annotation
can :new, DirectMessage
+ can [:read], Legislation::Process
+ can [:read], Legislation::DraftVersion
end
end
end
diff --git a/app/models/legislation/draft_version.rb b/app/models/legislation/draft_version.rb
index 22833cf6a..0cb0b99fc 100644
--- a/app/models/legislation/draft_version.rb
+++ b/app/models/legislation/draft_version.rb
@@ -9,4 +9,8 @@ class Legislation::DraftVersion < ActiveRecord::Base
validates :title, presence: true
validates :body, presence: true
validates :status, presence: true, inclusion: { in: VALID_STATUSES }
+
+ def body_in_html
+ body_html || Redcarpet::Markdown.new(Redcarpet::Render::HTML.new).render(body)
+ end
end
diff --git a/app/views/legislation/draft_versions/changes.html.erb b/app/views/legislation/draft_versions/changes.html.erb
new file mode 100644
index 000000000..80d902720
--- /dev/null
+++ b/app/views/legislation/draft_versions/changes.html.erb
@@ -0,0 +1,12 @@
+
+
<%= @process.title %>
+
<%= @draft_version.title %>
+
+
+ <%= link_to t('.see_text'), legislation_process_draft_version_path(@process, @draft_version) %>
+
+
+
+ <%= markdown @draft_version.changelog %>
+
+
diff --git a/app/views/legislation/draft_versions/show.html.erb b/app/views/legislation/draft_versions/show.html.erb
new file mode 100644
index 000000000..b924870c8
--- /dev/null
+++ b/app/views/legislation/draft_versions/show.html.erb
@@ -0,0 +1,12 @@
+
+
<%= link_to @process.title, @process %>
+
<%= @draft_version.title %>
+
+
+ <%= link_to t('.see_changes'), legislation_process_draft_version_changes_path(@process, @draft_version) %>
+
+
+
+ <%= @draft_version.body_in_html.html_safe %>
+
+
diff --git a/app/views/legislation/processes/index.html.erb b/app/views/legislation/processes/index.html.erb
new file mode 100644
index 000000000..fd9517c12
--- /dev/null
+++ b/app/views/legislation/processes/index.html.erb
@@ -0,0 +1,5 @@
+
+ <% @processes.each do |process| %>
+ <%= link_to process.title, process %>
+ <% end %>
+
diff --git a/app/views/legislation/processes/show.html.erb b/app/views/legislation/processes/show.html.erb
new file mode 100644
index 000000000..7d11f6f25
--- /dev/null
+++ b/app/views/legislation/processes/show.html.erb
@@ -0,0 +1,9 @@
+
+
+
<%= @process.title %>
+
+<% @process.draft_versions.each do |draft_version| %>
+ <%= link_to draft_version.title, legislation_process_draft_version_path(@process, draft_version) %>
+<% end %>
+
+
diff --git a/app/views/shared/_subnavigation.html.erb b/app/views/shared/_subnavigation.html.erb
index 9d87a0294..899125138 100644
--- a/app/views/shared/_subnavigation.html.erb
+++ b/app/views/shared/_subnavigation.html.erb
@@ -11,6 +11,11 @@
<%= link_to t("layouts.header.proposal_ballot"), proposal_ballots_path, class: ("active" if controller_name == "proposal_ballots"), accesskey: "v" %>
+ <% if feature?(:legislation) %>
+
+ <%= link_to t("layouts.header.collaborative_legislation"), legislation_processes_path, class: ("active" if controller.class.parent == Legislation ), accesskey: "l" %>
+
+ <% end %>
<% if feature?(:spending_proposals) %>
<%= link_to t("layouts.header.spending_proposals"), spending_proposals_path, class: ("active" if controller_name == "spending_proposals"), accesskey: "s" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 70556aa96..21d40f62f 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -186,6 +186,7 @@ en:
header:
administration: Administration
available_locales: Available languages
+ collaborative_legislation: Legislation processes
debates: Debates
external_link_blog: Blog
external_link_opendata: Open data
@@ -220,6 +221,12 @@ en:
text_sign_in: login
text_sign_up: sign up
title: How I can comment this document?
+ legislation:
+ draft_versions:
+ changes:
+ see_text: See text
+ show:
+ see_changes: See changes
locale: English
notifications:
index:
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 884255aad..226765184 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -186,6 +186,7 @@ es:
header:
administration: Administrar
available_locales: Idiomas disponibles
+ collaborative_legislation: Procesos legislativos
debates: Debates
external_link_blog: Blog
external_link_opendata: Datos abiertos
@@ -220,6 +221,12 @@ es:
text_sign_in: iniciar sesión
text_sign_up: registrarte
title: "¿Cómo puedo comentar este documento?"
+ legislation:
+ draft_versions:
+ changes:
+ see_text: Ver texto
+ show:
+ see_changes: Ver cambios
locale: Español
notifications:
index:
diff --git a/config/routes.rb b/config/routes.rb
index f88755592..07200f76c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -85,6 +85,15 @@ Rails.application.routes.draw do
get :search, on: :collection
end
+ namespace :legislation do
+ resources :processes, only: [:index, :show] do
+ resources :draft_versions, only: [:show] do
+ resources :annotations
+ get :changes
+ end
+ end
+ end
+
resources :users, only: [:show] do
resources :direct_messages, only: [:new, :create, :show]
end