From 39a2d25921017fc123661fc210d476781ce2aeb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Tue, 5 Sep 2017 18:32:33 +0200 Subject: [PATCH 01/21] Created migration to add video_url to poll questions --- ...5111444_add_video_url_to_poll_questions.rb | 5 +++ db/schema.rb | 43 ++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170905111444_add_video_url_to_poll_questions.rb 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 60ae69a0c..cbd91beac 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170720092638) do +ActiveRecord::Schema.define(version: 20170905111444) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -662,6 +662,7 @@ ActiveRecord::Schema.define(version: 20170720092638) 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 @@ -669,6 +670,20 @@ ActiveRecord::Schema.define(version: 20170720092638) do add_index "poll_questions", ["proposal_id"], name: "index_poll_questions_on_proposal_id", using: :btree add_index "poll_questions", ["tsv"], name: "index_poll_questions_on_tsv", using: :gin + create_table "poll_recounts", force: :cascade do |t| + t.integer "booth_assignment_id" + t.integer "officer_assignment_id" + t.integer "count" + t.text "count_log", default: "" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.date "date", null: false + t.text "officer_assignment_id_log", default: "" + end + + add_index "poll_recounts", ["booth_assignment_id"], name: "index_poll_recounts_on_booth_assignment_id", using: :btree + add_index "poll_recounts", ["officer_assignment_id"], name: "index_poll_recounts_on_officer_assignment_id", using: :btree + create_table "poll_voters", force: :cascade do |t| t.string "document_number" t.string "document_type" @@ -883,6 +898,32 @@ ActiveRecord::Schema.define(version: 20170720092638) do add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree add_index "tags", ["spending_proposals_count"], name: "index_tags_on_spending_proposals_count", using: :btree + create_table "tolk_locales", force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "tolk_locales", ["name"], name: "index_tolk_locales_on_name", unique: true, using: :btree + + create_table "tolk_phrases", force: :cascade do |t| + t.text "key" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "tolk_translations", force: :cascade do |t| + t.integer "phrase_id" + t.integer "locale_id" + t.text "text" + t.text "previous_text" + t.boolean "primary_updated", default: false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "tolk_translations", ["phrase_id", "locale_id"], name: "index_tolk_translations_on_phrase_id_and_locale_id", unique: true, using: :btree + create_table "users", force: :cascade do |t| t.string "email", default: "" t.string "encrypted_password", default: "", null: false From 4af44a45a131f7081231df5c48b3850769764487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 6 Sep 2017 12:00:46 +0200 Subject: [PATCH 02/21] Documents upload for questions working --- app/controllers/admin/poll/questions_controller.rb | 7 ++++++- app/controllers/polls/questions_controller.rb | 2 ++ app/models/poll/question.rb | 5 +++++ app/views/admin/poll/questions/_form.html.erb | 11 +++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) 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/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/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/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")) %> From 11ab061b9be8bac3b5cf6b5efcd04ebbaf0d5935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 6 Sep 2017 17:27:05 +0200 Subject: [PATCH 03/21] Added documents to question view Added same subnavigation as proposals for comments and documents in poll questions. --- .../polls/questions/_filter_subnav.html.erb | 22 +++++++++++++++++++ app/views/polls/questions/show.html.erb | 14 +++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 app/views/polls/questions/_filter_subnav.html.erb 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..a11ea5bd7 100644 --- a/app/views/polls/questions/show.html.erb +++ b/app/views/polls/questions/show.html.erb @@ -62,4 +62,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 %> +
+
From 288cedc4c4f79edf704ad48b178f5e11c6dee811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 6 Sep 2017 18:25:41 +0200 Subject: [PATCH 04/21] Poll questions documents tests added --- spec/factories.rb | 4 ++++ spec/models/abilities/administrator_spec.rb | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/spec/factories.rb b/spec/factories.rb index 7b1f6a417..ce92c88d3 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/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 From 12e6b9e681ac91e743d3dbd3491d1a5aa13bdc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 6 Sep 2017 19:11:28 +0200 Subject: [PATCH 05/21] Added video link to question public view --- app/assets/stylesheets/participation.scss | 1 + app/views/polls/questions/show.html.erb | 13 +++++++++++++ 2 files changed, 14 insertions(+) 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/views/polls/questions/show.html.erb b/app/views/polls/questions/show.html.erb index a11ea5bd7..bab6605d9 100644 --- a/app/views/polls/questions/show.html.erb +++ b/app/views/polls/questions/show.html.erb @@ -55,6 +55,19 @@ +<% if @question.video_url.present? %> +
+ +
+ +<% end %> +

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

