diff --git a/app/assets/stylesheets/_consul_settings.scss b/app/assets/stylesheets/_consul_settings.scss index 0844f861f..1f03c9be7 100644 --- a/app/assets/stylesheets/_consul_settings.scss +++ b/app/assets/stylesheets/_consul_settings.scss @@ -75,3 +75,5 @@ $accordion-content-color: foreground($accordion-background, $text); $tab-item-font-size: $base-font-size; $tab-item-padding: $line-height / 2 0; $tab-content-border: $border; + +$orbit-bullet-diameter: 0.8rem; diff --git a/app/assets/stylesheets/_settings.scss b/app/assets/stylesheets/_settings.scss index a38071a05..33800fed5 100644 --- a/app/assets/stylesheets/_settings.scss +++ b/app/assets/stylesheets/_settings.scss @@ -411,7 +411,7 @@ $maincontent-shadow: 0 0 10px rgba($black, 0.5); $orbit-bullet-background: $medium-gray; $orbit-bullet-background-active: $dark-gray; -$orbit-bullet-diameter: 0.8rem; +$orbit-bullet-diameter: 1.2rem; $orbit-bullet-margin: 0.1rem; $orbit-bullet-margin-top: 0.8rem; $orbit-bullet-margin-bottom: 0.8rem; diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 44b450779..b9f79430e 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -343,11 +343,9 @@ a { } .truncate-horizontal-text { - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - -o-text-overflow: ellipsis; - -ms-text-overflow: ellipsis; + white-space: nowrap; } .align-top { @@ -633,7 +631,7 @@ header { text-align: left; @include breakpoint(medium) { - margin-right: rem-calc(24); + margin-right: $line-height; } &:hover { @@ -2183,9 +2181,10 @@ table { } // 19. Recommended Section Home -// ----------- +// ---------------------------- .home-page { + .push { display: none; } @@ -2219,7 +2218,7 @@ table { .card-section { padding: $line-height 0; - max-width: 300px; + max-width: rem-calc(300); margin: 0 auto; p { @@ -2229,10 +2228,10 @@ table { } .orbit { - height: 300px; + height: rem-calc(300); .orbit-wrapper { - max-height: 250px; + max-height: rem-calc(250); overflow: hidden; position: relative; } @@ -2248,7 +2247,7 @@ table { background: image-url('truncate.png'); background-repeat: repeat-x; bottom: 0; - height: 20px; + height: rem-calc(20); position: absolute; width: 100%; } @@ -2269,21 +2268,21 @@ table { .proposals-inner, .budget-investments-inner { background: #fff; - max-height: 350px; + max-height: rem-calc(350); @include breakpoint(small) { - max-height: 400px; + max-height: rem-calc(400); } h4 { margin-top: $line-height; margin-bottom: 0; font-size: rem-calc(18); - min-height: 50px; + min-height: rem-calc(50); } h5 { - font-size: rem-calc(14); + font-size: $small-font-size; text-align: left; } } @@ -2291,20 +2290,20 @@ table { .carousel-image { .card .orbit { - height: 480px; + height: rem-calc(480); .orbit-wrapper { - max-height: 450px; + max-height: rem-calc(450); } } .debates-inner, .proposals-inner, .budget-investments-inner { - max-height: 500px; + max-height: rem-calc(500); @include breakpoint(small) { - max-height: 600px; + max-height: rem-calc(600); } } } @@ -2318,7 +2317,9 @@ table { } } -// 19. Documents +// 20. Documents +// ------------- + .documents-list { table { diff --git a/app/assets/stylesheets/mixins.scss b/app/assets/stylesheets/mixins.scss index 1aa51d1a6..ac3c0a923 100644 --- a/app/assets/stylesheets/mixins.scss +++ b/app/assets/stylesheets/mixins.scss @@ -2,7 +2,8 @@ // // 01. Logo // 02. Orbit bullets -// +// 03. Direct uploads +// ------------------ // 01. Logo // -------- @@ -34,6 +35,7 @@ // 02. Orbit bullet // ---------------- + @mixin orbit-bullets { @include disable-mouse-outline; position: relative; @@ -59,8 +61,9 @@ } } -// 02. Direct uploads +// 03. Direct uploads // ------------------ + @mixin direct-uploads { .cached-image { @@ -133,5 +136,4 @@ .loading-bar.no-transition { transition: none; } - } diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index b1edc246d..8877eb02e 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -310,6 +310,10 @@ .budget-investment-new, .proposal-form, .proposal-edit, +.new_poll_question, +.edit_poll_question, +.new_poll, +.edit_poll, .poll-question-form { @include direct-uploads; } @@ -668,16 +672,15 @@ padding-top: 100%; } } - - .column:first-child { - text-align: center; - } } @include breakpoint(medium) { .panel { - padding: 0 $line-height / 2 0 0; + + &.with-image { + padding: 0 $line-height / 2 0 0; + } .no-image { height: 100%; @@ -825,7 +828,7 @@ background: image-url('truncate.png'); background-repeat: repeat-x; bottom: 0; - height: 24px; + height: rem-calc(24); position: absolute; width: 100%; } diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index c95c8ed1f..cce880ed4 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -1,7 +1,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController load_and_authorize_resource - before_action :load_search, only: [:search_booths, :search_questions, :search_officers] + before_action :load_search, only: [:search_booths, :search_officers] before_action :load_geozones, only: [:new, :create, :edit, :update] def index @@ -47,25 +47,6 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController redirect_to admin_poll_path(@poll), notice: notice end - def remove_question - question = ::Poll::Question.find(params[:question_id]) - - if @poll.questions.include? question - @poll.questions.delete(question) - notice = t("admin.polls.flash.question_removed") - else - notice = t("admin.polls.flash.error_on_question_removed") - end - redirect_to admin_poll_path(@poll), notice: notice - end - - def search_questions - @questions = ::Poll::Question.where("poll_id IS ? OR poll_id != ?", nil, @poll.id).search(search: @search).order(title: :asc) - respond_to do |format| - format.js - end - end - private def load_geozones @@ -73,7 +54,9 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController end def poll_params - params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, geozone_ids: []) + params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, :summary, :description, + geozone_ids: [], + image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]) end def search_params diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index 97b301d43..107c06740 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -56,7 +56,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController private def question_params - params.require(:poll_question).permit(:poll_id, :title, :question, :description, :proposal_id, :valid_answers, :video_url, + params.require(:poll_question).permit(:poll_id, :title, :question, :proposal_id, :valid_answers, :video_url, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]) end diff --git a/app/controllers/officing/polls_controller.rb b/app/controllers/officing/polls_controller.rb index 5ba94e024..69b65ad23 100644 --- a/app/controllers/officing/polls_controller.rb +++ b/app/controllers/officing/polls_controller.rb @@ -7,7 +7,9 @@ class Officing::PollsController < Officing::BaseController def final @polls = if current_user.poll_officer? - current_user.poll_officer.final_days_assigned_polls.select {|poll| poll.ends_at > 2.weeks.ago && poll.expired?} + current_user.poll_officer.final_days_assigned_polls.select do |poll| + poll.ends_at > 2.weeks.ago && poll.expired? || poll.ends_at.today? + end else [] end diff --git a/app/controllers/officing/results_controller.rb b/app/controllers/officing/results_controller.rb index f517f081a..23ef0b038 100644 --- a/app/controllers/officing/results_controller.rb +++ b/app/controllers/officing/results_controller.rb @@ -93,7 +93,7 @@ class Officing::ResultsController < Officing::BaseController end def load_poll - @poll = ::Poll.expired.includes(:questions).find(params[:poll_id]) + @poll = ::Poll.includes(:questions).find(params[:poll_id]) end def load_officer_assignment diff --git a/app/controllers/officing/voters_controller.rb b/app/controllers/officing/voters_controller.rb index a5343f83d..2c3867416 100644 --- a/app/controllers/officing/voters_controller.rb +++ b/app/controllers/officing/voters_controller.rb @@ -13,7 +13,8 @@ class Officing::VotersController < Officing::BaseController document_number: @user.document_number, user: @user, poll: @poll, - origin: "booth") + origin: "booth", + officer: current_user.poll_officer) @voter.save! end diff --git a/app/controllers/polls/questions_controller.rb b/app/controllers/polls/questions_controller.rb index 1849dff97..74266a6fc 100644 --- a/app/controllers/polls/questions_controller.rb +++ b/app/controllers/polls/questions_controller.rb @@ -5,15 +5,6 @@ class Polls::QuestionsController < ApplicationController has_orders %w{most_voted newest oldest}, only: :show - def show - @commentable = @question.proposal.present? ? @question.proposal : @question - @comment_tree = CommentTree.new(@commentable, params[:page], @current_order) - set_comment_flags(@comment_tree.comments) - - question_answer = @question.answers.where(author_id: current_user.try(:id)).first - @answers_by_question_id = {@question.id => question_answer.try(:answer)} - end - def answer answer = @question.answers.find_or_initialize_by(author: current_user) diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 793f2cbd8..1bc8d5e0c 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -56,7 +56,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, :add_question, :search_booths, :search_officers], Poll can [:read, :create, :update, :destroy, :available], Poll::Booth can [:search, :create, :index, :destroy], ::Poll::Officer can [:create, :destroy], ::Poll::BoothAssignment diff --git a/app/models/poll.rb b/app/models/poll.rb index 624cfc704..84349bf0b 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -1,4 +1,6 @@ class Poll < ActiveRecord::Base + include Imageable + has_many :booth_assignments, class_name: "Poll::BoothAssignment" has_many :booths, through: :booth_assignments has_many :partial_results, through: :booth_assignments diff --git a/app/models/poll/officer_assignment.rb b/app/models/poll/officer_assignment.rb index 9fcf02890..417e6a150 100644 --- a/app/models/poll/officer_assignment.rb +++ b/app/models/poll/officer_assignment.rb @@ -8,7 +8,7 @@ class Poll validates :officer_id, presence: true validates :booth_assignment_id, presence: true - validates :date, presence: true, uniqueness: { scope: [:officer_id, :booth_assignment_id] } + validates :date, presence: true delegate :poll_id, :booth_id, to: :booth_assignment diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index d576ac95a..5d370509b 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -24,7 +24,6 @@ class Poll::Question < ActiveRecord::Base validates :poll_id, presence: true validates :title, length: { minimum: 4 } - validates :description, length: { maximum: Poll::Question.description_max_length } scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) } @@ -41,15 +40,10 @@ class Poll::Question < ActiveRecord::Base def searchable_values { title => 'A', proposal.try(:title) => 'A', - description => 'B', author.username => 'C', author_visible_name => 'C' } end - def description - super.try :html_safe - end - def valid_answers (super.try(:split, ',').compact || []).map(&:strip) end @@ -60,7 +54,6 @@ class Poll::Question < ActiveRecord::Base self.author_visible_name = proposal.author.name self.proposal_id = proposal.id self.title = proposal.title - self.description = proposal.description self.valid_answers = I18n.t('poll_questions.default_valid_answers') end end diff --git a/app/models/poll/shift.rb b/app/models/poll/shift.rb index d64bce9ac..4edeb26ef 100644 --- a/app/models/poll/shift.rb +++ b/app/models/poll/shift.rb @@ -5,28 +5,37 @@ class Poll validates :booth_id, presence: true validates :officer_id, presence: true - validates :date, presence: true - validates :date, uniqueness: { scope: [:officer_id, :booth_id] } + validates :date, presence: true, uniqueness: { scope: [:officer_id, :booth_id, :task] } validates :task, presence: true enum task: { vote_collection: 0, recount_scrutiny: 1 } before_create :persist_data after_create :create_officer_assignments - - def create_officer_assignments - booth.booth_assignments.each do |booth_assignment| - attrs = { officer_id: officer_id, - date: date, - booth_assignment_id: booth_assignment.id } - Poll::OfficerAssignment.create!(attrs) - end - end + before_destroy :destroy_officer_assignments def persist_data self.officer_name = officer.name self.officer_email = officer.email end + def create_officer_assignments + booth.booth_assignments.each do |booth_assignment| + attrs = { + officer_id: officer_id, + date: date, + booth_assignment_id: booth_assignment.id, + final: recount_scrutiny? + } + Poll::OfficerAssignment.create!(attrs) + end + end + + def destroy_officer_assignments + Poll::OfficerAssignment.where(booth_assignment: booth.booth_assignments, + officer: officer, + date: date, + final: recount_scrutiny?).destroy_all + end end end diff --git a/app/models/poll/voter.rb b/app/models/poll/voter.rb index abcae7d25..bc0118a88 100644 --- a/app/models/poll/voter.rb +++ b/app/models/poll/voter.rb @@ -8,6 +8,7 @@ class Poll belongs_to :geozone belongs_to :booth_assignment belongs_to :officer_assignment + belongs_to :officer validates :poll_id, presence: true validates :user_id, presence: true diff --git a/app/views/admin/poll/booth_assignments/show.html.erb b/app/views/admin/poll/booth_assignments/show.html.erb index f01270bd4..fd303d099 100644 --- a/app/views/admin/poll/booth_assignments/show.html.erb +++ b/app/views/admin/poll/booth_assignments/show.html.erb @@ -14,15 +14,15 @@
| - <%= link_to t("admin.booths.booth.shifts"), - new_admin_booth_shift_path(booth), - class: "button hollow" %> - <%= link_to t("admin.actions.edit"), - edit_admin_booth_path(booth), - class: "button hollow" %> + <% if controller_name == "shifts" || controller_name == "booths" && action_name == "available" %> + <%= link_to t("admin.booths.booth.shifts"), + new_admin_booth_shift_path(booth), + class: "button hollow" %> + <%= link_to t("admin.actions.edit"), + edit_admin_booth_path(booth), + class: "button hollow" %> + <% end %> | - \ No newline at end of file + diff --git a/app/views/admin/poll/booths/index.html.erb b/app/views/admin/poll/booths/index.html.erb index 05044dd0e..95b248b3f 100644 --- a/app/views/admin/poll/booths/index.html.erb +++ b/app/views/admin/poll/booths/index.html.erb @@ -1,7 +1,8 @@||
| <%= t("admin.poll_officer_assignments.index.table_name") %> | <%= t("admin.poll_officer_assignments.index.table_email") %> | -<%= t("admin.polls.show.table_assignment") %> |
|---|---|---|
| - <%= user.name %> + + <%= link_to user.name, by_officer_admin_poll_officer_assignments_path(@poll, officer_id: user.id) %> + | <%= user.email %> | -- <% if @poll.officer_ids.include?(user.poll_officer.id) %> - <%= link_to t("admin.poll_officer_assignments.index.edit_officer_assignments"), - by_officer_admin_poll_officer_assignments_path(@poll, officer_id: user.poll_officer.id), - class: "button hollow alert" %> - <% else %> - <%= link_to t("admin.poll_officer_assignments.index.add_officer_assignments"), - by_officer_admin_poll_officer_assignments_path(@poll, officer_id: user.poll_officer.id), - class: "button hollow" %> - <% end %> - |
| <%= t("admin.poll_officer_assignments.by_officer.date") %> | -<%= t("admin.poll_officer_assignments.by_officer.booth") %> | -<%= t("admin.poll_officer_assignments.by_officer.total_recount") %> | -
|---|---|---|
| <%= l(officer_assignment.date.to_date) %> | -<%= booth_name_with_location(officer_assignment.booth_assignment.booth) %> | -- <% if officer_assignment.recounts.any? %> - <%= officer_assignment.recounts.to_a.sum(&:total_amount) %> - <% else %> - - - <% end %> - | -
| <%= t("admin.polls.show.table_name") %> | -<%= t("admin.polls.show.table_assignment") %> | -
|---|---|
| - <%= question.title %> - | -- <%= link_to t("admin.polls.show.add_question"), - add_question_admin_poll_path(poll_id: @poll.id, question_id: question.id), - method: :patch, - class: "button hollow" %> - | -
- <%= t("admin.questions.show.description") %>
-
- <%= @question.description %>
-
<%= t("admin.questions.show.video_url") %> @@ -64,7 +58,5 @@ <%= @question.documents.first.title %>
<% end %> - - <%= link_to t("admin.questions.show.preview"), question_path(@question) %>- - <%= t('proposals.show.title_video_url') %> -
- <%= text_with_links @question.video_url %> -
- <%= t("shared.comments.title") %> - (<%= @commentable.comments_count %>) -
- - <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> - - <% if user_signed_in? %> - <%= render 'comments/form', {commentable: @commentable, parent_id: nil, toggeable: false} %> - <% else %> -- -