-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing Redirect on Successful License Submission #450
Changes from 5 commits
cb1c711
9e65600
bab4db8
8a771be
1092f16
7dd8ef3
e541769
fa33d71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,7 +352,7 @@ def createIssue(licenseAuthorName, licenseName, licenseIdentifier, licenseCommen | |
headers = {'Authorization': 'token ' + token} | ||
url = "{0}/issues".format(TYPE_TO_URL_LICENSE[urlType]) | ||
r = requests.post(url, data=json.dumps(payload), headers=headers) | ||
return r.status_code | ||
return r.status_code, r.json()["number"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will r.json() always work without issues? What about when status_code is not as expected like 404, 400, will r.json() parse correctly. Also, will "number" be always in the json? If not let's parse status_code for successfull code list and parse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No actually, the number parameter will not be there if there was any issue while creating it through the API, I have added the code to handle that now, let me know if anything else needs to be done in that. |
||
|
||
|
||
def postToGithub(message, encodedContent, filename): | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -87,6 +87,7 @@ def submitNewLicense(request): | |||||||||
""" | ||||||||||
context_dict = {} | ||||||||||
ajaxdict = {} | ||||||||||
githubIssueId = "" | ||||||||||
if request.method=="POST": | ||||||||||
if not request.user.is_authenticated: | ||||||||||
if (request.is_ajax()): | ||||||||||
|
@@ -162,7 +163,9 @@ def submitNewLicense(request): | |||||||||
licenseId = licenseRequest.id | ||||||||||
serverUrl = request.build_absolute_uri('/') | ||||||||||
licenseRequestUrl = os.path.join(serverUrl, reverse('license-requests')[1:], str(licenseId)) | ||||||||||
statusCode = utils.createIssue(licenseAuthorName, licenseName, licenseIdentifier, licenseComments, licenseSourceUrls, licenseHeader, licenseOsi, licenseExamples, licenseRequestUrl, token, urlType) | ||||||||||
statusCode, githubIssueId = utils.createIssue(licenseAuthorName, licenseName, licenseIdentifier, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W291: trailing whitespace ❗❗ 5 similar findings have been found in this PR 🔎 Expand here to view all instances of this findingℹ️ Expand to see all @sonatype-lift commandsYou can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
Note: When talking to LiftBot, you need to refresh the page to see its response. Help us improve LIFT! (Sonatype LiftBot external survey) Was this a good recommendation for you? Answering this survey will not impact your Lift settings. [ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ] |
||||||||||
licenseComments, licenseSourceUrls, licenseHeader, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E501: line too long (120 > 79 characters) ❗❗ 7 similar findings have been found in this PR 🔎 Expand here to view all instances of this findingℹ️ Expand to see all @sonatype-lift commandsYou can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
Note: When talking to LiftBot, you need to refresh the page to see its response. Help us improve LIFT! (Sonatype LiftBot external survey) Was this a good recommendation for you? Answering this survey will not impact your Lift settings. [ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ] |
||||||||||
licenseOsi, licenseExamples, licenseRequestUrl, token, urlType) | ||||||||||
|
||||||||||
# If the license text matches with either rejected or yet not approved license then return 409 Conflict | ||||||||||
else: | ||||||||||
|
@@ -172,6 +175,7 @@ def submitNewLicense(request): | |||||||||
data['issueUrl'] = issueUrl | ||||||||||
|
||||||||||
data['statusCode'] = str(statusCode) | ||||||||||
data['issueId'] = str(githubIssueId) | ||||||||||
return JsonResponse(data) | ||||||||||
except UserSocialAuth.DoesNotExist: | ||||||||||
""" User not authenticated with GitHub """ | ||||||||||
|
@@ -986,7 +990,9 @@ def promoteNamespaceRequests(request, license_id=None): | |||||||||
if 'urlType' in request.POST: | ||||||||||
# This is present only when executing submit license via tests | ||||||||||
urlType = request.POST["urlType"] | ||||||||||
statusCode = utils.createIssue(licenseAuthorName, licenseName, licenseIdentifier, licenseComments, licenseSourceUrls, licenseHeader, licenseOsi, licenseExamples, licenseRequestUrl, token, urlType) | ||||||||||
statusCode, githubIssueId = utils.createIssue(licenseAuthorName, licenseName, licenseIdentifier, | ||||||||||
licenseComments, licenseSourceUrls, licenseHeader, licenseOsi, | ||||||||||
licenseExamples, licenseRequestUrl, token, urlType) | ||||||||||
return_tuple = (statusCode, licenseRequest) | ||||||||||
statusCode = return_tuple[0] | ||||||||||
if statusCode == 201: | ||||||||||
|
@@ -1161,7 +1167,9 @@ def issue(request): | |||||||||
licenseRequestId = licenseRequest.id | ||||||||||
serverUrl = request.build_absolute_uri('/') | ||||||||||
licenseRequestUrl = os.path.join(serverUrl, reverse('license-requests')[1:], str(licenseRequestId)) | ||||||||||
statusCode = utils.createIssue(licenseAuthorName, licenseName, licenseIdentifier, licenseComments, licenseSourceUrls, licenseHeader, licenseOsi, licenseExamples, licenseRequestUrl, token, urlType, matchId, diffUrl, msg) | ||||||||||
statusCode, githubIssueId = utils.createIssue(licenseAuthorName, licenseName, licenseIdentifier, | ||||||||||
licenseComments, licenseSourceUrls, licenseHeader, licenseOsi, | ||||||||||
licenseExamples, licenseRequestUrl, token, urlType, matchId, diffUrl, msg) | ||||||||||
data['statusCode'] = str(statusCode) | ||||||||||
return JsonResponse(data) | ||||||||||
except UserSocialAuth.DoesNotExist: | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Let's have this as constant -
https://github.com/spdx/licnse-list-xml/issues/