-
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?
Conversation
…itor-hidden-project-2-hidden [TAN-3815] Changed method of hiding project to use hidden: true
@@ -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 comment
The 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
# Conflicts: # back/engines/commercial/multi_tenancy/db/seeds/tenants.rb
…d check for last page being present
@@ -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 comment
The 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
|
||
# Check the last field is a page | ||
if @participation_method.supports_pages_in_form? && fields.last[:input_type] != 'page' | ||
errors["#{fields.length - 1}"] = { structure: [{ error: "Last field must be of type 'page'" }] } | ||
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.
This is unrelated, but noticed this logic was missing
@@ -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 comment
The 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
@@ -25,7 +25,7 @@ def clean_assignees_for_project!(project) | |||
end | |||
|
|||
def automatically_assigned_idea_assignee(idea) | |||
return if idea.participation_method_on_creation.instance_of?(ParticipationMethod::NativeSurvey) | |||
return unless idea.participation_method_on_creation.automatically_assign_idea? |
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.
Changed so that we can check multiple participation methods
def form_logic_enabled? | ||
false | ||
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.
Not actually used at the moment, but will be used for community monitor
input_type: 'page', | ||
page_layout: 'default' | ||
), | ||
start_page_field(custom_form), |
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.
Now shared between methods. Suspect there may be some overlap here with Edwin's work
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.
This is mainly a copy of native survey, but differences are likely to be introduced later
Changes in a nutshell:
internal_role: 'community_monitor
and a new fieldhidden: true
on projectcommunity_monitor
which also stores the project ID for this projectcommunity_monitor_survey
participation method which inherits fromnative survey
community_monitor_survey
currently inherits most things fromnative_survey
I have removedphase.native_survey?
everywhere and usedphase.pmethod.supports_survey_form?
- in line with us wanting to delegate as much as possible to the participation methodChangelog
Technical