From f8091aab64e962a7f53168415fd5d01f1e7cb24e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 4 Feb 2018 05:03:50 +0100 Subject: submit_week_for_approval: Don't submit if already submitted Check that the timesheet hasn't already been submitted before trying to submit it. Otherwise we'd resubmit the timesheet which is not what we want. We only want a single submission across successive runs of the program. --- harvester_submit_week_for_approval.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'harvester_submit_week_for_approval.py') diff --git a/harvester_submit_week_for_approval.py b/harvester_submit_week_for_approval.py index 1731f73..6f9e047 100644 --- a/harvester_submit_week_for_approval.py +++ b/harvester_submit_week_for_approval.py @@ -56,10 +56,15 @@ def submit_week_for_approval(driver, wait, subdomain): '//a[@aria-label="{}"]'.format(friday.strftime('%A, %d %B')) ))) + approval_button = driver.find_element_by_css_selector( + '.approval-button .submit-link') + + # Don't submit if the time sheet has already been submitted + if approval_button.text == 'Resubmit Week for Approval': + return driver + # Click "Submit Week for Approval" button - driver.find_element_by_css_selector( - '.approval-button .submit-link' - ).click() + approval_button.click() # Click "Yes, Submit Timesheet" button wait.until( -- cgit v1.2.3