Skip to content

Commit

Permalink
Fix typo reminder -> remainder
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramez Ashraf committed May 27, 2023
1 parent 02d332d commit a5cf80a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 40 deletions.
26 changes: 13 additions & 13 deletions slick_reporting/form_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_crispy_helper(
foreign_keys_map=None,
crosstab_model=None,
crosstab_key_name=None,
crosstab_display_compute_reminder=False,
crosstab_display_compute_remainder=False,
add_date_range=True,
):
from crispy_forms.helper import FormHelper
Expand All @@ -52,8 +52,8 @@ def get_crispy_helper(
# first add the crosstab model and its display reimder then the rest of the fields
if crosstab_model:
filters_container.append(Field(crosstab_key_name))
if crosstab_display_compute_reminder:
filters_container.append(Field("crosstab_compute_reminder"))
if crosstab_display_compute_remainder:
filters_container.append(Field("crosstab_compute_remainder"))

for k in foreign_keys_map:
if k != crosstab_key_name:
Expand Down Expand Up @@ -115,16 +115,16 @@ def get_crosstab_ids(self):
return [x for x in qs.values_list("pk", flat=True)]
return []

def get_crosstab_compute_reminder(self):
return self.cleaned_data.get("crosstab_compute_reminder", True)
def get_crosstab_compute_remainder(self):
return self.cleaned_data.get("crosstab_compute_remainder", True)

def get_crispy_helper(self, foreign_keys_map=None, crosstab_model=None, **kwargs):
return get_crispy_helper(
self.foreign_keys,
crosstab_model=getattr(self, "crosstab_model", None),
crosstab_key_name=getattr(self, "crosstab_key_name", None),
crosstab_display_compute_reminder=getattr(
self, "crosstab_display_compute_reminder", False
crosstab_display_compute_remainder=getattr(
self, "crosstab_display_compute_remainder", False
),
**kwargs,
)
Expand All @@ -140,7 +140,7 @@ def _default_foreign_key_widget(f_field):
def report_form_factory(
model,
crosstab_model=None,
display_compute_reminder=True,
display_compute_remainder=True,
fkeys_filter_func=None,
foreign_key_widget_func=None,
excluded_fields=None,
Expand All @@ -159,7 +159,7 @@ def report_form_factory(
:param model: the report_model
:param crosstab_model: crosstab model if any
:param display_compute_reminder: relevant only if crosstab_model is specified. Control if we show the check to
:param display_compute_remainder: relevant only if crosstab_model is specified. Control if we show the check to
display the rest.
:param fkeys_filter_func: a receives an OrderedDict of Foreign Keys names and their model field instances found on the model, return the OrderedDict that would be used
:param foreign_key_widget_func: receives a Field class return the used widget like this {'form_class': forms.ModelMultipleChoiceField, 'required': False, }
Expand Down Expand Up @@ -219,9 +219,9 @@ def report_form_factory(
field_attrs["required"] = True
fields[name] = f_field.formfield(**field_attrs)

if crosstab_model and display_compute_reminder:
fields["crosstab_compute_reminder"] = forms.BooleanField(
required=False, label=_("Display the crosstab reminder"), initial=True
if crosstab_model and display_compute_remainder:
fields["crosstab_compute_remainder"] = forms.BooleanField(
required=False, label=_("Display the crosstab remainder"), initial=True
)

bases = (
Expand All @@ -236,7 +236,7 @@ def report_form_factory(
"_fkeys": fkeys_list,
"foreign_keys": fkeys_map,
"crosstab_model": crosstab_model,
"crosstab_display_compute_reminder": display_compute_reminder,
"crosstab_display_compute_remainder": display_compute_remainder,
},
)
return new_form
22 changes: 11 additions & 11 deletions slick_reporting/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ReportGenerator(object):
crosstab_ids = None
"""A list is the ids to create a crosstab report on"""

crosstab_compute_reminder = True
crosstab_compute_remainder = True
"""Include an an extra crosstab_columns for the outer group ( ie: all expects those `crosstab_ids`) """

show_empty_records = True
Expand Down Expand Up @@ -161,7 +161,7 @@ def __init__(
crosstab_model=None,
crosstab_columns=None,
crosstab_ids=None,
crosstab_compute_reminder=None,
crosstab_compute_remainder=None,
swap_sign=False,
show_empty_records=None,
print_flag=False,
Expand All @@ -187,7 +187,7 @@ def __init__(
:param crosstab_model:
:param crosstab_columns:
:param crosstab_ids:
:param crosstab_compute_reminder:
:param crosstab_compute_remainder:
:param swap_sign:
:param show_empty_records:
:param base_model:
Expand Down Expand Up @@ -226,10 +226,10 @@ def __init__(
self.crosstab_model = self.crosstab_model or crosstab_model
self.crosstab_columns = crosstab_columns or self.crosstab_columns or []
self.crosstab_ids = self.crosstab_ids or crosstab_ids or []
self.crosstab_compute_reminder = (
self.crosstab_compute_reminder
if crosstab_compute_reminder is None
else crosstab_compute_reminder
self.crosstab_compute_remainder = (
self.crosstab_compute_remainder
if crosstab_compute_remainder is None
else crosstab_compute_remainder
)

self.format_row = format_row_func or self._default_format_row
Expand Down Expand Up @@ -374,11 +374,11 @@ def _apply_queryset_options(self, query, fields=None):

def _construct_crosstab_filter(self, col_data):
"""
In charge of adding the needed crosstab filter, specific to the case of is_reminder or not
In charge of adding the needed crosstab filter, specific to the case of is_remainder or not
:param col_data:
:return:
"""
if col_data["is_reminder"]:
if col_data["is_remainder"]:
filters = [~Q(**{f"{col_data['model']}_id__in": self.crosstab_ids})]
else:
filters = [Q(**{f"{col_data['model']}_id": col_data["id"]})]
Expand Down Expand Up @@ -805,7 +805,7 @@ def get_crosstab_parsed_columns(self):
"""
report_columns = self.crosstab_columns or []
ids = list(self.crosstab_ids)
if self.crosstab_compute_reminder:
if self.crosstab_compute_remainder:
ids.append("----")
output_cols = []
ids_length = len(ids) - 1
Expand All @@ -827,7 +827,7 @@ def get_crosstab_parsed_columns(self):
"ref": magic_field_class,
"id": id,
"model": self.crosstab_model,
"is_reminder": counter == ids_length,
"is_remainder": counter == ids_length,
"source": "magic_field" if magic_field_class else "",
"is_summable": magic_field_class.is_summable,
}
Expand Down
12 changes: 6 additions & 6 deletions slick_reporting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SlickReportViewBase(FormView):
crosstab_model = None
crosstab_ids = None
crosstab_columns = None
crosstab_compute_reminder = True
crosstab_compute_remainder = True
excluded_fields = None
report_title_context_key = "title"

Expand Down Expand Up @@ -184,7 +184,7 @@ def get_form_class(self):
return self.form_class or report_form_factory(
self.get_report_model(),
crosstab_model=self.crosstab_model,
display_compute_reminder=self.crosstab_compute_reminder,
display_compute_remainder=self.crosstab_compute_remainder,
excluded_fields=self.excluded_fields,
initial=self.get_form_initial(),
show_time_series_selector=self.time_series_selector,
Expand Down Expand Up @@ -223,10 +223,10 @@ def get_report_generator(self, queryset, for_print):
if self.crosstab_model:
self.crosstab_ids = self.form.get_crosstab_ids()

crosstab_compute_reminder = (
self.form.get_crosstab_compute_reminder()
crosstab_compute_remainder = (
self.form.get_crosstab_compute_remainder()
if self.request.GET or self.request.POST
else self.crosstab_compute_reminder
else self.crosstab_compute_remainder
)

time_series_pattern = self.time_series_pattern
Expand All @@ -251,7 +251,7 @@ def get_report_generator(self, queryset, for_print):
crosstab_model=self.crosstab_model,
crosstab_ids=self.crosstab_ids,
crosstab_columns=self.crosstab_columns,
crosstab_compute_reminder=crosstab_compute_reminder,
crosstab_compute_remainder=crosstab_compute_remainder,
format_row_func=self.format_row,
container_class=self,
)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
class MatrixTests(BaseTestData, TestCase):
def test_matrix_column_included(self):
report = CrosstabOnClient(
crosstab_ids=[self.client1.pk], crosstab_compute_reminder=False
crosstab_ids=[self.client1.pk], crosstab_compute_remainder=False
)
columns = report.get_list_display_columns()
self.assertEqual(len(columns), 3, columns)

report = CrosstabOnClient(
crosstab_ids=[self.client1.pk], crosstab_compute_reminder=True
crosstab_ids=[self.client1.pk], crosstab_compute_remainder=True
)
columns = report.get_list_display_columns()
self.assertEqual(len(columns), 4, columns)
Expand All @@ -39,14 +39,14 @@ def test_matrix_column_position(self):
report = CrosstabOnClient(
columns=["__crosstab__", "name", "__total_quantity__"],
crosstab_ids=[self.client1.pk],
crosstab_compute_reminder=False,
crosstab_compute_remainder=False,
)
columns = report.get_list_display_columns()
self.assertEqual(len(columns), 3, columns)
self.assertEqual(columns[0]["name"], "value__sumCT1")

report = CrosstabOnClient(
crosstab_ids=[self.client1.pk], crosstab_compute_reminder=True
crosstab_ids=[self.client1.pk], crosstab_compute_remainder=True
)
columns = report.get_list_display_columns()
self.assertEqual(len(columns), 4, columns)
Expand All @@ -69,7 +69,7 @@ def test_get_crosstab_parsed_columns(self):
:return:
"""
report = CrosstabOnClient(
crosstab_ids=[self.client1.pk], crosstab_compute_reminder=False
crosstab_ids=[self.client1.pk], crosstab_compute_remainder=False
)
columns = report.get_crosstab_parsed_columns()
for col in columns:
Expand Down
10 changes: 5 additions & 5 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def test_crosstab_report_view(self):
from .report_generators import ProductClientSalesMatrix

data = ProductClientSalesMatrix(
crosstab_compute_reminder=True,
crosstab_compute_remainder=True,
crosstab_ids=[self.client1.pk, self.client2.pk],
).get_report_data()

Expand All @@ -446,7 +446,7 @@ def test_crosstab_report_view(self):
reverse("product_crosstab_client"),
data={
"client_id": [self.client1.pk, self.client2.pk],
"crosstab_compute_reminder": True,
"crosstab_compute_remainder": True,
},
HTTP_X_REQUESTED_WITH="XMLHttpRequest",
)
Expand All @@ -456,15 +456,15 @@ def test_crosstab_report_view(self):

def test_crosstab_report_view_clumns_on_fly(self):
data = ProductClientSalesMatrix2(
crosstab_compute_reminder=True,
crosstab_compute_remainder=True,
crosstab_ids=[self.client1.pk, self.client2.pk],
).get_report_data()

response = self.client.get(
reverse("crosstab-columns-on-fly"),
data={
"client_id": [self.client1.pk, self.client2.pk],
"crosstab_compute_reminder": True,
"crosstab_compute_remainder": True,
},
HTTP_X_REQUESTED_WITH="XMLHttpRequest",
)
Expand All @@ -477,7 +477,7 @@ def test_chart_settings(self):
reverse("product_crosstab_client"),
data={
"client_id": [self.client1.pk, self.client2.pk],
"crosstab_compute_reminder": True,
"crosstab_compute_remainder": True,
},
HTTP_X_REQUESTED_WITH="XMLHttpRequest",
)
Expand Down

0 comments on commit a5cf80a

Please sign in to comment.