Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
IvaKop committed Jan 9, 2024
2 parents d7b4ac2 + f565d5d commit 7462453
Show file tree
Hide file tree
Showing 341 changed files with 6,328 additions and 7,477 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ psql:
add-campaign-and-notification:
back/bin/add_campaign_and_notification ${source} ${target}

blint back-lint-autocorrect:
docker compose run web bundle exec rubocop -P --format simple --autocorrect

# =================
# E2E tests
# =================
Expand Down
1 change: 1 addition & 0 deletions back/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ require:
- rubocop-rails
- rubocop-performance
- rubocop-rspec
- ./lib/rubocop/cop/forbidden_app_configuration_method.rb

AllCops:
NewCops: enable
Expand Down
5 changes: 3 additions & 2 deletions back/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ RUN find engines -type f -not -name "*.gemspec" -not -name "version.rb" -print0
FROM ruby:2.7.6-slim
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update \
&& apt-get install -qq -y --no-install-recommends \
RUN apt-get update \
&& apt-get install -qq -y --no-install-recommends \
build-essential \
curl \
lsb-release \
# Required to install git dependencies in Gemfile and by bundle-audit
git \
libgeos-dev \
Expand Down
1 change: 1 addition & 0 deletions back/Dockerfile.development
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ruby:2.7.6-slim

RUN apt-get update && apt-get install -qq -y --no-install-recommends \
lsb-release \
build-essential \
libpq-dev \
file \
Expand Down
13 changes: 2 additions & 11 deletions back/app/controllers/web_api/v1/areas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class WebApi::V1::AreasController < ApplicationController
before_action :set_area, except: %i[index create]
before_action :set_side_effects_service, only: %i[create update reorder destroy]
before_action :set_side_effects_service, only: %i[create update destroy]
skip_before_action :authenticate_user, only: %i[index show]

def index
Expand Down Expand Up @@ -86,16 +86,6 @@ def destroy
end
end

def reorder
@side_fx_service.before_update(@area, current_user)
if @area.insert_at(permitted_attributes(@area)[:ordering])
@side_fx_service.after_update(@area, current_user)
render json: WebApi::V1::AreaSerializer.new(@area.reload, params: jsonapi_serializer_params).serializable_hash, status: :ok
else
render json: { errors: @area.errors.details }, status: :unprocessable_entity
end
end

private

def set_area
Expand All @@ -106,6 +96,7 @@ def set_area
def area_params
params.require(:area).permit(
:include_in_onboarding,
:ordering,
title_multiloc: CL2_SUPPORTED_LOCALES,
description_multiloc: CL2_SUPPORTED_LOCALES
)
Expand Down
1 change: 0 additions & 1 deletion back/app/controllers/web_api/v1/avatars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def index
authorize initiative, :show?
avatars_service.avatars_for_initiative(initiative, users: users, limit: limit)
when nil
users = User.none if !HomePage.first.banner_avatars_enabled && !AppConfiguration.instance.feature_activated?('homepage_builder') # TODO: clean up after migrating homepage craftjs
avatars_service.some_avatars(users: users, limit: limit)
end

Expand Down
58 changes: 0 additions & 58 deletions back/app/controllers/web_api/v1/home_pages_controller.rb

This file was deleted.

4 changes: 2 additions & 2 deletions back/app/controllers/web_api/v1/stats_comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def comments_by_topic_as_xlsx
topics = Topic.where(id: serie.keys).select(:id, :title_multiloc)
res = serie.map do |topic_id, count|
{
'topic' => @@multiloc_service.t(topics.find(topic_id).title_multiloc),
'topic' => @@multiloc_service.t(topics.find(topic_id).title_multiloc, current_user&.locale),
'topic_id' => topic_id,
'comments' => count
}
Expand Down Expand Up @@ -76,7 +76,7 @@ def comments_by_project_as_xlsx
projects = Project.where(id: serie.keys).select(:id, :title_multiloc)
res = serie.map do |project_id, count|
{
'project' => @@multiloc_service.t(projects.find(project_id).title_multiloc),
'project' => @@multiloc_service.t(projects.find(project_id).title_multiloc, current_user&.locale),
'project_id' => project_id,
'comments' => count
}
Expand Down
6 changes: 3 additions & 3 deletions back/app/controllers/web_api/v1/stats_ideas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def ideas_by_topic_as_xlsx
res = []
serie.each do |topic_id, count|
res.push({
'topic' => @@multiloc_service.t(topics.find(topic_id).title_multiloc),
'topic' => @@multiloc_service.t(topics.find(topic_id).title_multiloc, current_user&.locale),
'topic_id' => topic_id,
'ideas' => count
})
Expand Down Expand Up @@ -72,7 +72,7 @@ def ideas_by_project_as_xlsx

