Skip to content

Commit

Permalink
PROTO-TMP-FIX: report submission
Browse files Browse the repository at this point in the history
Still needs to redirect to the right place but pushing this for now
  • Loading branch information
sfount committed Feb 28, 2025
1 parent 7d20f87 commit b2aee58
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion proto/common/data/models/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def status(self):
@property
def can_be_submitted(self):
return len(self.data_collection_instance.section_data) == len(
self.round.data_collection_definition.sections
self.reporting_round.data_collection_definition.sections
) and all(sd.completed for sd in self.data_collection_instance.section_data)

@property
Expand Down
11 changes: 9 additions & 2 deletions proto/common/data/services/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import string
import uuid

from sqlalchemy import select
from sqlalchemy import delete, select

from db import db
from proto.common.data.models import (
Expand All @@ -18,7 +18,14 @@ def _generate_report_code():
return "".join(random.choices(string.ascii_uppercase, k=6))


def get_or_create_monitoring_reports_for_grant_recipient(grant_recipient: ProtoGrantRecipient) -> list[ProtoReport]:
def get_or_create_monitoring_reports_for_grant_recipient(
grant_recipient: ProtoGrantRecipient, preview: bool = False
) -> list[ProtoReport]:
if preview:
db.session.execute(
delete(ProtoReport).filter(ProtoReport.fake.is_(True), ProtoReport.recipient == grant_recipient)
)

def _get_reports() -> list[ProtoReport]:
return (
db.session.scalars(
Expand Down
2 changes: 1 addition & 1 deletion proto/manage/platform/reporting_rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def preview_report(grant_code, round_ext_id):
form = PreviewReportForm(submit_label=None)
if form.validate_on_submit():
get_or_create_monitoring_reports_for_grant_recipient(
get_grant_recipient_for_organisation(g.account.organisation_id, grant.short_name)
get_grant_recipient_for_organisation(g.account.organisation_id, grant.short_name), preview=True
)
return redirect(
url_for("proto_report.tasklist", short_name=grant.short_name, reporting_round_id=reporting_round.id)
Expand Down

0 comments on commit b2aee58

Please sign in to comment.