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

GitHub issue creation #38

Merged
merged 17 commits into from
Aug 8, 2018
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
a4dcd97
Implementing function used when creating a GitHub issue after a licen…
gaalocastillo Jul 25, 2018
e71cbc6
Updating Github repository in which the issue would be created.
gaalocastillo Jul 25, 2018
8885edb
Updating issue's body and tittle.
gaalocastillo Jul 25, 2018
a42ef3c
Calling createIssue function when submiting a new license request.
gaalocastillo Jul 25, 2018
c40bd70
Obtaining GitHub token from external file.
gaalocastillo Jul 29, 2018
cff353a
Empty license submittal form fields on submission success. Showing su…
gaalocastillo Jul 29, 2018
349ae5b
Implementing function used when creating a GitHub issue after a licen…
gaalocastillo Jul 25, 2018
de7e346
Updating Github repository in which the issue would be created.
gaalocastillo Jul 25, 2018
69d5b07
Updating issue's body and tittle.
gaalocastillo Jul 25, 2018
4e66a6d
Calling createIssue function when submiting a new license request.
gaalocastillo Jul 25, 2018
9c5de66
Obtaining GitHub token from external file.
gaalocastillo Jul 29, 2018
0b85588
Displaying warning message when the submitted license issue cannot be…
gaalocastillo Jul 30, 2018
e22b485
Displaying warning message when the submitted license issue cannot be…
gaalocastillo Jul 30, 2018
5b9f87c
Updating gitignore file. Adding GitHub token used to create issues.
gaalocastillo Jul 30, 2018
d5a82cd
Updating gitignore file.
gaalocastillo Jul 30, 2018
719d763
Removing GitHub utils file.
gaalocastillo Jul 30, 2018
01bfaee
Removing merge conflicts.
gaalocastillo Aug 2, 2018
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -116,3 +116,6 @@ org.eclipse.core.resources.prefs

# Various junk and temp files
.DS_Store

#GitHub token
github_utils.py
36 changes: 32 additions & 4 deletions src/app/templates/app/submit_new_license.html
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@
</script>
<script type="text/javascript">
$(document).on('click', '.roundedButton', function(){
var html = '<div><input type="text" id="sourceurl" placeholder="" name = "sourceurl"></div>';
var html = '<div><input type="text" id="sourceUrl" placeholder="" name = "sourceurl"></div>';
$(this).parent().append(html);
});
</script>
@@ -162,9 +162,37 @@
timeout: 600000,
data: form,
success: function (data) {
console.log("SUCCESS : ", data);
$("#submitbutton").text("Submit");
$("#submitbutton").prop('disabled', false);
var githubCode = data.statusCode;
if(githubCode == '201'){
var successMessage = "The license request has been successfully submitted.";
$("#messages").html('<div class="alert alert-success alert-dismissable fade in"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Success! </strong>'+ successMessage +'</div>');
setTimeout(function() {
$("#messages").html("");
}, 7000);
}
else{
var warningMessage = "Please note that there was a problem opening the issue for the SPDX legal team. Please email spdx-legal@lists.spdx.org with SPDX ID for the license you are submitting";
$("#messages").html('<div class="alert alert-warning alert-dismissable fade in"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Warning! </strong>'+ warningMessage +'</div>');
setTimeout(function() {
$("#messages").html("");
}, 7000);
}
$("#fullname").val("");
$("#shortIdentifier").val("");
$("#sourceUrl").val("");
$("#osiApproved").val(0);
$("#notes").val("");
$("#licenseHeader").val("");
$("#text").val("");
$("#userEmail").val("");
var sources = $('[id="sourceUrl"]');
if(sources.length > 1){
for (var i = 3; i < sources.length + 2; i++) {
$("#addSourceUrl").parent().parent().children(i.toString()).remove();
}
}
$("#submitbutton").text("Submit");
$("#submitbutton").prop('disabled', false);
},
error: function (e) {
console.log("ERROR : ", e);
Empty file added src/app/utils/__init__.py
Empty file.
30 changes: 28 additions & 2 deletions src/app/views.py
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
from django.contrib.auth.models import User
from django.utils.datastructures import MultiValueDictKeyError
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse

import jpype
from traceback import format_exc
@@ -34,13 +35,16 @@
import datetime
from wsgiref.util import FileWrapper
import os
from requests import post

from app.models import UserID
from app.forms import UserRegisterForm,UserProfileForm,InfoForm,OrgInfoForm

from .forms import LicenseRequestForm
from .models import LicenseRequest

from utils.github_utils import getGithubToken

def index(request):
""" View for index
returns index.html template
@@ -63,6 +67,7 @@ def submitNewLicense(request):
""" View for submit new licenses
returns submit_new_license.html template
"""
context_dict={}
if request.method == 'POST':
form = LicenseRequestForm(request.POST, auto_id='%s')
if form.is_valid() and request.is_ajax():
@@ -80,10 +85,13 @@ def submitNewLicense(request):
licenseRequest = LicenseRequest(fullname=licenseName,shortIdentifier=licenseIdentifier,
submissionDatetime=now, userEmail=userEmail, xml=xml)
licenseRequest.save()
form = LicenseRequestForm()
statusCode = createIssue(licenseName, licenseIdentifier, licenseSourceUrls, licenseOsi)
data = {'statusCode' : str(statusCode)}
return JsonResponse(data)

else:
form = LicenseRequestForm(auto_id='%s')
context_dict={'form': form}
context_dict['form'] = form
return render(request,
'app/submit_new_license.html', context_dict
)
@@ -103,6 +111,24 @@ def generateLicenseXml(licenseOsi, licenseIdentifier, licenseName, licenseSource
xmlString = ET.tostring(root, encoding='utf8', method='xml')
return xmlString

def createIssue(licenseName, licenseIdentifier, licenseSourceUrls, licenseOsi):
""" View for creating an GitbHub issue
when submitting a new license request
"""
myToken = getGithubToken()
body = '**1.** License Name: ' + licenseName + '\n**2.** Short identifier: ' + licenseIdentifier + '\n**3.** URL: '
for url in licenseSourceUrls:
body += url
body += '\n'
body += '**4.** OSI Approval: ' + licenseOsi
title = 'New license request: ' + licenseIdentifier + ' [SPDX-Online-Tools]'
payload = {'title' : title, 'body': body, 'labels': ['new license/exception request']}
headers = {'Authorization': 'token ' + myToken}
url = 'https://api.github.com/repos/spdx/license-list-XML/issues'
r = post(url, data=dumps(payload), headers=headers)
return r.status_code


def licenseRequests(request):
""" View for license requests
returns license_requests.html template