Changeset - 520d27f40b51
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 15 years ago 2011-02-15 23:19:01
marcin@python-works.com
#113 removed anonymous access from forking, added system messages in login box.
3 files changed with 21 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/settings.py
Show inline comments
 
@@ -32,15 +32,18 @@ import formencode
 

	
 
from pylons import tmpl_context as c, request, url
 
from pylons.controllers.util import redirect
 
from pylons.i18n.translation import _
 

	
 
import rhodecode.lib.helpers as h
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator
 

	
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator, \
 
    NotAnonymous
 
from rhodecode.lib.base import BaseRepoController, render
 
from rhodecode.lib.utils import invalidate_cache, action_logger
 

	
 
from rhodecode.model.forms import RepoSettingsForm, RepoForkForm
 
from rhodecode.model.repo import RepoModel
 
from rhodecode.model.db import User
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -154,12 +157,13 @@ class SettingsController(BaseRepoControl
 
        except Exception:
 
            h.flash(_('An error occurred during deletion of %s') % repo_name,
 
                    category='error')
 

	
 
        return redirect(url('home'))
 

	
 
    @NotAnonymous()
 
    @HasRepoPermissionAllDecorator('repository.read')
 
    def fork(self, repo_name):
 
        repo_model = RepoModel()
 
        c.repo_info = repo = repo_model.get_by_repo_name(repo_name)
 
        if not repo:
 
            h.flash(_('%s repository is not mapped to db perhaps'
 
@@ -169,13 +173,13 @@ class SettingsController(BaseRepoControl
 
                      category='error')
 

	
 
            return redirect(url('home'))
 

	
 
        return render('settings/repo_fork.html')
 

	
 

	
 
    @NotAnonymous()
 
    @HasRepoPermissionAllDecorator('repository.read')
 
    def fork_create(self, repo_name):
 
        repo_model = RepoModel()
 
        c.repo_info = repo_model.get_by_repo_name(repo_name)
 
        _form = RepoForkForm(old_data={'repo_type':c.repo_info.repo_type})()
 
        form_result = {}
rhodecode/lib/auth.py
Show inline comments
 
@@ -30,12 +30,13 @@ import logging
 
import traceback
 

	
 
from decorator import decorator
 

	
 
from pylons import config, session, url, request
 
from pylons.controllers.util import abort, redirect
 
from pylons.i18n.translation import _
 

	
 
from rhodecode.lib.exceptions import LdapPasswordError, LdapUsernameError
 
from rhodecode.lib.utils import get_repo_slug
 
from rhodecode.lib.auth_ldap import AuthLdap
 

	
 
from rhodecode.model import meta
 
@@ -381,12 +382,16 @@ class NotAnonymous(object):
 
            if request.environ.get('SCRIPT_NAME') != '/':
 
                p += request.environ.get('SCRIPT_NAME')
 

	
 
            p += request.environ.get('PATH_INFO')
 
            if request.environ.get('QUERY_STRING'):
 
                p += '?' + request.environ.get('QUERY_STRING')
 

	
 
            import rhodecode.lib.helpers as h
 
            h.flash(_('You need to be a registered user to perform this action'),
 
                    category='warning')
 
            return redirect(url('login_home', came_from=p))
 
        else:
 
            return func(*fargs, **fkwargs)
 

	
 
class PermsDecorator(object):
 
    """Base class for decorators"""
rhodecode/templates/login.html
Show inline comments
 
@@ -10,12 +10,22 @@
 
        <!-- stylesheets -->
 
        <link rel="stylesheet" type="text/css" href="${h.url('/css/style.css')}" media="screen" />
 

	
 
    </head>
 
    <body>
 
<div id="login">
 
        <div class="flash_msg">
 
            <% messages = h.flash.pop_messages() %>
 
            % if messages:
 
            <ul id="flash-messages">
 
                % for message in messages:
 
                <li class="${message.category}_msg">${message}</li>
 
                % endfor
 
            </ul>
 
            % endif
 
        </div>          
 
            <!-- login -->
 
            <div class="title top-left-rounded-corner top-right-rounded-corner">
 
                <h5>${_('Sign In to')} ${c.rhodecode_name}</h5>
 
            </div>
 
            <div class="inner">            
 
                ${h.form(h.url.current(came_from=c.came_from))}
0 comments (0 inline, 0 general)