diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e81e74f34..bccb2132b 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -50,6 +50,7 @@ //= require markdown_editor //= require cocoon //= require allegations +//= require legislation_questions //= require custom var initialize_modules = function() { @@ -74,6 +75,7 @@ var initialize_modules = function() { App.SocialShare.initialize(); App.MarkdownEditor.initialize(); App.Allegations.initialize(); + App.LegislationQuestions.initialize(); }; $(function(){ diff --git a/app/assets/javascripts/legislation_questions.js.coffee b/app/assets/javascripts/legislation_questions.js.coffee new file mode 100644 index 000000000..f8bea46f3 --- /dev/null +++ b/app/assets/javascripts/legislation_questions.js.coffee @@ -0,0 +1,8 @@ +App.LegislationQuestions = + + initialize: -> + $('form#new_legislation_answer input.button').hide() + $('form#new_legislation_answer input[type=radio]').on + click: -> + $('form#new_legislation_answer').submit() + diff --git a/app/assets/javascripts/votes.js.coffee b/app/assets/javascripts/votes.js.coffee index b842c3ffc..22f7653b7 100644 --- a/app/assets/javascripts/votes.js.coffee +++ b/app/assets/javascripts/votes.js.coffee @@ -13,4 +13,5 @@ App.Votes = initialize: -> App.Votes.hoverize "div.votes" App.Votes.hoverize "div.supports" + App.Votes.hoverize "div.debate-questions" false diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index e5e6562d3..0ef13f01a 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -901,16 +901,12 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar { } .author-deleted, .user-deleted { - background-color: rgba(255,255,255,.5); color: rgba(0,0,0,.4); - font-size: rem-calc(40); - left: 11px; - position: absolute; - top: 72px; -} - -.user-deleted { - top: -4px; + display: inline-block; + font-size: rem-calc(32); + line-height: rem-calc(32); + height: rem-calc(32); + vertical-align: top; } .user-permissions { @@ -1069,10 +1065,6 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar { background: #C0392B; } -.is-deleted { - background: #E7E7E7; -} - .level-1 { background: #1ABC9C; } @@ -1601,7 +1593,10 @@ table { } .comment-body { - margin-left: rem-calc(42); + + img { + margin-right: $line-height/2; + } .reply { background: white; @@ -1609,20 +1604,28 @@ table { border-left: 0; border-right: 0; font-size: $small-font-size; - margin: rem-calc(6) 0; - padding: rem-calc(6); + margin: $line-height/4 0; + padding: $line-height/4; position: relative; + a.relative, [class^="icon-arrow"] { + padding-left: $line-height/2; + } + [class^="icon-arrow"] { - font-size: rem-calc(18); + font-size: $base-font-size; left: -20px; position: absolute; - top: 0; + top: -1px; } .divider { color: $text-light; } + + form { + margin-top: $line-height/2; + } } .comment-user { @@ -1650,27 +1653,19 @@ table { } } - .is-deleted { - background: #E7E7E7; - margin-left: rem-calc(42); - padding: $line-height/4 $line-height/2; - } - .comment-children { border-left: 1px dashed $border; - margin-left: rem-calc(42); - padding-left: $line-height/4; - - @media only screen and (max-width: 40em) { - margin-left: rem-calc(16); - } + display: inline-block; + margin-left: rem-calc(16); + padding-left: rem-calc(8); + width: 100%; } .comment-info { color: $text-medium; + display: inline-block; font-size: $small-font-size; - margin-top: $line-height/4; - vertical-align: middle; + line-height: rem-calc(32); // Same as avatar height span.user-name { color: $text; @@ -1703,6 +1698,11 @@ table { } } +.comment-form { + display: inline-block; + width: 100%; +} + // 16. Flags // --------- diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index f837b3921..4fc1bee3c 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -293,6 +293,7 @@ } .debate-questions { + position: relative; list-style: none; .control { diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 9af22d4ab..73ad3bec4 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -326,9 +326,13 @@ clear: both; color: $text-medium; font-size: $small-font-size; - min-height: $line-height*2; + margin-bottom: $line-height/2; position: relative; + span { + line-height: rem-calc(32); // Same as avatar height + } + a { color: $text-medium; } @@ -338,15 +342,6 @@ line-height: $line-height; margin: 0; } - - .author-deleted { - left: 0; - top: 4px; - } - - .author.deleted { - margin-left: rem-calc(48); - } } .debate-description, .proposal-description { @@ -371,9 +366,9 @@ } .author-photo { - line-height: $line-height*2; + line-height: rem-calc(32); margin-right: rem-calc(6); - vertical-align: middle; + vertical-align: top; width: 32px; } diff --git a/app/controllers/admin/signature_sheets_controller.rb b/app/controllers/admin/signature_sheets_controller.rb new file mode 100644 index 000000000..60299c5a6 --- /dev/null +++ b/app/controllers/admin/signature_sheets_controller.rb @@ -0,0 +1,32 @@ +class Admin::SignatureSheetsController < Admin::BaseController + + def index + @signature_sheets = SignatureSheet.all + end + + def new + @signature_sheet = SignatureSheet.new + end + + def create + @signature_sheet = SignatureSheet.new(signature_sheet_params) + @signature_sheet.author = current_user + if @signature_sheet.save + @signature_sheet.delay.verify_signatures + redirect_to [:admin, @signature_sheet], notice: I18n.t('flash.actions.create.signature_sheet') + else + render :new + end + end + + def show + @signature_sheet = SignatureSheet.find(params[:id]) + end + + private + + def signature_sheet_params + params.require(:signature_sheet).permit(:signable_type, :signable_id, :document_numbers) + end + +end \ No newline at end of file diff --git a/app/controllers/legislation/answers_controller.rb b/app/controllers/legislation/answers_controller.rb new file mode 100644 index 000000000..ac77ea5f1 --- /dev/null +++ b/app/controllers/legislation/answers_controller.rb @@ -0,0 +1,41 @@ +class Legislation::AnswersController < Legislation::BaseController + before_action :authenticate_user! + before_action :verify_resident! + + load_and_authorize_resource :process + load_and_authorize_resource :question, through: :process + load_and_authorize_resource :answer, through: :question + + respond_to :html, :js + + def create + if @process.open_phase?(:debate) + @answer.user = current_user + @answer.save + track_event + respond_to do |format| + format.js + format.html { redirect_to legislation_process_question_path(@process, @question) } + end + else + respond_to do |format| + format.js + format.html { redirect_to legislation_process_question_path(@process, @question), alert: t('legislation.questions.participation.phase_not_open') } + end + end + end + + private + def answer_params + params.require(:legislation_answer).permit( + :legislation_question_option_id, + ) + end + + def track_event + ahoy.track "legislation_answer_created".to_sym, + "legislation_answer_id": @answer.id, + "legislation_question_option_id": @answer.legislation_question_option_id, + "legislation_question_id": @answer.legislation_question_id + end +end diff --git a/app/controllers/legislation/questions_controller.rb b/app/controllers/legislation/questions_controller.rb index 7114c98cb..d50443281 100644 --- a/app/controllers/legislation/questions_controller.rb +++ b/app/controllers/legislation/questions_controller.rb @@ -8,5 +8,6 @@ class Legislation::QuestionsController < Legislation::BaseController @commentable = @question @comment_tree = CommentTree.new(@commentable, params[:page], @current_order) set_comment_flags(@comment_tree.comments) + @answer = @question.answer_for_user(current_user) || Legislation::Answer.new end end diff --git a/app/helpers/signature_sheets_helper.rb b/app/helpers/signature_sheets_helper.rb new file mode 100644 index 000000000..acd75a5ab --- /dev/null +++ b/app/helpers/signature_sheets_helper.rb @@ -0,0 +1,8 @@ +module SignatureSheetsHelper + + def signable_options + [[t("activerecord.models.proposal", count: 1), Proposal], + [t("activerecord.models.spending_proposal", count: 1), SpendingProposal]] + end + +end \ No newline at end of file diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 1dbc5baa2..ea1d4fa40 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,5 +1,5 @@ class ApplicationMailer < ActionMailer::Base helper :settings - default from: "Consul " + default from: "#{Setting['mailer_from_name']} <#{Setting['mailer_from_address']}>" layout 'mailer' end diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb index e22bcb7e0..466b6a5ba 100644 --- a/app/models/abilities/everyone.rb +++ b/app/models/abilities/everyone.rb @@ -14,6 +14,7 @@ module Abilities can [:read, :draft_publication, :allegations, :final_version_publication], Legislation::Process can [:read], Legislation::DraftVersion can [:read], Legislation::Question + can [:create], Legislation::Answer end end end diff --git a/app/models/legislation/answer.rb b/app/models/legislation/answer.rb new file mode 100644 index 000000000..fd4bc90ed --- /dev/null +++ b/app/models/legislation/answer.rb @@ -0,0 +1,9 @@ +class Legislation::Answer < ActiveRecord::Base + belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :answers, counter_cache: true + belongs_to :question_option, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_option_id', dependent: :destroy, inverse_of: :answers, counter_cache: true + belongs_to :user, dependent: :destroy, inverse_of: :legislation_answers + + validates :question, presence: true, uniqueness: { scope: :user_id} + validates :question_option, presence: true + validates :user, presence: true +end diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index dbc31c7b3..86b250b18 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -2,9 +2,9 @@ class Legislation::Process < ActiveRecord::Base acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases - has_many :draft_versions, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id' + has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id' has_one :final_draft_version, -> { where final_version: true }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id' - has_many :questions, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id' + has_many :questions, -> { order(:id) }, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id' validates :title, presence: true validates :description, presence: true diff --git a/app/models/legislation/question.rb b/app/models/legislation/question.rb index 2b779d1f8..7df8f67cf 100644 --- a/app/models/legislation/question.rb +++ b/app/models/legislation/question.rb @@ -5,7 +5,8 @@ class Legislation::Question < ActiveRecord::Base belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :process, class_name: 'Legislation::Process', foreign_key: 'legislation_process_id' - has_many :question_options, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question + has_many :question_options, -> { order(:id) }, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question + has_many :answers, class_name: 'Legislation::Answer', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question has_many :comments, as: :commentable accepts_nested_attributes_for :question_options, :reject_if => proc { |attributes| attributes[:value].blank? }, allow_destroy: true @@ -16,4 +17,8 @@ class Legislation::Question < ActiveRecord::Base def next_question_id @next_question_id ||= process.questions.where("id > ?", id).order('id ASC').limit(1).pluck(:id).first end + + def answer_for_user(user) + answers.where(user: user).first + end end diff --git a/app/models/legislation/question_option.rb b/app/models/legislation/question_option.rb index 93bc20320..f7927dd1a 100644 --- a/app/models/legislation/question_option.rb +++ b/app/models/legislation/question_option.rb @@ -3,6 +3,7 @@ class Legislation::QuestionOption < ActiveRecord::Base include ActsAsParanoidAliases belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id', inverse_of: :question_options + has_many :answers, class_name: 'Legislation::Answer', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question validates :question, presence: true validates :value, presence: true, uniqueness: { scope: :legislation_question_id } diff --git a/app/models/signature.rb b/app/models/signature.rb new file mode 100644 index 000000000..47408858a --- /dev/null +++ b/app/models/signature.rb @@ -0,0 +1,85 @@ +class Signature < ActiveRecord::Base + belongs_to :signature_sheet + belongs_to :user + + validates :document_number, presence: true + validates :signature_sheet, presence: true + + scope :verified, -> { where(verified: true) } + scope :unverified, -> { where(verified: false) } + + delegate :signable, to: :signature_sheet + + def verified? + user_exists? || in_census? + end + + def verify + if verified? + assign_vote + mark_as_verified + end + end + + def assign_vote + if user_exists? + assign_vote_to_user + else + create_user + assign_vote_to_user + end + end + + def assign_vote_to_user + set_user + signable.register_vote(user, "yes") + assign_signature_to_vote + end + + def assign_signature_to_vote + vote = Vote.where(votable: signable, voter: user).first + vote.update(signature: self) + end + + def user_exists? + User.where(document_number: document_number).any? + end + + def create_user + user_params = { + document_number: document_number, + created_from_signature: true, + verified_at: Time.now, + erased_at: Time.now, + password: random_password, + terms_of_service: '1', + email: nil + } + User.create!(user_params) + end + + def random_password + (0...20).map { ('a'..'z').to_a[rand(26)] }.join + end + + def in_census? + response = document_types.detect do |document_type| + CensusApi.new.call(document_type, document_number).valid? + end + response.present? + end + + def set_user + user = User.where(document_number: document_number).first + update(user: user) + end + + def mark_as_verified + update(verified: true) + end + + def document_types + %w(1 2 3 4) + end + +end \ No newline at end of file diff --git a/app/models/signature_sheet.rb b/app/models/signature_sheet.rb new file mode 100644 index 000000000..9720c891f --- /dev/null +++ b/app/models/signature_sheet.rb @@ -0,0 +1,38 @@ +class SignatureSheet < ActiveRecord::Base + belongs_to :signable, polymorphic: true + belongs_to :author, class_name: 'User', foreign_key: 'author_id' + + VALID_SIGNABLES = %w( Proposal SpendingProposal ) + + has_many :signatures + + validates :author, presence: true + validates :signable_type, inclusion: {in: VALID_SIGNABLES} + validates :document_numbers, presence: true + validates :signable, presence: true + validate :signable_found + + def name + "#{signable_name} #{signable_id}" + end + + def signable_name + I18n.t("activerecord.models.#{signable_type.underscore}", count: 1) + end + + def verify_signatures + parsed_document_numbers.each do |document_number| + signature = self.signatures.where(document_number: document_number).first_or_create + signature.verify + end + update(processed: true) + end + + def parsed_document_numbers + document_numbers.split(/\r\n|\n|[,]/).collect {|d| d.gsub(/\s+/, '') } + end + + def signable_found + errors.add(:signable_id, :not_found) if errors.messages[:signable].present? + end +end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 03f2db27b..4ded8d99e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,6 +25,7 @@ class User < ActiveRecord::Base has_many :notifications has_many :direct_messages_sent, class_name: 'DirectMessage', foreign_key: :sender_id has_many :direct_messages_received, class_name: 'DirectMessage', foreign_key: :receiver_id + has_many :legislation_answers, class_name: 'Legislation::Answer', dependent: :destroy, inverse_of: :user belongs_to :geozone validates :username, presence: true, if: :username_required? diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 93adbc03c..8257b3c8a 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -35,8 +35,16 @@ <% end %> + <% if feature?(:signature_sheets) %> +
  • > + <%= link_to admin_signature_sheets_path do %> + <%= t("admin.menu.signature_sheets") %> + <% end %> +
  • + <% end %> + <% if feature?(:legislation) %> -
  • > +
  • > <%= link_to admin_legislation_processes_path do %> <%= t("admin.menu.legislation") %> <% end %> diff --git a/app/views/admin/legislation/questions/index.html.erb b/app/views/admin/legislation/questions/index.html.erb index 7d41f1b83..f0a4638ee 100644 --- a/app/views/admin/legislation/questions/index.html.erb +++ b/app/views/admin/legislation/questions/index.html.erb @@ -29,7 +29,9 @@ <%= content_tag :ul do %> <% question.question_options.each do |question_option| %> - <%= content_tag :li, question_option.value %> + <%= content_tag :li do %> + <%= question_option.value %> (<%= question_option.answers_count %>) + <% end %> <% end %> <% end %> diff --git a/app/views/admin/signature_sheets/index.html.erb b/app/views/admin/signature_sheets/index.html.erb new file mode 100644 index 000000000..74241b5b0 --- /dev/null +++ b/app/views/admin/signature_sheets/index.html.erb @@ -0,0 +1,31 @@ +

    <%= t("admin.signature_sheets.index.title") %>

    + +<%= link_to t("admin.signature_sheets.index.new"), new_admin_signature_sheet_path, + class: "button success float-right" %> + +<% if @signature_sheets.any? %> + + + + + + + <% @signature_sheets.each do |signature_sheet| %> + + + + + + <% end %> +
    <%= t("admin.signature_sheets.name") %><%= t("admin.signature_sheets.author") %><%= t("admin.signature_sheets.created_at") %>
    + <%= link_to signature_sheet.name, [:admin, signature_sheet] %> + + <%= signature_sheet.author.name %> + + <%= l(signature_sheet.created_at, format: :short) %> +
    +<% else %> +
    + <%= t("admin.signature_sheets.no_signature_sheets") %> +
    +<% end %> diff --git a/app/views/admin/signature_sheets/new.html.erb b/app/views/admin/signature_sheets/new.html.erb new file mode 100644 index 000000000..f471e1ea5 --- /dev/null +++ b/app/views/admin/signature_sheets/new.html.erb @@ -0,0 +1,22 @@ +<%= render 'shared/back_link' %> + +

    <%= t("admin.signature_sheets.new.title") %>

    + +<%= form_for [:admin, @signature_sheet] do |f| %> + <%= render 'shared/errors', + resource: @signature_sheet %> + +
    + <%= f.select :signable_type, signable_options %> +
    + +
    + <%= f.text_field :signable_id %> +
    + + <%= f.label :document_numbers %> +

    <%= t("admin.signature_sheets.new.document_numbers_note") %>

    + <%= f.text_area :document_numbers, rows: "6", label: false %> + + <%= f.submit(class: "button", value: t("admin.signature_sheets.new.submit")) %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/signature_sheets/show.html.erb b/app/views/admin/signature_sheets/show.html.erb new file mode 100644 index 000000000..0c2536b34 --- /dev/null +++ b/app/views/admin/signature_sheets/show.html.erb @@ -0,0 +1,44 @@ +

    <%= @signature_sheet.name %>

    + +
    + <%= t("admin.signature_sheets.show.created_at") %> + <%= l(@signature_sheet.created_at, format: :short) %> +  •  + <%= t("admin.signature_sheets.show.author") %> + <%= @signature_sheet.author.name %> +
    + +

    + <%= t("admin.signature_sheets.show.document_count") %> + <%= @signature_sheet.signatures.count %> +

    + +
    +

    <%= t("admin.signature_sheets.show.documents") %>

    + <%= simple_format @signature_sheet.document_numbers %> +
    + + +
    + + <%= t("admin.signature_sheets.show.verified", + count: @signature_sheet.signatures.verified.count ) %> + +
    + +
    +

    + + <%= t("admin.signature_sheets.show.unverified", + count: @signature_sheet.signatures.unverified.count ) %> + <%= t("admin.signature_sheets.show.unverified_error") %> + +

    + <%= @signature_sheet.signatures.unverified.map(&:document_number).join(", ") %> +
    + +<% unless @signature_sheet.processed? %> +
    + <%= t("admin.signature_sheets.show.loading") %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index deb6fa58d..46039f65d 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,10 +1,9 @@ <% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (@comment_flags[comment.id] if @comment_flags)] do %> -
    -
      - +
        +
      • <% if comment.hidden? || comment.user.hidden? %> <% if comment.children.size > 0 %> -
        +

        <%= t("comments.comment.deleted") %>

        <% end %> @@ -23,82 +22,84 @@ <% end %> <% end %> -
      • -
        +
        - <% if comment.as_administrator? %> - <%= t("comments.comment.admin") %> #<%= comment.administrator_id%> - <% elsif comment.as_moderator? %> - <%= t("comments.comment.moderator") %> #<%= comment.moderator_id%> + <% if comment.as_administrator? %> + <%= t("comments.comment.admin") %> #<%= comment.administrator_id%> + <% elsif comment.as_moderator? %> + <%= t("comments.comment.moderator") %> #<%= comment.moderator_id%> + <% else %> + + <% if comment.user.hidden? || comment.user.erased? %> + <%= t("comments.comment.user_deleted") %> <% else %> - - <% if comment.user.hidden? || comment.user.erased? %> - <%= t("comments.comment.user_deleted") %> - <% else %> - <%= link_to comment.user.name, user_path(comment.user) %> - <% if comment.user.display_official_position_badge? %> -  •  - - <%= comment.user.official_position %> - - <% end %> - <% end %> - <% if comment.user.verified_organization? %> + <%= link_to comment.user.name, user_path(comment.user) %> + <% if comment.user.display_official_position_badge? %>  •  - - <%= t("shared.collective") %> + + <%= comment.user.official_position %> <% end %> - <% if comment.user_id == comment.commentable.author_id %> -  •  - - <%= t("comments.comment.author") %> - - <% end %> - + <% end %> + <% if comment.user.verified_organization? %> +  •  + + <%= t("shared.collective") %> + + <% end %> + <% if comment.user_id == comment.commentable.author_id %> +  •  + + <%= t("comments.comment.author") %> + <% end %> -  •  + <% end %> + +  • <%= l comment.created_at.to_datetime, format: :datetime %> +
        + +
        + <%= simple_format text_with_links(comment.body), {}, sanitize: false %> +
        + +
        +
        + <%= render 'comments/votes', comment: comment %>
        -
        - <%= simple_format text_with_links(comment.body), {}, sanitize: false %> -
        - -
        - - <%= render 'comments/votes', comment: comment %> - - - <% if comment.children.size > 0 %> - <%= link_to "", class: "js-toggle-children relative", data: {'id': "#{dom_id(comment)}"} do %> - - <%= t("shared.hide") %> - <%= t("comments.comment.responses", count: comment.children.size) %> - <% end %> - <% else %> - <%= t("comments.comment.responses", count: 0) %> + <% if comment.children.size > 0 %> + <%= link_to "#{dom_id(comment)}", class: "js-toggle-children relative", data: {'id': "#{dom_id(comment)}"} do %> + + <%= t("shared.hide") %> + <%= t("comments.comment.responses", count: comment.children.size) %> <% end %> + <% else %> + <%= t("comments.comment.responses", count: 0) %> + <% end %> - <% if user_signed_in? %> -  |  - <%= link_to(comment_link_text(comment), "", - class: "js-add-comment-link", data: {'id': dom_id(comment)}) %> + <% if user_signed_in? %> +  |  + <%= link_to(comment_link_text(comment), "", + class: "js-add-comment-link", data: {'id': dom_id(comment)}) %> - <%= render 'comments/actions', comment: comment %> + <%= render 'comments/actions', comment: comment %> - <%= render 'comments/form', {commentable: comment.commentable, parent_id: comment.id, toggeable: true} %> - <% end %> -
        -
      • + <%= render 'comments/form', {commentable: comment.commentable, parent_id: comment.id, toggeable: true} %> + <% end %> +
    <% end %> +
  • +
  • - - +
  • + <% end %> diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 601e45a47..e3399c383 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -1,6 +1,6 @@ <% cache [locale_and_user_status, parent_id, commentable_cache_key(commentable)] do %> <% css_id = parent_or_commentable_dom_id(parent_id, commentable) %> -
    > +
    class="comment-form"> <%= form_for Comment.new, remote: true do |f| %> <%= label_tag "comment-body-#{css_id}", t("comments.form.leave_comment") %> <%= f.text_area :body, id: "comment-body-#{css_id}", maxlength: Comment.body_max_length, label: false %> diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index 30152b366..c88045f26 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -1,6 +1,5 @@ <%= form_for(@debate) do |f| %> - <%= render 'shared/errors', resource: @debate %>
    diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index e2e2c84c9..363a3bab3 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -58,6 +58,7 @@ <% end %>
    +
    <% end %> diff --git a/app/views/legislation/answers/create.js.erb b/app/views/legislation/answers/create.js.erb new file mode 100644 index 000000000..468b2610b --- /dev/null +++ b/app/views/legislation/answers/create.js.erb @@ -0,0 +1 @@ +$("#legislation-answer-form").html('<%= j render("legislation/questions/answer_form", process: @process, question: @question, answer: @answer) %>'); diff --git a/app/views/legislation/questions/_answer_form.html.erb b/app/views/legislation/questions/_answer_form.html.erb new file mode 100644 index 000000000..775e93faa --- /dev/null +++ b/app/views/legislation/questions/_answer_form.html.erb @@ -0,0 +1,28 @@ +<% if question.question_options.any? %> + <% if process.open_phase?(:debate) && !answer.persisted? %> + + <%= form_for answer, url: legislation_process_question_answers_path(process, question, answer), remote: true , html: { class: "controls-stacked"} do |f| %> + <% question.question_options.each do |question_option| %> + + <% end %> + <%= f.submit t('legislation.questions.show.answer_question'), class: "button" %> + <% end %> + + <% else %> + +
    + <% question.question_options.each do |question_option| %> + + <% end %> +
    + + <% end %> +<% end %> diff --git a/app/views/legislation/questions/_participation_not_allowed.html.erb b/app/views/legislation/questions/_participation_not_allowed.html.erb new file mode 100644 index 000000000..b330f7fe0 --- /dev/null +++ b/app/views/legislation/questions/_participation_not_allowed.html.erb @@ -0,0 +1,20 @@ +<% if user_signed_in? && current_user.organization? %> + +<% elsif user_signed_in? && current_user.unverified? %> + +<% elsif !user_signed_in? %> + +<% end %> diff --git a/app/views/legislation/questions/show.html.erb b/app/views/legislation/questions/show.html.erb index d22289d28..be8e90445 100644 --- a/app/views/legislation/questions/show.html.erb +++ b/app/views/legislation/questions/show.html.erb @@ -22,17 +22,10 @@

    <%= @question.title %>

    -
    -
    - <% @question.question_options.each do |question_option| %> - - <% end %> -
    -
    +
    + <%= render 'answer_form', process: @process, question: @question, answer: @answer %> + <%= render 'participation_not_allowed' %> +