res = serie.map do |project_id, count|
{
'project' => @@multiloc_service.t(projects.find(project_id).title_multiloc),
'project' => @@multiloc_service.t(projects.find(project_id).title_multiloc, current_user&.locale),
'project_id' => project_id,
'ideas' => count
}
Expand Down Expand Up @@ -104,7 +104,7 @@ def ideas_by_status_as_xlsx
res = []
ideas_by_status_serie.each do |status_id, count|
res.push({
'status' => @@multiloc_service.t(IdeaStatus.find(status_id).title_multiloc),
'status' => @@multiloc_service.t(IdeaStatus.find(status_id).title_multiloc, current_user&.locale),
'status_id' => status_id,
'ideas' => count
})
Expand Down
4 changes: 2 additions & 2 deletions back/app/controllers/web_api/v1/stats_reactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def reactions_by_topic_as_xlsx
topics = Topic.where(id: serie.keys).select(:id, :title_multiloc)
res = serie.map do |topic_id, count|
{
'topic' => @@multiloc_service.t(topics.find(topic_id).title_multiloc),
'topic' => @@multiloc_service.t(topics.find(topic_id).title_multiloc, current_user&.locale),
'topic_id' => topic_id,
'reactions' => count
}
Expand Down Expand Up @@ -80,7 +80,7 @@ def reactions_by_project_as_xlsx
projects = Project.where(id: serie.keys).select(:id, :title_multiloc)
res = serie.map do |project_id, count|
{
'project' => @@multiloc_service.t(projects.find(project_id).title_multiloc),
'project' => @@multiloc_service.t(projects.find(project_id).title_multiloc, current_user&.locale),
'project_id' => project_id,
'reactions' => count
}
Expand Down
1 change: 0 additions & 1 deletion back/app/models/admin_publication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class AdminPublication < ApplicationRecord
PUBLICATION_STATUSES = %w[draft published archived]

belongs_to :publication, polymorphic: true, touch: true
has_many :pins, inverse_of: :admin_publication, dependent: :destroy

acts_as_nested_set dependent: :destroy, order_column: :ordering, counter_cache: :children_count
acts_as_list column: :ordering, top_of_list: 0, scope: [:parent_id], add_new_at: :top
Expand Down
127 changes: 0 additions & 127 deletions back/app/models/home_page.rb

This file was deleted.

5 changes: 5 additions & 0 deletions back/app/models/idea.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ class Idea < ApplicationRecord
.order("idea_statuses.ordering #{direction}, ideas.id")
}

scope :activity_after, lambda { |time_ago|
left_joins(:comments, :reactions)
.where('ideas.updated_at >= ? OR comments.updated_at >= ? OR reactions.created_at >= ?', time_ago, time_ago, time_ago)
}

scope :feedback_needed, lambda {
joins(:idea_status).where(idea_statuses: { code: 'proposed' })
.where('ideas.id NOT IN (SELECT DISTINCT(post_id) FROM official_feedbacks)')
Expand Down
9 changes: 9 additions & 0 deletions back/app/models/initiative.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ class Initiative < ApplicationRecord
.where(initiative_status_changes: { initiative_status: InitiativeStatus.find_by(code: 'proposed') })
end)

scope :activity_after, lambda { |time_ago|
joins(:initiative_status_changes)
.where(
'initiative_status_changes.initiative_status_id IN (?) AND initiative_status_changes.created_at > ?',
InitiativeStatus.where(code: %w[threshold_reached proposed]).ids,
time_ago
)
}

def self.review_required?
app_config = AppConfiguration.instance
require_review = app_config.settings('initiatives', 'require_review')
Expand Down
2 changes: 2 additions & 0 deletions back/app/models/phase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class Phase < ApplicationRecord
}

def ends_before?(date)
return false if end_at.blank?

end_at.iso8601 < date.to_date.iso8601
end

Expand Down
Loading

0 comments on commit 7462453

Please sign in to comment.