changeset 4028:c3245a0452a3

Added --no-public-access / --public-access flags into setup-rhodecode command to enable setup without public access
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 21 Jun 2013 00:36:01 +0200
parents 4eaeae84f474
children c9bcfe2d2ade
files rhodecode/lib/db_manage.py rhodecode/lib/paster_commands/setup_rhodecode.py rhodecode/tests/scripts/create_rc.sh
diffstat 3 files changed, 23 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/db_manage.py	Fri Jun 21 00:01:31 2013 +0200
+++ b/rhodecode/lib/db_manage.py	Fri Jun 21 00:36:01 2013 +0200
@@ -696,10 +696,18 @@
     def create_default_user(self):
         log.info('creating default user')
         # create default user for handling default permissions.
-        UserModel().create_or_update(username='default',
-                              password=str(uuid.uuid1())[:8],
-                              email='anonymous@rhodecode.org',
-                              firstname='Anonymous', lastname='User')
+        user = UserModel().create_or_update(username=User.DEFAULT_USER,
+                                            password=str(uuid.uuid1())[:20],
+                                            email='anonymous@rhodecode.org',
+                                            firstname='Anonymous',
+                                            lastname='User')
+        # based on configuration options activate/deactive this user which
+        # controlls anonymous access
+        if self.cli_args.get('public_access') is False:
+            log.info('Public access disabled')
+            user.active = False
+            Session().add(user)
+            Session().commit()
 
     def create_permissions(self):
         """
--- a/rhodecode/lib/paster_commands/setup_rhodecode.py	Fri Jun 21 00:01:31 2013 +0200
+++ b/rhodecode/lib/paster_commands/setup_rhodecode.py	Fri Jun 21 00:36:01 2013 +0200
@@ -64,7 +64,16 @@
                        dest='force_ask',
                        default=None,
                        help='Force no to every question')
-
+    parser.add_option('--public-access',
+                       action='store_true',
+                       dest='public_access',
+                       default=None,
+                       help='Enable public access on this installation (default)')
+    parser.add_option('--no-public-access',
+                       action='store_false',
+                       dest='public_access',
+                       default=None,
+                       help='Disable public access on this installation ')
     def command(self):
         config_spec = self.args[0]
         section = self.options.section_name
--- a/rhodecode/tests/scripts/create_rc.sh	Fri Jun 21 00:01:31 2013 +0200
+++ b/rhodecode/tests/scripts/create_rc.sh	Fri Jun 21 00:36:01 2013 +0200
@@ -1,6 +1,6 @@
 psql -U postgres -h localhost -c 'drop database if exists rhodecode;'
 psql -U postgres -h localhost -c 'create database rhodecode;'
-paster setup-rhodecode rc.ini --force-yes --user=marcink --password=qweqwe --email=marcin@python-blog.com --repos=/home/marcink/repos
+paster setup-rhodecode rc.ini --force-yes --user=marcink --password=qweqwe --email=marcin@python-blog.com --repos=/home/marcink/repos --no-public-access
 API_KEY=`psql -R " " -A -U postgres -h localhost -c "select api_key from users where admin=TRUE" -d rhodecode | awk '{print $2}'`
 echo "run those after running server"
 paster serve rc.ini --pid-file=rc.pid --daemon