Skip to content

Commit

Permalink
cleans pylint reports
Browse files Browse the repository at this point in the history
  • Loading branch information
smirolo committed Jan 25, 2024
1 parent 95fd43f commit efc691f
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 90 deletions.
8 changes: 4 additions & 4 deletions djaopsp/api/audits.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def get_response_data(self, request, *args, **kwargs):
self.account, campaign=self.campaign,
start_at=self.accounts_start_at, ends_at=self.accounts_ends_at,
search_terms=self.search_terms,
as_percentage=self.is_percentage)
is_percentage=self.is_percentage)
table = [{
'slug': 'completed',
'title': _('Completed'),
Expand All @@ -448,7 +448,7 @@ def retrieve(self, request, *args, **kwargs):

def completed_verified_by_week(grantee, campaign=None,
start_at=None, ends_at=None, search_terms=None,
as_percentage=False):
is_percentage=False):
"""
Returns two lists with completed and verified samples per week.
"""
Expand Down Expand Up @@ -489,12 +489,12 @@ def completed_verified_by_week(grantee, campaign=None,
nb_frozen_samples = frozen_samples.count()
period_start_at = period_ends_at

if as_percentage:
if is_percentage:
rate = as_percentage(nb_frozen_samples, nb_frozen_samples)
else:
rate = nb_frozen_samples
completed_values += [(period_ends_at, rate)]
if as_percentage:
if is_percentage:
rate = as_percentage(nb_verified_samples, nb_frozen_samples)
else:
rate = nb_verified_samples
Expand Down
5 changes: 3 additions & 2 deletions djaopsp/api/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ def create(self, request, *args, **kwargs):
frozen_assessment_sample, calculator,
segment_path, segment_title)
self._report_queries("freezing assessment: scorecard cache created")

# After a sample is frozen, send the signal.
sample_frozen.send(sender=self.__class__, sample=frozen_assessment_sample, request=request)
sample_frozen.send(sender=self.__class__,
sample=frozen_assessment_sample, request=request)

# Next step in the assessment. After complete, scorecard is optional.
next_url = reverse('share', args=(
Expand Down
69 changes: 6 additions & 63 deletions djaopsp/api_docs/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,71 +643,14 @@ def get_notification_schema(notification_slug, api_base_url=None):
#pylint:disable=too-many-statements
serializer = None
docstring = None
if notification_slug == 'card_expires_soon':
serializer = ExpireProfileNotificationSerializer()
docstring = notification_signals.card_expires_soon_notice.__doc__
elif notification_slug == 'card_updated':
serializer = ChangeProfileNotificationSerializer()
docstring = notification_signals.card_updated_notice.__doc__
elif notification_slug == 'charge_updated':
serializer = ChargeNotificationSerializer()
docstring = notification_signals.charge_updated_notice.__doc__
elif notification_slug == 'claim_code_generated':
serializer = ClaimNotificationSerializer()
docstring = notification_signals.claim_code_generated_notice.__doc__
elif notification_slug == 'expires_soon':
serializer = SubscriptionExpireNotificationSerializer()
docstring = notification_signals.expires_soon_notice.__doc__
elif notification_slug == 'order_executed':
serializer = InvoiceNotificationSerializer()
docstring = notification_signals.order_executed_notice.__doc__
elif notification_slug == 'period_sales_report_created':
serializer = AggregatedSalesNotificationSerializer()
if notification_slug == 'portfolios_grant_initiated':
serializer = PortfolioGrantInitiatedSerializer()
docstring = \
notification_signals.period_sales_report_created_notice.__doc__
elif notification_slug == 'processor_setup_error':
serializer = ProcessorSetupNotificationSerializer()
docstring = notification_signals.processor_setup_error_notice.__doc__
elif notification_slug == 'profile_updated':
serializer = ChangeProfileNotificationSerializer()
docstring = notification_signals.profile_updated_notice.__doc__
elif notification_slug == 'renewal_charge_failed':
serializer = RenewalFailedNotificationSerializer()
docstring = notification_signals.renewal_charge_failed_notice.__doc__
elif notification_slug == 'role_grant_accepted':
serializer = RoleGrantNotificationSerializer()
docstring = notification_signals.role_grant_accepted_notice.__doc__
elif notification_slug == 'role_grant_created':
serializer = RoleGrantNotificationSerializer()
docstring = notification_signals.role_grant_created_notice.__doc__
elif notification_slug == 'role_request_created':
serializer = RoleRequestNotificationSerializer()
docstring = notification_signals.role_request_created_notice.__doc__
elif notification_slug == 'subscription_grant_accepted':
serializer = SubscriptionAcceptedNotificationSerializer()
notification_signals.portfolios_grant_initiated_notice.__doc__
elif notification_slug == 'portfolios_request_initiated':
serializer = PortfolioNotificationSerializer()
docstring = \
notification_signals.subscription_grant_accepted_notice.__doc__
elif notification_slug == 'subscription_grant_created':
serializer = SubscriptionCreatedNotificationSerializer()
docstring = \
notification_signals.subscription_grant_created_notice.__doc__
elif notification_slug == 'subscription_request_accepted':
serializer = SubscriptionAcceptedNotificationSerializer()
docstring = \
notification_signals.subscription_request_accepted_notice.__doc__
elif notification_slug == 'subscription_request_created':
serializer = SubscriptionCreatedNotificationSerializer()
docstring = \
notification_signals.subscription_request_created_notice.__doc__
elif notification_slug == 'user_activated':
serializer = UserNotificationSerializer()
docstring = notification_signals.user_activated_notice.__doc__
elif notification_slug == 'user_contact':
serializer = ContactUsNotificationSerializer()
docstring = notification_signals.user_contact_notice.__doc__
elif notification_slug == 'user_registered':
serializer = UserNotificationSerializer()
docstring = notification_signals.user_registered_notice.__doc__
notification_signals.portfolios_request_initiated_notice.__doc__

generator = APIDocGenerator()
inspector = AutoSchema()
Expand Down
3 changes: 2 additions & 1 deletion djaopsp/management/commands/generate_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def generate_frozen_samples(self, profiles, campaign, verification_campaign,
enumeratedquestions__question__path__startswith=segment_path)
for profile in profiles:
created_date = fake.date_between(start_at, ends_at)
created_at = datetime_or_now(datetime.datetime(created_date.year, created_date.month, created_date.day))
created_at = datetime_or_now(datetime.datetime(
created_date.year, created_date.month, created_date.day))
sample = Sample.objects.create(
campaign=campaign, account=profile, created_at=created_at)
for question in questions:
Expand Down
2 changes: 1 addition & 1 deletion djaopsp/notifications/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class Meta:
read_only_fields = ('grantee', 'account', 'campaign',
'last_completed_at',)


class SampleFrozenNotificationSerializer(NotificationSerializer):
account = ProfileSerializer()
sample = SampleSerializer()

class Meta:
fields = ('account', 'sample')

2 changes: 1 addition & 1 deletion djaopsp/notifications/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def portfolio_request_accepted_notice(sender, portfolio, request, **kwargs):


@receiver(sample_frozen,
dispatch_uid="sample_frozen")
dispatch_uid="sample_frozen_notice")
def send_sample_frozen_notification(sender, sample, request, **kwargs):

back_url = request.build_absolute_uri(reverse('scorecard',
Expand Down
2 changes: 1 addition & 1 deletion djaopsp/templatetags/djaopsp_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,4 @@ def not_key(param_name):

@register.filter
def get_item(dictionary, key):
return dictionary.get(key)
return dictionary.get(key)
5 changes: 3 additions & 2 deletions djaopsp/urls/views/content.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Copyright (c) 2022, DjaoDjin inc.
# Copyright (c) 2024, DjaoDjin inc.
# see LICENSE.

"""
Views URLs
"""
from django.urls import path, re_path
from pages.views.sequences import CertificateDownloadView

from ...views.content import (ContentDetailView, ContentIndexView,
SequenceProgressView, SequencePageElementView)
from pages.views.sequences import CertificateDownloadView


urlpatterns = [
Expand Down
11 changes: 7 additions & 4 deletions djaopsp/views/assess.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,13 @@ def apply_background(self, slide):
slide.background.fill.fore_color.rgb = RGBColor(*bg_color)

def format_slide_title(self, title_shape):
title_shape.text_frame.paragraphs[0].font.name = self.template_config["title_font"]
title_shape.text_frame.paragraphs[0].font.size = Pt(self.template_config["title_font_size"])
title_shape.text_frame.paragraphs[0].font.name = \
self.template_config["title_font"]
title_shape.text_frame.paragraphs[0].font.size = Pt(
self.template_config["title_font_size"])
title_shape.text_frame.paragraphs[0].font.bold = True
title_shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(*self.template_config["title_font_color"])
title_shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(
*self.template_config["title_font_color"])

def format_entry_content(self, entry):
content = []
Expand Down Expand Up @@ -678,4 +681,4 @@ def get(self, request, *args, **kwargs):

def get_filename(self):
return datetime_or_now().strftime("%s-%s-%%Y%%m%%d.pptx" % (
self.sample.account.slug, self.campaign.slug))
self.sample.account.slug, self.campaign.slug))
9 changes: 6 additions & 3 deletions djaopsp/views/content.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Copyright (c) 2022, DjaoDjin inc.
# Copyright (c) 2024, DjaoDjin inc.
# see LICENSE.

from pages.views.elements import PageElementView, PageElementEditableView
from pages.views.sequences import (SequenceProgressView as BaseSequenceProgressView,
from pages.views.sequences import (
SequenceProgressView as BaseSequenceProgressView,
SequencePageElementView as BaseSequencePageElementView)

from ..mixins import AccountMixin, SequenceProgressMixin


class SequenceProgressView(SequenceProgressMixin, BaseSequenceProgressView):
pass

class SequencePageElementView(SequenceProgressMixin, BaseSequencePageElementView):
class SequencePageElementView(SequenceProgressMixin,
BaseSequencePageElementView):
pass

class ContentIndexView(PageElementView):
Expand Down
16 changes: 8 additions & 8 deletions djaopsp/views/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
site_url)
from deployutils.helpers import update_context_urls
from django.db import connection
from django.db.models.query import QuerySet, RawQuerySet
from django.http import HttpResponse
from survey.helpers import get_extra
from survey.models import Campaign, PortfolioDoubleOptIn, Unit
Expand All @@ -19,8 +18,7 @@
from ..compat import force_str, gettext_lazy as _, reverse
from ..mixins import AccountsNominativeQuerysetMixin
from ..models import ScorecardCache
from ..queries import (get_completed_assessments_at_by, get_engagement,
get_coalesce_engagement)
from ..queries import get_completed_assessments_at_by, get_coalesce_engagement
from ..utils import get_requested_accounts
from .downloads import PracticesSpreadsheetView
from .portfolios import UpdatedMenubarMixin
Expand Down Expand Up @@ -89,8 +87,9 @@ def _get_title(element):
@property
def verified_campaign(self):
if not hasattr(self, '_verified_campaign'):
#pylint:disable=attribute-defined-outside-init
self._verified_campaign = self.campaign
look = re.match('(\S+)-verified$', self._verified_campaign.slug)
look = re.match(r'(\S+)-verified$', self._verified_campaign.slug)
if look:
self._verified_campaign = get_object_or_404(
Campaign.objects.all(), slug=look.group(1))
Expand Down Expand Up @@ -293,7 +292,8 @@ def merge_tabularized(self, orig_tab, tab, path=""):
continue
val = account.get(orig_key)
if orig_val and val and (orig_val != val):
LOGGER.warning("[%s] value for key '%s' differs (%s vs %s)", path, orig_key, orig_val, val)
LOGGER.warning("[%s] value for key '%s' differs (%s vs %s)",
path, orig_key, orig_val, val)
if not orig_val and val:
orig_account[orig_key] = val

Expand All @@ -312,7 +312,8 @@ def get_answers_by_paths(self, latest_samples):
answers_by_paths = {}
question_clause = ""
if self.kwargs.get('path'):
question_clause = "WHERE survey_question.path ILIKE '/%s%%'" % self.kwargs.get('path')
question_clause = ("WHERE survey_question.path ILIKE '/%s%%'"
% self.kwargs.get('path'))
if self.requested_accounts:
reporting_answers_sql = """
WITH samples AS (
Expand Down Expand Up @@ -501,8 +502,7 @@ def write_headers(self):
last_activity_at_by_accounts.update({
sample.account_id: sample.created_at})
headings = [force_str(_("Last completed at"))]
reporting_status_strings = {key: val
for key, val in EngagementSerializer.REPORTING_STATUSES}
reporting_status_strings = dict(EngagementSerializer.REPORTING_STATUSES)
for reporting in self.accounts_with_engagement:
account_id = reporting.pk
last_activity_at = last_activity_at_by_accounts.get(account_id)
Expand Down

0 comments on commit efc691f

Please sign in to comment.