Skip to content

Commit

Permalink
Merge pull request #560 from fecgov/release/sprint-32
Browse files Browse the repository at this point in the history
Release/sprint 32
  • Loading branch information
mjtravers authored Oct 25, 2023
2 parents d275088 + 4f95e17 commit b599a42
Show file tree
Hide file tree
Showing 141 changed files with 4,010 additions and 4,448 deletions.
3 changes: 3 additions & 0 deletions .safety.dependency.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
59293 2023-12-01 # django
55264 2023-12-01 # django
60350 2023-12-01 # django
60841 2023-12-01 # django
60789 2023-12-01 # django
60956 2023-12-01 # django
3 changes: 2 additions & 1 deletion django-backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ local_settings.py
/env/
.python-version
*.python_history
*.bash_history
*.bash_history
fecfiler/web_services/dot_fec/output/
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Migration(migrations.Migration):
("contacts", "0008_committee_fk_to_int"),
("f3x_summaries", "0023_committee_fk_to_int"),
("memo_text", "0005_committee_fk_to_int"),
("scha_transactions", "0021_committee_fk_to_int"),
]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Migration(migrations.Migration):
("contacts", "0009_committee_uuid_fk"),
("f3x_summaries", "0024_committee_uuid_fk"),
("memo_text", "0006_committee_uuid_fk"),
("scha_transactions", "0022_committee_uuid_fk"),
]

operations = [
Expand Down
3 changes: 0 additions & 3 deletions django-backend/fecfiler/contacts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ class Meta:
if f.name
not in [
"deleted",
"schatransaction",
"scheduleatransaction",
"schedulebtransaction",
"transaction",
"contact_1_transaction_set",
"contact_2_transaction_set",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Migration(migrations.Migration):

dependencies = [
("memo_text", "0003_report_id"),
("scha_transactions", "0019_report_id"),
("f3x_summaries", "0020_f3xsummary_submission_keys"),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Migration(migrations.Migration):

dependencies = [
("memo_text", "0004_report_fk"),
("scha_transactions", "0020_report_fk"),
("f3x_summaries", "0021_f3xsummary_uuid_primary"),
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.1.3 on 2023-10-06 22:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('f3x_summaries', '0027_remove_f3xsummary_filer_committee_id_number'),
]

operations = [
migrations.AddField(
model_name='f3xsummary',
name='report_id',
field=models.TextField(blank=True, null=True),
),
migrations.AddField(
model_name='f3xsummary',
name='report_version',
field=models.TextField(blank=True, null=True),
),
]
8 changes: 6 additions & 2 deletions django-backend/fecfiler/f3x_summaries/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class F3XSummary(SoftDeleteModel, CommitteeOwnedModel):
)

form_type = models.TextField(null=True, blank=True)
# fec 1-up version of amendment
report_version = models.TextField(null=True, blank=True)
# fec id for report
report_id = models.TextField(null=True, blank=True)
# TODO get rid of this field. It is redundant with the related Committee_Account
committee_name = models.TextField(null=True, blank=True)
change_of_address = models.BooleanField(default=False, null=True, blank=True)
Expand Down Expand Up @@ -390,7 +394,7 @@ def pull_forward_loans(self):

if previous_report:
loans_to_pull_forward = previous_report.transaction_set.filter(
~Q(loan_balance=Decimal(0)) | Q(loan_balance=None),
~Q(loan_balance=Decimal(0)) | Q(loan_balance__isnull=True),
~Q(memo_code=True),
schedule_c_id__isnull=False,
)
Expand Down Expand Up @@ -425,7 +429,7 @@ def pull_forward_debts(self):

if previous_report:
debts_to_pull_forward = previous_report.transaction_set.filter(
~Q(balance_at_close=Decimal(0)) | Q(balance_at_close=None),
~Q(balance_at_close=Decimal(0)) | Q(balance_at_close__isnull=True),
~Q(memo_code=True),
schedule_d_id__isnull=False,
)
Expand Down
3 changes: 0 additions & 3 deletions django-backend/fecfiler/f3x_summaries/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ class Meta:
if f.name
not in [
"deleted",
"schatransaction",
"scheduleatransaction",
"schedulebtransaction",
"transaction",
"dotfec",
"memotext",
Expand Down
39 changes: 0 additions & 39 deletions django-backend/fecfiler/f3x_summaries/test_views.py

This file was deleted.

17 changes: 14 additions & 3 deletions django-backend/fecfiler/f3x_summaries/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def get_status_mapping():
]
) | Q(upload_submission__fec_status=FECStatus.PROCESSING)
success = Q(upload_submission__fec_status=FECStatus.ACCEPTED)
failed = Q(
upload_submission__fecfile_task_state=FECSubmissionState.FAILED
) | Q(
failed = Q(upload_submission__fecfile_task_state=FECSubmissionState.FAILED) | Q(
upload_submission__fec_status=FECStatus.REJECTED
)

Expand Down Expand Up @@ -78,6 +76,19 @@ def coverage_dates(self, request):
)
return JsonResponse(data, safe=False)

@action(
detail=True,
methods=["post"],
url_name="amend",
)
def amend(self, request, pk):
report = self.get_object()
report.form_type = "F3XA"
report.report_version = int(report.report_version or "0") + 1
report.upload_submission = None
report.save()
return Response(f"amended {report}")

@action(
detail=False,
methods=["post"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.12 on 2022-06-30 19:35
# Generated by Django 4.1.3 on 2023-10-13 15:54

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -7,19 +7,19 @@
class Migration(migrations.Migration):

dependencies = [
("scha_transactions", "0009_alter_schatransaction_contribution_date"),
("reports", "0002_copy_to_unified_table"),
("memo_text", "0011_remove_memotext_back_reference_sched_form_name_and_more"),
]

operations = [
migrations.AddField(
model_name="schatransaction",
name="parent_transaction_id",
migrations.AlterField(
model_name="memotext",
name="report",
field=models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="scha_transactions.schatransaction",
to="reports.report",
),
),
]
2 changes: 1 addition & 1 deletion django-backend/fecfiler/memo_text/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fecfiler.soft_delete.models import SoftDeleteModel
from fecfiler.committee_accounts.models import CommitteeOwnedModel
from fecfiler.f3x_summaries.models import ReportMixin
from fecfiler.reports.models import ReportMixin
from fecfiler.shared.utilities import generate_fec_uid
from django.db import models
import uuid
Expand Down
3 changes: 0 additions & 3 deletions django-backend/fecfiler/memo_text/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ class Meta:
not in [
"report",
"deleted",
"schatransaction",
"scheduleatransaction",
"schedulebtransaction",
"transaction",
]
] + [
Expand Down
2 changes: 1 addition & 1 deletion django-backend/fecfiler/memo_text/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class MemoTextTestCase(TestCase):
fixtures = ["test_f3x_summaries", "test_memo_text", "test_committee_accounts"]
fixtures = ["test_f3x_reports", "test_memo_text", "test_committee_accounts"]

def setUp(self):
self.valid_memo_text = MemoText(
Expand Down
8 changes: 3 additions & 5 deletions django-backend/fecfiler/memo_text/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class MemoTextSerializerTestCase(TestCase):
fixtures = ["test_memo_text", "test_committee_accounts", "test_f3x_summaries"]
fixtures = ["test_memo_text", "test_committee_accounts", "test_f3x_reports"]

def setUp(self):
self.valid_memo_text = {
Expand All @@ -31,13 +31,11 @@ def setUp(self):

def test_serializer_validate(self):
valid_serializer = MemoTextSerializer(
data=self.valid_memo_text,
context={"request": self.mock_request},
data=self.valid_memo_text, context={"request": self.mock_request},
)
self.assertTrue(valid_serializer.is_valid(raise_exception=True))
invalid_serializer = MemoTextSerializer(
data=self.invalid_memo_text,
context={"request": self.mock_request},
data=self.invalid_memo_text, context={"request": self.mock_request},
)
self.assertFalse(invalid_serializer.is_valid())
self.assertIsNotNone(invalid_serializer.errors["rec_type"])
2 changes: 1 addition & 1 deletion django-backend/fecfiler/memo_text/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class MemoTextViewSetTest(TestCase):
fixtures = [
"test_f3x_summaries",
"test_f3x_reports",
"test_memo_text",
"test_committee_accounts",
"test_accounts",
Expand Down
9 changes: 3 additions & 6 deletions django-backend/fecfiler/memo_text/views.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
from .models import MemoText
from .serializers import MemoTextSerializer
from fecfiler.committee_accounts.views import CommitteeOwnedViewSet
from fecfiler.f3x_summaries.views import ReportViewMixin
from fecfiler.reports.views import ReportViewMixin


class MemoTextViewSet(CommitteeOwnedViewSet, ReportViewMixin):
def get_queryset(self):
memos = MemoText.objects.all()
query_params = self.request.query_params.keys()
if ("report_id" in query_params):
if "report_id" in query_params:
report_id = self.request.query_params["report_id"]
memos = memos.filter(
report_id=report_id,
transaction_uuid=None
)
memos = memos.filter(report_id=report_id, transaction_uuid=None)

return memos

Expand Down
3 changes: 3 additions & 0 deletions django-backend/fecfiler/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Django App for Reports
"""
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.apps import AppConfig


class SchedAConfig(AppConfig):
name = "fecfiler.scha_transactions"
class ReportsConfig(AppConfig):
name = "fecfiler.reports"

def ready(self):
# Implicitly connect a signal handlers decorated with @receiver.
Expand Down
Loading

0 comments on commit b599a42

Please sign in to comment.