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
# Loop through data rows # encountered_empty_row = False
for i, row in enumerate(csv_data):
# Check if this row is the start of a new report # # Loop through data rows
if row[0] == 'PRODUCTIVITY REPORT': # for i, row in enumerate(csv_data):
# Reset variables for the new report # # Check if this row is the start of a new report
report_no = row[1] # if row[0] == 'PRODUCTIVITY REPORT':
employee = None # # Reset variables for the new report
prod_date = None # report_no = row[1]
workinghours = None # employee = None
remarks = None # prod_date = None
prod_score = None # workinghours = None
joborder_no = None # remarks = None
process = None # prod_score = None
status = None # joborder_no = None
# process = None
# Skip 8 rows # status = None
count = 0
while count < 8: # # Skip 8 rows
next(csv_data) # count = 0
count += 1 # while count < 8:
# next(csv_data)
# Reset the flag for encountered empty row # count += 1
encountered_empty_row = False
# # Reset the flag for encountered empty row
# Read headers from 9th row # encountered_empty_row = False
headers = next(csv_data)
jo_no_index = headers.index('JO NO') # # Read headers from 9th row
status_index = headers.index('Status') # headers = next(csv_data)
process_index = headers.index('Process') # jo_no_index = headers.index('JO NO')
duration_index = headers.index('Duration') # status_index = headers.index('Status')
remarks_index = headers.index('Remarks') # process_index = headers.index('Process')
elif all(cell == '' for cell in row): # duration_index = headers.index('Duration')
# Check if an empty row has been encountered before # remarks_index = headers.index('Remarks')
if encountered_empty_row: # elif all(cell == '' for cell in row):
# Stop processing data as we have encountered two consecutive empty rows # # Check if an empty row has been encountered before
break # if encountered_empty_row:
else: # # Stop processing data as we have encountered two consecutive empty rows
# Set the flag to indicate that an empty row has been encountered # break
encountered_empty_row = True # else:
else: # # Set the flag to indicate that an empty row has been encountered
# Read data from the row # encountered_empty_row = True
joborder_no = row[jo_no_index] # else:
status = row[status_index] # # Read data from the row
process = row[process_index] # joborder_no = row[jo_no_index]
workinghours = row[duration_index] # status = row[status_index]
remarks = row[remarks_index] # process = row[process_index]
# workinghours = row[duration_index]
# Convert working hours to a Duration object # remarks = row[remarks_index]
if workinghours:
hours, minutes = map(int, workinghours.split(':')) # # Convert working hours to a Duration object
workinghours = timedelta(hours=hours, minutes=minutes) # if workinghours:
# hours, minutes = map(int, workinghours.split(':'))
# Create a new productivity object # workinghours = timedelta(hours=hours, minutes=minutes)
Productivity.objects.create(
#report_no=report_no, # # Create a new productivity object
#employee=employee, # Productivity.objects.create(
#prod_date=prod_date, # #report_no=report_no,
workinghours=workinghours, # #employee=employee,
remarks=remarks, # #prod_date=prod_date,
#prod_score=prod_score, # workinghours=workinghours,
joborder_no=joborder_no, # remarks=remarks,
process=process, # #prod_score=prod_score,
status=status # joborder_no=joborder_no,
) # process=process,
# 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