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

Differentiate Exceptions from License Submission #471

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ data/certbot/

container_logs

node_modules/
5 changes: 5 additions & 0 deletions src/app/formatxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
'name',
'listVersionAdded',
],
'exception': [
'licenseId',
'name',
'listVersionAdded',
],
'alt': [
'name',
'match',
Expand Down
45 changes: 39 additions & 6 deletions src/app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@
("Unknown", "Don't know")
)

YES_NO_CHOICES = (
(True, 'Yes'),
(False, 'No'),
)

class TooltipTextInput(forms.TextInput):
Copy link

Choose a reason for hiding this comment

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

8% of developers fix this issue

E302: expected 2 blank lines, found 1


ℹ️ 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.

def __init__(self, tooltip='', attrs=None):
super().__init__(attrs)
self.tooltip = tooltip

def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
context['widget']['attrs']['data-toggle'] = 'tooltip'
context['widget']['attrs']['title'] = self.tooltip
return context

Copy link

Choose a reason for hiding this comment

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

12% of developers fix this issue

W293: blank line contains whitespace


ℹ️ 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.

class CustomSelectWidget(forms.Select):
Copy link

Choose a reason for hiding this comment

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

8% of developers fix this issue

E302: expected 2 blank lines, found 1


ℹ️ 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.

def __init__(self, *args, **kwargs):
self.tooltip = kwargs.pop('tooltip', '') # Get the tooltip text from widget attributes
Copy link

Choose a reason for hiding this comment

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

6% of developers fix this issue

E501: line too long (95 > 79 characters)


ℹ️ 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.

super().__init__(*args, **kwargs)

def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
context['widget'].update({'attrs': {'title': self.tooltip}}) # Add the title attribute to the widget
Copy link

Choose a reason for hiding this comment

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

6% of developers fix this issue

E501: line too long (109 > 79 characters)


ℹ️ 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.

return context

class UserRegisterForm(forms.ModelForm):

password = forms.CharField(widget=forms.PasswordInput())
Expand Down Expand Up @@ -75,12 +101,19 @@ def __init__(self, *args, **kwargs):
super(LicenseRequestForm, self).__init__(*args,**kwargs)
self.fields["userEmail"] = forms.EmailField(label='Email', initial=self.email, max_length=35, required=False)

licenseAuthorName = forms.CharField(label="License Author name", max_length=100, required=False)
fullname = forms.CharField(label="Fullname", max_length=70)
shortIdentifier = forms.CharField(label='Short identifier', max_length=25)
sourceUrl = forms.CharField(label='Source / URL', required=False)
osiApproved = forms.CharField(label="OSI Status", widget=forms.Select(choices=OSI_CHOICES))
exampleUrl = forms.CharField(label='Example Projects / URL', required=True)
licenseAuthorName = forms.CharField(label="License Author name", max_length=100, required=False, widget=TooltipTextInput(tooltip='License Author name text goes here'))
fullname = forms.CharField(label="Fullname", max_length=70, widget=TooltipTextInput(tooltip='Tooltip text goes here'))
shortIdentifier = forms.CharField(label='Short identifier', max_length=25, widget=TooltipTextInput(tooltip='Tooltip text goes here'))
sourceUrl = forms.CharField(label='Source / URL', required=False, widget=TooltipTextInput(tooltip='Tooltip text goes here'))
osiApproved = forms.ChoiceField(
choices=OSI_CHOICES,
widget=CustomSelectWidget(tooltip='This is a tooltip')
)
isException = forms.ChoiceField(
choices=YES_NO_CHOICES,
widget=CustomSelectWidget(tooltip='Yes No tooltip')
)
exampleUrl = forms.CharField(label='Example Projects / URL', required=True, widget=TooltipTextInput(tooltip='Tooltip text goes here'))
comments = forms.CharField(label='Comments', required=True, widget=forms.Textarea(attrs={'rows': 4, 'cols': 40}))
licenseHeader = forms.CharField(label='Standard License Header', widget=forms.Textarea(attrs={'rows': 3, 'cols': 40}), required=False)
text = forms.CharField(label='Text', widget=forms.Textarea(attrs={'rows': 4, 'cols': 40}))
Expand Down
7 changes: 5 additions & 2 deletions src/app/generateXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def getTextElement(points):
return elements[0]


