-
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.
Merge pull request #4 from nyashaChiza/dashboard
Dashboard
- Loading branch information
Showing
926 changed files
with
374,416 additions
and
61,772 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,4 +1,5 @@ | ||
{ | ||
"python.analysis.autoImportCompletions": true, | ||
"python.analysis.typeCheckingMode": "basic" | ||
"python.analysis.typeCheckingMode": "basic", | ||
"taipyStudio.gUI.elementsFilePaths": [] | ||
} |
Empty file.
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,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DashboardConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'dashboard' |
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 @@ | ||
from .dashboard_data import * |
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,23 @@ | ||
from transactions.models import Transaction | ||
from stock.models import Gas | ||
from datetime import datetime | ||
|
||
class DashboardData: | ||
def __init__(self, date: datetime): | ||
self.date = date | ||
|
||
def get_sales_data(self): | ||
|
||
return {"current_month_total_sales": 678, "total_sales": 1000, "last_month_total_sales": 679, "week_total_sales": 67.45 , "total_sales_today":14.7} | ||
|
||
def get_stock_data(self): | ||
|
||
return {"current_month_total_sales_quantity": 340.3,"week_total_sales_quantity":29.4, "total_sales_quantity": 340.3,"last_month_total_sales_quantity": 340.3, "current_available_gas_quantity":230, "total_gas_quantity_sold":1220, "total_requisitions":68 } | ||
|
||
def get_sales_plot_data(self): | ||
|
||
return {"monthly_average":345, "weekly_average":89.3, "daily_average":23.4, "plot_data":[]} | ||
|
||
def get_stock_sales_table_data(self): | ||
|
||
return Transaction.objects.filter().all() |
Empty file.
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,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
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 @@ | ||
from . import custom_tags # noqa: F401 |
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,22 @@ | ||
from django import template | ||
from django.conf import settings | ||
from django.contrib.auth.models import Group | ||
|
||
|
||
register = template.Library() | ||
|
||
@register.filter | ||
def format_amount(value): | ||
""" | ||
Formats a number with thousands separators and two decimal places. | ||
""" | ||
try: | ||
return "{:,.2f}".format(float(value)) | ||
except Exception as e: | ||
settings.LOGGER.error(e) | ||
return 0.00 | ||
|
||
@register.filter | ||
def has_role(user, role): | ||
group = Group.objects.filter(name=role).first() | ||
return group in user.groups.all() |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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,7 @@ | ||
from django.urls import path | ||
from dashboard.views import DashboardView | ||
|
||
|
||
urlpatterns = [ | ||
path('', DashboardView.as_view(), name='dashboard'), | ||
] |
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,12 @@ | ||
from django.views.generic import TemplateView | ||
from dashboard.helpers import DashboardData | ||
from datetime import datetime | ||
|
||
class DashboardView(TemplateView): | ||
template_name = 'dashboard/index.html' | ||
def get_context_data(self, **kwargs): | ||
context = super().get_context_data(**kwargs) | ||
|
||
context['dashboard_data'] = DashboardData(datetime.now()) | ||
return context | ||
|
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
Binary file not shown.
Oops, something went wrong.