aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2019-01-29 12:05:05 -0500
committerParker Berberian <pberberian@iol.unh.edu>2019-01-29 12:36:50 -0500
commita4ad17749b58b5c9696acace6d3aced372051284 (patch)
treef9025714fa4b95c3447fec99e7cd08bac4e52514 /src
parent33ce5acd438fbb81522fffeb81e2d1a58861b57f (diff)
Fixed PTL Checks
First, this commit correctly parses the gerrit urls and can redirect itself to the raw info file if the user provides the html rendered one. This commit also fixes the way it checks the user against the found PTLs. The returned data changed format when support was added for sub-PTLs and the checks were never updated. Change-Id: I5801d207ec823c718a5beb5d5e78ee5780ec65e0 Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src')
-rw-r--r--src/workflow/models.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/workflow/models.py b/src/workflow/models.py
index 4e79546..beaaee4 100644
--- a/src/workflow/models.py
+++ b/src/workflow/models.py
@@ -61,15 +61,25 @@ class BookingAuthManager():
def parse_gerrit_url(self, url):
project_leads = []
try:
- parts = url.split("/")
+ halfs = url.split("?")
+ parts = halfs[0].split("/")
+ args = halfs[1].split(";")
if "http" in parts[0]: # the url include http(s)://
parts = parts[2:]
- if "f=INFO.yaml" not in parts[-1].split(";"):
+ if "f=INFO.yaml" not in args:
return None
if "gerrit.opnfv.org" not in parts[0]:
return None
+ try:
+ i = args.index("a=blob")
+ args[i] = "a=blob_plain"
+ except ValueError:
+ pass
+ # recreate url
+ halfs[1] = ";".join(args)
+ halfs[0] = "/".join(parts)
# now to download and parse file
- url = "https://" + "/".join(parts)
+ url = "https://" + "?".join(halfs)
info_file = requests.get(url, timeout=15).text
info_parsed = yaml.load(info_file)
ptl = info_parsed.get('project_lead')
@@ -138,8 +148,11 @@ class BookingAuthManager():
return True # admin override for this user
if repo.BOOKING_INFO_FILE not in repo.el:
return False # INFO file not provided
- ptl_info = self.parse_url(repo.BOOKING_INFO_FILE)
- return ptl_info and ptl_info == booking.owner.userprofile.email_addr
+ ptl_info = self.parse_url(repo.el.get(repo.BOOKING_INFO_FILE))
+ for ptl in ptl_info:
+ if ptl['email'] == booking.owner.userprofile.email_addr:
+ return True
+ return False
class WorkflowStep(object):