def generateLicenseXml(licenseOsi, licenseIdentifier, licenseName, listVersionAdded, licenseSourceUrls, licenseHeader, licenseNotes, licenseText):
def generateLicenseXml(licenseOsi, licenseIdentifier, licenseName, listVersionAdded, licenseSourceUrls, licenseHeader, licenseNotes, licenseText, isException=False):
""" Generate a spdx license xml
returns the license xml as a string
"""
Expand All @@ -140,7 +140,10 @@ def generateLicenseXml(licenseOsi, licenseIdentifier, licenseName, listVersionAd
licenseOsi = "true"
else:
licenseOsi = "false"
license = ET.SubElement(root, "license", isOsiApproved=licenseOsi, licenseId=licenseIdentifier, listVersionAdded=listVersionAdded, name=licenseName)
if isException:
license = ET.SubElement(root, "exception", isOsiApproved=licenseOsi, licenseId=licenseIdentifier, listVersionAdded=listVersionAdded, name=licenseName)
Copy link

Choose a reason for hiding this comment

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

6% of developers fix this issue

E501: line too long (158 > 79 characters)

❗❗ 17 similar findings have been found in this PR

🔎 Expand here to view all instances of this finding
File Path Line Number
src/app/generateXml.py 146
src/app/generateXml.py 158
src/app/utils.py 72
src/app/utils.py 181
src/app/utils.py 183
src/app/utils.py 184
src/app/utils.py 187
src/app/utils.py 203
src/app/utils.py 205
src/app/utils.py 207

Showing 10 of 17 findings. Visit the Lift Web Console to see all.


ℹ️ 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sonatype-lift ignoreall

Copy link

Choose a reason for hiding this comment

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

The ignoreall command is active on this PR, all the existing Lift issues are ignored.

else:
license = ET.SubElement(root, "license", isOsiApproved=licenseOsi, licenseId=licenseIdentifier, listVersionAdded=listVersionAdded, name=licenseName)
crossRefs = ET.SubElement(license, "crossRefs")
for sourceUrl in licenseSourceUrls:
ET.SubElement(crossRefs, "crossRef").text = sourceUrl
Expand Down
33 changes: 33 additions & 0 deletions src/app/migrations/0002_auto_20230529_1433.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.2.18 on 2023-05-29 14:33

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.

9% 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.

Copy link

Choose a reason for hiding this comment

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

11% 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.



class Migration(migrations.Migration):

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

operations = [
migrations.AddField(
model_name='licensenamespace',
name='isException',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='licensenamespace',
name='text',
field=models.TextField(default=''),
Copy link
Collaborator

Choose a reason for hiding this comment

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

You will need to commit only changed migrations if this is fixed in the other PR

),
migrations.AddField(
model_name='licenserequest',
name='isException',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='licenserequest',
name='text',
field=models.TextField(default=''),
),
]
2 changes: 2 additions & 0 deletions src/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class License(models.Model):
userEmail = models.EmailField(max_length=35)
notes = models.CharField(max_length=255, default="")
xml = models.TextField()
text = models.TextField(default="")
isException = models.BooleanField(default=True)
archive = models.BooleanField(default=False)

class Meta:
Expand Down
1 change: 1 addition & 0 deletions src/app/templates/app/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" title="GitHub Pull Request body, can be edited later." style="font-size:12px;"></span>
<textarea class="form-control" rows="5" id="prBody" name="prBody" style="resize:none; width:200px;"></textarea>
</div><br>
<input type="hidden" name="hidden_field" value="{{license_id}}">
</textarea>
</form>
</div>
Expand Down
13 changes: 13 additions & 0 deletions src/app/templates/app/submit_new_license.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@
</div>
</div>

<div class = "form-group">
<div class="col-sm-12">
<label class="control-label col-sm-3" >Is Exception</label>
<div class="col-sm-4">
{{ form.isException }}
</div>
</div>
</div>

<div class = "form-group">
<div class="col-sm-12">
<label class="control-label col-sm-3" >Text of license
Expand Down Expand Up @@ -164,6 +173,10 @@

{% block script_block %}
<script type="text/javascript">
$(function () {
$('[data-toggle="tooltip"]').tooltip();
});

$(document).ready(function () {
var is_touch_device = "ontouchstart" in document.documentElement;

Expand Down
38 changes: 33 additions & 5 deletions src/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def checkPermission(user):
logger.error("Permission denied while accessing the github api.")
return False

def makePullRequest(username, token, branchName, updateUpstream, fileName, commitMessage, prTitle, prBody, xmlText, is_ns):
def makePullRequest(username, token, branchName, updateUpstream, fileName, commitMessage, prTitle, prBody, xmlText, plainText, isException, is_ns):
Copy link

Choose a reason for hiding this comment

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

9% of developers fix this issue

E302: expected 2 blank lines, found 1


ℹ️ 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.


if not xmlText:
logger.error("Error occurred while getting xml text. The xml text is empty")
Expand Down Expand Up @@ -171,26 +171,54 @@ def makePullRequest(username, token, branchName, updateUpstream, fileName, commi
""" Creating Commit """
if fileName[-4:] == ".xml":
fileName = fileName[:-4]
fileName += ".xml"
commit_url = "{0}repos/{1}/{2}/contents/src/{3}".format(url, username, settings.NAMESPACE_REPO_NAME if is_ns else settings.LICENSE_REPO_NAME, fileName)
if isException:
textFileName = fileName + "-exception.txt"
fileName += "-exception.xml"
else:
textFileName = fileName + ".txt"
fileName += ".xml"
if isException:
commit_url = "{0}repos/{1}/{2}/contents/src/exceptions/{3}".format(url, username, settings.NAMESPACE_REPO_NAME if is_ns else settings.LICENSE_REPO_NAME, fileName)
else:
commit_url = "{0}repos/{1}/{2}/contents/src/{3}".format(url, username, settings.NAMESPACE_REPO_NAME if is_ns else settings.LICENSE_REPO_NAME, fileName)
Copy link

Choose a reason for hiding this comment

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

3% of developers fix this issue

W291: trailing whitespace


ℹ️ 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.

text_commit_url = "{0}repos/{1}/{2}/contents/test/simpleTestForGenerator/{3}".format(url, username, settings.NAMESPACE_REPO_NAME if is_ns else settings.LICENSE_REPO_NAME, textFileName)
xmlText = xmlText.encode('utf-8') if isinstance(xmlText, str) else xmlText
fileContent = base64.b64encode(xmlText).decode()
plainText = plainText.encode('utf-8') if isinstance(plainText, str) else plainText
textFileContent = base64.b64encode(plainText).decode()
body = {
"path":"src/"+fileName,
"message":commitMessage,
"content":fileContent,
"branch":branchName,
}
text_file_body = {
"path":"src/"+ textFileName,
Copy link

Choose a reason for hiding this comment

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

2% of developers fix this issue

E231: missing whitespace after ':'


ℹ️ 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.

Copy link

Choose a reason for hiding this comment

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

41% of developers fix this issue

E225: missing whitespace around operator

❗❗ 4 similar findings have been found in this PR

🔎 Expand here to view all instances of this finding
File Path Line Number
src/app/utils.py 221
src/app/utils.py 221
src/app/utils.py 221
src/app/utils.py 221

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.

"message":commitMessage,
"content":textFileContent,
Copy link

Choose a reason for hiding this comment

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

2% of developers fix this issue

E231: missing whitespace after ':'


ℹ️ 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.

"branch":branchName,
}
""" Check if file already exists """
file_url = "{0}/contents/src/{1}".format(TYPE_TO_URL_NAMESPACE[NORMAL] if is_ns else TYPE_TO_URL_LICENSE[NORMAL], fileName)
if isException:
file_url = "{0}/contents/src/exceptions/{1}".format(TYPE_TO_URL_NAMESPACE[NORMAL] if is_ns else TYPE_TO_URL_LICENSE[NORMAL], fileName)
else:
file_url = "{0}/contents/src/{1}".format(TYPE_TO_URL_NAMESPACE[NORMAL] if is_ns else TYPE_TO_URL_LICENSE[NORMAL], fileName)
Copy link

Choose a reason for hiding this comment

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

3% of developers fix this issue

W291: trailing whitespace


ℹ️ 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.

response = requests.get(file_url, headers=headers)
text_file_url = "{0}/contents/test/simpleTestForGenerator/{1}".format(TYPE_TO_URL_NAMESPACE[NORMAL] if is_ns else TYPE_TO_URL_LICENSE[NORMAL], textFileName)
text_response = requests.get(text_file_url, headers=headers)
if response.status_code == 200:
""" Creating Commit by updating the file """
data = json.loads(response.text)
file_sha = data["sha"]
body["sha"] = file_sha
if text_response.status_code == 200:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some changes looks similar to #470 . Please look into working with multiple branches on git. Create PRs with the correct upstream branch (branch before this one)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made a new PR #492 for this, like further moving forward I have to redo #470 because of the migrations issues which it has having, so I have incorporated all the changes which you had suggested in #470 in #492, so now there is an extra utils function as well. Let me know if anything else needs to be done in that

""" Creating Commit by updating the file """
data = json.loads(text_response.text)
file_sha = data["sha"]
text_file_body["sha"] = file_sha
response = requests.put(commit_url, headers=headers, data=json.dumps(body))
if not (response.status_code==201 or response.status_code==200):
text_response = requests.put(text_commit_url, headers=headers, data=json.dumps(text_file_body))
if not (response.status_code==201 or response.status_code==200 or text_response.status_code==201 or text_response.status_code==200):
logger.error("[Pull Request] Error occured while making commit, for {0} user. {1}".format(username, response.text))
return {
"type":"error",
Expand Down
22 changes: 16 additions & 6 deletions src/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ def submitNewLicense(request):
licenseName = form.cleaned_data['fullname']
licenseIdentifier = form.cleaned_data['shortIdentifier']
licenseOsi = form.cleaned_data['osiApproved']
isException = form.cleaned_data['isException']
if isException == "False":
isException = False
else:
isException = True
licenseSourceUrls = request.POST.getlist('sourceUrl')
licenseExamples = request.POST.getlist('exampleUrl')
licenseHeader = form.cleaned_data['licenseHeader']
Expand Down Expand Up @@ -154,10 +159,10 @@ def submitNewLicense(request):
# Check if the license text doesn't matches with the rejected as well as not yet approved licenses
if not matches:
xml = generateLicenseXml(licenseOsi, licenseIdentifier, licenseName,
listVersionAdded, licenseSourceUrls, licenseHeader, licenseNotes, licenseText)
listVersionAdded, licenseSourceUrls, licenseHeader, licenseNotes, licenseText, isException)
Copy link

Choose a reason for hiding this comment

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

17% of developers fix this issue

E128: continuation line under-indented for visual indent

❗❗ 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 161
src/app/views.py 982

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.

now = datetime.datetime.now()
licenseRequest = LicenseRequest(licenseAuthorName=licenseAuthorName, fullname=licenseName, shortIdentifier=licenseIdentifier,
submissionDatetime=now, notes=licenseNotes, xml=xml)
submissionDatetime=now, notes=licenseNotes, xml=xml, text=licenseText, isException=isException)
licenseRequest.save()
licenseId = licenseRequest.id
serverUrl = request.build_absolute_uri('/')
Expand Down Expand Up @@ -852,7 +857,7 @@ def license_xml_edit(request, page_id):
return HttpResponseRedirect('/app/xml_upload')


def get_context_dict_for_license_xml(request, license_obj):
def get_context_dict_for_license_xml(request, license_obj, license_id):
context_dict = {}
if request.user.is_authenticated:
user = request.user
Expand All @@ -863,6 +868,7 @@ def get_context_dict_for_license_xml(request, license_obj):
context_dict["github_login"] = github_login
context_dict["xml_text"] = license_obj.xml
context_dict["license_name"] = license_obj.fullname
context_dict["license_id"] = license_id
return context_dict


Expand All @@ -873,7 +879,7 @@ def edit_license_xml(request, license_id=None):
if not LicenseRequest.objects.filter(id=license_id).exists():
return render(request, "404.html", {}, status=404)
license_obj = LicenseRequest.objects.get(id=license_id)
context_dict = get_context_dict_for_license_xml(request, license_obj)
context_dict = get_context_dict_for_license_xml(request, license_obj, license_id)
return render(request, "app/editor.html", context_dict, status=200)
else:
return HttpResponseRedirect('/app/license_requests')
Expand All @@ -886,7 +892,7 @@ def edit_license_namespace_xml(request, license_id=None):
if not LicenseNamespace.objects.filter(id=license_id).exists():
return render(request, "404.html", {}, status=404)
license_obj = LicenseNamespace.objects.get(id=license_id)
context_dict = get_context_dict_for_license_xml(request, license_obj)
context_dict = get_context_dict_for_license_xml(request, license_obj, license_id)
return render(request, "app/ns_editor.html", context_dict, status=200)
else:
return HttpResponseRedirect('/app/license_namespace_requests')
Expand Down Expand Up @@ -977,7 +983,7 @@ def promoteNamespaceRequests(request, license_id=None):
listVersionAdded, licenseSourceUrls, licenseHeader, licenseNotes, licenseText)
now = datetime.datetime.now()
licenseRequest = LicenseRequest(licenseAuthorName=licenseAuthorName, fullname=licenseName, shortIdentifier=licenseIdentifier,
submissionDatetime=now, userEmail=userEmail, notes=licenseNotes, xml=xml)
submissionDatetime=now, userEmail=userEmail, notes=licenseNotes, xml=xml, text=licenseText)
licenseRequest.save()
licenseId = licenseRequest.id
serverUrl = request.build_absolute_uri('/')
Expand Down Expand Up @@ -1200,6 +1206,8 @@ def handle_pull_request(request, is_ns):
github_login = user.social_auth.get(provider="github")
token = github_login.extra_data["access_token"]
username = github_login.extra_data["login"]
license_id = request.POST.get('hidden_field')
license_obj = LicenseRequest.objects.get(id=license_id)
response = utils.makePullRequest(
username,
token,
Expand All @@ -1210,6 +1218,8 @@ def handle_pull_request(request, is_ns):
request.POST["prTitle"],
request.POST["prBody"],
request.POST["xmlText"],
license_obj.text,
license_obj.isException,
is_ns,
)
if response["type"] == "success":
Expand Down