-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TAN-3815 - Community monitor backend #10365
base: master
Are you sure you want to change the base?
Changes from 52 commits
44aec87
1667276
7924cd0
557125b
dfcf6b3
d1d2b20
bc4f5b9
45860ab
f76c55e
1508955
faa7d76
0e2e0b8
bc8cd55
e36b26e
0cf1592
e519018
7b5bc0e
c006832
a0d5aa2
87bd42d
37a6773
bd2abdc
c9b0d4d
92de3fe
e6c65d8
ef10676
7af6681
f65673c
8e88d85
2aa1064
a173464
4c529e8
de312c4
d5746cf
5893bd4
dd5cc6e
0220682
f022b8c
c30dd87
7bd9ae2
fbc1248
bad1f86
266ab4a
e5f18e5
e269c3a
0c8783a
528916f
4176e35
a2776e0
34f0270
bdc6522
94aebb1
772b8fd
072d08a
3b63b20
3d817d9
f650cf5
33b6fac
4577759
d6cd458
2e28c55
4f75390
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ class Permission < ApplicationRecord | |
'ideation' => %w[posting_idea commenting_idea reacting_idea attending_event], | ||
'proposals' => %w[posting_idea commenting_idea reacting_idea attending_event], | ||
'native_survey' => %w[posting_idea attending_event], | ||
'community_monitor_survey' => %w[posting_idea attending_event], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably don't need attending event, but all other phases have attending event and there would be some refactoring not to have it |
||
'survey' => %w[taking_survey attending_event], | ||
'poll' => %w[taking_poll attending_event], | ||
'voting' => %w[voting commenting_idea attending_event], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,6 @@ class Phase < ApplicationRecord | |
# voting? | ||
with_options if: :voting? do | ||
validates :voting_method, presence: true, inclusion: { in: VOTING_METHODS } | ||
validate :validate_voting | ||
validates :voting_term_singular_multiloc, multiloc: { presence: false } | ||
validates :voting_term_plural_multiloc, multiloc: { presence: false } | ||
validates :autoshare_results_enabled, inclusion: { in: [true, false] } | ||
|
@@ -182,12 +181,14 @@ class Phase < ApplicationRecord | |
where(start_at: date) | ||
} | ||
|
||
# native_survey? | ||
with_options if: :native_survey? do | ||
# any type of native_survey phase | ||
with_options if: ->(phase) { phase.pmethod.supports_survey_form? } do | ||
validates :native_survey_title_multiloc, presence: true, multiloc: { presence: true } | ||
validates :native_survey_button_multiloc, presence: true, multiloc: { presence: true } | ||
end | ||
|
||
validate :validate_phase_participation_method | ||
|
||
scope :published, lambda { | ||
joined = includes(project: { admin_publication: :parent }) | ||
joined.where( | ||
|
@@ -256,11 +257,6 @@ def voting? | |
participation_method == 'voting' | ||
end | ||
|
||
# Used for validations (which are hard to delegate through the participation method) | ||
def native_survey? | ||
participation_method == 'native_survey' | ||
end | ||
|
||
def pmethod | ||
reload_participation_method if !@pmethod | ||
@pmethod | ||
|
@@ -371,6 +367,8 @@ def reload_participation_method | |
ParticipationMethod::Proposals.new(self) | ||
when 'native_survey' | ||
ParticipationMethod::NativeSurvey.new(self) | ||
when 'community_monitor_survey' | ||
ParticipationMethod::CommunityMonitorSurvey.new(self) | ||
when 'document_annotation' | ||
ParticipationMethod::DocumentAnnotation.new(self) | ||
when 'survey' | ||
|
@@ -390,8 +388,9 @@ def set_presentation_mode | |
self.presentation_mode ||= 'card' | ||
end | ||
|
||
def validate_voting | ||
Factory.instance.voting_method_for(self).validate_phase | ||
# Delegate any rules specific to a method to the participation method itself | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made this more generic so any participation method can now implement it's own validation rules |
||
def validate_phase_participation_method | ||
pmethod.validate_phase | ||
end | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,6 +335,7 @@ def yml_phases(shift_timestamps: 0, timeline_start_at: nil) | |
yml_phase['document_annotation_embed_url'] = phase.document_annotation_embed_url | ||
end | ||
|
||
# TODO: JS - Needed for community monitor? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will we ever need to copy this project? |
||
if yml_phase['participation_method'] == 'native_survey' | ||
yml_phase['native_survey_title_multiloc'] = phase.native_survey_title_multiloc | ||
yml_phase['native_survey_button_multiloc'] = phase.native_survey_button_multiloc | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
class ProjectsFinderService | ||
def initialize(projects, user = nil, params = {}) | ||
@projects = projects | ||
@projects = projects.not_hidden | ||
@user = user | ||
@page_size = (params.dig(:page, :size) || 500).to_i | ||
@page_number = (params.dig(:page, :number) || 1).to_i | ||
|
@@ -22,7 +22,7 @@ def participation_possible | |
subquery = projects_with_active_phase(subquery) | ||
.joins('INNER JOIN phases AS active_phases ON active_phases.project_id = projects.id') | ||
.where.not(phases: { participation_method: 'information' }) | ||
.select('projects.*, projects.created_at AS projects_created_at, projects.id AS projects_id') | ||
.select('projects.created_at AS projects_created_at, projects.id AS projects_id') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This turned out to be unneeded as it was double returning all the fields |
||
|
||
# Perform the SELECT DISTINCT on the outer query and order first by the end date of the active phase, | ||
# second by project created_at, and third by project ID. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddHiddenToProjects < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :projects, :hidden, :boolean, default: false, null: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did not add an index here as for booleans I don't think it often gets used |
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could have used
unless phase.project.hidden?
but decided that it didn't make sense for notifications to be made unless the project was live