From 33f621850ad9e1bf2e1a3dab5ba5f9cb788d8330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 6 Sep 2017 20:20:01 +0200 Subject: [PATCH 06/21] Fixed schema --- db/schema.rb | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 7f4d4a569..9b4ffd97b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -677,20 +677,6 @@ ActiveRecord::Schema.define(version: 20170905111444) do add_index "poll_questions", ["proposal_id"], name: "index_poll_questions_on_proposal_id", using: :btree add_index "poll_questions", ["tsv"], name: "index_poll_questions_on_tsv", using: :gin - create_table "poll_recounts", force: :cascade do |t| - t.integer "booth_assignment_id" - t.integer "officer_assignment_id" - t.integer "count" - t.text "count_log", default: "" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.date "date", null: false - t.text "officer_assignment_id_log", default: "" - end - - add_index "poll_recounts", ["booth_assignment_id"], name: "index_poll_recounts_on_booth_assignment_id", using: :btree - add_index "poll_recounts", ["officer_assignment_id"], name: "index_poll_recounts_on_officer_assignment_id", using: :btree - create_table "poll_shifts", force: :cascade do |t| t.integer "booth_id" t.integer "officer_id" @@ -919,32 +905,6 @@ ActiveRecord::Schema.define(version: 20170905111444) do add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree add_index "tags", ["spending_proposals_count"], name: "index_tags_on_spending_proposals_count", using: :btree - create_table "tolk_locales", force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "tolk_locales", ["name"], name: "index_tolk_locales_on_name", unique: true, using: :btree - - create_table "tolk_phrases", force: :cascade do |t| - t.text "key" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "tolk_translations", force: :cascade do |t| - t.integer "phrase_id" - t.integer "locale_id" - t.text "text" - t.text "previous_text" - t.boolean "primary_updated", default: false - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "tolk_translations", ["phrase_id", "locale_id"], name: "index_tolk_translations_on_phrase_id_and_locale_id", unique: true, using: :btree - create_table "topics", force: :cascade do |t| t.string "title", null: false t.text "description" @@ -1012,7 +972,7 @@ ActiveRecord::Schema.define(version: 20170905111444) 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-06-22 11:21:30', 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: "" From 3ff89b247605cf572d9307894c9085493dda410d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 6 Sep 2017 20:29:59 +0200 Subject: [PATCH 07/21] CSS minor fix --- app/views/polls/questions/show.html.erb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/views/polls/questions/show.html.erb b/app/views/polls/questions/show.html.erb index bab6605d9..f67633129 100644 --- a/app/views/polls/questions/show.html.erb +++ b/app/views/polls/questions/show.html.erb @@ -56,13 +56,15 @@
<% if @question.video_url.present? %> -
- diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index c91719104..d62d80e75 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -590,6 +590,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/es/admin.yml b/config/locales/es/admin.yml index 58fd31aa1..76fc72204 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -509,7 +509,7 @@ es: assignments: "Turnos en esta urna" no_assignments: "Esta urna no tiene turnos asignados" 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 +590,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: From 27ac4c58154ba75fad27d8816732b8839eeae0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Thu, 7 Sep 2017 17:19:07 +0200 Subject: [PATCH 09/21] Added poll questions documents and video specs New tests to ensure video URL is shown in the admin preview. Also that the video URL and documents are correctly saved after creating a question. --- spec/features/admin/poll/questions_spec.rb | 3 +++ spec/features/polls/questions_spec.rb | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) 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/polls/questions_spec.rb b/spec/features/polls/questions_spec.rb index 6f2225175..7368c7857 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_link(document.title) + end + context 'Answering' do let(:geozone) { create(:geozone) } let(:poll) { create(:poll, geozone_restricted: true, geozone_ids: [geozone.id]) } From fb5211f25159c60e4eccda9d786b3202f70c35d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Thu, 7 Sep 2017 17:51:55 +0200 Subject: [PATCH 10/21] Fixed test --- spec/features/polls/questions_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/polls/questions_spec.rb b/spec/features/polls/questions_spec.rb index 7368c7857..1563ca81a 100644 --- a/spec/features/polls/questions_spec.rb +++ b/spec/features/polls/questions_spec.rb @@ -41,7 +41,7 @@ feature 'Poll Questions' do visit question_path(normal_question) - expect(page).to have_link(document.title) + expect(page).to have_content(document.title) end context 'Answering' do From 4527236284c7a847779f6646bab0b1d955980684 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 7 Sep 2017 22:38:42 +0200 Subject: [PATCH 11/21] adds searching for officers when creating shifts --- .../admin/poll/shifts_controller.rb | 19 ++++++--- .../poll/officer_assignments/index.html.erb | 6 --- app/views/admin/poll/shifts/_form.html.erb | 29 ++++++++++++++ .../poll/shifts/_search_officers.html.erb | 19 +++++++++ .../shifts/_search_officers_results.html.erb | 36 +++++++++++++++++ app/views/admin/poll/shifts/_shifts.html.erb | 6 +-- app/views/admin/poll/shifts/new.html.erb | 40 ++++--------------- .../admin/poll/shifts/search_officers.js.erb | 1 + config/routes.rb | 4 +- 9 files changed, 111 insertions(+), 49 deletions(-) create mode 100644 app/views/admin/poll/shifts/_form.html.erb create mode 100644 app/views/admin/poll/shifts/_search_officers.html.erb create mode 100644 app/views/admin/poll/shifts/_search_officers_results.html.erb create mode 100644 app/views/admin/poll/shifts/search_officers.js.erb 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/views/admin/poll/officer_assignments/index.html.erb b/app/views/admin/poll/officer_assignments/index.html.erb index f6e75c602..6ffe3f04c 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 %> 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..4311d00fe --- /dev/null +++ b/app/views/admin/poll/shifts/_form.html.erb @@ -0,0 +1,29 @@ +<%= form_for @shift, as: :shift, url: admin_booth_shifts_path do |f| %> + <%= render "shared/errors", resource: @shift %> + +
+ + <%= t("admin.poll_shifts.new.new_shift") %> + + +
+ 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 hollow margin-top" %> +
+
+<% end %> \ No newline at end of file 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..793ac0311 --- /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..edb96eaf4 --- /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 alert" %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/poll/shifts/_shifts.html.erb b/app/views/admin/poll/shifts/_shifts.html.erb index 800c6944b..4c10f9ab5 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 @@ - - + <% @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 6ffe3f04c..f27f6b2ae 100644 --- a/app/views/admin/poll/officer_assignments/index.html.erb +++ b/app/views/admin/poll/officer_assignments/index.html.erb @@ -34,4 +34,4 @@ <%= paginate @officers %> <% end %> - \ No newline at end of file + diff --git a/app/views/admin/poll/shifts/_form.html.erb b/app/views/admin/poll/shifts/_form.html.erb index 4311d00fe..f0461855f 100644 --- a/app/views/admin/poll/shifts/_form.html.erb +++ b/app/views/admin/poll/shifts/_form.html.erb @@ -5,12 +5,13 @@ <%= t("admin.poll_shifts.new.new_shift") %> - -
- Officer: <%= @officer.name %> + +
+ <%= t("admin.poll_shifts.new.officer") %> +
<%= @officer.name %> <%= f.hidden_field :officer_id, value: @officer.id %>
- +
<%= f.select :date, @@ -23,7 +24,7 @@
<%= f.submit t("admin.poll_shifts.new.add_shift"), - class: "button expanded hollow margin-top" %> + class: "button expanded margin-top" %>
-<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/admin/poll/shifts/_search_officers.html.erb b/app/views/admin/poll/shifts/_search_officers.html.erb index 793ac0311..e63d09d41 100644 --- a/app/views/admin/poll/shifts/_search_officers.html.erb +++ b/app/views/admin/poll/shifts/_search_officers.html.erb @@ -1,14 +1,14 @@
- <%= form_tag search_officers_admin_booth_shifts_path, + <%= 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"), + placeholder: t("admin.poll_shifts.new.search_officer_placeholder"), id: "search-officers" %>
- <%= submit_tag t("admin.poll_shifts.new.search_officer_button"), + <%= submit_tag t("admin.poll_shifts.new.search_officer_button"), class: "button" %>
diff --git a/app/views/admin/poll/shifts/_search_officers_results.html.erb b/app/views/admin/poll/shifts/_search_officers_results.html.erb index edb96eaf4..70525ba6d 100644 --- a/app/views/admin/poll/shifts/_search_officers_results.html.erb +++ b/app/views/admin/poll/shifts/_search_officers_results.html.erb @@ -10,7 +10,7 @@
- @@ -24,13 +24,13 @@ - <% end %>
<%= 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..7a01aeaf6 100644 --- a/app/views/admin/poll/shifts/new.html.erb +++ b/app/views/admin/poll/shifts/new.html.erb @@ -2,43 +2,17 @@

