incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [4/9] git commit: [#6456] Changed field names for GC project import
Date Tue, 23 Jul 2013 02:52:47 GMT
[#6456] Changed field names for GC project import

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/a5371df3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a5371df3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a5371df3

Branch: refs/heads/master
Commit: a5371df3be09ff8bf017057e86570d6ab3a3c1fc
Parents: 7af8206
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Mon Jul 22 18:57:20 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Tue Jul 23 02:45:41 2013 +0000

----------------------------------------------------------------------
 .../forgeimporters/google/__init__.py           |  4 +--
 ForgeImporters/forgeimporters/google/project.py | 19 +++++++------
 .../google/templates/project.html               | 30 ++++++++++----------
 3 files changed, 27 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a5371df3/ForgeImporters/forgeimporters/google/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/__init__.py b/ForgeImporters/forgeimporters/google/__init__.py
index e01dcfb..235791f 100644
--- a/ForgeImporters/forgeimporters/google/__init__.py
+++ b/ForgeImporters/forgeimporters/google/__init__.py
@@ -48,8 +48,8 @@ class GoogleCodeProjectExtractor(object):
         })
 
     def __init__(self, project, page='project_info'):
-        gc_project_name = project.get_tool_data('google-code', 'project_name')
-        page = urllib2.urlopen(self.PAGE_MAP[page] % urllib.quote(gc_project_name))
+        project_name = project.get_tool_data('google-code', 'project_name')
+        page = urllib2.urlopen(self.PAGE_MAP[page] % urllib.quote(project_name))
         self.project = project
         self.page = BeautifulSoup(page)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a5371df3/ForgeImporters/forgeimporters/google/project.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/project.py b/ForgeImporters/forgeimporters/google/project.py
index fdd3c97..ec8de53 100644
--- a/ForgeImporters/forgeimporters/google/project.py
+++ b/ForgeImporters/forgeimporters/google/project.py
@@ -24,6 +24,7 @@ from allura import model as M
 from allura.lib.decorators import require_post
 from allura.lib.widgets.forms import NeighborhoodProjectShortNameValidator
 from allura.lib import helpers as h
+from allura.lib import exceptions
 
 from .. import base
 from . import tasks
@@ -32,8 +33,8 @@ from . import tasks
 
 class GoogleCodeProjectForm(schema.Schema):
     neighborhood = fev.PlainText(not_empty=True)
-    gc_project_name = fev.Regex(r'^[a-z0-9][a-z0-9-]{,61}$', not_empty=True)
-    project_unixname = NeighborhoodProjectShortNameValidator()
+    project_name = fev.Regex(r'^[a-z0-9][a-z0-9-]{,61}$', not_empty=True)
+    project_shortname = NeighborhoodProjectShortNameValidator()
     tools = base.ToolsValidator('Google Code')
 
 
@@ -49,13 +50,13 @@ class GoogleCodeProjectImporter(base.ProjectImporter):
     @require_post()
     @expose()
     @validate(GoogleCodeProjectForm(), error_handler=index)
-    def process(self, gc_project_name=None, project_unixname=None, tools=None, **kw):
+    def process(self, project_name=None, project_shortname=None, tools=None, **kw):
         neighborhood = M.Neighborhood.query.get(url_prefix='/p/')
-        project_name = h.really_unicode(gc_project_name).encode('utf-8')
-        project_unixname = h.really_unicode(project_unixname).encode('utf-8').lower()
+        project_name = h.really_unicode(project_name).encode('utf-8')
+        project_shortname = h.really_unicode(project_shortname).encode('utf-8').lower()
 
         try:
