diff --git a/app/blueprints/assessments/models/fund_summary.py b/app/blueprints/assessments/models/fund_summary.py index 8a4c1f11..64045ab6 100644 --- a/app/blueprints/assessments/models/fund_summary.py +++ b/app/blueprints/assessments/models/fund_summary.py @@ -94,10 +94,17 @@ def create_round_summaries( round_short_name=round.short_name.lower(), report_type="OUTPUT_TRACKER", ) - feedback_export_href = url_for( - "assessment_bp.feedback_export", - fund_short_name=fund.short_name, - round_short_name=round.short_name.lower(), + feedback_export_href = ( + url_for( + "assessment_bp.feedback_export", + fund_short_name=fund.short_name, + round_short_name=round.short_name.lower(), + ) + if ( + round.feedback_survey_config.has_feedback_survey + or round.feedback_survey_config.has_section_feedback + ) + else "" ) if has_devolved_authority_validation(fund_id=fund.id): diff --git a/app/blueprints/assessments/templates/macros/fund_dashboard_summary.html b/app/blueprints/assessments/templates/macros/fund_dashboard_summary.html index 32ae99cb..bdeb2d51 100644 --- a/app/blueprints/assessments/templates/macros/fund_dashboard_summary.html +++ b/app/blueprints/assessments/templates/macros/fund_dashboard_summary.html @@ -83,7 +83,7 @@

{{summary. View all submitted applications {{ round_links(summary.access_controller, summary.round_application_fields_download_available, summary.export_href, summary.feedback_export_href, summary.assessment_tracker_href) }} - {% elif summary.access_controller.is_lead_assessor %} + {% elif summary.access_controller.is_lead_assessor and summary.feedback_export_href %} Export applicants feedback information diff --git a/app/blueprints/services/models/round.py b/app/blueprints/services/models/round.py index 39d3fa91..5c9130e5 100644 --- a/app/blueprints/services/models/round.py +++ b/app/blueprints/services/models/round.py @@ -5,6 +5,25 @@ from .application import Application +@dataclass +class FeedbackSurveyConfig: + has_feedback_survey: bool = False + is_feedback_survey_optional: bool = True + has_section_feedback: bool = False + is_section_feedback_optional: bool = True + + @staticmethod + def from_json(d: dict): + # Filter unknown fields from JSON dictionary + return FeedbackSurveyConfig( + **{ + k: v + for k, v in d.items() + if k in inspect.signature(FeedbackSurveyConfig).parameters + } + ) + + @dataclass class Round: id: str @@ -19,6 +38,15 @@ class Round: application_fields_download_available: bool = False display_logo_on_pdf_exports: bool = False applications: List[Application] = None + feedback_survey_config: FeedbackSurveyConfig = None + + def __post_init__(self): + if isinstance(self.feedback_survey_config, dict): + self.feedback_survey_config = FeedbackSurveyConfig.from_json( + self.feedback_survey_config + ) + elif self.feedback_survey_config is None: + self.feedback_survey_config = FeedbackSurveyConfig() @classmethod def from_dict(cls, d: dict): @@ -50,6 +78,8 @@ def from_json(data: dict): or False, display_logo_on_pdf_exports=data.get("display_logo_on_pdf_exports") or False, + feedback_survey_config=data.get("feedback_survey_config") + or FeedbackSurveyConfig(), ) def add_application(self, application: Application):