Renamed org-accept.js to bulk-review.js
authorLennard de Rijk <ljvderijk@gmail.com>
Thu, 26 Feb 2009 20:25:56 +0000
changeset 1535 a5277d506a21
parent 1534 0a8dbeccf0d9
child 1536 59d74d918af1
Renamed org-accept.js to bulk-review.js Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/content/js/bulk-review.js
app/soc/content/js/org-accept.js
app/soc/templates/soc/base.html
app/soc/views/helper/params.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/content/js/bulk-review.js	Thu Feb 26 20:25:56 2009 +0000
@@ -0,0 +1,92 @@
+$(document).ready(function() {
+	$("#applications_progress_bar").progressBar({showText: false});
+});
+
+function bulkReviewInit(bulk_review_link) {
+	// get the JSON object with details of every application for bulk acceptance
+	$.getJSON(bulk_review_link+"?_="+(new Date().getTime()),
+		function(data){
+			// If there are applications to review...
+			if (data.nr_applications != 0) {
+				//...then fade out the button, show the progress bar and call the function for review
+				$("#button_bulk_review").fadeOut("slow",
+					function() {
+						$("#applications_progress_bar").progressBar(0);
+						$("#description_done").html("");
+						$("#applications_progress_bar").fadeIn("slow", bulkReview(data));
+					}
+				);
+			}else {
+				$("#description_done").html("<strong>No organizations to accept</strong>");
+			}
+		}
+	);
+}
+
+function bulkReview(data) {
+	// some global constants
+	var GLOBAL_LINK = data.link;
+	var TOTAL_APPLICATIONS = data.nr_applications;
+
+	// some global variables set needed for internal iteration
+	var application_index = 0;
+	// number of iteration is not taken from data.nr_applications
+	// to ensure avoidance of array out of bounds errors
+	var total_index = data.applications.length;
+
+
+	// call immediately the function for review
+	// real iteration is inside
+	setTimeout(function(){
+		var error_happened = false;
+
+		var application = data.applications[application_index];
+		var current_application = application_index + 1;
+		// regular expression to find a valid scope path inside matching parenthesis
+		var re = /\((\w*)\)/;
+		var scope_path = GLOBAL_LINK.match(re)[1];
+		// the URL is obtained by using the scope path found in the matching parenthesis
+		var url_to_call = GLOBAL_LINK.replace(re, eval("application." + scope_path));
+		// now we can call the URL found
+		$.ajax({
+			async: false,
+			cache: false,
+			url: url_to_call,
+			timeout: 10000,
+			success: function(data) {
+				if (data) {
+					// update progress bar percentage and description
+					var percentage = Math.floor(100 * (current_application) / (TOTAL_APPLICATIONS));
+					$("#description_progressbar").html(" Processed application " + application.name + " (" + (current_application) + "/" + TOTAL_APPLICATIONS + ")");
+					$("#applications_progress_bar").progressBar(percentage);
+				}
+			},
+			error: function(XMLHttpRequest, textStatus, errorThrown) {
+				// if there is an error return the button and leave a try again message
+				error_happened = true;
+				$("#button_bulk_review").fadeIn("slow", function() {
+					$("#description_done").html("<strong class='error'> Error encountered, try again</strong>");
+				});
+			}
+		});
+		// if there were no errors, continue the iteration
+		if (!error_happened) {
+			// prepare for new iteration and then recall this function
+			application_index++;
+			if (application_index < total_index) {
+				setTimeout(arguments.callee, 0);
+			}
+			else {
+				// all ok, tell the user we are done
+				$("#applications_progress_bar").fadeOut("slow",
+					function() {
+						$("#applications_progress_bar").progressBar(0);
+						$("#button_bulk_review").fadeIn("slow");
+					}
+				);
+				$("#description_progressbar").html("");
+				$("#description_done").html("<strong>Done!</strong>");
+			}
+		}
+	},0);
+}
--- a/app/soc/content/js/org-accept.js	Thu Feb 26 20:23:21 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-$(document).ready(function() {
-	$("#applications_progress_bar").progressBar({showText: false});
-});
-
-function acceptOrgInit(bulk_accept_link) {
-	// get the JSON object with details of every application for bulk acceptance
-	$.getJSON(bulk_accept_link+"?_="+(new Date().getTime()),
-		function(data){
-			// If there are applications to accept...
-			if (data.nr_applications != 0) {
-				//...then fade out the button, show the progress bar and call the function for acceptance
-				$("#button_accept").fadeOut("slow",
-					function() {
-						$("#applications_progress_bar").progressBar(0);
-						$("#button_accept").val("Bulk accept");
-						$("#description_done").html("");
-						$("#applications_progress_bar").fadeIn("slow", acceptOrgs(data));
-					}
-				);
-			}else {
-				$("#description_done").html("<strong>No organizations to accept</strong>");
-			}
-		}
-	);
-}
-
-function acceptOrgs(data) {
-	// some global constants
-	var GLOBAL_LINK = data.link;
-	var TOTAL_APPLICATIONS = data.nr_applications;
-
-	// some global variables set needed for internal iteration
-	var application_index = 0;
-	// number of iteration is not taken from data.nr_applications
-	// to ensure avoidance of array out of bounds errors
-	var total_index = data.applications.length;
-
-
-	// call immediately the function for acceptance
-	// real iteration is inside
-	setTimeout(function(){
-		var error_happened = false;
-
-		var application = data.applications[application_index];
-		var current_application = application_index + 1;
-		// regular expression to find a valid scope path inside matching parenthesis
-		var re = /\((\w*)\)/;
-		var scope_path = GLOBAL_LINK.match(re)[1];
-		// the URL is obtained by using the scope path found in the matching parenthesis
-		var url_to_call = GLOBAL_LINK.replace(re, eval("application." + scope_path));
-		// now we can call the URL found
-		$.ajax({
-			async: false,
-			cache: false,
-			url: url_to_call,
-			timeout: 10000,
-			success: function(data) {
-				if (data) {
-					// update progress bar percentage and description
-					var percentage = Math.floor(100 * (current_application) / (TOTAL_APPLICATIONS));
-					$("#description_progressbar").html(" Processed application " + application.name + " (" + (current_application) + "/" + TOTAL_APPLICATIONS + ")");
-					$("#applications_progress_bar").progressBar(percentage);
-				}
-			},
-			error: function(XMLHttpRequest, textStatus, errorThrown) {
-				// if there is an error rename the button to Retry and show an error message
-				error_happened = true;
-				$("#button_accept").val("Retry");
-				$("#button_accept").fadeIn("slow", function() {
-					$("#description_done").html("<strong class='error'> Error encountered, try again</strong>");
-				});
-			}
-		});
-		// if there were no errors, continue the iteration
-		if (!error_happened) {
-			// prepare for new iteration and then recall this function
-			application_index++;
-			if (application_index < total_index) {
-				setTimeout(arguments.callee, 0);
-			}
-			else {
-				// all ok, tell the user we are done
-				$("#applications_progress_bar").fadeOut("slow",
-					function() {
-						$("#applications_progress_bar").progressBar(0);
-						$("#button_accept").fadeIn("slow");
-					}
-				);
-				$("#description_progressbar").html("");
-				$("#description_done").html("<strong>Done!</strong>");
-			}
-		}
-	},0);
-}
--- a/app/soc/templates/soc/base.html	Thu Feb 26 20:23:21 2009 +0000
+++ b/app/soc/templates/soc/base.html	Thu Feb 26 20:25:56 2009 +0000
@@ -68,8 +68,8 @@
   {% if uses_jq_progressbar %}
   <script type="text/javascript" src="/jquery/jquery-progressbar.js"></script>
   {% endif %}
-  {% if uses_orgaccept %}
-  <script type="text/javascript" src="/soc/content/js/org-accept.js"></script>
+  {% if uses_bulk_review %}
+  <script type="text/javascript" src="/soc/content/js/bulk-review.js"></script>
   {% endif %}
   {% if uses_jq_ui_core %}
   <script type="text/javascript" src="/jquery/jquery-ui.core.js"></script>
--- a/app/soc/views/helper/params.py	Thu Feb 26 20:23:21 2009 +0000
+++ b/app/soc/views/helper/params.py	Thu Feb 26 20:25:56 2009 +0000
@@ -59,7 +59,7 @@
     'jq_thickbox',
     'jq_ui_core',
     'menu',
-    'orgaccept',
+    'bulk_review',
     'tinymce',
     ]
 
@@ -121,7 +121,7 @@
   if 'document_prefix' not in params:
     params['document_prefix'] = params['url_name']
 
-  # Do not expand edit_redirect to allow it to be overriden without suffix
+  # Do not expand edit_redirect to allow it to be overwritten without suffix
   new_params['edit_redirect'] = '/%(url_name)s/edit/%(suffix)s'
   new_params['missing_redirect'] = '/%(url_name)s/create' % params
   new_params['delete_redirect'] = '/%(url_name)s/list' % params