-            c.project = neighborhood.register_project(project_unixname,
+            c.project = neighborhood.register_project(project_shortname,
                     project_name=project_name)
         except exceptions.ProjectOverlimitError:
             flash("You have exceeded the maximum number of projects you are allowed to create",
'error')
@@ -64,11 +65,11 @@ class GoogleCodeProjectImporter(base.ProjectImporter):
             flash("Project creation rate limit exceeded.  Please try again later.", 'error')
             redirect('.')
         except Exception as e:
-            log.error('error registering project: %s', project_unixname, exc_info=True)
+            log.error('error registering project: %s', project_shortname, exc_info=True)
             flash('Internal Error. Please try again later.', 'error')
             redirect('.')
 
-        c.project.set_tool_data('google-code', project_name=gc_project_name)
+        c.project.set_tool_data('google-code', project_name=project_name)
         tasks.import_project_info.post()
         for tool in tools:
             tool.import_tool(c.project)
@@ -79,5 +80,5 @@ class GoogleCodeProjectImporter(base.ProjectImporter):
 
     @expose('json:')
     @validate(GoogleCodeProjectForm())
-    def check_names(self, gc_project_name=None, project_unixname=None, tools=None, **kw):
+    def check_names(self, project_name=None, project_shortname=None, tools=None, **kw):
         return c.form_errors

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a5371df3/ForgeImporters/forgeimporters/google/templates/project.html
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/templates/project.html b/ForgeImporters/forgeimporters/google/templates/project.html
index ae9362a..a98d5ef 100644
--- a/ForgeImporters/forgeimporters/google/templates/project.html
+++ b/ForgeImporters/forgeimporters/google/templates/project.html
@@ -41,19 +41,19 @@
         var manual = false;
         function suggest_name() {
             if (!manual) {
-                $('#project_unixname').val($('#gc_project_name').val()).trigger('change');
+                $('#project_shortname').val($('#project_name').val()).trigger('change');
             }
         }
 
         function check_names() {
             var data = {
                 'neighborhood': $('#neighborhood').val(),
-                'gc_project_name': $('#gc_project_name').val(),
-                'project_unixname': $('#project_unixname').val()
+                'project_name': $('#project_name').val(),
+                'project_shortname': $('#project_shortname').val()
             };
             $.getJSON('check_names', data, function(result) {
-                $('#gc_project_name_error').addClass('hidden');
-                $('#project_unixname_error').addClass('hidden');
+                $('#project_name_error').addClass('hidden');
+                $('#project_shortname_error').addClass('hidden');
                 for(var field in result) {
                     $('#'+field+'_error').text(result[field]).removeClass('hidden');
                 }
@@ -61,13 +61,13 @@
         }
 
         function update_url() {
-            $('#url-fragment').text($('#project_unixname').val());
+            $('#url-fragment').text($('#project_shortname').val());
         }
 
         $(function() {
-            $('#gc_project_name').focus().bind('change keyup', suggest_name);
+            $('#project_name').focus().bind('change keyup', suggest_name);
 
-            $('#project_unixname').bind('change keyup', function(event) {
+            $('#project_shortname').bind('change keyup', function(event) {
                 if (event.type == 'keyup') {
                     manual = true;
                 }
@@ -83,9 +83,9 @@
         <label>Google Project Name</label>
     </div>
     <div class="grid-10">
-        <input id="gc_project_name" name="gc_project_name" value="{{c.form_values['gc_project_name']}}"/>
-        <div id="gc_project_name_error" class="error{% if not c.form_errors['gc_project_name']
%} hidden{% endif %}">
-            {{c.form_errors['gc_project_name']}}
+        <input id="project_name" name="project_name" value="{{c.form_values['project_name']}}"/>
+        <div id="project_name_error" class="error{% if not c.form_errors['project_name']
%} hidden{% endif %}">
+            {{c.form_errors['project_name']}}
         </div>
     </div>
 
@@ -93,12 +93,12 @@
         <label>URL Name</label>
     </div>
     <div class="grid-10">
-        <input id="project_unixname" name="project_unixname" value="{{c.form_values['project_unixname']}}"/>
-        <div id="project_unixname_error" class="error{% if not c.form_errors['project_unixname']
%} hidden{% endif %}">
-            {{c.form_errors['project_unixname']}}
+        <input id="project_shortname" name="project_shortname" value="{{c.form_values['project_shortname']}}"/>
+        <div id="project_shortname_error" class="error{% if not c.form_errors['project_shortname']
%} hidden{% endif %}">
+            {{c.form_errors['project_shortname']}}
         </div>
         <div id="project-url">
-            http://{{request.environ['HTTP_HOST']}}{{neighborhood.url()}}<span id="url-fragment">{{c.form_values['project_unixname']}}</span>
+            http://{{request.environ['HTTP_HOST']}}{{neighborhood.url()}}<span id="url-fragment">{{c.form_values['project_shortname']}}</span>
         </div>
     </div>
 {% endblock %}


Mime
View raw message