Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/CitizenLabDotCo/citizenlab
Browse files Browse the repository at this point in the history
…into TAN-3233/sticky-nav-positioning-with-context
  • Loading branch information
brentguf committed Dec 12, 2024
2 parents bb97eab + a283096 commit 0c775f2
Show file tree
Hide file tree
Showing 144 changed files with 1,473 additions and 604 deletions.
4 changes: 1 addition & 3 deletions back/app/policies/project_folders/folder_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ def published_folders
def show?
return true if user && UserRoleService.new.can_moderate?(record, user)
return false if record.admin_publication.publication_status == 'draft'
return true if record.projects.empty?

# We check if the user has access to at least one of the projects in the folder
scope_for(record.projects).exists?
true
end

def by_slug?
Expand Down
15 changes: 0 additions & 15 deletions back/app/services/admin_publications_filtering_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ def for_homepage_filter(scope)
scope.where(publication_type: Project.name)
end

# This filter removes AdminPublications that represent folders,
# which contain *only* projects which should not be visible to the current user.
add_filter('remove_not_allowed_parents') do |scope, options|
next scope unless ['true', true, '1'].include? options[:remove_not_allowed_parents]

# We remove parents that have only draft projects
parents_with_visible_children = scope.where(id: scope.not_draft.filter_map(&:parent_id).uniq)
parents_without_any_children = scope.where(children_allowed: true, children_count: 0)
non_parents = scope.where(children_allowed: false)

parents_with_visible_children
.or(parents_without_any_children)
.or(non_parents)
end

add_filter('by_publication_status') do |scope, options|
publication_status = options[:publication_statuses]

Expand Down
15 changes: 6 additions & 9 deletions back/app/services/anonymize_user_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,14 @@ def random_email(first_name, last_name)
"#{email.split('@').first}_#{SecureRandom.uuid[...6]}@anonymized.com"
end

def random_avatar_assignment(_first_name, _last_name, gender)
def random_avatar_assignment(first_name, last_name, gender)
gender = mismatch_gender(gender) if rand(30) == 0

# Some initials avatars, like do_avatar.png are currently broken.
# We are no longer using the initials avatars as a temporary fix.
# if rand(5) == 0
# { 'remote_avatar_url' => random_face_avatar_url(gender) }
# else
# { 'remote_avatar_url' => "#{@initials_avatars_url}#{(first_name[0] + last_name[0]).downcase}_avatar.png" }
# end
{ 'remote_avatar_url' => random_face_avatar_url(gender) }
if rand(5) == 0
{ 'remote_avatar_url' => random_face_avatar_url(gender) }
else
{ 'remote_avatar_url' => "#{@initials_avatars_url}#{(first_name[0] + last_name[0]).downcase}_avatar.png" }
end
rescue StandardError => e
ErrorReporter.report e
{}
Expand Down
2 changes: 1 addition & 1 deletion back/app/services/participants_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,6 @@ def destroy_participation_data(project)
# (Ideas in voting phases are considered part of the project setup.)
voting_phases = project.phases.where(participation_method: 'voting')
ideas_in_voting_phases = IdeasPhase.where(phase: voting_phases).select(:idea_id)
Idea.where.not(id: ideas_in_voting_phases).destroy_all
Idea.where(project: project).where.not(id: ideas_in_voting_phases).destroy_all
end
end
12 changes: 0 additions & 12 deletions back/config/schemas/settings.schema.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -1397,18 +1397,6 @@
}
},

"new_homepage_widgets": {
"type": "object",
"title": "New homepage widgets",
"description": "New homepage widgets (sticky homepages tandem). Feature flagged until pricing plan stuff decided.",
"additionalProperties": false,
"required": ["allowed", "enabled"],
"properties": {
"allowed": { "type": "boolean", "default": false },
"enabled": { "type": "boolean", "default": false }
}
},

