Skip to content

Commit

Permalink
chore #3168 Clean up old prints in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
joemull committed Dec 11, 2024
1 parent f18276d commit 9bcbedb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ def check_for_bad_login_attempts(request):
time = timezone.now() - timedelta(minutes=10)

attempts = models.LoginAttempt.objects.filter(user_agent=user_agent, ip_address=ip_address, timestamp__gte=time)
print(time, attempts.count())
logger.info(time, attempts.count())
return attempts.count()


Expand Down
11 changes: 7 additions & 4 deletions src/cron/management/commands/send_publication_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from journal import models as journal_models
from submission import models as submission_models
from utils import notify_helpers, setting_handler, render_template
from utils.logger import get_logger

logger = get_logger(__name__)


def create_fake_request(journal):
Expand Down Expand Up @@ -47,12 +50,12 @@ def handle(self, *args, **options):
setting_name='send_reader_notifications',
journal=journal,
).value:
print('Sending notification for {}'.format(journal.name))
logger.info('Sending notification for {}'.format(journal.name))
readers = journal.users_with_role('reader')
bcc_list = [reader.email for reader in readers]

if bcc_list:
print("Sending notifications to {}".format(
logger.info("Sending notifications to {}".format(
", ".join(bcc_list)
))

Expand Down Expand Up @@ -98,8 +101,8 @@ def handle(self, *args, **options):
}
)
else:
print("No articles were published today.")
logger.info("No articles were published today.")
else:
print('Reader publication notifications are not enabled for {}'.format(journal.name))
logger.info('Reader publication notifications are not enabled for {}'.format(journal.name))


7 changes: 5 additions & 2 deletions src/cron/management/commands/send_reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

from cron import models
from journal import models as journal_models
from utils.logger import get_logger

logger = get_logger(__name__)


class Command(BaseCommand):
Expand All @@ -19,12 +22,12 @@ def handle(self, *args, **options):
journals = journal_models.Journal.objects.all()

for journal in journals:
print("Processing reminders for journal {0}: {1}".format(journal.pk, journal.name))
logger.info("Processing reminders for journal {0}: {1}".format(journal.pk, journal.name))

reminders = models.Reminder.objects.filter(journal=journal)

for reminder in reminders:
print("Reminder {0}, target date: {1}".format(reminder, reminder.target_date()))
logger.info("Reminder {0}, target date: {1}".format(reminder, reminder.target_date()))
if action == 'test':
reminder.send_reminder(test=True)
else:
Expand Down
5 changes: 4 additions & 1 deletion src/utils/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
from journal import models
from press import models as press_models
from utils import setting_handler
from utils.logger import get_logger
from submission import models as submission_models
from cms import models as cms_models

logger = get_logger(__name__)


def update_settings(journal_object=None, management_command=False,
overwrite_with_defaults=False,
Expand Down Expand Up @@ -83,7 +86,7 @@ def update_settings(journal_object=None, management_command=False,
setting.editable_by.add(*roles)

if management_command:
print('Parsed setting {0}'.format(item['setting'].get('name')))
logger.info('Parsed setting {0}'.format(item['setting'].get('name')))


def load_permissions(file_path='utils/install/journal_defaults.json'):
Expand Down
7 changes: 5 additions & 2 deletions src/utils/management/commands/install_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
from django.core.management.base import BaseCommand

from core import plugin_loader
from utils.logger import get_logger

from importlib import import_module

logger = get_logger(__name__)


class Command(BaseCommand):
"""A management command to check for and install new plugins."""
Expand Down Expand Up @@ -40,13 +43,13 @@ def handle(self, *args, **options):
)

for plugin in plugin_dirs:
print('Checking plugin {0}'.format(plugin))
logger.debug('Checking plugin {0}'.format(plugin))
plugin_module_name = "plugins.{0}.plugin_settings".format(plugin)
plugin_settings = import_module(plugin_module_name)
plugin_settings.install()

for plugin in homepage_dirs:
print('Checking plugin {0}'.format(plugin))
logger.debug('Checking plugin {0}'.format(plugin))
plugin_module_name = "core.homepage_elements.{0}.plugin_settings".format(plugin)
plugin_settings = import_module(plugin_module_name)
plugin_settings.install()

0 comments on commit 9bcbedb

Please sign in to comment.