diff --git a/app/assets/stylesheets/admin/poll/questions/filter.scss b/app/assets/stylesheets/admin/poll/questions/filter.scss deleted file mode 100644 index 498872d2b..000000000 --- a/app/assets/stylesheets/admin/poll/questions/filter.scss +++ /dev/null @@ -1,11 +0,0 @@ -.admin .poll-questions-filter { - $gap: 0.5em; - @include flex-with-gap($gap); - align-items: flex-end; - flex-wrap: wrap; - - [type="submit"] { - @include regular-button; - margin-left: $gap; - } -} diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index c9f4cc37d..8700b6ef0 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -512,28 +512,6 @@ } } - .icon-debates, - .icon-proposals, - .icon-budget { - font-size: rem-calc(18); - line-height: $line-height; - margin-left: rem-calc(6); - top: 0; - } - - .icon-debates { - color: $debates; - } - - .icon-proposals { - color: $proposals-dark; - } - - .icon-budget { - color: $budget; - font-size: $small-font-size; - } - .debate-info, .proposal-info, .investment-project-info, diff --git a/app/components/admin/poll/questions/filter_component.html.erb b/app/components/admin/poll/questions/filter_component.html.erb deleted file mode 100644 index ee1f443ff..000000000 --- a/app/components/admin/poll/questions/filter_component.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<%= form_tag "", method: :get, class: "poll-questions-filter" do %> -
- <%= label_tag :poll_id, t("admin.questions.index.filter_poll") %> - <%= select_tag "poll_id", poll_select_options, prompt: t("polls.all") %> -
- <%= submit_tag t("shared.filter") %> -<% end %> diff --git a/app/components/admin/poll/questions/filter_component.rb b/app/components/admin/poll/questions/filter_component.rb deleted file mode 100644 index 8b396bd9b..000000000 --- a/app/components/admin/poll/questions/filter_component.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Admin::Poll::Questions::FilterComponent < ApplicationComponent - attr_reader :polls - use_helpers :current_path_with_query_params - - def initialize(polls) - @polls = polls - end - - private - - def poll_select_options - options_from_collection_for_select(polls, :id, :name, params[:poll_id]) - end -end diff --git a/app/components/admin/proposals/index_component.html.erb b/app/components/admin/proposals/index_component.html.erb new file mode 100644 index 000000000..74ef9c4f1 --- /dev/null +++ b/app/components/admin/proposals/index_component.html.erb @@ -0,0 +1,41 @@ +<% provide :main_class, "admin-proposals-index" %> + +<%= header do %> + <%= successful_proposals_link %> +<% end %> + +<% if proposals.any? %> + <%= render Admin::SearchComponent.new(label: t("admin.shared.search.label.proposals")) %> + +

<%= page_entries_info proposals %>

