diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index e10c0327f..3c37e9657 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -314,6 +314,7 @@ .debate-show, .proposal-show, +.poll-question-show, .investment-project-show, .budget-investment-show, .polls-show, diff --git a/app/controllers/admin/poll/booths_controller.rb b/app/controllers/admin/poll/booths_controller.rb index ff3700436..4b322f0b2 100644 --- a/app/controllers/admin/poll/booths_controller.rb +++ b/app/controllers/admin/poll/booths_controller.rb @@ -30,6 +30,11 @@ class Admin::Poll::BoothsController < Admin::BaseController end end + def available + @booths = Poll::Booth.available.order(name: :asc).page(params[:page]) + render :index + end + private def booth_params diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index ab7297a95..3bbe1c395 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -1,4 +1,6 @@ class Admin::Poll::QuestionsController < Admin::BaseController + include CommentableActions + load_and_authorize_resource :poll load_and_authorize_resource :question, class: 'Poll::Question' @@ -20,6 +22,7 @@ class Admin::Poll::QuestionsController < Admin::BaseController def create @question.author = @question.proposal.try(:author) || current_user + recover_documents_from_cache(@question) if @question.save redirect_to admin_question_path(@question) @@ -29,6 +32,7 @@ class Admin::Poll::QuestionsController < Admin::BaseController end def show + @document = Document.new(documentable: @question) end def edit @@ -54,7 +58,8 @@ class Admin::Poll::QuestionsController < Admin::BaseController private def question_params - params.require(:poll_question).permit(:poll_id, :title, :question, :description, :proposal_id, :valid_answers) + params.require(:poll_question).permit(:poll_id, :title, :question, :description, :proposal_id, :valid_answers, :video_url, + documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id]) end def search_params diff --git a/app/controllers/admin/poll/shifts_controller.rb b/app/controllers/admin/poll/shifts_controller.rb index 8a808a7a9..168284474 100644 --- a/app/controllers/admin/poll/shifts_controller.rb +++ b/app/controllers/admin/poll/shifts_controller.rb @@ -2,20 +2,21 @@ class Admin::Poll::ShiftsController < Admin::BaseController before_action :load_booth before_action :load_polls + before_action :load_officer def new - load_officers load_shifts @shift = ::Poll::Shift.new end def create @shift = ::Poll::Shift.new(shift_params) + @officer = @shift.officer + if @shift.save notice = t("admin.poll_shifts.flash.create") redirect_to new_admin_booth_shift_path(@shift.booth), notice: notice else - load_officers load_shifts render :new end @@ -28,6 +29,10 @@ class Admin::Poll::ShiftsController < Admin::BaseController redirect_to new_admin_booth_shift_path(@booth), notice: notice end + def search_officers + @officers = User.search(params[:search]).order(username: :asc) + end + private def load_booth @@ -38,14 +43,16 @@ class Admin::Poll::ShiftsController < Admin::BaseController @polls = ::Poll.current_or_incoming end - def load_officers - @officers = ::Poll::Officer.all - end - def load_shifts @shifts = @booth.shifts end + def load_officer + if params[:officer_id].present? + @officer = ::Poll::Officer.find(params[:officer_id]) + end + end + def shift_params params.require(:shift).permit(:booth_id, :officer_id, :date) end diff --git a/app/controllers/polls/questions_controller.rb b/app/controllers/polls/questions_controller.rb index 1849dff97..bb1560f54 100644 --- a/app/controllers/polls/questions_controller.rb +++ b/app/controllers/polls/questions_controller.rb @@ -10,6 +10,8 @@ class Polls::QuestionsController < ApplicationController @comment_tree = CommentTree.new(@commentable, params[:page], @current_order) set_comment_flags(@comment_tree.comments) + @document = Document.new(documentable: @question) + question_answer = @question.answers.where(author_id: current_user.try(:id)).first @answers_by_question_id = {@question.id => question_answer.try(:answer)} end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 9fadfea39..d56c658bd 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -25,7 +25,7 @@ module AdminHelper end def menu_polls? - ["polls", "questions", "officers", "booths", "officer_assignments", "booth_assignments", "recounts", "results"].include? controller_name + ["polls", "questions", "officers", "booths", "officer_assignments", "booth_assignments", "recounts", "results", "shifts"].include? controller_name end def menu_profiles? diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index db4cee09d..773dabf34 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -57,7 +57,7 @@ module Abilities can [:index, :create, :edit, :update, :destroy], Geozone can [:read, :create, :update, :destroy, :add_question, :remove_question, :search_booths, :search_questions, :search_officers], Poll - can [:read, :create, :update, :destroy], Poll::Booth + can [:read, :create, :update, :destroy, :available], Poll::Booth can [:search, :create, :index, :destroy], ::Poll::Officer can [:create, :destroy], ::Poll::BoothAssignment can [:create, :destroy], ::Poll::OfficerAssignment diff --git a/app/models/poll/booth.rb b/app/models/poll/booth.rb index 9edbcbaf0..0aca6eecb 100644 --- a/app/models/poll/booth.rb +++ b/app/models/poll/booth.rb @@ -5,10 +5,15 @@ class Poll has_many :shifts validates :name, presence: true, uniqueness: true - + def self.search(terms) return Booth.none if terms.blank? Booth.where("name ILIKE ? OR location ILIKE ?", "%#{terms}%", "%#{terms}%") end + + def self.available + where(polls: { id: Poll.current_or_incoming }).includes(:polls) + end + end end \ No newline at end of file diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index 28dd8ed4a..8e02dcfe2 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -1,6 +1,11 @@ class Poll::Question < ActiveRecord::Base include Measurable include Searchable + include Documentable + documentable max_documents_allowed: 1, + max_file_size: 3.megabytes, + accepted_content_types: [ "application/pdf" ] + accepts_nested_attributes_for :documents, allow_destroy: true acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index b42e717b4..e629f5807 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -73,12 +73,15 @@ <%= link_to t('admin.menu.poll_officers'), admin_officers_path %> -
  • > +
  • > <%= link_to t('admin.menu.poll_booths'), admin_booths_path %>
  • -
  • > - <%= link_to t('admin.menu.poll_shifts'), admin_booths_path %> +
  • > + <%= link_to t('admin.menu.poll_shifts'), available_admin_booths_path %>
  • diff --git a/app/views/admin/poll/booths/index.html.erb b/app/views/admin/poll/booths/index.html.erb index 0dbb62cdf..05044dd0e 100644 --- a/app/views/admin/poll/booths/index.html.erb +++ b/app/views/admin/poll/booths/index.html.erb @@ -15,8 +15,7 @@ <%= t("admin.booths.index.name") %> <%= t("admin.booths.index.location") %> -   -   + <%= t("admin.actions.actions") %> <% @booths.each do |booth| %> diff --git a/app/views/admin/poll/officer_assignments/index.html.erb b/app/views/admin/poll/officer_assignments/index.html.erb index f6e75c602..f27f6b2ae 100644 --- a/app/views/admin/poll/officer_assignments/index.html.erb +++ b/app/views/admin/poll/officer_assignments/index.html.erb @@ -15,7 +15,6 @@ <%= t("admin.poll_officer_assignments.index.table_name") %> <%= t("admin.poll_officer_assignments.index.table_email") %> - <%= t("admin.actions.actions") %> <% @officers.each do |officer| %> @@ -28,11 +27,6 @@ <%= officer.email %> - - <%= link_to t("admin.poll_officer_assignments.index.edit_officer_assignments"), - by_officer_admin_poll_officer_assignments_path(@poll, officer_id: officer.id), - class: "button hollow" %> - <% end %> @@ -40,4 +34,4 @@ <%= paginate @officers %> <% end %> - \ No newline at end of file + diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index 959aa4ddf..2b32ed680 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -26,6 +26,17 @@ ckeditor: { language: I18n.locale } %> +
    + <%= render 'documents/nested_documents', documentable: @question %> +
    + +
    + <%= f.label :video_url, t("proposals.form.proposal_video_url") %> +

    <%= t("proposals.form.proposal_video_url_note") %>

    + <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), label: false, + aria: {describedby: "video-url-help-text"} %> +
    +
    <%= f.submit(class: "button expanded", value: t("shared.save")) %> diff --git a/app/views/admin/poll/questions/show.html.erb b/app/views/admin/poll/questions/show.html.erb index 3be660f79..3f776c5c0 100644 --- a/app/views/admin/poll/questions/show.html.erb +++ b/app/views/admin/poll/questions/show.html.erb @@ -40,6 +40,21 @@ <%= @question.description %>

    + <% if @question.video_url.present? %> +

    + <%= t("admin.questions.show.video_url") %> +
    + <%= @question.video_url %> +

    + <% end %> + + <% if @question.documents.any? %> +

    + <%= t("admin.questions.show.documents") %> +
    + <%= @question.documents.first.title %> +

    + <% end %> <%= link_to t("admin.questions.show.preview"), question_path(@question) %>
    diff --git a/app/views/admin/poll/shifts/_form.html.erb b/app/views/admin/poll/shifts/_form.html.erb new file mode 100644 index 000000000..f0461855f --- /dev/null +++ b/app/views/admin/poll/shifts/_form.html.erb @@ -0,0 +1,30 @@ +<%= form_for @shift, as: :shift, url: admin_booth_shifts_path do |f| %> + <%= render "shared/errors", resource: @shift %> + +
    + + <%= t("admin.poll_shifts.new.new_shift") %> + + +
    + <%= t("admin.poll_shifts.new.officer") %> +
    <%= @officer.name %> + <%= f.hidden_field :officer_id, value: @officer.id %> +
    + +
    + + <%= f.select :date, + shift_dates_select_options(@polls), + prompt: t("admin.poll_shifts.new.select_date"), + label: false %> +
    + + <%= f.hidden_field :booth_id, value: @booth.id %> + +
    + <%= f.submit t("admin.poll_shifts.new.add_shift"), + class: "button expanded margin-top" %> +
    +
    +<% end %> diff --git a/app/views/admin/poll/shifts/_search_officers.html.erb b/app/views/admin/poll/shifts/_search_officers.html.erb new file mode 100644 index 000000000..e63d09d41 --- /dev/null +++ b/app/views/admin/poll/shifts/_search_officers.html.erb @@ -0,0 +1,19 @@ +
    +
    + <%= form_tag search_officers_admin_booth_shifts_path, + method: :get, remote: true do |f| %> +
    + <%= text_field_tag :search, + @search, + placeholder: t("admin.poll_shifts.new.search_officer_placeholder"), + id: "search-officers" %> +
    + <%= submit_tag t("admin.poll_shifts.new.search_officer_button"), + class: "button" %> +
    +
    + <% end %> +
    +
    + +
    diff --git a/app/views/admin/poll/shifts/_search_officers_results.html.erb b/app/views/admin/poll/shifts/_search_officers_results.html.erb new file mode 100644 index 000000000..70525ba6d --- /dev/null +++ b/app/views/admin/poll/shifts/_search_officers_results.html.erb @@ -0,0 +1,36 @@ +<% if @officers.blank? %> +
    + <%= t('admin.shared.no_search_results') %> +
    +<% else %> +

    <%= t('admin.shared.search_results') %>

    + + + + + + + + + + + <% @officers.each do |user| %> + + + + + + <% end %> + +
    <%= t("admin.poll_shifts.new.table_name") %><%= t("admin.poll_shifts.new.table_email") %> + <%= t("admin.poll_shifts.new.table_shift") %> +
    + <%= user.name %> + + <%= user.email %> + + <%= link_to t("admin.poll_shifts.new.edit_shifts"), + new_admin_booth_shift_path(officer_id: user.poll_officer.id), + class: "button hollow" %> +
    +<% end %> diff --git a/app/views/admin/poll/shifts/_shifts.html.erb b/app/views/admin/poll/shifts/_shifts.html.erb index 16376d22c..f2de53548 100644 --- a/app/views/admin/poll/shifts/_shifts.html.erb +++ b/app/views/admin/poll/shifts/_shifts.html.erb @@ -1,10 +1,10 @@ -

    <%= t("admin.poll_shifts.new.assignments") %>

    +

    <%= t("admin.poll_shifts.new.shifts") %>

    - + @@ -13,7 +13,7 @@
    <%= t("admin.poll_shifts.new.date") %> <%= t("admin.poll_shifts.new.officer") %><%= t("admin.poll_shifts.new.assignment") %><%= t("admin.poll_shifts.new.shift") %>
    <%= l(shift.date.to_date, format: :long) %> <%= shift.officer_name %> - <%= link_to t("admin.poll_shifts.new.remove_assignment"), + <%= link_to t("admin.poll_shifts.new.remove_shift"), admin_booth_shift_path(@booth, shift), method: :delete, class: "button hollow alert" %> diff --git a/app/views/admin/poll/shifts/new.html.erb b/app/views/admin/poll/shifts/new.html.erb index c997dc35f..b975c40a9 100644 --- a/app/views/admin/poll/shifts/new.html.erb +++ b/app/views/admin/poll/shifts/new.html.erb @@ -2,45 +2,21 @@

    <%= @booth.name %>

    -<%= form_for @shift, as: :shift, url: admin_booth_shifts_path do |f| %> - <%= render "shared/errors", resource: @shift %> - -
    - - <%= t("admin.poll_shifts.new.new_assignment") %> - - -
    - - <%= f.select :date, - shift_dates_select_options(@polls), - prompt: t("admin.poll_shifts.new.select_date"), - label: false %> -
    - -
    - - <%= f.select :officer_id, - officer_select_options(@officers), - prompt: t("admin.poll_shifts.new.select_officer"), - label: false %> -
    - - <%= f.hidden_field :booth_id, value: @booth.id %> - -
    - <%= f.submit t("admin.poll_shifts.new.add_assignment"), - class: "button expanded hollow margin-top" %> -
    -
    +<% if @officer.blank? %> +

    + <%= t("admin.poll_shifts.new.search_officer_text") %> +

    + <%= render "search_officers" %> +<% else %> + <%= render "form" %> <% end %>
    <% if @shifts.empty? %> -
    - <%= t("admin.poll_shifts.new.no_assignments") %> +
    + <%= t("admin.poll_shifts.new.no_shifts") %>
    <% else %> <%= render "shifts" %> <% end %> -
    \ No newline at end of file +
    diff --git a/app/views/admin/poll/shifts/search_officers.js.erb b/app/views/admin/poll/shifts/search_officers.js.erb new file mode 100644 index 000000000..ba621d8f7 --- /dev/null +++ b/app/views/admin/poll/shifts/search_officers.js.erb @@ -0,0 +1 @@ +$("#search-officers-results").html("<%= j render 'search_officers_results' %>"); \ No newline at end of file diff --git a/app/views/polls/questions/_filter_subnav.html.erb b/app/views/polls/questions/_filter_subnav.html.erb new file mode 100644 index 000000000..738fc3700 --- /dev/null +++ b/app/views/polls/questions/_filter_subnav.html.erb @@ -0,0 +1,22 @@ +
    +
    +
      +
    • + <%= link_to "#tab-comments" do %> +

      + <%= t("proposals.show.comments_tab") %> + (<%= @question.comments_count %>) +

      + <% end %> +
    • +
    • + <%= link_to "#tab-documents" do %> +

      + <%= t("documents.tab") %> + (<%= @question.documents.count %>) +

      + <% end %> +
    • +
    +
    +
    diff --git a/app/views/polls/questions/show.html.erb b/app/views/polls/questions/show.html.erb index da46ebbcc..f67633129 100644 --- a/app/views/polls/questions/show.html.erb +++ b/app/views/polls/questions/show.html.erb @@ -55,6 +55,21 @@ +<% if @question.video_url.present? %> +
    +
    + +
    +
    + +<% end %> +

    <%= t('poll_questions.show.more_info') %>

    @@ -62,4 +77,16 @@
    -<%= render "comments" %> +
    + <%= render "polls/questions/filter_subnav" %> + +
    + <%= render "polls/questions/comments" %> +
    + +
    + <%= render 'documents/documents', + documents: @question.documents, + max_documents_allowed: Poll::Question.max_documents_allowed %> +
    +
    diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 177228d76..1dc918e8e 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -23,7 +23,8 @@ <% end %> <% if author_of?(@proposal, current_user) %> - <%= link_to t("proposals.show.send_notification"), new_proposal_notification_path(proposal_id: @proposal.id), + <%= link_to t("proposals.show.send_notification"), + new_proposal_notification_path(proposal_id: @proposal.id), class: 'button hollow float-right' %> <% end %> diff --git a/app/views/shared/_admin_login_items.html.erb b/app/views/shared/_admin_login_items.html.erb index 85a367e97..5ba498523 100644 --- a/app/views/shared/_admin_login_items.html.erb +++ b/app/views/shared/_admin_login_items.html.erb @@ -1,37 +1,37 @@ <% if show_admin_menu? %> -
  • - <%= link_to t("layouts.header.administration_menu"), "#", rel: "nofollow" %> - +
  • <% end %> diff --git a/app/views/shared/_subnavigation.html.erb b/app/views/shared/_subnavigation.html.erb index 487edeb39..dd9809dd3 100644 --- a/app/views/shared/_subnavigation.html.erb +++ b/app/views/shared/_subnavigation.html.erb @@ -20,7 +20,7 @@
  • <%= layout_menu_link_to t("layouts.header.poll_questions"), polls_path, - controller_name == "polls", + controller_name == "polls" || controller_name == "questions", accesskey: "3", title: t("shared.go_to_page") + t("layouts.header.poll_questions") %>
  • diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index c91719104..3f1b12189 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -498,16 +498,22 @@ en: final_recount: "Final recount (by officer)" poll_shifts: new: - new_assignment: "New shift" + add_shift: "Add shift" + shift: "Assignment" + shifts: "Shifts in this booth" date: "Date" + edit_shifts: Edit shifts + new_shift: "New shift" + no_shifts: "This booth has no shifts" officer: "Officer" - assignment: "Assignment" + remove_shift: "Remove" + search_officer_button: Search + search_officer_placeholder: Search officer + search_officer_text: Search for an officer to assign a new shift select_date: "Select day" - select_officer: "Select officer" - add_assignment: "Add shift" - remove_assignment: "Remove" - assignments: "Shifts in this booth" - no_assignments: "This booth has no shifts" + table_shift: "Shift" + table_email: "Email" + table_name: "Name" flash: create: "Shift added" destroy: "Shift removed" @@ -590,6 +596,8 @@ en: title: Title valid_answers: Valid answers description: Description + video_url: External video + documents: Documents preview: View on website recounts: index: diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 93075d3dc..321887388 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -175,6 +175,7 @@ en: proposal_notification: "Notification" spending_proposal: Spending proposal budget/investment: Investment + poll/shift: Shift user: Account verification/sms: phone signature_sheet: Signature sheet diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index 83db1a8e4..d1884cbad 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -63,9 +63,9 @@ en: text: |- Use it in your local government or help us to improve it, it is free software. - This Open Government Portal use the [CONSUL app](https://github.com/ayuntamientomadrid 'consul github') that is free software, with [licence AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), that means in simple words that anyone can use the code freely, copy it, see it in detail, modify it and redistribute it to the word with the modifications he wants (allowing others to do the same). Because we think culture is better and richer when it is released. + This Open Government Portal use the [CONSUL app](https://github.com/consul/consul 'consul github') that is free software, with [licence AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), that means in simple words that anyone can use the code freely, copy it, see it in detail, modify it and redistribute it to the word with the modifications he wants (allowing others to do the same). Because we think culture is better and richer when it is released. - If you are a programmer, you can see the code and help us to improve it at [CONSUL app](https://github.com/ayuntamientomadrid 'consul github'). + If you are a programmer, you can see the code and help us to improve it at [CONSUL app](https://github.com/consul/consul 'consul github'). titles: how_to_use: Use it in your local government privacy: Privacy Policy diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 58fd31aa1..9872baa0d 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -498,18 +498,24 @@ es: final_recount: "Recuento final (presidente de mesa)" poll_shifts: new: - new_assignment: "Nuevo turno" + add_shift: "Añadir turno" + shift: "Asignación" + shifts: "Turnos en esta urna" date: "Fecha" + edit_shifts: Asignar turno + new_shift: "Nuevo turno" + no_shifts: "Esta urna no tiene turnos asignados" officer: "Presidente de mesa" - assignment: "Asignación" + remove_shift: "Eliminar turno" + search_officer_button: Buscar + search_officer_placeholder: Buscar presidentes de mesa + search_officer_text: Busca al presidente de mesa para asignar un turno select_date: "Seleccionar día" - select_officer: "Seleccionar presidente de mesa" - add_assignment: "Añadir turno" - remove_assignment: "Eliminar turno" - assignments: "Turnos en esta urna" - no_assignments: "Esta urna no tiene turnos asignados" + table_shift: "Turno" + table_email: "Email" + table_name: "Nombre" flash: - create: "Añadido turno de presidente de mesa" + create: "Añadido turno de presidente de mesa" destroy: "Eliminado turno de presidente de mesa" poll_booth_assignments: flash: @@ -590,6 +596,8 @@ es: title: Título valid_answers: Respuestas válidas description: Descripción + video_url: Video externo + documents: Documentos preview: Ver en la web recounts: index: diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 18597d347..c4fd431b9 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -175,6 +175,7 @@ es: proposal_notification: "la notificación" spending_proposal: la propuesta de gasto budget/investment: la propuesta de inversión + poll/shift: el turno user: la cuenta verification/sms: el teléfono signature_sheet: la hoja de firmas diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index 81c916b5a..d67568b2d 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -63,9 +63,9 @@ es: text: |- Utilízalo en tu municipio libremente o ayúdanos a mejorarlo, es software libre. - Este Portal de Gobierno Abierto usa la [aplicación CONSUL](https://github.com/ayuntamientomadrid 'github consul') que es software libre, con [licencia AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), esto significa en palabras sencillas, que cualquiera puede libremente usar el código, copiarlo, verlo en detalle, modificarlo, y redistribuirlo al mundo con las modificaciones que quiera (manteniendo el que otros puedan a su vez hacer lo mismo). Porque creemos que la cultura es mejor y más rica cuando se libera. + Este Portal de Gobierno Abierto usa la [aplicación CONSUL](https://github.com/consul/consul 'github consul') que es software libre, con [licencia AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), esto significa en palabras sencillas, que cualquiera puede libremente usar el código, copiarlo, verlo en detalle, modificarlo, y redistribuirlo al mundo con las modificaciones que quiera (manteniendo el que otros puedan a su vez hacer lo mismo). Porque creemos que la cultura es mejor y más rica cuando se libera. - Si eres programador, puedes ver el código y ayudarnos a mejorarlo en [aplicación CONSUL](https://github.com/ayuntamientomadrid 'github consul'). + Si eres programador, puedes ver el código y ayudarnos a mejorarlo en [aplicación CONSUL](https://github.com/consul/consul 'github consul'). titles: how_to_use: Utilízalo en tu municipio privacy: Política de Privacidad @@ -81,4 +81,4 @@ es: info_code: 'Ahora introduce el código que has recibido en tu carta:' password: Contraseña submit: Verificar mi cuenta - title: Verifica tu cuenta \ No newline at end of file + title: Verifica tu cuenta diff --git a/config/locales/fr/general.yml b/config/locales/fr/general.yml index e4d0f9a51..cf1488375 100644 --- a/config/locales/fr/general.yml +++ b/config/locales/fr/general.yml @@ -1196,7 +1196,7 @@ fr: how_to_use: text: "Utilisez cet outil dans votre collectivité ou aidez-nous àl'améliorer, c'est un logiciel libre.\r\n\r\nCe portail de gouvernement ouvert utilise - cette [application Consul ](https://github.com/ayuntamientomadrid 'consul + cette [application Consul ](https://github.com/consul/consul 'consul github') qui est un logiciel libre, avec une [license AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), ce qui signifie en fait que n'importe qui peut utiliser le code librement, le copier, l'étudier en détail, le modifier et le redistribuer @@ -1207,7 +1207,7 @@ fr: la Mairie de Madrid autant que possible pour le faire. Si vous êtes intéressé, n'hésitez pas à nous contacter : ag.gobiernoabierto@consul.dev\r\n\r\nSi vous êtes développeur, vous pouvez voir le code et nous aider à l'améliorer - sur [Consul app](https://github.com/ayuntamientomadrid 'consul github ' + sur [Consul app](https://github.com/consul/consul 'consul github ' )." titles: faq: Solution pour les problèmes techniques (FAQ) diff --git a/config/locales/fr/pages.yml b/config/locales/fr/pages.yml index 42a4e3f2b..dcb57d400 100644 --- a/config/locales/fr/pages.yml +++ b/config/locales/fr/pages.yml @@ -59,9 +59,9 @@ fr: text: |- Utilisez le librement pour votre gouvernement ou aider nous à l'améliorer, c'est un logiciel libre. - Ce portail de Gouvernement Ouvert utilise l'[application Consul](https://github.com/ayuntamientomadrid 'consul github') qui est un logiciel libre, sous [licence AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), ce qui, en quelques mots, signifie que tout le monde peut utiliser le code librement, le copier, le voir en détail, le modifier et le redistribuer avec ces modifications (permettant à d'autres d'en faire de même). Car nous pensons que la culture est meilleure et plus riche quand elle est libre. + Ce portail de Gouvernement Ouvert utilise l'[application Consul](https://github.com/consul/consul 'consul github') qui est un logiciel libre, sous [licence AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), ce qui, en quelques mots, signifie que tout le monde peut utiliser le code librement, le copier, le voir en détail, le modifier et le redistribuer avec ces modifications (permettant à d'autres d'en faire de même). Car nous pensons que la culture est meilleure et plus riche quand elle est libre. - Si vous êtes un développeur, vous pouvez voir le code et nous aider à l'améliorer en allant sur l'[applicationConsul](https://github.com/ayuntamientomadrid 'consul github'). + Si vous êtes un développeur, vous pouvez voir le code et nous aider à l'améliorer en allant sur l'[applicationConsul](https://github.com/consul/consul 'consul github'). titles: how_to_use: Utilisez-le pour votre gouvernement privacy: Politique de confidentialité diff --git a/config/locales/nl/pages.yml b/config/locales/nl/pages.yml index 71edb19fe..a07151243 100644 --- a/config/locales/nl/pages.yml +++ b/config/locales/nl/pages.yml @@ -60,9 +60,9 @@ nl: text: |- Gebruik het in uw gemeente en help ons het te verbeteren, het is gratis software. - Deze Open Overheid site gebruikt de [Consul web-app](https://github.com/ayuntamientomadrid 'consul github'). Gratis software, onder de [AGPLv3 Licentie](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ). Simpel gezegd betekend dit dat u de app kunt inspecteren, gebruiken, aanpassen en herdistribueren (onder voorwaarde dat anderen hetzelfde kunnen doen met uw versie). + Deze Open Overheid site gebruikt de [Consul web-app](https://github.com/consul/consul 'consul github'). Gratis software, onder de [AGPLv3 Licentie](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ). Simpel gezegd betekend dit dat u de app kunt inspecteren, gebruiken, aanpassen en herdistribueren (onder voorwaarde dat anderen hetzelfde kunnen doen met uw versie). - Voor programmeurs: help ons het te verbeteren via [Consul app](https://github.com/ayuntamientomadrid 'consul github'). + Voor programmeurs: help ons het te verbeteren via [Consul app](https://github.com/consul/consul 'consul github'). titles: how_to_use: Gebruik het in uw gemeente privacy: Privacy Verklaring @@ -78,4 +78,4 @@ nl: info_code: 'en de code die u heeft ontvangen:' password: Wachtwoord submit: Verifieer mijn account - title: Verifieer uw account \ No newline at end of file + title: Verifieer uw account diff --git a/config/locales/pt-BR/general.yml b/config/locales/pt-BR/general.yml index 69ca72c02..816c14fa2 100644 --- a/config/locales/pt-BR/general.yml +++ b/config/locales/pt-BR/general.yml @@ -1212,7 +1212,7 @@ pt-BR: how_to_use: text: "Use este programa em seu governo local ou nos ajude a melhorá-lo, ele é um software livre.\r\n\r\nEste Portal de Governo Aberto usa o [app Consul] - (https://github.com/ayuntamientomadrid 'cônsul github'), que é um software + (https://github.com/consul/consul 'cônsul github'), que é um software livre, com [licença AGPLv3] (http://www.gnu.org/licenses/agpl- 3.0.html 'AGPLv3 gnu'), o que significa, em palavras simples que qualquer um pode usar o código livremente, copiá-lo, vê-lo em detalhes, modificá-lo e redistribuí-lo @@ -1223,7 +1223,7 @@ pt-BR: Madrid, o tanto quanto possível para fazê-lo, por isso, se você estiver interessado escreva-nos: ag.gobiernoabierto@consul.dev \r\n\r\nSe você é um programador, você - pode ver o código e nos ajudar a melhorá-lo em [app Consul] (https://github.com/ayuntamientomadrid + pode ver o código e nos ajudar a melhorá-lo em [app Consul] (https://github.com/consul/consul 'cônsul github')." titles: faq: Solução para problemas técnicos (FAQ) diff --git a/config/routes.rb b/config/routes.rb index eaf6b98f4..a41e8d429 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -287,7 +287,11 @@ Rails.application.routes.draw do end resources :booths do - resources :shifts + get :available, on: :collection + + resources :shifts do + get :search_officers, on: :collection + end end resources :questions diff --git a/db/migrate/20170905111444_add_video_url_to_poll_questions.rb b/db/migrate/20170905111444_add_video_url_to_poll_questions.rb new file mode 100644 index 000000000..800ca915e --- /dev/null +++ b/db/migrate/20170905111444_add_video_url_to_poll_questions.rb @@ -0,0 +1,5 @@ +class AddVideoUrlToPollQuestions < ActiveRecord::Migration + def change + add_column :poll_questions, :video_url, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 98f1b69bc..ba856107c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -669,6 +669,7 @@ ActiveRecord::Schema.define(version: 20170908175149) do t.datetime "created_at" t.datetime "updated_at" t.tsvector "tsv" + t.string "video_url" end add_index "poll_questions", ["author_id"], name: "index_poll_questions_on_author_id", using: :btree @@ -973,7 +974,7 @@ ActiveRecord::Schema.define(version: 20170908175149) do t.boolean "email_digest", default: true t.boolean "email_on_direct_message", default: true t.boolean "official_position_badge", default: false - t.datetime "password_changed_at", default: '2017-08-07 11:14:09', null: false + t.datetime "password_changed_at", default: '2017-09-06 18:19:39', null: false t.boolean "created_from_signature", default: false t.integer "failed_email_digests_count", default: 0 t.text "former_users_data_log", default: "" diff --git a/spec/factories.rb b/spec/factories.rb index 226723fe3..9cebfddea 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -380,6 +380,10 @@ FactoryGirl.define do trait :budget_investment_document do association :documentable, factory: :budget_investment end + + trait :poll_question_document do + association :documentable, factory: :poll_question + end end factory :comment do diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb index ec8c10d58..fd8fb9e84 100644 --- a/spec/features/admin/poll/booths_spec.rb +++ b/spec/features/admin/poll/booths_spec.rb @@ -36,6 +36,32 @@ feature 'Admin booths' do expect(page).to_not have_content "There are no booths" end + scenario "Available" do + booth_for_current_poll = create(:poll_booth) + booth_for_incoming_poll = create(:poll_booth) + booth_for_expired_poll = create(:poll_booth) + + current_poll = create(:poll, :current) + incoming_poll = create(:poll, :incoming) + expired_poll = create(:poll, :expired) + + create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll) + create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll) + create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll) + + visit admin_root_path + + within('#side_menu') do + click_link "Manage shifts" + end + + expect(page).to have_css(".booth", count: 2) + + expect(page).to have_content booth_for_current_poll.name + expect(page).to have_content booth_for_incoming_poll.name + expect(page).to_not have_content booth_for_expired_poll.name + end + scenario 'Show' do booth = create(:poll_booth) diff --git a/spec/features/admin/poll/questions_spec.rb b/spec/features/admin/poll/questions_spec.rb index e9b9f277a..392b2aabf 100644 --- a/spec/features/admin/poll/questions_spec.rb +++ b/spec/features/admin/poll/questions_spec.rb @@ -38,6 +38,7 @@ feature 'Admin poll questions' do Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy.... } + video_url = "https://puppyvideos.com" visit admin_questions_path click_link "Create question" @@ -45,11 +46,13 @@ feature 'Admin poll questions' do select 'Movies', from: 'poll_question_poll_id' fill_in 'poll_question_title', with: title fill_in 'poll_question_description', with: description + fill_in 'poll_question_video_url', with: video_url click_button 'Save' expect(page).to have_content(title) expect(page).to have_content(description) + expect(page).to have_content(video_url) end scenario 'Create from successful proposal index' do diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb index 473b27963..761a79536 100644 --- a/spec/features/admin/poll/shifts_spec.rb +++ b/spec/features/admin/poll/shifts_spec.rb @@ -30,7 +30,7 @@ feature 'Admin shifts' do expect(page).to have_content officer.name end - scenario "Create" do + scenario "Create", :js do poll = create(:poll) booth = create(:poll_booth) officer = create(:poll_officer) @@ -41,10 +41,13 @@ feature 'Admin shifts' do click_link "Manage shifts" end - select I18n.l(poll.starts_at.to_date, format: :long), from: 'shift_date' - select officer.name, from: 'shift_officer_id' - click_button "Add shift" + fill_in "search", with: officer.email + click_button "Search" + click_link "Edit shifts" + select I18n.l(poll.starts_at.to_date, format: :long), from: 'shift_date' + click_button "Add shift" + expect(page).to have_content "Shift added" within("#shifts") do @@ -54,6 +57,25 @@ feature 'Admin shifts' do end end + scenario "Erros on create", :js do + poll = create(:poll) + booth = create(:poll_booth) + officer = create(:poll_officer) + + visit admin_booths_path + + within("#booth_#{booth.id}") do + click_link "Manage shifts" + end + + fill_in "search", with: officer.email + click_button "Search" + click_link "Edit shifts" + click_button "Add shift" + + expect(page).to have_content "can't be blank" + end + scenario "Destroy" do poll = create(:poll) booth = create(:poll_booth) diff --git a/spec/features/polls/questions_spec.rb b/spec/features/polls/questions_spec.rb index 6f2225175..1563ca81a 100644 --- a/spec/features/polls/questions_spec.rb +++ b/spec/features/polls/questions_spec.rb @@ -25,6 +25,25 @@ feature 'Poll Questions' do expect(page).to have_content(question_with_author_visible_name.author_visible_name) end + scenario '#show view has video_url present' do + poll = create(:poll) + normal_question = create(:poll_question, poll: poll, video_url: "https://puppyvideos.com") + + visit question_path(normal_question) + + expect(page).to have_link(normal_question.video_url) + end + + scenario '#show view has document present' do + poll = create(:poll) + normal_question = create(:poll_question, poll: poll) + document = create(:document, documentable: normal_question) + + visit question_path(normal_question) + + expect(page).to have_content(document.title) + end + context 'Answering' do let(:geozone) { create(:geozone) } let(:poll) { create(:poll, geozone_restricted: true, geozone_ids: [geozone.id]) } diff --git a/spec/models/abilities/administrator_spec.rb b/spec/models/abilities/administrator_spec.rb index bbec927a0..dcb099ecd 100644 --- a/spec/models/abilities/administrator_spec.rb +++ b/spec/models/abilities/administrator_spec.rb @@ -14,9 +14,11 @@ describe "Abilities::Administrator" do let(:proposal) { create(:proposal) } let(:budget_investment) { create(:budget_investment) } let(:legislation_question) { create(:legislation_question) } + let(:poll_question) { create(:poll_question) } let(:proposal_document) { build(:document, documentable: proposal) } let(:budget_investment_document) { build(:document, documentable: budget_investment) } + let(:poll_question_document) { build(:document, documentable: poll_question) } let(:hidden_debate) { create(:debate, :hidden) } let(:hidden_comment) { create(:comment, :hidden) } @@ -83,4 +85,8 @@ describe "Abilities::Administrator" do it { should be_able_to(:new, budget_investment_document) } it { should be_able_to(:create, budget_investment_document) } it { should be_able_to(:destroy, budget_investment_document) } + + it { should be_able_to(:new, poll_question_document) } + it { should be_able_to(:create, poll_question_document) } + it { should be_able_to(:destroy, poll_question_document) } end diff --git a/spec/models/poll/booth_spec.rb b/spec/models/poll/booth_spec.rb index c095c62cd..d340d8197 100644 --- a/spec/models/poll/booth_spec.rb +++ b/spec/models/poll/booth_spec.rb @@ -24,4 +24,25 @@ describe :booth do end end + describe "#available" do + + it "returns booths associated to current or incoming polls" do + booth_for_current_poll = create(:poll_booth) + booth_for_incoming_poll = create(:poll_booth) + booth_for_expired_poll = create(:poll_booth) + + current_poll = create(:poll, :current) + incoming_poll = create(:poll, :incoming) + expired_poll = create(:poll, :expired) + + create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll) + create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll) + create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll) + + expect(Poll::Booth.available).to include(booth_for_current_poll) + expect(Poll::Booth.available).to include(booth_for_incoming_poll) + expect(Poll::Booth.available).to_not include(booth_for_expired_poll) + end + + end end \ No newline at end of file