Commit 29281064 authored by Dexter Sapugay's avatar Dexter Sapugay

final

parent 2a6949c7
from django.contrib import admin from django.contrib import admin
from .models import Employee, Productivity, Position, History, User, SummaryReport from .models import Employee, Productivity, Position, History, IPSUser, SummaryReport
admin.site.register(User) admin.site.register(IPSUser)
admin.site.register(Employee) admin.site.register(Employee)
admin.site.register(Productivity) admin.site.register(Productivity)
admin.site.register(Position) admin.site.register(Position)
......
# Generated by Django 4.2 on 2023-04-04 10:24 # Generated by Django 4.2 on 2023-04-04 18:18
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
...@@ -8,78 +8,116 @@ class Migration(migrations.Migration): ...@@ -8,78 +8,116 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = []
]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='Employee', name="Employee",
fields=[ fields=[
('employee_id', models.CharField(max_length=10, primary_key=True, serialize=False)), (
('employee_fname', models.CharField(max_length=255)), "employee_id",
('employee_mname', models.CharField(blank=True, max_length=255, null=True)), models.CharField(max_length=10, primary_key=True, serialize=False),
('employee_lname', models.CharField(max_length=255)), ),
('employee_sex', models.CharField(max_length=1)), ("employee_fname", models.CharField(max_length=255)),
('employee_bday', models.DateField()), (
('employee_email', models.CharField(max_length=255)), "employee_mname",
('employee_num', models.CharField(blank=True, max_length=10, null=True)), models.CharField(blank=True, max_length=255, null=True),
('employee_emergnum', models.CharField(blank=True, max_length=10, 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( migrations.CreateModel(
name='Position', name="IPSUser",
fields=[ fields=[
('position_id', models.CharField(max_length=10, primary_key=True, serialize=False)), (
('history_no', models.CharField(max_length=10)), "id",
('position_name', models.CharField(max_length=255)), 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( migrations.CreateModel(
name='Productivity', name="Position",
fields=[ fields=[
('report_no', models.AutoField(max_length=10, primary_key=True, serialize=False)), (
('prod_date', models.DateField(null=True)), "position_id",
('workinghours', models.DurationField()), models.CharField(max_length=10, primary_key=True, serialize=False),
('remarks', models.TextField(blank=True, max_length=2000)), ),
('prod_score', models.FloatField(null=True)), ("history_no", models.CharField(max_length=10)),
('joborder_no', models.CharField(max_length=10)), ("position_name", models.CharField(max_length=255)),
('process', models.CharField(max_length=255)),
('status', models.CharField(max_length=255)),
], ],
), ),
migrations.CreateModel( migrations.CreateModel(
name='SummaryReport', name="Productivity",
fields=[ fields=[
('sr_no', models.AutoField(primary_key=True, serialize=False)), ("report_no", models.AutoField(primary_key=True, serialize=False)),
('prod_score', models.IntegerField()), ("prod_date", models.DateField(null=True)),
('date', models.DateField()), ("workinghours", models.DurationField()),
('totalworkhrs', 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( migrations.CreateModel(
name='User', name="SummaryReport",
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ("sr_no", models.AutoField(primary_key=True, serialize=False)),
('username', models.CharField(max_length=300, unique=True)), ("employee_name", models.CharField(default="No Name", max_length=255)),
('password', models.CharField(max_length=300)), ("prod_score", models.FloatField()),
('first_name', models.CharField(max_length=300)), ("date", models.DateField()),
('last_name', models.CharField(max_length=300)), ("totalworkhrs", models.DurationField()),
('birthday', models.DateField()),
('sex', models.CharField(max_length=50)),
], ],
), ),
migrations.CreateModel( migrations.CreateModel(
name='History', name="History",
fields=[ fields=[
('history_no', models.CharField(max_length=10, primary_key=True, serialize=False)), (
('employee_fname', models.CharField(max_length=255)), "history_no",
('employee_mname', models.CharField(blank=True, max_length=255)), models.CharField(max_length=10, primary_key=True, serialize=False),
('employee_lname', models.CharField(max_length=255)), ),
('position_name', models.CharField(max_length=255)), ("employee_fname", models.CharField(max_length=255)),
('position_startdate', models.DateField()), ("employee_mname", models.CharField(blank=True, max_length=255)),
('position_enddate', models.DateField(null=True)), ("employee_lname", models.CharField(max_length=255)),
('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='IPSapp.employee')), ("position_name", models.CharField(max_length=255)),
('position', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='IPSapp.position')), ("position_startdate", models.DateField()),
("position_enddate", models.DateField(null=True)),
(
"employee",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="IPSapp.employee",
),
),
(
"position",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="IPSapp.position",
),
),
], ],
), ),
] ]
# Generated by Django 4.2 on 2023-04-04 12:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('IPSapp', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='summaryreport',
name='employee_name',
field=models.CharField(default='No Name', max_length=255),
),
migrations.AlterField(
model_name='productivity',
name='report_no',
field=models.AutoField(primary_key=True, serialize=False),
),
]
# Generated by Django 4.2 on 2023-04-04 13:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('IPSapp', '0002_summaryreport_employee_name_and_more'),
]
operations = [
migrations.AlterField(
model_name='summaryreport',
name='prod_score',
field=models.FloatField(),
),
]
...@@ -128,7 +128,7 @@ class SummaryReport(models.Model): ...@@ -128,7 +128,7 @@ class SummaryReport(models.Model):
# ) # )
# ] # ]
class User(models.Model): class IPSUser(models.Model):
username = models.CharField(max_length=300, unique=True) username = models.CharField(max_length=300, unique=True)
password = models.CharField(max_length=300) password = models.CharField(max_length=300)
first_name = models.CharField(max_length=300) first_name = models.CharField(max_length=300)
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<p> <p>
Signed in as: Signed in as:
<b <b
>marc leighton chua >Bo Caj
<!-- PUT INFO HERE --></b <!-- PUT INFO HERE --></b
> >
</p> </p>
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
</div> </div>
<div class="sidebar-hover"> <div class="sidebar-hover">
<a href=""> <a href="{% url 'signin' %}">
<div class="icon-align sidebar-button"> <div class="icon-align sidebar-button">
<i class="gg-log-out"></i> <i class="gg-log-out"></i>
</div> </div>
......
<table>
<thead>
<tr>
<th>SR No</th>
<th>Employee Name</th>
<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.sr_no}}</td>
<td>{{ row.employee_name}}</td>
<td>{{ row.date}}</td>
<td>{{ row.prod_score }}</td>
<td>{{ row.totalworkhrs }}</td>
<!-- add more cells for additional fields -->
</tr>
{% endfor %}
</tbody>
</table>
...@@ -2,7 +2,7 @@ from django.shortcuts import render, redirect ...@@ -2,7 +2,7 @@ from django.shortcuts import render, redirect
import io import io
import csv import csv
from datetime import datetime, timedelta from datetime import datetime, timedelta
from .models import Productivity, User, SummaryReport from .models import Productivity, IPSUser, SummaryReport
from django.contrib import messages from django.contrib import messages
from django.utils.dateparse import parse_date, parse_duration from django.utils.dateparse import parse_date, parse_duration
# from dateutil.parser import parse as parse_date # from dateutil.parser import parse as parse_date
...@@ -20,7 +20,7 @@ def home(request): ...@@ -20,7 +20,7 @@ def home(request):
def my_view(request): def my_view(request):
user = User.objects.getUsername() user = IPSUser.objects.getUsername()
return render(request, 'EmployeeProdDB/base.html', {'user': user}) return render(request, 'EmployeeProdDB/base.html', {'user': user})
# def show_csv_data2(request): # def show_csv_data2(request):
...@@ -39,11 +39,11 @@ def signup(request): ...@@ -39,11 +39,11 @@ def signup(request):
sex = request.POST.get('sex') sex = request.POST.get('sex')
if pword==confirm_pword: if pword==confirm_pword:
if User.objects.filter(username=uname).exists(): if IPSUser.objects.filter(username=uname).exists():
messages.error(request, 'Username already taken.') messages.error(request, 'Username already taken.')
return redirect('signup') return redirect('signup')
else: else:
user = User.objects.create(username = uname, password = pword, first_name = fname, last_name = lname, birthday = bday, sex = sex) user = IPSUser.objects.create(username = uname, password = pword, first_name = fname, last_name = lname, birthday = bday, sex = sex)
user.save() user.save()
messages.success(request, 'User account created.') messages.success(request, 'User account created.')
return redirect('loginpage') return redirect('loginpage')
...@@ -60,10 +60,10 @@ def loginpage(request): ...@@ -60,10 +60,10 @@ def loginpage(request):
uname = request.POST.get('username') uname = request.POST.get('username')
pword = request.POST.get('password') pword = request.POST.get('password')
accountList = User.objects.filter(username = uname) accountList = IPSUser.objects.filter(username = uname)
if(len(accountList) > 0): if(len(accountList) > 0):
findUser = User.objects.get(username= uname) findUser = IPSUser.objects.get(username= uname)
if(findUser.getPassword() == pword): if(findUser.getPassword() == pword):
global loggedInUser global loggedInUser
......
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