You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/05/28 22:13:25 UTC

[23/26] allura git commit: [#7868] ticket:777 Show phone verification overlay after form submit

[#7868] ticket:777 Show phone verification overlay after form submit


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

Branch: refs/heads/master
Commit: 9b6c507ae91a3a0438aa8e81e08d4bd0b8cdf646
Parents: 9b9b0e8
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue May 26 17:16:01 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 28 20:11:47 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py             | 5 ++---
 Allura/allura/lib/widgets/forms.py               | 8 ++++++++
 Allura/allura/public/nf/js/phone-verification.js | 5 ++++-
 3 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/9b6c507a/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index f0e068b..d5f390a 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -185,9 +185,8 @@ class NeighborhoodController(object):
     @without_trailing_slash
     def add_project(self, **form_data):
         require_access(self.neighborhood, 'register')
-        provider = plugin.ProjectRegistrationProvider.get()
-        phone_verified = provider.phone_verified(c.user, self.neighborhood)
-        c.show_phone_verification_overlay = not phone_verified
+        verify = c.form_errors == {'_the_form': u'phone-verification'}
+        c.show_phone_verification_overlay = verify
         c.add_project = W.add_project
         form_data.setdefault(
             'tools', [u'Wiki', u'Git', u'Tickets', u'Discussion'])

http://git-wip-us.apache.org/repos/asf/allura/blob/9b6c507a/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 27fd242..f62aa4a 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -949,6 +949,14 @@ class NeighborhoodAddProjectForm(ForgeForm):
             ew.CheckboxSet(name='tools', options=tools_options),
         ])
 
+    @ew_core.core.validator
+    def validate(self, value, state=None):
+        value = super(NeighborhoodAddProjectForm, self).validate(value, state)
+        provider = plugin.ProjectRegistrationProvider.get()
+        if not provider.phone_verified(c.user, c.project.neighborhood):
+            raise formencode.Invalid(u'phone-verification', value, None)
+        return value
+
     def resources(self):
         for r in super(NeighborhoodAddProjectForm, self).resources():
             yield r

http://git-wip-us.apache.org/repos/asf/allura/blob/9b6c507a/Allura/allura/public/nf/js/phone-verification.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/phone-verification.js b/Allura/allura/public/nf/js/phone-verification.js
index 77d25f7..e6bb8fc 100644
--- a/Allura/allura/public/nf/js/phone-verification.js
+++ b/Allura/allura/public/nf/js/phone-verification.js
@@ -145,7 +145,10 @@ var StepCheck = React.createClass({
   getAPIData: function() { return {'pin': this.props.state[this.getKey()]}; },
   getLabel: function() { return 'Enter PIN'; },
   getKey: function() { return 'pin'; },
-  onSuccess: function() { window.top.location.reload(); }
+  onSuccess: function() {
+    var form = window.top.jQuery('form[action="/p/register"]');
+    form.submit();
+  }
 });
 
 var PhoneVerificationForm = React.createClass({