Commit 53a8ac75 authored by Dexter Sapugay's avatar Dexter Sapugay

s

parent 966a3a04
from django.contrib import admin
from .models import Employee, Productivity, Position, History, Dashboard, User
from .models import Employee, Productivity, Position, History, User
admin.site.register(User)
admin.site.register(Employee)
admin.site.register(Productivity)
admin.site.register(Position)
admin.site.register(History)
admin.site.register(Dashboard)
# Generated by Django 4.0.4 on 2023-04-02 13:16
# Generated by Django 4.0.4 on 2023-04-03 13:53
from django.db import migrations, models
import django.db.models.deletion
......@@ -34,6 +34,28 @@ class Migration(migrations.Migration):
('position_name', models.CharField(max_length=255)),
],
),
migrations.CreateModel(
name='Productivity',
fields=[
('report_no', models.AutoField(max_length=10, primary_key=True, serialize=False)),
('prod_date', models.DateField(null=True)),
('workinghours', models.DurationField()),
('remarks', models.TextField(blank=True, max_length=2000)),
('prod_score', models.FloatField(null=True)),
('joborder_no', models.CharField(max_length=10)),
('process', models.CharField(max_length=255)),
('status', models.CharField(max_length=255)),
],
),
migrations.CreateModel(
name='SummaryPR',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('productivity_score', models.IntegerField(max_length=3)),
('date', models.DateField()),
('totalworkhrs', models.DurationField()),
],
),
migrations.CreateModel(
name='User',
fields=[
......@@ -46,20 +68,6 @@ class Migration(migrations.Migration):
('sex', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='Productivity',
fields=[
('report_no', models.CharField(max_length=10, primary_key=True, serialize=False)),
('prod_date', models.DateField()),
('workinghours', models.DurationField()),
('remarks', models.TextField(blank=True, max_length=2000)),
('prod_score', models.FloatField(null=True)),
('joborder_no', models.CharField(max_length=10)),
('process', models.CharField(max_length=255)),
('status', models.CharField(max_length=255)),
('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='EmployeeProdDB.employee')),
],
),
migrations.CreateModel(
name='History',
fields=[
......@@ -74,17 +82,4 @@ class Migration(migrations.Migration):
('position', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='EmployeeProdDB.position')),
],
),
migrations.CreateModel(
name='Dashboard',
fields=[
('dashboard_id', models.CharField(max_length=10, primary_key=True, serialize=False)),
('report_no', models.CharField(max_length=255)),
('timespan', models.DurationField()),
('displaytype', models.CharField(max_length=255)),
('total_workinghours', models.DurationField()),
('contribution', models.CharField(max_length=10)),
('avgprodscore', models.FloatField()),
('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='EmployeeProdDB.employee')),
],
),
]
# Generated by Django 4.0.4 on 2023-04-02 14:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('EmployeeProdDB', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='productivity',
name='employee',
),
migrations.AlterField(
model_name='productivity',
name='prod_date',
field=models.DateField(null=True),
),
migrations.AlterField(
model_name='productivity',
name='report_no',
field=models.AutoField(max_length=10, primary_key=True, serialize=False),
),
]
......@@ -87,15 +87,10 @@ class History(models.Model):
# )
# ]
class Dashboard(models.Model):
dashboard_id = models.CharField(max_length=10, primary_key=True)
employee = models.ForeignKey('Employee', on_delete=models.CASCADE)
report_no = models.CharField(max_length=255)
timespan = models.DurationField()
displaytype = models.CharField(max_length=255)
total_workinghours = models.DurationField()
contribution = models.CharField(max_length=10)
avgprodscore = models.FloatField()
class SummaryPR(models.Model):
productivity_score = models.IntegerField(max_length=3)
date = models.DateField()
totalworkhrs = models.DurationField()
# class Meta:
# constraints = [
......
{% extends 'base.html' %}
{% block content %}
<div id="chart-container">
{{ chart|safe }}
</div>
{% endblock %}
\ No newline at end of file
......@@ -2,10 +2,14 @@ import io
import csv
from datetime import datetime, timedelta
from django.shortcuts import render, redirect
from .models import Productivity, User
from .models import Productivity, User, SummaryPR
from django.contrib import messages
from django.utils.dateparse import parse_date, parse_duration
from dateutil.parser import parse as parse_date
from django.shortcuts import render
from django.views.generic import View
from chartjs.views.lines import BaseLineChartView
import Chart from 'chart.js/auto';
def home(request):
return render(request, 'EmployeeProdDB/home.html')
......@@ -145,32 +149,41 @@ def upload_csv(request):
return render(request, 'EmployeeProdDB/upload_csv.html')
def chart_view(request):
# Define the data pool
data_pool = DataPool(
series=[{
'options': {
'source': SummaryPR.objects.all()
},
'terms': [
'my_field_1',
'my_field_2',
]
}]
)
# Define the chart
chart = Chart(
datasource=data_pool,
series_options=[{
'options': {
'type': 'pie',
'stacking': False
},
'terms': {
'my_field_1': 'my_field_2'
}
}]
)
# Render the chart template
return render(request, 'chart_template.html', {
'chart': chart,
})
def show_csv_data(request):
csv_data = Productivity.objects.all()
return render(request, 'EmployeeProdDB/show_csv_data.html', {'csv_data': csv_data})
#def handle_file_upload(request):
# if request.method == 'POST':
# file = request.FILES.get('file-input')
# You can now process the file as needed
# ...
# return render(request, 'uploadpage.html')
#def login_page(request):
# return render(request, 'loginpage.html')
#def upload_file(request):
# if request.method == 'POST':
# form = Upload(request.POST.get('file'), request.FILES.get('file'))
# if form.is_valid():
# form.save()
# return redirect('success_url')
# else:
# form = Upload()
# return render(request, 'uploadpage.html', {'form': form})
#def index(request):
# return render(request, 'index.html')
......@@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
......@@ -38,7 +39,9 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'EmployeeProdDB'
'EmployeeProdDB',
'chartjs'
]
MIDDLEWARE = [
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment