Commit 96c0fcfa authored by DwyxE's avatar DwyxE

still cant figure out the no such table error

parent 53a8ac75
from django.contrib import admin
from .models import Employee, Productivity, Position, History, User
from .models import Employee, Productivity, Position, History, User, SummaryReport
admin.site.register(User)
admin.site.register(Employee)
admin.site.register(Productivity)
admin.site.register(Position)
admin.site.register(History)
admin.site.register(SummaryReport)
# Generated by Django 4.0.4 on 2023-04-03 13:53
# Generated by Django 4.2 on 2023-04-04 06:46
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Employee',
fields=[
('employee_id', models.CharField(max_length=10, primary_key=True, serialize=False)),
('employee_fname', models.CharField(max_length=255)),
('employee_mname', models.CharField(blank=True, max_length=255, null=True)),
('employee_lname', models.CharField(max_length=255)),
('employee_sex', models.CharField(max_length=1)),
('employee_bday', models.DateField()),
('employee_email', models.CharField(max_length=255)),
('employee_num', models.CharField(blank=True, max_length=10, null=True)),
('employee_emergnum', models.CharField(blank=True, max_length=10, null=True)),
],
),
migrations.CreateModel(
name='Position',
fields=[
('position_id', models.CharField(max_length=10, primary_key=True, serialize=False)),
('history_no', models.CharField(max_length=10)),
('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=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=300, unique=True)),
('password', models.CharField(max_length=300)),
('first_name', models.CharField(max_length=300)),
('last_name', models.CharField(max_length=300)),
('birthday', models.DateField()),
('sex', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='History',
fields=[
('history_no', models.CharField(max_length=10, primary_key=True, serialize=False)),
('employee_fname', models.CharField(max_length=255)),
('employee_mname', models.CharField(blank=True, max_length=255)),
('employee_lname', models.CharField(max_length=255)),
('position_name', models.CharField(max_length=255)),
('position_startdate', models.DateField()),
('position_enddate', models.DateField(null=True)),
('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='EmployeeProdDB.employee')),
('position', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='EmployeeProdDB.position')),
],
),
]
......@@ -87,8 +87,13 @@ class History(models.Model):
# )
# ]
class SummaryPR(models.Model):
productivity_score = models.IntegerField(max_length=3)
# class SummaryPR(models.Model):
# productivity_score = models.IntegerField()
# date = models.DateField()
# totalworkhrs = models.DurationField()
class SummaryReport(models.Model):
prod_score = models.IntegerField()
date = models.DateField()
totalworkhrs = models.DurationField()
......
<table>
<thead>
<tr>
<th>Date</th>
<th>Prod Score</th>
<th>Total Work Hrs</th>
<!-- add more headers for additional fields -->
</tr>
</thead>
<tbody>
{% for row in csv_data %}
<tr>
<td>{{ row.date}}</td>
<td>{{ row.productivity_score }}</td>
<td>{{ row.totalworkhrs }}</td>
<!-- add more cells for additional fields -->
</tr>
{% endfor %}
</tbody>
</table>
......@@ -8,7 +8,8 @@ urlpatterns = [
path('home/', views.home, name='home'),
path('upload_csv/', views.upload_csv, name = 'upload_csv'),
path('show_csv_data/', views.show_csv_data, name ='show_csv_data'),
path('signup/', views.signup, name='signup')
path('signup/', views.signup, name='signup'),
path('show_csv_data2/', views.show_csv_data2, name='show_csv_data2')
#path('', views.login_page, name='loginpage'),
]
\ No newline at end of file
......@@ -2,14 +2,14 @@ import io
import csv
from datetime import datetime, timedelta
from django.shortcuts import render, redirect
from .models import Productivity, User, SummaryPR
from .models import Productivity, User, SummaryReport
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';
# from chartjs.views.lines import BaseLineChartView
# import Chart from 'chart.js/auto';
def home(request):
return render(request, 'EmployeeProdDB/home.html')
......@@ -149,41 +149,43 @@ 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 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 show_csv_data2(request):
csv_data = SummaryReport.objects.all()
return render(request, 'EmployeeProdDB/show_csv_data2.html', {'csv_data': csv_data})
\ No newline at end of file
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