community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1665026 - in /comdev/reporter.apache.org/site: addrelease.py render.js
Date Sun, 08 Mar 2015 15:35:44 GMT
Author: humbedooh
Date: Sun Mar  8 15:35:43 2015
New Revision: 1665026

URL: http://svn.apache.org/r1665026
Log:
smarter in-report adding of releases, plus allow members to add data

Modified:
    comdev/reporter.apache.org/site/addrelease.py
    comdev/reporter.apache.org/site/render.js

Modified: comdev/reporter.apache.org/site/addrelease.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/site/addrelease.py?rev=1665026&r1=1665025&r2=1665026&view=diff
==============================================================================
--- comdev/reporter.apache.org/site/addrelease.py (original)
+++ comdev/reporter.apache.org/site/addrelease.py Sun Mar  8 15:35:43 2015
@@ -7,6 +7,7 @@ user = os.environ['HTTP_X_AUTHENTICATED_
 date = int(form['date'].value) if ('date' in form and len(form['date'].value) > 0) else
None
 version = form['version'].value if ('version' in form and len(form['version'].value) >
0) else None
 project = form['project'].value if 'project' in form else None
+dojson = form['json'].value if 'json' in form else None
     
 def getPMCs(uid):
     groups = []
@@ -20,6 +21,16 @@ def getPMCs(uid):
     return groups
 
 
+def isMember(uid):
+    members = []
+    ldapdata = subprocess.check_output(['ldapsearch', '-x', '-LLL', '-b', 'cn=member,ou=groups,dc=apache,dc=org'])
+    for match in re.finditer(r"memberUid: ([-a-z0-9_.]+)", ldapdata):
+        group = match.group(1)
+        members.append(group)
+    if uid in members:
+        return True
+    return False
+
 def getReleaseData(project):
     try:
         with open("/var/www/reporter.apache.org/data/releases/%s.json" % project, "r") as
f:
@@ -32,15 +43,22 @@ def getReleaseData(project):
 saved = False
 projects = getPMCs(user)
 if date and version and project:
-    if project in projects:
+    if project in projects or isMember(user):
         rdata = getReleaseData(project)
         rdata[version] = date
         with open("/var/www/reporter.apache.org/data/releases/%s.json" % project, "w") as
f:
             f.write(json.dumps(rdata))
             f.close()
             saved = True
-            print("Content-Type: text/html\r\n\r\n<h3>Data submitted!</h3>You
may see the updated project data at: <a href='https://reporter.apache.org/?%s'>https://reporter.apache.org/?%s</a>."
% (project, project))
+            if dojson:
+                print("Content-Type: application/json\r\n\r\n")
+                print(json.dumps({'versions': rdata}))
+            else:
+                print("Content-Type: text/html\r\n\r\n<h3>Data submitted!</h3>You
may see the updated project data at: <a href='https://reporter.apache.org/?%s'>https://reporter.apache.org/?%s</a>."
% (project, project))
 
 if not saved:
-    print("Content-Type: text/plain\r\n\r\nCould not save. Make sure you have filled out
all fields and have access to this projects data! For further inquiries, please contact dev@community.apache.org")
+    if dojson:
+        print("Content-Type: application/json\r\n\r\n{\"error\": \"Not saved\"}")
+    else:
+        print("Content-Type: text/plain\r\n\r\nCould not save. Make sure you have filled
out all fields and have access to this projects data! For further inquiries, please contact
dev@community.apache.org")
     
\ No newline at end of file

Modified: comdev/reporter.apache.org/site/render.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/site/render.js?rev=1665026&r1=1665025&r2=1665026&view=diff
==============================================================================
--- comdev/reporter.apache.org/site/render.js (original)
+++ comdev/reporter.apache.org/site/render.js Sun Mar  8 15:35:43 2015
@@ -373,7 +373,7 @@ function renderFrontPage(json) {
 			}
 		}
 		releases.innerHTML += "<i>(A total of " + (tr - nr) + " older release(s) were found
for " + pmc + " in our db)</i><br/>"
-		releases.innerHTML += "<br/><a href='addrelease.html?" + pmc + "'>Add a release</a>
- <a href='javascript:void(0);' onclick=\"$('#dialog_" + pmc + "').dialog({minWidth: 450,
minHeight: 240});\">Fetch releases from JIRA</a><br/>"
+		releases.innerHTML += "<br/><a href='javascript:void(0);' onclick=\"$('#rdialog_"
+ pmc + "').dialog({minWidth: 450, minHeight: 240});\">Add a release</a> - <a
href='javascript:void(0);' onclick=\"$('#dialog_" + pmc + "').dialog({minWidth: 450, minHeight:
240});\">Fetch releases from JIRA</a><br/>"
 
 		if (tr > 0) {
 			var div = renderReleaseChart(json.releases[pmc], pmc, releases);
@@ -521,6 +521,14 @@ function renderFrontPage(json) {
 		dialog.setAttribute("style", "display: none;")
 		dialog.innerHTML = "<form><b>JIRA Project:</b><input type='text' name='jira'
placeholder='FOO'><br/><b>Optional prepend:</b> <input name='prepend'
type='text' placeholder='Foo'/><br><input type='button' value='Fetch from JIRA'
onclick='fetchJIRA(\"" + pmc + "\", this.form[\"jira\"].value, this.form[\"prepend\"].value);'></form><p>If
you have multiple JIRA projects and they only have the version number in their release versions,
please enter the component name in the 'prepend' field.</p>"
 		document.getElementById('tab_' + pmc).appendChild(dialog)
+		
+		// Manually add release dialog
+		var rdialog = document.createElement('div');
+		rdialog.setAttribute("id", "rdialog_" + pmc);
+		rdialog.setAttribute("title", "Add a release")
+		rdialog.setAttribute("style", "display: none;")
+		rdialog.innerHTML = "<form><b>Version:</b><input type='text' name='version'
placeholder='1.2.3'><br/><b>Date:</b> <input name='date' type='text'
placeholder='YYYY-MM-DD'/><br><input type='button' value='Add release' onclick='addRelease(\""
+ pmc + "\", this.form[\"version\"].value, this.form[\"date\"].value);'></form>"
+		document.getElementById('tab_' + pmc).appendChild(rdialog)
 
 	}
 	if (json.pmcs.length == 0) {
@@ -789,5 +797,30 @@ function fetchJIRA(pmc, project, prepend
 			}
 		})
 	}
+
+}
+
+function addRelease(pmc, version, date) {
+	if (version && version.length > 1 && date.match(/^(\d\d\d\d)-(\d\d)-(\d\d)$/))
{
+		var x = date.split("-");
+		var y = new Date(x[0],parseInt(x[1])-1,parseInt(x[2]));
+		var nn = parseInt(y.getTime()/1000);
+		GetAsyncJSON("/addrelease.py?json=true&project=" + pmc + "&version=" + escape(version)
+ "&date=" + nn, null, function(json) {
+			if (json && json.versions) {
+				var n = 0;
+				for (version in json.versions) {
+					n++;
+					jsdata.releases[pmc][version] = json.versions[version]
+				}
+				$('#rdialog_' + pmc).dialog("close")
+				var nproject = pmc
+				alert("Release added!")
+				renderFrontPage(jsdata)
+
+			} else {
+				alert("Couldn't add release data :(")
+			}
+		})
+	}
 
 }
\ No newline at end of file



Mime
View raw message