<%= @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" %> -
-
-<% end %> +<% 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" %> 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/config/routes.rb b/config/routes.rb index eaf6b98f4..67f816e32 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -287,7 +287,9 @@ Rails.application.routes.draw do end resources :booths do - resources :shifts + resources :shifts do + get :search_officers, on: :collection + end end resources :questions From d3890d1432a7c0966e83f64b37f681bfd1d111f1 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 7 Sep 2017 22:38:54 +0200 Subject: [PATCH 12/21] updates translations --- config/locales/en/admin.yml | 20 +++++++++++++------- config/locales/en/general.yml | 1 + config/locales/es/admin.yml | 20 +++++++++++++------- config/locales/es/general.yml | 1 + 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index c91719104..3c82199a5 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: Please 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" 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/es/admin.yml b/config/locales/es/admin.yml index 58fd31aa1..f657ae54d 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -498,16 +498,22 @@ 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: Por favor 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" destroy: "Eliminado turno de presidente de mesa" 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 From b1abb9dbb3c588b2c6146c01e990ec0a8b2a796b Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 7 Sep 2017 22:39:03 +0200 Subject: [PATCH 13/21] adds specs --- spec/features/admin/poll/shifts_spec.rb | 30 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb index fd9b9f4ca..b55e40c7c 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) From e8f95f4b5b13e5fefae692ffec94388b15c07b25 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 8 Sep 2017 12:39:23 +0200 Subject: [PATCH 14/21] Format link_to consistently --- app/views/proposals/show.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 %> From da3ef02e2fdb7fc63245b21c7504150803c96804 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 8 Sep 2017 12:45:20 +0200 Subject: [PATCH 15/21] Correctly indent admin login erb file --- app/views/shared/_admin_login_items.html.erb | 62 ++++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) 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 %> From 90a5053ca8c2efdbd314b14d54590e2330f0398f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 8 Sep 2017 14:55:08 +0200 Subject: [PATCH 16/21] Correct consul github url on how to use translations --- config/locales/en/pages.yml | 4 ++-- config/locales/es/pages.yml | 6 +++--- config/locales/fr/general.yml | 4 ++-- config/locales/fr/pages.yml | 4 ++-- config/locales/nl/pages.yml | 6 +++--- config/locales/pt-BR/general.yml | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) 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/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) From 3b4e80a34dc0ad9b641d909ffdca893d813858ea Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 8 Sep 2017 16:50:53 +0200 Subject: [PATCH 17/21] improves layout and tables for polls shifts --- app/views/admin/poll/booths/index.html.erb | 3 +-- .../admin/poll/officer_assignments/index.html.erb | 2 +- app/views/admin/poll/shifts/_form.html.erb | 13 +++++++------ .../admin/poll/shifts/_search_officers.html.erb | 6 +++--- .../poll/shifts/_search_officers_results.html.erb | 8 ++++---- app/views/admin/poll/shifts/new.html.erb | 10 ++++++---- config/locales/en/admin.yml | 2 +- config/locales/es/admin.yml | 4 ++-- 8 files changed, 25 insertions(+), 23 deletions(-) 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") %>
    <%= t("admin.poll_shifts.new.table_name") %> <%= t("admin.poll_shifts.new.table_email") %> + <%= t("admin.poll_shifts.new.table_shift") %>
    <%= 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 alert" %> + class: "button hollow" %>
    -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/admin/poll/shifts/new.html.erb b/app/views/admin/poll/shifts/new.html.erb index 7a01aeaf6..b975c40a9 100644 --- a/app/views/admin/poll/shifts/new.html.erb +++ b/app/views/admin/poll/shifts/new.html.erb @@ -3,18 +3,20 @@

    <%= @booth.name %>

    <% if @officer.blank? %> - <%= t("admin.poll_shifts.new.search_officer_text") %> +

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

    <%= render "search_officers" %> <% else %> <%= render "form" %> -<% end %> +<% end %>
    <% if @shifts.empty? %> -
    +
    <%= t("admin.poll_shifts.new.no_shifts") %>
    <% else %> <%= render "shifts" %> <% end %> -
    \ No newline at end of file +
    diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 3c82199a5..3e5cb9d31 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -509,7 +509,7 @@ en: remove_shift: "Remove" search_officer_button: Search search_officer_placeholder: Search officer - search_officer_text: Please search for an officer to assign a new shift + search_officer_text: Search for an officer to assign a new shift select_date: "Select day" table_shift: "Shift" table_email: "Email" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index f657ae54d..1b98adaf2 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -509,13 +509,13 @@ es: remove_shift: "Eliminar turno" search_officer_button: Buscar search_officer_placeholder: Buscar presidentes de mesa - search_officer_text: Por favor busca al presidente de mesa para asignar un turno + search_officer_text: Busca al presidente de mesa para asignar un turno select_date: "Seleccionar día" 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: From 503a375b2f46f8bf4a1e97dc07891fb4c912d00a Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 8 Sep 2017 18:41:46 +0200 Subject: [PATCH 18/21] includes question controller name on polls subnavigation --- app/views/shared/_subnavigation.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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") %>
  • From 45d2fdd201d1027e6d975312a70e87ba86785b45 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 8 Sep 2017 21:59:54 +0200 Subject: [PATCH 19/21] adds available booths --- app/controllers/admin/poll/booths_controller.rb | 5 +++++ app/models/abilities/administrator.rb | 2 +- app/models/poll/booth.rb | 7 ++++++- config/routes.rb | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) 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/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/config/routes.rb b/config/routes.rb index eaf6b98f4..a3f351e60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -287,6 +287,8 @@ Rails.application.routes.draw do end resources :booths do + get :available, on: :collection + resources :shifts end From 0ad24c108070a1410fb614b9437565bec14237d9 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 8 Sep 2017 22:00:45 +0200 Subject: [PATCH 20/21] highlights correct item in admin menu --- app/helpers/admin_helper.rb | 2 +- app/views/admin/_menu.html.erb | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) 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/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 %>
  • From 4d1f61a87ea6bbf9b019aabfe4d70df2d7289be4 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 8 Sep 2017 22:00:50 +0200 Subject: [PATCH 21/21] adds specs --- spec/features/admin/poll/booths_spec.rb | 26 +++++++++++++++++++++++++ spec/models/poll/booth_spec.rb | 21 ++++++++++++++++++++ 2 files changed, 47 insertions(+) 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/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