+ + + + + + + + + + + + + + <% proposals.each do |proposal| %> + + + + + + + + <% end %> + +
<%= t("admin.proposals.index.id") %><%= Proposal.human_attribute_name(:title) %><%= t("admin.proposals.index.author") %><%= t("admin.proposals.index.milestones") %><%= t("admin.proposals.index.selected") %>
<%= proposal.id %><%= link_to proposal.title, admin_proposal_path(proposal) %><%= proposal.author.username %><%= proposal.milestones.count %><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %>
+ + <%= paginate proposals %> +<% else %> +
+ <%= t("admin.proposals.index.no_proposals") %> +
+<% end %> diff --git a/app/components/admin/proposals/index_component.rb b/app/components/admin/proposals/index_component.rb new file mode 100644 index 000000000..1ca5ef298 --- /dev/null +++ b/app/components/admin/proposals/index_component.rb @@ -0,0 +1,20 @@ +class Admin::Proposals::IndexComponent < ApplicationComponent + include Header + attr_reader :proposals + + def initialize(proposals) + @proposals = proposals + end + + def title + t("admin.proposals.index.title") + end + + private + + def successful_proposals_link + if Proposal.successful.any? + link_to t("admin.questions.index.successful_proposals_tab"), successful_admin_proposals_path + end + end +end diff --git a/app/views/admin/poll/questions/_successful_proposals.html.erb b/app/components/admin/proposals/successful_component.html.erb similarity index 84% rename from app/views/admin/poll/questions/_successful_proposals.html.erb rename to app/components/admin/proposals/successful_component.html.erb index 669d76c94..2a3680acc 100644 --- a/app/views/admin/poll/questions/_successful_proposals.html.erb +++ b/app/components/admin/proposals/successful_component.html.erb @@ -1,3 +1,9 @@ +<% provide :main_class, "admin-proposals-successful" %> + +<%= back_link_to admin_proposals_path %> + +<%= header %> + @@ -6,7 +12,7 @@ - <% @proposals.each do |proposal| %> + <% proposals.each do |proposal| %>
<%= proposal.title %> diff --git a/app/components/admin/proposals/successful_component.rb b/app/components/admin/proposals/successful_component.rb new file mode 100644 index 000000000..553485665 --- /dev/null +++ b/app/components/admin/proposals/successful_component.rb @@ -0,0 +1,12 @@ +class Admin::Proposals::SuccessfulComponent < ApplicationComponent + include Header + attr_reader :proposals + + def initialize(proposals) + @proposals = proposals + end + + def title + t("admin.questions.index.successful_proposals_tab") + end +end diff --git a/app/controllers/admin/api/base_controller.rb b/app/controllers/admin/api/base_controller.rb deleted file mode 100644 index 8e8cd4138..000000000 --- a/app/controllers/admin/api/base_controller.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Admin::Api::BaseController < Admin::BaseController - protect_from_forgery with: :null_session -end diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index 3981f652b..19b659158 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -4,14 +4,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController load_and_authorize_resource :poll load_resource class: "Poll::Question" - authorize_resource except: [:new, :index] - - def index - @polls = Poll.not_budget - @questions = @questions.search(search_params).page(params[:page]).order("created_at DESC") - - @proposals = Proposal.successful.sort_by_confidence_score - end + authorize_resource except: :new def new proposal = Proposal.find(params[:proposal_id]) if params[:proposal_id].present? @@ -61,8 +54,4 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController attributes = [:poll_id, :question, :proposal_id, votation_type_attributes: [:vote_type, :max_votes]] [*attributes, translation_params(Poll::Question)] end - - def search_params - params.permit(:poll_id, :search) - end end diff --git a/app/controllers/admin/proposals_controller.rb b/app/controllers/admin/proposals_controller.rb index 5e9e52b49..a0c2770d1 100644 --- a/app/controllers/admin/proposals_controller.rb +++ b/app/controllers/admin/proposals_controller.rb @@ -6,7 +6,11 @@ class Admin::ProposalsController < Admin::BaseController has_orders %w[created_at] - before_action :load_proposal, except: :index + before_action :load_proposal, except: [:index, :successful] + + def successful + @proposals = Proposal.successful.sort_by_confidence_score + end def show end diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index b170b32a2..49bf4f8de 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -6,9 +6,7 @@ class Users::RegistrationsController < Devise::RegistrationsController invisible_captcha only: [:create], honeypot: :address, scope: :user def new - super do |user| - user.use_redeemable_code = true if params[:use_redeemable_code].present? - end + super end def create @@ -64,18 +62,13 @@ class Users::RegistrationsController < Devise::RegistrationsController private def sign_up_params - if params[:user].present? && params[:user][:redeemable_code].blank? - params[:user].delete(:redeemable_code) - end - params.require(:user).permit(allowed_params) end def allowed_params [ :username, :email, :password, - :password_confirmation, :terms_of_service, :locale, - :redeemable_code + :password_confirmation, :terms_of_service, :locale ] end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 82f93bb3c..85ee522da 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -18,17 +18,15 @@ module WelcomeHelper end end - def render_recommendation_image(recommended, image_default) - image_path = calculate_image_path(recommended, image_default) + def render_recommendation_image(recommended) + image_path = calculate_image_path(recommended) image_tag(image_path) if image_path.present? end - def calculate_image_path(recommended, image_default) + def calculate_image_path(recommended) if recommended.respond_to?(:image) && recommended.image.present? && recommended.image.attachment.attached? recommended.image.variant(:medium) - elsif image_default.present? - image_default end end diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index c55320560..f1015bba7 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -1,6 +1,5 @@ class Poll::Question < ApplicationRecord include Measurable - include Searchable acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases @@ -30,25 +29,9 @@ class Poll::Question < ApplicationRecord delegate :multiple?, :vote_type, to: :votation_type, allow_nil: true - scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) } - scope :sort_for_list, -> { order(Arel.sql("poll_questions.proposal_id IS NULL"), :created_at) } scope :for_render, -> { includes(:author, :proposal) } - def self.search(params) - results = all - results = results.by_poll_id(params[:poll_id]) if params[:poll_id].present? - results = results.pg_search(params[:search]) if params[:search].present? - results - end - - def searchable_values - { title => "A", - proposal&.title => "A", - author.username => "C", - author_visible_name => "C" } - end - def copy_attributes_from_proposal(proposal) if proposal.present? self.author = proposal.author diff --git a/app/models/user.rb b/app/models/user.rb index 8ba6d0f4c..4f71af75a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -89,7 +89,7 @@ class User < ApplicationRecord accepts_nested_attributes_for :organization, update_only: true - attr_accessor :skip_password_validation, :use_redeemable_code, :login + attr_accessor :skip_password_validation, :login scope :administrators, -> { joins(:administrator) } scope :moderators, -> { joins(:moderator) } diff --git a/app/views/admin/poll/questions/_filter_subnav.html.erb b/app/views/admin/poll/questions/_filter_subnav.html.erb deleted file mode 100644 index 7f641d390..000000000 --- a/app/views/admin/poll/questions/_filter_subnav.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -
    -
  • - <%= link_to "#tab-questions" do %> - <%= t("admin.questions.index.questions_tab") %> - <% end %> -
  • -
  • - <%= link_to "#tab-successful-proposals" do %> - <%= t("admin.questions.index.successful_proposals_tab") %> - <% end %> -
  • -
