Commit 07abeafd authored by DwyxE's avatar DwyxE

nav bar buttons have been linked

parent 394320e2
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<p> <p>
Signed in as: Signed in as:
<b <b
>test user >{{ user }}
<!-- PUT INFO HERE --></b <!-- PUT INFO HERE --></b
> >
</p> </p>
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</div> </div>
<div class="sidebar-hover"> <div class="sidebar-hover">
<a href=""> <a href="/upload_csv">
<div class="icon-align sidebar-button"> <div class="icon-align sidebar-button">
<i class="gg-import"></i> <i class="gg-import"></i>
</div> </div>
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
</div> </div>
<div class="sidebar-hover"> <div class="sidebar-hover">
<a href=""> <a href="/">
<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>
......
...@@ -10,6 +10,6 @@ urlpatterns = [ ...@@ -10,6 +10,6 @@ urlpatterns = [
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('signup/', views.signup, name='signup'), path('signup/', views.signup, name='signup'),
path('show_csv_data2/', views.show_csv_data2, name='show_csv_data2') path('show_csv_data2/', views.show_csv_data2, name='show_csv_data2')
#path('', views.login_page, name='loginpage'), # path('', views.login_page, name='loginpage'),
] ]
\ No newline at end of file
...@@ -9,10 +9,21 @@ from django.utils.dateparse import parse_date, parse_duration ...@@ -9,10 +9,21 @@ from django.utils.dateparse import parse_date, parse_duration
from django.views.generic import View from django.views.generic import View
# from chartjs.views.lines import BaseLineChartView # from chartjs.views.lines import BaseLineChartView
# import Chart from 'chart.js/auto'; # import Chart from 'chart.js/auto';
from django.contrib.auth.decorators import login_required
def home(request): def home(request):
return render(request, 'EmployeeProdDB/home.html') return render(request, 'EmployeeProdDB/home.html')
def my_view(request):
user = User.objects.getUsername()
return render(request, 'EmployeeProdDB/base.html', {'user': user})
# def show_csv_data2(request):
# csv_data = SummaryReport.objects.all()
# return render(request, 'EmployeeProdDB/show_csv_data2.html', {'csv_data': csv_data})
def signup(request): def signup(request):
if request.method == 'POST': if request.method == 'POST':
uname = request.POST.get('username') uname = request.POST.get('username')
...@@ -107,92 +118,92 @@ def upload_csv(request): ...@@ -107,92 +118,92 @@ def upload_csv(request):
def upload_csv(request): # def upload_csv(request):
if request.method == 'POST': # if request.method == 'POST':
csv_file = request.FILES['csv_file'] # csv_file = request.FILES['csv_file']
if not csv_file.name.endswith('.csv'): # if not csv_file.name.endswith('.csv'):
messages.error(request, 'This is not a CSV file') # messages.error(request, 'This is not a CSV file')
else: # else:
# read the data from the uploaded file # # read the data from the uploaded file
csv_data = csv.reader( # csv_data = csv.reader(
(line.decode('utf-8') for line in csv_file), # (line.decode('utf-8') for line in csv_file),
delimiter=',', # delimiter=',',
quotechar='"' # quotechar='"'
) # )
encountered_empty_row = False # encountered_empty_row = False
# Loop through data rows # # Loop through data rows
for i, row in enumerate(csv_data): # for i, row in enumerate(csv_data):
# Check if this row is the start of a new report # # Check if this row is the start of a new report
if row[0] == 'PRODUCTIVITY REPORT': # if row[0] == 'PRODUCTIVITY REPORT':
# Reset variables for the new report # # Reset variables for the new report
report_no = row[1] # report_no = row[1]
employee = None # employee = None
prod_date = None # prod_date = None
workinghours = None # workinghours = None
remarks = None # remarks = None
prod_score = None # prod_score = None
joborder_no = None # joborder_no = None
process = None # process = None
status = None # status = None
# Skip 8 rows # # Skip 8 rows
count = 0 # count = 0
while count < 8: # while count < 8:
next(csv_data) # next(csv_data)
count += 1 # count += 1
# Reset the flag for encountered empty row # # Reset the flag for encountered empty row
encountered_empty_row = False # encountered_empty_row = False
# Read headers from 9th row # # Read headers from 9th row
headers = next(csv_data) # headers = next(csv_data)
jo_no_index = headers.index('JO NO') # jo_no_index = headers.index('JO NO')
status_index = headers.index('Status') # status_index = headers.index('Status')
process_index = headers.index('Process') # process_index = headers.index('Process')
duration_index = headers.index('Duration') # duration_index = headers.index('Duration')
remarks_index = headers.index('Remarks') # remarks_index = headers.index('Remarks')
elif all(cell == '' for cell in row): # elif all(cell == '' for cell in row):
# Check if an empty row has been encountered before # # Check if an empty row has been encountered before
if encountered_empty_row: # if encountered_empty_row:
# Stop processing data as we have encountered two consecutive empty rows # # Stop processing data as we have encountered two consecutive empty rows
break # break
else: # else:
# Set the flag to indicate that an empty row has been encountered # # Set the flag to indicate that an empty row has been encountered
encountered_empty_row = True # encountered_empty_row = True
else: # else:
# Read data from the row # # Read data from the row
joborder_no = row[jo_no_index] # joborder_no = row[jo_no_index]
status = row[status_index] # status = row[status_index]
process = row[process_index] # process = row[process_index]
workinghours = row[duration_index] # workinghours = row[duration_index]
remarks = row[remarks_index] # remarks = row[remarks_index]
# Convert working hours to a Duration object # # Convert working hours to a Duration object
if workinghours: # if workinghours:
hours, minutes = map(int, workinghours.split(':')) # hours, minutes = map(int, workinghours.split(':'))
workinghours = timedelta(hours=hours, minutes=minutes) # workinghours = timedelta(hours=hours, minutes=minutes)
# Create a new productivity object # # Create a new productivity object
Productivity.objects.create( # Productivity.objects.create(
#report_no=report_no, # #report_no=report_no,
#employee=employee, # #employee=employee,
#prod_date=prod_date, # #prod_date=prod_date,
workinghours=workinghours, # workinghours=workinghours,
remarks=remarks, # remarks=remarks,
#prod_score=prod_score, # #prod_score=prod_score,
joborder_no=joborder_no, # joborder_no=joborder_no,
process=process, # process=process,
status=status # status=status
) # )
return render(request, 'EmployeeProdDB/upload_csv.html', {'message': 'Data imported successfully!'}) # return render(request, 'EmployeeProdDB/upload_csv.html', {'message': 'Data imported successfully!'})
return render(request, 'EmployeeProdDB/upload_csv.html') # return render(request, 'EmployeeProdDB/upload_csv.html')
# # def chart_view(request): # def chart_view(request):
# # Define the data pool # Define the data pool
# data_pool = DataPool( # data_pool = DataPool(
# series=[{ # series=[{
# 'options': { # 'options': {
......
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