-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added allowed_chart_types with defaults to kpi & removed chart type m…
…odel
- Loading branch information
Showing
8 changed files
with
192 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,58 @@ | ||
from django.contrib import admin | ||
from .models import Kpi, ReportTemplate, ReportTemplatePage, KpiReportElement, Alarm, ChartType | ||
from .models import ( | ||
Kpi, | ||
ReportTemplate, | ||
ReportTemplatePage, | ||
KpiReportElement, | ||
Alarm, | ||
) | ||
|
||
|
||
class KpiReportElementInline(admin.TabularInline): | ||
model = KpiReportElement | ||
extra = 1 | ||
|
||
|
||
class ReportTemplatePageInline(admin.TabularInline): | ||
model = ReportTemplatePage | ||
extra = 1 | ||
show_change_link = True | ||
inlines = [KpiReportElementInline] | ||
|
||
|
||
@admin.register(Kpi) | ||
class KpiAdmin(admin.ModelAdmin): | ||
list_display = ('name',) | ||
search_fields = ('name',) | ||
list_display = ("name",) | ||
search_fields = ("name",) | ||
|
||
|
||
@admin.register(ReportTemplate) | ||
class ReportTemplateAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'frequency') | ||
list_filter = ('frequency',) | ||
list_display = ("name", "frequency") | ||
list_filter = ("frequency",) | ||
inlines = [ReportTemplatePageInline] | ||
|
||
|
||
@admin.register(ReportTemplatePage) | ||
class ReportTemplatePageAdmin(admin.ModelAdmin): | ||
list_display = ('report_template', 'layout') | ||
list_filter = ('layout',) | ||
list_display = ("report_template", "layout") | ||
list_filter = ("layout",) | ||
inlines = [KpiReportElementInline] | ||
|
||
|
||
@admin.register(KpiReportElement) | ||
class KpiReportElementAdmin(admin.ModelAdmin): | ||
list_display = ('report_page', 'kpi', 'chart_type') | ||
list_filter = ('chart_type',) | ||
list_display = ("report_page", "kpi", "chart_type") | ||
list_filter = ("chart_type",) | ||
|
||
|
||
@admin.register(Alarm) | ||
class AlarmAdmin(admin.ModelAdmin): | ||
list_display = ('id', 'user_type', 'kpi', 'min_value', 'max_value') | ||
list_filter = ('user_type', 'kpi') | ||
search_fields = ('user_type', 'kpi__name') | ||
|
||
def get_kpi_name(self, obj): | ||
return obj.kpi.name | ||
|
||
get_kpi_name.short_description = 'KPI Name' | ||
|
||
@admin.register(ChartType) | ||
class ChartTypeAdmin(admin.ModelAdmin): | ||
list_display = ('id', 'kpi', 'plot_name') | ||
list_filter = ('kpi',) | ||
search_fields = ('kpi__name',) | ||
list_display = ("id", "user_type", "kpi", "min_value", "max_value") | ||
list_filter = ("user_type", "kpi") | ||
search_fields = ("user_type", "kpi__name") | ||
|
||
def get_kpi_name(self, obj): | ||
return obj.kpi.name | ||
|
||
get_kpi_name.short_description = 'KPI Name' | ||
get_kpi_name.short_description = "KPI Name" |
21 changes: 21 additions & 0 deletions
21
smartreport_app/migrations/0002_kpi_allowed_charts_delete_charttype.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 4.2.7 on 2023-11-11 10:27 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('smartreport_app', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='kpi', | ||
name='allowed_charts', | ||
field=models.JSONField(default=list), | ||
), | ||
migrations.DeleteModel( | ||
name='ChartType', | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
smartreport_app/migrations/0003_alter_kpi_allowed_charts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.7 on 2023-11-11 10:30 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('smartreport_app', '0002_kpi_allowed_charts_delete_charttype'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='kpi', | ||
name='allowed_charts', | ||
field=models.JSONField(default=['line', 'bar', 'pie', 'doughnut', 'radar']), | ||
), | ||
] |
19 changes: 19 additions & 0 deletions
19
smartreport_app/migrations/0004_alter_kpi_allowed_charts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 4.2.7 on 2023-11-11 10:30 | ||
|
||
from django.db import migrations, models | ||
import smartreport_app.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('smartreport_app', '0003_alter_kpi_allowed_charts'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='kpi', | ||
name='allowed_charts', | ||
field=models.JSONField(default=smartreport_app.models.DEFAULT_CHART_CHOICES), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.