Commit 80bdb954 authored by Dexter Sapugay's avatar Dexter Sapugay

nutz

parent d9f9de23
from django.contrib import admin from django.contrib import admin
from .models import Employee, Productivity, JobOrder, Position, History, Dashboard from .models import Employee, Productivity, JobOrder, Position, History, Dashboard, User
admin.site.register(User)
admin.site.register(Employee) admin.site.register(Employee)
admin.site.register(Productivity) admin.site.register(Productivity)
admin.site.register(JobOrder) admin.site.register(JobOrder)
......
# Generated by Django 4.0.4 on 2023-02-14 17:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('EmployeeProdDB', '0001_initial'),
]
operations = [
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)),
],
),
]
...@@ -107,3 +107,33 @@ class Dashboard(models.Model): ...@@ -107,3 +107,33 @@ class Dashboard(models.Model):
# name='dashboard_fk2' # name='dashboard_fk2'
# ) # )
# ] # ]
class User(models.Model):
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)
objects = models.Manager()
def getUsername(self):
return self.username
def getPassword(self):
return self.password
def getFirstName(self):
return self.first_name
def getLastName(self):
return self.last_name
def getBirthday(self):
return self.birthday
def getSex(self):
return self.sex
def __str__(self):
return "pk: " + str(self.pk) + ": " + self.username + ", " + self.first_name + " " + self.last_name + ", " + str(self.birthday) + ", " + self.sex
...@@ -10,10 +10,7 @@ ...@@ -10,10 +10,7 @@
<div style="width:100%"> <div style="width:100%">
<h1>TOPC</h1> <h1>TOPC</h1>
<form> <form>
<input type="file" id="file-input"> <a href="{% url 'upload_csv' %}"><button type="button" class="btn btn-danger" style="font-family:'Poppins'; position:absolute; right:2%; top:5%;">Import File</button></a>
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Import File</button>
</form> </form>
</div> </div>
</body> </body>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
{% block content %} {% block content %}
<div class="login-box"> <div class="login-box">
<div class="login-logo"> <div class="login-logo">
<b>Voting System</b> <b>Individual Productivity System TOPC</b>
</div> </div>
<div class="login-box-body"> <div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p> <p class="login-box-msg">Sign in to start your session</p>
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
</form> </form>
<a href="{% url 'createaccount' %}"><button>SIGN UP HERE</button></a>
</div> </div>
</div> </div>
{% endblock content %} {% endblock content %}
......
...@@ -4,7 +4,8 @@ from . import views ...@@ -4,7 +4,8 @@ from . import views
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', views.home, name='home'), path('', views.loginpage, name='loginpage'),
path('home/', views.home, name='home'),
path('upload_csv/', views.upload_csv, name = 'upload_csv'), path('upload_csv/', views.upload_csv, name = 'upload_csv'),
path('show_csv_data/', views.show_csv_data, name ='show_csv_data') path('show_csv_data/', views.show_csv_data, name ='show_csv_data')
#path('', views.login_page, name='loginpage'), #path('', views.login_page, name='loginpage'),
......
import csv import csv
from datetime import datetime from datetime import datetime
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from .models import Productivity from .models import Productivity, User
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
def home(request): def home(request):
return render(request, 'EmployeeProdDB/index.html') return render(request, 'EmployeeProdDB/home.html')
def loginpage(request):
if(request.method == "POST"):
uname = request.POST.get('username')
pword = request.POST.get('password')
accountList = User.objects.filter(username = uname)
if(len(accountList) > 0):
findUser = User.objects.get(username= uname)
if(findUser.getPassword() == pword):
global loggedInUser
loggedInUser = findUser
messages.success(request, 'SUCCESSFULLY LOGGED IN!')
return redirect('home')
else:
messages.info(request, 'Invalid Username or Password')
return render(request, 'EmployeeProdDB/loginpage.html')
else:
messages.info(request, 'User Account Not Found')
return render(request, 'EmployeeProdDB/loginpage.html')
else:
return render(request, 'EmployeeProdDB/loginpage.html')
def upload_csv(request): def upload_csv(request):
if request.method == 'POST': if request.method == 'POST':
...@@ -56,6 +80,8 @@ def upload_csv(request): ...@@ -56,6 +80,8 @@ def upload_csv(request):
def show_csv_data(request): def show_csv_data(request):
csv_data = Productivity.objects.all() csv_data = Productivity.objects.all()
return render(request, 'EmployeeProdDB/show_csv_data.html', {'csv_data': csv_data}) return render(request, 'EmployeeProdDB/show_csv_data.html', {'csv_data': csv_data})
#def handle_file_upload(request): #def handle_file_upload(request):
# if request.method == 'POST': # if request.method == 'POST':
# file = request.FILES.get('file-input') # file = request.FILES.get('file-input')
......
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