diff --git a/app/views/admin/poll/questions/_questions.html.erb b/app/views/admin/poll/questions/_questions.html.erb deleted file mode 100644 index e764107de..000000000 --- a/app/views/admin/poll/questions/_questions.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -<%= render Admin::Poll::Questions::FilterComponent.new(@polls) %> - -<% if @questions.count == 0 %> -
- <%= t("admin.questions.index.no_questions") %> -
-<% else %> - - - - - - - - - - <% @questions.each do |question| %> - - - - - - <% end %> - -
<%= t("admin.questions.index.table_question") %><%= t("admin.questions.index.table_poll") %><%= t("admin.actions.actions") %>
<%= question.title %> - <% if question.poll.present? %> - <%= question.poll.name %> - <% else %> - <%= t("admin.questions.index.poll_not_assigned") %> - <% end %> - - <%= render Admin::TableActionsComponent.new(question) do |actions| %> - <%= actions.action(:options, text: t("admin.polls.show.edit_answers")) %> - <% end %> -
- - <%= paginate @questions %> -<% end %> diff --git a/app/views/admin/poll/questions/index.html.erb b/app/views/admin/poll/questions/index.html.erb deleted file mode 100644 index 6f704e489..000000000 --- a/app/views/admin/poll/questions/index.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -

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

- -<%= link_to t("admin.questions.index.create"), new_admin_question_path, - class: "button float-right" %> - -<%= render "search" %> - -
- <%= render "filter_subnav" %> - -
- <%= render "questions" %> -
- -
- <%= render "successful_proposals" %> -
-
diff --git a/app/views/admin/poll/questions/show.html.erb b/app/views/admin/poll/questions/show.html.erb index 1cb73202a..35b09b9f9 100644 --- a/app/views/admin/poll/questions/show.html.erb +++ b/app/views/admin/poll/questions/show.html.erb @@ -100,11 +100,3 @@ <% end %>
- -<% if @question.video_url.present? %> -

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

-<% end %> diff --git a/app/views/admin/proposals/index.html.erb b/app/views/admin/proposals/index.html.erb index 27964da5b..06d6de765 100644 --- a/app/views/admin/proposals/index.html.erb +++ b/app/views/admin/proposals/index.html.erb @@ -1,41 +1 @@ -<% provide(:title) do %> - <%= t("admin.header.title") %> - <%= t("admin.proposals.index.title") %> -<% end %> - -

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

- -<% if @proposals.any? %> - <%= render Admin::SearchComponent.new(label: t("admin.shared.search.label.proposals")) %> - -

<%= page_entries_info @proposals %>

- - - - - - - - - - - - - - <% @proposals.each do |proposal| %> - - - - - - - - <% end %> - -
<%= t("admin.proposals.index.id") %><%= Proposal.human_attribute_name(:title) %><%= t("admin.proposals.index.author") %><%= t("admin.proposals.index.milestones") %><%= t("admin.proposals.index.selected") %>
<%= proposal.id %><%= link_to proposal.title, admin_proposal_path(proposal) %><%= proposal.author.username %><%= proposal.milestones.count %><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %>
- - <%= paginate @proposals %> -<% else %> -
- <%= t("admin.proposals.index.no_proposals") %> -
-<% end %> +<%= render Admin::Proposals::IndexComponent.new(@proposals) %> diff --git a/app/views/admin/proposals/successful.html.erb b/app/views/admin/proposals/successful.html.erb new file mode 100644 index 000000000..d3c3c9c62 --- /dev/null +++ b/app/views/admin/proposals/successful.html.erb @@ -0,0 +1 @@ +<%= render Admin::Proposals::SuccessfulComponent.new(@proposals) %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b0daa354b..4028a7d85 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -18,7 +18,7 @@ <%= raw setting["html.per_page_code_body"] %>
- <%= render "layouts/header", with_subnavigation: true %> + <%= render "layouts/header" %>
<%= render "layouts/flash" %> diff --git a/app/views/layouts/dashboard.html.erb b/app/views/layouts/dashboard.html.erb index ef35fbfcb..a5dda956e 100644 --- a/app/views/layouts/dashboard.html.erb +++ b/app/views/layouts/dashboard.html.erb @@ -18,7 +18,7 @@

<%= setting["org_name"] %>

- <%= render "layouts/header", with_subnavigation: false %> + <%= render "layouts/header" %>