Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
JARVIS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacob Dylan D. Vitug
JARVIS
Commits
07abeafd
Commit
07abeafd
authored
Apr 04, 2023
by
DwyxE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nav bar buttons have been linked
parent
394320e2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
101 additions
and
90 deletions
+101
-90
settings.cpython-39.pyc
IPS/IPS/__pycache__/settings.cpython-39.pyc
+0
-0
models.cpython-39.pyc
IPS/IPSapp/__pycache__/models.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
IPS/IPSapp/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
IPS/IPSapp/__pycache__/views.cpython-39.pyc
+0
-0
base.html
IPS/IPSapp/templates/EmployeeProdDB/base.html
+3
-3
urls.py
IPS/IPSapp/urls.py
+1
-1
views.py
IPS/IPSapp/views.py
+97
-86
No files found.
IPS/IPS/__pycache__/settings.cpython-39.pyc
View file @
07abeafd
No preview for this file type
IPS/IPSapp/__pycache__/models.cpython-39.pyc
View file @
07abeafd
No preview for this file type
IPS/IPSapp/__pycache__/urls.cpython-39.pyc
View file @
07abeafd
No preview for this file type
IPS/IPSapp/__pycache__/views.cpython-39.pyc
View file @
07abeafd
No preview for this file type
IPS/IPSapp/templates/EmployeeProdDB/base.html
View file @
07abeafd
...
...
@@ -37,7 +37,7 @@
<p>
Signed in as:
<b
>
test user
>
{{ user }}
<!-- PUT INFO HERE -->
</b
>
</p>
...
...
@@ -66,7 +66,7 @@
</div>
<div
class=
"sidebar-hover"
>
<a
href=
""
>
<a
href=
"
/upload_csv
"
>
<div
class=
"icon-align sidebar-button"
>
<i
class=
"gg-import"
></i>
</div>
...
...
@@ -76,7 +76,7 @@
</div>
<div
class=
"sidebar-hover"
>
<a
href=
""
>
<a
href=
"
/
"
>
<div
class=
"icon-align sidebar-button"
>
<i
class=
"gg-log-out"
></i>
</div>
...
...
IPS/IPSapp/urls.py
View file @
07abeafd
...
...
@@ -10,6 +10,6 @@ urlpatterns = [
path
(
'show_csv_data/'
,
views
.
show_csv_data
,
name
=
'show_csv_data'
),
path
(
'signup/'
,
views
.
signup
,
name
=
'signup'
),
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
IPS/IPSapp/views.py
View file @
07abeafd
...
...
@@ -9,10 +9,21 @@ from django.utils.dateparse import parse_date, parse_duration
from
django.views.generic
import
View
# from chartjs.views.lines import BaseLineChartView
# import Chart from 'chart.js/auto';
from
django.contrib.auth.decorators
import
login_required
def
home
(
request
):
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
):
if
request
.
method
==
'POST'
:
uname
=
request
.
POST
.
get
(
'username'
)
...
...
@@ -107,92 +118,92 @@ def upload_csv(request):
def
upload_csv
(
request
):
if
request
.
method
==
'POST'
:
csv_file
=
request
.
FILES
[
'csv_file'
]
if
not
csv_file
.
name
.
endswith
(
'.csv'
):
messages
.
error
(
request
,
'This is not a CSV file'
)
else
:
# read the data from the uploaded file
csv_data
=
csv
.
reader
(
(
line
.
decode
(
'utf-8'
)
for
line
in
csv_file
),
delimiter
=
','
,
quotechar
=
'"'
)
encountered_empty_row
=
False
# Loop through data rows
for
i
,
row
in
enumerate
(
csv_data
):
# Check if this row is the start of a new report
if
row
[
0
]
==
'PRODUCTIVITY REPORT'
:
# Reset variables for the new report
report_no
=
row
[
1
]
employee
=
None
prod_date
=
None
workinghours
=
None
remarks
=
None
prod_score
=
None
joborder_no
=
None
process
=
None
status
=
None
# Skip 8 rows
count
=
0
while
count
<
8
:
next
(
csv_data
)
count
+=
1
# Reset the flag for encountered empty row
encountered_empty_row
=
False
# Read headers from 9th row
headers
=
next
(
csv_data
)
jo_no_index
=
headers
.
index
(
'JO NO'
)
status_index
=
headers
.
index
(
'Status'
)
process_index
=
headers
.
index
(
'Process'
)
duration_index
=
headers
.
index
(
'Duration'
)
remarks_index
=
headers
.
index
(
'Remarks'
)
elif
all
(
cell
==
''
for
cell
in
row
):
# Check if an empty row has been encountered before
if
encountered_empty_row
:
# Stop processing data as we have encountered two consecutive empty rows
break
else
:
# Set the flag to indicate that an empty row has been encountered
encountered_empty_row
=
True
else
:
# Read data from the row
joborder_no
=
row
[
jo_no_index
]
status
=
row
[
status_index
]
process
=
row
[
process_index
]
workinghours
=
row
[
duration_index
]
remarks
=
row
[
remarks_index
]
# Convert working hours to a Duration object
if
workinghours
:
hours
,
minutes
=
map
(
int
,
workinghours
.
split
(
':'
))
workinghours
=
timedelta
(
hours
=
hours
,
minutes
=
minutes
)
# Create a new productivity object
Productivity
.
objects
.
create
(
#report_no=report_no,
#employee=employee,
#prod_date=prod_date,
workinghours
=
workinghours
,
remarks
=
remarks
,
#prod_score=prod_score,
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'
)
#
#
def chart_view(request):
#
#
Define the data pool
#
def upload_csv(request):
#
if request.method == 'POST':
#
csv_file = request.FILES['csv_file']
#
if not csv_file.name.endswith('.csv'):
#
messages.error(request, 'This is not a CSV file')
#
else:
#
# read the data from the uploaded file
#
csv_data = csv.reader(
#
(line.decode('utf-8') for line in csv_file),
#
delimiter=',',
#
quotechar='"'
#
)
#
encountered_empty_row = False
#
# Loop through data rows
#
for i, row in enumerate(csv_data):
#
# Check if this row is the start of a new report
#
if row[0] == 'PRODUCTIVITY REPORT':
#
# Reset variables for the new report
#
report_no = row[1]
#
employee = None
#
prod_date = None
#
workinghours = None
#
remarks = None
#
prod_score = None
#
joborder_no = None
#
process = None
#
status = None
#
# Skip 8 rows
#
count = 0
#
while count < 8:
#
next(csv_data)
#
count += 1
#
# Reset the flag for encountered empty row
#
encountered_empty_row = False
#
# Read headers from 9th row
#
headers = next(csv_data)
#
jo_no_index = headers.index('JO NO')
#
status_index = headers.index('Status')
#
process_index = headers.index('Process')
#
duration_index = headers.index('Duration')
#
remarks_index = headers.index('Remarks')
#
elif all(cell == '' for cell in row):
#
# Check if an empty row has been encountered before
#
if encountered_empty_row:
#
# Stop processing data as we have encountered two consecutive empty rows
#
break
#
else:
#
# Set the flag to indicate that an empty row has been encountered
#
encountered_empty_row = True
#
else:
#
# Read data from the row
#
joborder_no = row[jo_no_index]
#
status = row[status_index]
#
process = row[process_index]
#
workinghours = row[duration_index]
#
remarks = row[remarks_index]
#
# Convert working hours to a Duration object
#
if workinghours:
#
hours, minutes = map(int, workinghours.split(':'))
#
workinghours = timedelta(hours=hours, minutes=minutes)
#
# Create a new productivity object
#
Productivity.objects.create(
#
#report_no=report_no,
#
#employee=employee,
#
#prod_date=prod_date,
#
workinghours=workinghours,
#
remarks=remarks,
#
#prod_score=prod_score,
#
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')
# def chart_view(request):
# Define the data pool
# data_pool = DataPool(
# series=[{
# 'options': {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment