Skip to content
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

#453 addressing issue #454

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def submit_license(request):
if 'urlType' in request.POST:
# This is present only when executing submit license via tests
urlType = request.POST["urlType"]
statusCode = createIssue(licenseAuthorName, licenseName, licenseIdentifier, licenseComments, licenseSourceUrls, licenseHeader, licenseOsi, licenseRequestUrl, token, urlType)
statusCode,issueId = createIssue(licenseAuthorName, licenseName, licenseIdentifier, licenseComments, licenseSourceUrls, licenseHeader, licenseOsi, licenseRequestUrl, token, urlType)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0% of developers fix this issue

E231: missing whitespace after ','

❗❗ 2 similar findings have been found in this PR

🔎 Expand here to view all instances of this finding
File Path Line Number
src/app/views.py 991
src/app/views.py 1166

Visit the Lift Web Console to find more details in your report.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


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 ]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1% of developers fix this issue

E501: line too long (193 > 79 characters)

❗❗ 3 similar findings have been found in this PR

🔎 Expand here to view all instances of this finding
File Path Line Number
src/app/views.py 165
src/app/views.py 991
src/app/views.py 1166

Visit the Lift Web Console to find more details in your report.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


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 ]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E1120: No value for argument 'urlType' in function call


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


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 ]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7% of developers fix this issue

reportGeneralTypeIssues: Argument missing for parameter "urlType"


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


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 ]

if str(statusCode) == '201':
result = "Success! The license request has been successfully submitted."
query.result = result
Expand Down
23 changes: 23 additions & 0 deletions src/app/migrations/0002_auto_20230330_0034.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.18 on 2023-03-29 19:04

from django.db import migrations, models
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1% of developers fix this issue

E0401: Unable to import 'django.db'


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


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 ]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1% of developers fix this issue

reportMissingImports: Import "django.db" could not be resolved


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


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 ]



class Migration(migrations.Migration):

dependencies = [
('app', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='licensenamespace',
name='issueId',
field=models.TextField(default=''),
),
migrations.AddField(
model_name='licenserequest',
name='issueId',
field=models.TextField(default=''),
),
]
17 changes: 17 additions & 0 deletions src/app/migrations/0003_remove_licensenamespace_issueid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.18 on 2023-04-01 08:58

from django.db import migrations
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1% of developers fix this issue

E0401: Unable to import 'django.db'


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


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 ]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1% of developers fix this issue

reportMissingImports: Import "django.db" could not be resolved


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


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 ]



class Migration(migrations.Migration):

dependencies = [
('app', '0002_auto_20230330_0034'),
]

operations = [
migrations.RemoveField(
model_name='licensenamespace',
name='issueId',
),
]
1 change: 1 addition & 0 deletions src/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Meta:
abstract = True

class LicenseRequest(License):
issueId = models.TextField(default='')

def __unicode__(self):
return "%s" % (self.fullname)
Expand Down
10 changes: 9 additions & 1 deletion src/app/templates/app/license_information.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<p class ="lead"> {{ error }}</p>
<div class="panel panel-default">
{% if licenseInformation %}
<div class="panel-heading"> <p class="lead">{{licenseInformation.fullname}}
<div class="panel-heading"><a href="https://github.com/spdx/licnse-list-xml/issues/{{licenseInformation.issueId}}" target=”_blank”>
<p class="lead">{{licenseInformation.fullname}}</a>
{% if licenseInformation.archive %}
<span class="label label-success">Archived</span>
{% endif %}
Expand Down Expand Up @@ -51,6 +52,13 @@
<p class="fieldName">Text</p>
<p>{{licenseInformation.text|safe}}</p>
</div>
<div class="licenseField col-sm-12">
<p class="fieldName">Github Issue</p>
<a href="https://github.com/spdx/licnse-list-xml/issues/{{licenseInformation.issueId}}" target=”_blank”>
<p>Issue #{{licenseInformation.issueId|safe}}</p>
</a>
</div>

<div class="licenseField col-sm-12">
<p class="fieldName">Submission Date</p>
<p>{{licenseInformation.submissionDatetime}}</p>
Expand Down
2 changes: 1 addition & 1 deletion src/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]


def postToGithub(message, encodedContent, filename):
Expand Down
10 changes: 6 additions & 4 deletions src/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,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, issueId = utils.createIssue(licenseAuthorName, licenseName, licenseIdentifier, licenseComments, licenseSourceUrls, licenseHeader, licenseOsi, licenseExamples, licenseRequestUrl, token, urlType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utils.createIssue is used at multiple places, please update everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rtgdk done

licenseRequest.issueId = issueId
licenseRequest.save()
# If the license text matches with either rejected or yet not approved license then return 409 Conflict
else:
statusCode = 409
Expand Down Expand Up @@ -346,6 +347,7 @@ def licenseInformation(request, licenseId):

licenseInformation['licenseAuthorName'] = licenseRequest.licenseAuthorName
licenseInformation['archive'] = licenseRequest.archive
licenseInformation['issueId'] = licenseRequest.issueId
xmlString = licenseRequest.xml
data = utils.parseXmlString(xmlString)
licenseInformation['osiApproved'] = data['osiApproved']
Expand Down Expand Up @@ -986,7 +988,7 @@ 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,issueId = utils.createIssue(licenseAuthorName, licenseName, licenseIdentifier, licenseComments, licenseSourceUrls, licenseHeader, licenseOsi, licenseExamples, licenseRequestUrl, token, urlType)
return_tuple = (statusCode, licenseRequest)
statusCode = return_tuple[0]
if statusCode == 201:
Expand Down Expand Up @@ -1161,7 +1163,7 @@ 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,issueId = 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:
Expand Down