"project_review": {
"type": "object",
"title": "Project review",
Expand Down
108 changes: 108 additions & 0 deletions back/config/tenant_templates/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,114 @@ models:
content_builder/layout:
- code: homepage
enabled: true
craftjs_json:
ROOT:
type: 'div'
isCanvas: true
props:
id: 'e2e-content-builder-frame'
displayName: 'div'
custom: {}
hidden: false
nodes: ['HOMEPAGEBANNER', 'FOLLOWED_ITEMS', 'OPEN_TO_PARTICIPATION', 'FINISHED_OR_ARCHIVED']
linked_nodes: {}
HOMEPAGEBANNER:
type:
resolvedName: 'HomepageBanner'
isCanvas: false
props:
homepageSettings:
banner_layout: 'full_width_banner_layout'
banner_avatars_enabled: true
banner_cta_signed_in_url: ''
banner_cta_signed_in_type: 'no_button'
banner_cta_signed_out_url: ''
banner_cta_signed_out_type: 'sign_up_button'
banner_signed_in_header_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_signed_out_header_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_cta_signed_in_text_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_cta_signed_out_text_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_signed_out_subheader_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_signed_in_header_overlay_color: '#0A5159'
banner_signed_out_header_overlay_color: '#0A5159'
banner_signed_in_header_overlay_opacity: 90
banner_signed_out_header_overlay_opacity: 90
image:
imageUrl: 'https://cl2-seed-and-template-assets.s3.eu-central-1.amazonaws.com/images/header.jpg'
errors: []
hasError: false
displayName: 'HomepageBanner'
custom:
title:
id: 'app.containers.admin.ContentBuilder.homepage.homepageBanner'
defaultMessage: 'Homepage banner'
noPointerEvents: true
noDelete: true
parent: 'ROOT'
hidden: false
nodes: []
linkedNodes: {}
FOLLOWED_ITEMS:
type:
resolvedName: 'FollowedItems'
nodes: []
props:
titleMultiloc:
en: 'For you'
nl-BE: 'Voor jou'
fr-BE: 'Pour vous'
custom: {}
hidden: false
parent: 'ROOT'
isCanvas: false
displayName: 'FollowedItems'
linkedNodes: {}
OPEN_TO_PARTICIPATION:
type:
resolvedName: 'OpenToParticipation'
nodes: []
props:
titleMultiloc:
en: 'Open to participation'
nl-BE: 'Open voor deelname'
fr-BE: 'Ouvert à la participation'
custom: {}
hidden: false
parent: 'ROOT'
isCanvas: false
displayName: 'OpenToParticipation'
linkedNodes: {}
FINISHED_OR_ARCHIVED:
type:
resolvedName: 'FinishedOrArchived'
nodes: []
props:
filterBy: 'finished_and_archived'
titleMultiloc:
en: 'You said, we did...'
nl-BE: 'Jij zei, wij deden...'
fr-BE: "La boucle est bouclée"
custom: {}
hidden: false
parent: 'ROOT'
isCanvas: false
displayName: 'FinishedOrArchived'
linkedNodes: {}
idea_status:
-
title_multiloc: idea_statuses.prescreening
Expand Down
128 changes: 128 additions & 0 deletions back/config/tenant_templates/e2etests_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,134 @@ models:
content_builder/layout:
- code: homepage
enabled: true
craftjs_json:
ROOT:
type: 'div'
isCanvas: true
props:
id: 'e2e-content-builder-frame'
displayName: 'div'
custom: {}
hidden: false
nodes: ['HOMEPAGEBANNER', 'FOLLOWED_ITEMS', 'OPEN_TO_PARTICIPATION', 'FINISHED_OR_ARCHIVED', 'PROJECTS']
linked_nodes: {}
HOMEPAGEBANNER:
type:
resolvedName: 'HomepageBanner'
isCanvas: false
props:
homepageSettings:
banner_layout: 'full_width_banner_layout'
banner_avatars_enabled: true
banner_cta_signed_in_url: ''
banner_cta_signed_in_type: 'no_button'
banner_cta_signed_out_url: ''
banner_cta_signed_out_type: 'sign_up_button'
banner_signed_in_header_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_signed_out_header_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_cta_signed_in_text_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_cta_signed_out_text_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_signed_out_subheader_multiloc:
en: ''
nl-BE: ''
fr-BE: ''
banner_signed_in_header_overlay_color: '#0A5159'
banner_signed_out_header_overlay_color: '#0A5159'
banner_signed_in_header_overlay_opacity: 90
banner_signed_out_header_overlay_opacity: 90
image:
imageUrl: 'https://cl2-seed-and-template-assets.s3.eu-central-1.amazonaws.com/images/header.jpg'
errors: []
hasError: false
displayName: 'HomepageBanner'
custom:
title:
id: 'app.containers.admin.ContentBuilder.homepage.homepageBanner'
defaultMessage: 'Homepage banner'
noPointerEvents: true
noDelete: true
parent: 'ROOT'
hidden: false
nodes: []
linkedNodes: {}
FOLLOWED_ITEMS:
type:
resolvedName: 'FollowedItems'
nodes: []
props:
titleMultiloc:
en: 'For you'
nl-BE: 'Voor jou'
fr-BE: 'Pour vous'
custom: {}
hidden: false
parent: 'ROOT'
isCanvas: false
displayName: 'FollowedItems'
linkedNodes: {}
OPEN_TO_PARTICIPATION:
type:
resolvedName: 'OpenToParticipation'
nodes: []
props:
titleMultiloc:
en: 'Open to participation'
nl-BE: 'Open voor deelname'
fr-BE: 'Ouvert à la participation'
custom: {}
hidden: false
parent: 'ROOT'
isCanvas: false
displayName: 'OpenToParticipation'
linkedNodes: {}
FINISHED_OR_ARCHIVED:
type:
resolvedName: 'FinishedOrArchived'
nodes: []
props:
filterBy: 'finished_and_archived'
titleMultiloc:
en: 'You said, we did...'
nl-BE: 'Jij zei, wij deden...'
fr-BE: "La boucle est bouclée"
custom: {}
hidden: false
parent: 'ROOT'
isCanvas: false
displayName: 'FinishedOrArchived'
linkedNodes: {}
PROJECTS:
type:
resolvedName: 'Projects'
isCanvas: false
props:
currentlyWorkingOnText:
en: ''
nl-BE: ''
fr-BE: ''
displayName: 'Projects'
custom:
title:
id: 'app.containers.Admin.pagesAndMenu.containers.ContentBuilder.components.CraftComponents.Projects.projectsTitle'
defaultMessage: 'Projects'
noPointerEvents: true
noDelete: true
parent: 'ROOT'
hidden: false
nodes: []
linkedNodes: {}
idea_status:
-
title_multiloc: idea_statuses.prescreening
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module ContentBuilder
class Layout < ApplicationRecord
belongs_to :content_buildable, polymorphic: true, optional: true

before_validation :swap_data_images, on: :create
before_validation :set_craftjs_json, :sanitize_craftjs_json

validates :code, presence: true
Expand Down Expand Up @@ -80,5 +81,12 @@ def set_craftjs_json
json_craftjs_str = ERB.new(File.read(craftjs_filepath)).result(binding)
self.craftjs_json = ContentBuilder::LayoutImageService.new.swap_data_images(JSON.parse(json_craftjs_str))
end

# This ensures we process image data in a homepage layout created from the internal templates
def swap_data_images
return if code != 'homepage' || craftjs_json.blank?

self.craftjs_json = ContentBuilder::LayoutImageService.new.swap_data_images(craftjs_json)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def before_update(idea, user)

def after_update(idea, user)
super
remove_duplicate_survey_responses_on_publish(idea)
# remove_duplicate_survey_responses_on_publish(idea)
return unless idea.assignee_id_previously_changed?

initiating_user = user_for_activity_on_anonymizable_item(idea, @automatic_assignment ? nil : user)
Expand Down
Loading

0 comments on commit 0c775f2

Please sign in to comment.