allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#6529] Added login overlay for project importers
Date Tue, 10 Sep 2013 21:55:29 GMT
Updated Branches:
  refs/heads/cj/6529 [created] c33f5b993


[#6529] Added login overlay for project importers

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/c33f5b99
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c33f5b99
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c33f5b99

Branch: refs/heads/cj/6529
Commit: c33f5b99377e48681482c735e62b0dd5c38d8d02
Parents: 21b64d0
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Tue Sep 10 21:55:05 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Tue Sep 10 21:55:05 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py                      |  4 ++++
 Allura/allura/lib/app_globals.py                       |  7 +++++++
 Allura/allura/lib/security.py                          | 10 +++++++---
 Allura/allura/lib/widgets/forms.py                     |  3 ++-
 Allura/allura/nf/allura/css/allura.css                 | 13 ++++++++++++-
 Allura/allura/templates/jinja_master/master.html       |  3 +++
 Allura/allura/templates/jinja_master/theme_macros.html | 11 ++++++++++-
 Allura/allura/templates/widgets/forge_form.html        |  1 +
 ForgeImporters/forgeimporters/base.py                  |  3 ++-
 9 files changed, 48 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c33f5b99/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 4c1ee37..fa00208 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -105,6 +105,10 @@ class AuthController(BaseController):
         c.form = F.login_form
         return dict(oid_providers=OID_PROVIDERS, return_to=return_to)
 
+    @expose('jinja:allura:templates/login_fragment.html')
+    def login_fragment(self, *args, **kwargs):
+        return self.index(*args, **kwargs)
+
     @expose('jinja:allura:templates/custom_login.html')
     def login_verify_oid(self, provider, username, return_to=None):
         if provider:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c33f5b99/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index c1c0b32..e684383 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -115,6 +115,7 @@ class Globals(object):
         # Load login/logout urls; only used for SFX logins
         self.login_url = config.get('auth.login_url', '/auth/')
         self.logout_url = config.get('auth.logout_url', '/auth/logout')
+        self.login_fragment_url = config.get('auth.login_fragment_url', '/auth/login_fragment')
 
         # Setup Gravatar
         self.gravatar = gravatar.url
@@ -401,6 +402,12 @@ class Globals(object):
     def resource_manager(self):
         return ew_core.widget_context.resource_manager
 
+    def register_css(self, href, **kw):
+        self.resource_manager.register(ew.CSSLink(href, **kw))
+
+    def register_js(self, href, **kw):
+        self.resource_manager.register(ew.JSLink(href, **kw))
+
     def register_forge_css(self, href, **kw):
         self.resource_manager.register(ew.CSSLink('allura/' + href, **kw))
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c33f5b99/Allura/allura/lib/security.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/security.py b/Allura/allura/lib/security.py
index a0497ca..4718e56 100644
--- a/Allura/allura/lib/security.py
+++ b/Allura/allura/lib/security.py
@@ -383,7 +383,7 @@ def all_allowed(obj, user_or_role=None, project=None):
         return set([M.ALL_PERMISSIONS])
     return perms
 
-def require(predicate, message=None):
+def require(predicate, message=None, login_overlay=False):
     '''
     Example: require(has_access(c.app, 'read'))
 
@@ -401,13 +401,17 @@ def require(predicate, message=None):
     if c.user != M.User.anonymous():
         request.environ['error_message'] = message
         raise exc.HTTPForbidden(detail=message)
+    elif login_overlay:
+        c.show_login_overlay = True
     else:
         raise exc.HTTPUnauthorized()
 
-def require_access(obj, permission, **kwargs):
+def require_access(obj, permission, login_overlay=False, **kwargs):
     if obj is not None:
         predicate = has_access(obj, permission, **kwargs)
-        return require(predicate, message='%s access required' % permission.capitalize())
+        return require(predicate,
+                message='%s access required' % permission.capitalize(),
+                login_overlay=login_overlay)
     else:
         raise exc.HTTPForbidden(detail="Could not verify permissions for this page.")
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c33f5b99/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index ae90b26..9d3f602 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -84,7 +84,8 @@ class ForgeForm(ew.SimpleForm):
         submit_text='Save',
         style='standard',
         method='post',
-        enctype=None)
+        enctype=None,
+        target=None)
 
     def display_label(self, field, label_text=None):
         ctx = super(ForgeForm, self).context_for(field)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c33f5b99/Allura/allura/nf/allura/css/allura.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/allura.css b/Allura/allura/nf/allura/css/allura.css
index 1334b0c..38404f7 100644
--- a/Allura/allura/nf/allura/css/allura.css
+++ b/Allura/allura/nf/allura/css/allura.css
@@ -215,4 +215,15 @@ b.ico.ico-vote-down { background-image: url('../images/vote_down.png');
}
 tr.rev div.markdown_content p {
     padding: 0;
     margin-bottom: 0;
-}
\ No newline at end of file
+}
+
+#login_overlay .title {
+    margin-bottom: 0;
+    padding-left: 10px;
+    border-top-left-radius: 4px;
+    border-top-right-radius: 4px;
+}
+
+#login_overlay iframe {
+    width: 400px;
+}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c33f5b99/Allura/allura/templates/jinja_master/master.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/master.html b/Allura/allura/templates/jinja_master/master.html
index e3afa6a..8060240 100644
--- a/Allura/allura/templates/jinja_master/master.html
+++ b/Allura/allura/templates/jinja_master/master.html
@@ -132,6 +132,9 @@
           </section>
         {% endfor %}
     </div>
+    {% if c.show_login_overlay %}
+        {{theme_macros.login_overlay()}}
+    {% endif %}
     {% for blob in g.resource_manager.emit('body_js') %}
       {{ blob }}
     {% endfor %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c33f5b99/Allura/allura/templates/jinja_master/theme_macros.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/theme_macros.html b/Allura/allura/templates/jinja_master/theme_macros.html
index 61f5e2f..7fc070c 100644
--- a/Allura/allura/templates/jinja_master/theme_macros.html
+++ b/Allura/allura/templates/jinja_master/theme_macros.html
@@ -112,4 +112,13 @@
          {% endif %}
       </div>
   {% endif %}
-{%- endmacro %}
\ No newline at end of file
+{%- endmacro %}
+
+{%- macro login_overlay() %}
+    {% do g.register_js('js/jquery.lightbox_me.js') %}
+    {% do g.register_js('js/login_overlay.js') %}
+    <div id="login_overlay" class="ui-widget-content">
+        <h2 class="dark title">Login Required</h2>
+        <iframe src="{{g.login_fragment_url}}"></iframe>
+    </div>
+{%- endmacro %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c33f5b99/Allura/allura/templates/widgets/forge_form.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/forge_form.html b/Allura/allura/templates/widgets/forge_form.html
index 8adde73..adbc01c 100644
--- a/Allura/allura/templates/widgets/forge_form.html
+++ b/Allura/allura/templates/widgets/forge_form.html
@@ -18,6 +18,7 @@
 -#}
 <form method="{{method}}"
       {% if enctype %}enctype="{{enctype}}"{% endif %}
+      {% if target %}target="{{target}}"{% endif %}
       action="{{action}}">
   {% set extra_width = 0 %}
   {% if style == 'wide' %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c33f5b99/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index ffb1650..8cb8066 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -188,7 +188,7 @@ class ProjectImporter(BaseController):
         self.neighborhood = neighborhood
 
     def _check_security(self):
-        require_access(self.neighborhood, 'register')
+        require_access(self.neighborhood, 'register', login_overlay=True)
 
     @LazyProperty
     def tool_importers(self):
@@ -229,6 +229,7 @@ class ProjectImporter(BaseController):
         tools installed and redirect to the new project, presumably with a
         message indicating that some data will not be available immediately.
         """
+        require_access(self.neighborhood, 'register', login_overlay=False)
         try:
             c.project = self.neighborhood.register_project(kw['project_shortname'],
                     project_name=kw['project_name'])


Mime
View raw message