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

Adapt project for Jazzmin Admin Template, added spanish language support #72

Open
wants to merge 5 commits into
base: master
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ demoproject/static
*nbproject*
*devserver*
*.idea*
.vscode
docs/build/*
build/
dist/
Expand Down
37 changes: 27 additions & 10 deletions admin_tools_stats/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class DashboardStatsCriteriaInline(admin.TabularInline):
)
autocomplete_fields = ("criteria",)
extra = 0
verbose_name = _("Criteria")
verbose_name_plural = _("Criterias")

def criteria__dynamic_criteria_field_name(self, obj):
return format_html(
Expand Down Expand Up @@ -105,23 +107,38 @@ class DashboardStatsAdmin(admin.ModelAdmin):
"fields": (
"graph_key",
"graph_title",
("model_app_name", "model_name", "date_field_name"),
("operation_field_name", "distinct"),
("user_field_name", "show_to_users"),
("allowed_type_operation_field_name", "type_operation_field_name"),
("allowed_chart_types", "default_chart_type"),
(
"allowed_time_scales",
"default_time_scale",
"default_time_period",
),
"operation_field_name", "distinct",
"user_field_name", "show_to_users",
"y_axis_format",
"default_multiseries_criteria",
"is_visible",
"cache_values",
),
},
),
( _("Related model"),
{
"fields": ("model_app_name", "model_name", "date_field_name"),
}
),
(
_("Time scale"),
{
"fields": (
"allowed_time_scales",
"default_time_scale",
"default_time_period",
),
}
),
(
_("Chart type"),{
"fields": ("allowed_type_operation_field_name",
"type_operation_field_name",
"allowed_chart_types",
"default_chart_type"),
}
)
)
list_display = (
"id",
Expand Down
3 changes: 2 additions & 1 deletion admin_tools_stats/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.apps import AppConfig

from django.utils.translation import gettext_lazy as _

class AdminChartsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "admin_tools_stats"
verbose_name = _("Tools stats")
26 changes: 13 additions & 13 deletions admin_tools_stats/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django import forms
from django.utils.timezone import now

from django.utils.translation import gettext_lazy as _

class ChartSettingsForm(forms.Form):
def __init__(self, stats, user=None, *args, **kwargs):
Expand All @@ -19,7 +19,7 @@ def __init__(self, stats, user=None, *args, **kwargs):
)
self.fields[f"select_box_dynamic_{ch_filter.id}"].widget.attrs[
"class"
] = "chart-input"
] = "chart-input form-control"

self.fields["graph_key"] = forms.CharField(
initial=stats.graph_key,
Expand All @@ -42,15 +42,15 @@ def __init__(self, stats, user=None, *args, **kwargs):
)
self.fields["select_box_multiple_series"].widget.attrs[
"class"
] = "chart-input select_box_multiple_series"
] = "chart-input form-control select_box_multiple_series"

if len(stats.allowed_type_operation_field_name) > 1:
self.fields["select_box_operation"] = forms.ChoiceField(
choices=stats.allowed_type_operation_field_name_choices(),
label="Operation",
initial=stats.type_operation_field_name,
)
self.fields["select_box_operation"].widget.attrs["class"] = "chart-input"
self.fields["select_box_operation"].widget.attrs["class"] = "chart-input form-control"

operations_list = stats.get_operations_list()
if operations_list and len(operations_list) > 1:
Expand All @@ -59,37 +59,37 @@ def __init__(self, stats, user=None, *args, **kwargs):
label="Field",
initial=operations_list[0],
)
self.fields["select_box_operation_field"].widget.attrs["class"] = "chart-input"
self.fields["select_box_operation_field"].widget.attrs["class"] = "chart-input form-control"

if len(stats.allowed_time_scales) > 1:
self.fields["select_box_interval"] = forms.ChoiceField(
choices=stats.allowed_time_scales_choices(),
label="Scale",
label=_("Scale"),
initial=stats.default_time_scale,
)
self.fields["select_box_interval"].widget.attrs["class"] = "chart-input"
self.fields["select_box_interval"].widget.attrs["class"] = "chart-input form-control"

if len(stats.allowed_chart_types) > 1:
self.fields["select_box_chart_type"] = forms.ChoiceField(
choices=stats.allowed_chart_types_choices(),
label="Chart",
label=_("Chart"),
initial=stats.default_chart_type,
)
self.fields["select_box_chart_type"].widget.attrs[
"class"
] = "chart-input select_box_chart_type"
] = "chart-input form-control select_box_chart_type"

self.fields["time_since"] = forms.DateField(
label="Since",
label=_("Since"),
initial=(now() - timedelta(days=stats.default_time_period)).strftime("%Y-%m-%d"),
widget=forms.TextInput(
attrs={"type": "date", "class": "chart-input select_box_date_since"}
attrs={"type": "date", "class": "chart-input form-control select_box_date_since"}
),
)
self.fields["time_until"] = forms.DateField(
label="Until",
label=_("Until"),
initial=now().strftime("%Y-%m-%d"),
widget=forms.TextInput(
attrs={"type": "date", "class": "chart-input select_box_date_until"}
attrs={"type": "date", "class": "chart-input form-control select_box_date_until"}
),
)
Loading
Loading