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
cb539dd4
Commit
cb539dd4
authored
May 11, 2023
by
dexsap
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last push
parent
29281064
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
34 deletions
+44
-34
IPSapp.code-workspace
IPS/IPSapp/IPSapp.code-workspace
+10
-0
views.cpython-38.pyc
IPS/IPSapp/__pycache__/views.cpython-38.pyc
+0
-0
views.py
IPS/IPSapp/views.py
+34
-34
No files found.
IPS/IPSapp/IPSapp.code-workspace
0 → 100644
View file @
cb539dd4
{
"folders": [
{
"path": "."
},
{
"path": "../IPS"
}
]
}
\ No newline at end of file
IPS/IPSapp/__pycache__/views.cpython-38.pyc
View file @
cb539dd4
No preview for this file type
IPS/IPSapp/views.py
View file @
cb539dd4
...
...
@@ -79,40 +79,40 @@ def loginpage(request):
else
:
return
render
(
request
,
'EmployeeProdDB/loginpage.html'
)
#
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='"'
#
)
#
#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
#
sr_no = row[1]
#
employee_name= None
#
prod_score = None
#
date = None
#
totalworkhrs = None
#
# Check if this is the fifth row after the start of the report
#
elif i == 4 and employee_name is None:
#
employee_name = row[0]
#
# Check if this row contains a date and "Total Duration:" and "Productivity %"
#
if len(row) > 2 and "/" in row[0] and "Total Duration:" in row and "Productivity %" in row:
#
date = datetime.strptime(row[0], '%m/%d/%Y').date()
#
totalworkhrs = timedelta(hours=float(row[row.index("Total Duration:") + 2]))
#
prod_score = int(row[row.index("Productivity %") + 2])
#
summary_pr = SummaryReport.objects.create(sr_no=sr_no, employee_name=employee_name, prod_score=prod_score, date=date, totalworkhrs=totalworkhrs)
#
summary_pr.save()
#
return redirect('home')
#
return render(request, 'EmployeeProdDB/upload_csv.html')
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
=
'"'
)
#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
sr_no
=
row
[
1
]
employee_name
=
None
prod_score
=
None
date
=
None
totalworkhrs
=
None
# Check if this is the fifth row after the start of the report
elif
i
==
4
and
employee_name
is
None
:
employee_name
=
row
[
0
]
# Check if this row contains a date and "Total Duration:" and "Productivity %"
if
len
(
row
)
>
2
and
"/"
in
row
[
0
]
and
"Total Duration:"
in
row
and
"Productivity
%
"
in
row
:
date
=
datetime
.
strptime
(
row
[
0
],
'
%
m/
%
d/
%
Y'
)
.
date
()
totalworkhrs
=
timedelta
(
hours
=
float
(
row
[
row
.
index
(
"Total Duration:"
)
+
2
]))
prod_score
=
int
(
row
[
row
.
index
(
"Productivity
%
"
)
+
2
])
summary_pr
=
SummaryReport
.
objects
.
create
(
sr_no
=
sr_no
,
employee_name
=
employee_name
,
prod_score
=
prod_score
,
date
=
date
,
totalworkhrs
=
totalworkhrs
)
summary_pr
.
save
()
return
redirect
(
'home'
)
return
render
(
request
,
'EmployeeProdDB/upload_csv.html'
)
def
upload_csv
(
request
):
...
...
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