Skip to content
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

Feature/160 - Replaces print calls with logger calls #1201

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Generated by Django 4.2.10 on 2024-04-19 19:10

from django.db import migrations, models
import structlog

logger = structlog.get_logger(__name__)


def migrate_committee_data(apps, schema_editor):
Expand All @@ -20,7 +23,7 @@ def migrate_committee_data(apps, schema_editor):
report.zip = form.zip
report.save()
else:
print("Report not found for ", form)
logger.error(f"F24 Form has no corresponding report! {form}")

for form in Form3x.objects.all():
report = Report.objects.filter(form_3x=form).first()
Expand All @@ -32,7 +35,7 @@ def migrate_committee_data(apps, schema_editor):
report.zip = form.zip
report.save()
else:
print("Report not found for ", form)
logger.error(f"F3X Form has no corresponding report! {form}")

for form in Form99.objects.all():
report = Report.objects.filter(form_99=form).first()
Expand All @@ -45,7 +48,7 @@ def migrate_committee_data(apps, schema_editor):
report.zip = form.zip
report.save()
else:
print("Report not found for ", form)
logger.error(f"F99 Form has no corresponding report! {form}")

for form in Form1m.objects.all():
report = Report.objects.filter(form_1m=form).first()
Expand All @@ -58,7 +61,7 @@ def migrate_committee_data(apps, schema_editor):
report.zip = form.zip
report.save()
else:
print("Report not found for ", form)
logger.error(f"F1M Form has no corresponding report! {form}")


class Migration(migrations.Migration):
Expand Down
1 change: 0 additions & 1 deletion django-backend/fecfiler/transactions/tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ def test_debts(self):
self.assertEqual(original_debt_view.incurred_prior, Decimal("0"))
self.assertEqual(original_debt_view.payment_prior, Decimal("0"))
self.assertEqual(original_debt_view.payment_amount, Decimal("3.50"))
print("DEBT SUCCESS")

def test_line_label(self):
create_schedule_a(
Expand Down
4 changes: 0 additions & 4 deletions django-backend/fecfiler/transactions/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,19 +846,15 @@ def test_can_delete_debt(self):
m3_report.id
)
m3_report.save()
print(f"reports: {m1_report.id}, {m2_report.id}, {m3_report.id}")
original_debt.refresh_from_db()
# self.assertFalse(original_debt.can_delete)
print(f"blocking reports {original_debt.blocking_reports}")
m2_report.upload_submission = None
m2_report.save()
original_debt.refresh_from_db()
print(f"blocking reports {original_debt.blocking_reports}")
self.assertFalse(original_debt.can_delete)
m3_report.upload_submission = None
m3_report.save()
original_debt.refresh_from_db()
print(f"blocking reports {original_debt.blocking_reports}")
self.assertTrue(original_debt.can_delete)

def set_up_jf_transfer(self):
Expand Down
6 changes: 3 additions & 3 deletions django-backend/fecfiler/transactions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_queryset(self):
def create(self, request, *args, **kwargs):
with db_transaction.atomic():
saved_transaction = self.save_transaction(request.data, request)
print(f"transaction ID: {saved_transaction.id}")
logger.info(f"Created new transaction: {saved_transaction.id}")
update_dependent_parent(saved_transaction)
return Response(saved_transaction.id)

Expand Down Expand Up @@ -413,12 +413,12 @@ def get_save_hook(transaction: Transaction):
def stringify_queryset(qs):
database_uri = os.environ.get("DATABASE_URL")
if not database_uri:
print(
logger.error(
"""Environment variable DATABASE_URL not found.
Please check your settings and try again"""
)
exit(1)
print("Testing connection...")
logger.info("Testing connection...")
conn = psycopg2.connect(database_uri)
sql, params = qs.query.sql_with_params()
with conn.cursor() as cursor:
Expand Down
5 changes: 4 additions & 1 deletion django-backend/fecfiler/user/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import uuid
from fecfiler.shared.utilities import get_model_data
from django.core.management.utils import get_random_secret_key
import structlog

logger = structlog.get_logger(__name__)


def copy_users(apps, schema_editor):
if not apps.is_installed(
"authentication"
): # "authentication" not in [app_name for app_name, app in apps.get_models()]:
print("no authentication app")
logger.error("The authentication app isn't installed")
return
OldAccount = apps.get_model("authentication", "Account") # noqa
User = apps.get_model("user", "User") # noqa
Expand Down