Mercurial > kallithea
annotate rhodecode/lib/db_manage.py @ 4147:1c8f818787b3 rhodecode-2.2.5-gpl
old style: show the full link box on summary page - no overlap or truncation
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 02 Jul 2014 19:03:23 -0400 |
parents | ffd45b185016 |
children | 48ad84558fb4 |
rev | line source |
---|---|
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
1 # -*- coding: utf-8 -*- |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
2 # This program is free software: you can redistribute it and/or modify |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
3 # it under the terms of the GNU General Public License as published by |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
4 # the Free Software Foundation, either version 3 of the License, or |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
5 # (at your option) any later version. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
6 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
7 # This program is distributed in the hope that it will be useful, |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
10 # GNU General Public License for more details. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
11 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
12 # You should have received a copy of the GNU General Public License |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
14 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
15 rhodecode.lib.db_manage |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
16 ~~~~~~~~~~~~~~~~~~~~~~~ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
17 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
18 Database creation, and setup module for RhodeCode. Used for creation |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
19 of database as well as for migration operations |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
20 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
21 :created_on: Apr 10, 2010 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
22 :author: marcink |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
23 :copyright: (c) 2013 RhodeCode GmbH. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
24 :license: GPLv3, see LICENSE for more details. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
25 """ |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
26 |
249
bad9ccac26b7
fixed import errors on db_manage
Marcin Kuzminski <marcin@python-works.com>
parents:
243
diff
changeset
|
27 import os |
bad9ccac26b7
fixed import errors on db_manage
Marcin Kuzminski <marcin@python-works.com>
parents:
243
diff
changeset
|
28 import sys |
3907
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
29 import time |
327
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
307
diff
changeset
|
30 import uuid |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
31 import logging |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
32 from os.path import dirname as dn, join as jn |
3972
3cb5a35a319d
added migrations for column change for gists expiration date
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
33 import datetime |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
34 |
2827
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
35 from rhodecode import __dbversion__, __py_version__ |
249
bad9ccac26b7
fixed import errors on db_manage
Marcin Kuzminski <marcin@python-works.com>
parents:
243
diff
changeset
|
36 |
1634
1d904d972c47
User usermodel instead of db model to manage accounts
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
37 from rhodecode.model.user import UserModel |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
38 from rhodecode.lib.utils import ask_ok |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
39 from rhodecode.model import init_model |
1266
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
40 from rhodecode.model.db import User, Permission, RhodeCodeUi, \ |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
41 RhodeCodeSetting, UserToPerm, DbMigrateVersion, RepoGroup, \ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
42 UserRepoGroupToPerm, CacheInvalidation, UserGroup, Repository |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
43 |
239
b18f89d6d17f
Adde draft for permissions systems, made all needed decorators, and checks. For future usage in the system.
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
44 from sqlalchemy.engine import create_engine |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
45 from rhodecode.model.repo_group import RepoGroupModel |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
46 #from rhodecode.model import meta |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
47 from rhodecode.model.meta import Session, Base |
3309
b3cf4539d1bd
Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents:
3232
diff
changeset
|
48 from rhodecode.model.repo import RepoModel |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
49 from rhodecode.model.permission import PermissionModel |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
50 from rhodecode.model.user_group import UserGroupModel |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
51 |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
52 |
351
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
53 log = logging.getLogger(__name__) |
66
163464441e0d
updated db manage script for creating interactive admin account and db
Marcin Kuzminski <marcin@python-blog.com>
parents:
59
diff
changeset
|
54 |
1266
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
55 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
56 def notify(msg): |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
57 """ |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
58 Notification for migrations messages |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
59 """ |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
60 ml = len(msg) + (4 * 2) |
3907
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
61 print('\n%s\n*** %s ***\n%s' % ('*' * ml, msg, '*' * ml)).upper() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
62 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
63 |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
88
diff
changeset
|
64 class DbManage(object): |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
65 def __init__(self, log_sql, dbconf, root, tests=False, SESSION=None, cli_args={}): |
781
7ae66bddf48d
fixed db manage, to work on other databases than sqlite
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
66 self.dbname = dbconf.split('/')[-1] |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
67 self.tests = tests |
552
2642f128ad46
removed egg info, update files for distutils build
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
68 self.root = root |
781
7ae66bddf48d
fixed db manage, to work on other databases than sqlite
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
69 self.dburi = dbconf |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
70 self.log_sql = log_sql |
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
71 self.db_exists = False |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
72 self.cli_args = cli_args |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
73 self.init_db(SESSION=SESSION) |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
74 |
3671
658ccf9727ef
setup_rhodecode: fix --force-no - force_ask is tri-state
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
75 force_ask = self.cli_args.get('force_ask') |
658ccf9727ef
setup_rhodecode: fix --force-no - force_ask is tri-state
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
76 if force_ask is not None: |
658ccf9727ef
setup_rhodecode: fix --force-no - force_ask is tri-state
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
77 global ask_ok |
658ccf9727ef
setup_rhodecode: fix --force-no - force_ask is tri-state
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
78 ask_ok = lambda *args, **kwargs: force_ask |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
79 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
80 def init_db(self, SESSION=None): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
81 if SESSION: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
82 self.sa = SESSION |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
83 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
84 #init new sessions |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
85 engine = create_engine(self.dburi, echo=self.log_sql) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
86 init_model(engine) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
87 self.sa = Session() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
88 |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
89 def create_tables(self, override=False): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
90 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
91 Create a auth database |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
88
diff
changeset
|
92 """ |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
93 |
1138
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
94 log.info("Any existing database is going to be destroyed") |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
95 if self.tests: |
1138
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
96 destroy = True |
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
97 else: |
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
98 destroy = ask_ok('Are you sure to destroy old database ? [y/n]') |
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
99 if not destroy: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
100 print 'Nothing done.' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
101 sys.exit(0) |
1138
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
102 if destroy: |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
103 Base.metadata.drop_all() |
964
84bb5b8b498d
changed dev and tests to postgressql for more error proof setup.
Marcin Kuzminski <marcin@python-works.com>
parents:
907
diff
changeset
|
104 |
351
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
105 checkfirst = not override |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
106 Base.metadata.create_all(checkfirst=checkfirst) |
1976 | 107 log.info('Created tables for %s' % self.dbname) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
108 |
834
8924ed0e4f36
added current db version into rhodecode,
Marcin Kuzminski <marcin@python-works.com>
parents:
781
diff
changeset
|
109 def set_db_version(self): |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
110 ver = DbMigrateVersion() |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
111 ver.version = __dbversion__ |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
112 ver.repository_id = 'rhodecode_db_migrations' |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
113 ver.repository_path = 'versions' |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
114 self.sa.add(ver) |
1976 | 115 log.info('db version set to: %s' % __dbversion__) |
834
8924ed0e4f36
added current db version into rhodecode,
Marcin Kuzminski <marcin@python-works.com>
parents:
781
diff
changeset
|
116 |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
117 def upgrade(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
118 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
119 Upgrades given database schema to given revision following |
900
07f248329a3b
updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
890
diff
changeset
|
120 all needed steps, to perform the upgrade |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
121 |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
122 """ |
841
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
123 |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
124 from rhodecode.lib.dbmigrate.migrate.versioning import api |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
125 from rhodecode.lib.dbmigrate.migrate.exceptions import \ |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
126 DatabaseNotControlledError |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
127 |
1835
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
128 if 'sqlite' in self.dburi: |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
129 print ( |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
130 '********************** WARNING **********************\n' |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
131 'Make sure your version of sqlite is at least 3.7.X. \n' |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
132 'Earlier versions are known to fail on some migrations\n' |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
133 '*****************************************************\n') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
134 |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
135 upgrade = ask_ok('You are about to perform database upgrade, make ' |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
136 'sure You backed up your database before. ' |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
137 'Continue ? [y/n]') |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
138 if not upgrade: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
139 print 'No upgrade performed' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
140 sys.exit(0) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
141 |
843
3b21ba5f7cb0
fixed path issues in upgrade script
Marcin Kuzminski <marcin@python-works.com>
parents:
841
diff
changeset
|
142 repository_path = jn(dn(dn(dn(os.path.realpath(__file__)))), |
3b21ba5f7cb0
fixed path issues in upgrade script
Marcin Kuzminski <marcin@python-works.com>
parents:
841
diff
changeset
|
143 'rhodecode/lib/dbmigrate') |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
144 db_uri = self.dburi |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
145 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
146 try: |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
147 curr_version = api.db_version(db_uri, repository_path) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
148 msg = ('Found current database under version ' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
149 'control with version %s' % curr_version) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
150 |
1299
8eda822931c9
small fixes for interactive prompt in setup
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
151 except (RuntimeError, DatabaseNotControlledError): |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
152 curr_version = 1 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
153 msg = ('Current database is not under version control. Setting ' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
154 'as version %s' % curr_version) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
155 api.version_control(db_uri, repository_path, curr_version) |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
156 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
157 notify(msg) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
158 if curr_version == __dbversion__: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
159 print 'This database is already at the newest version' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
160 sys.exit(0) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
161 |
3757
f08881dcc9eb
invalidate: clear CacheInvalidation when upgrading
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
162 # clear cache keys |
f08881dcc9eb
invalidate: clear CacheInvalidation when upgrading
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
163 log.info("Clearing cache keys now...") |
f08881dcc9eb
invalidate: clear CacheInvalidation when upgrading
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
164 CacheInvalidation.clear_cache() |
f08881dcc9eb
invalidate: clear CacheInvalidation when upgrading
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
165 |
3906
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
166 upgrade_steps = range(curr_version + 1, __dbversion__ + 1) |
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
167 notify('attempting to do database upgrade from ' |
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
168 'version %s to version %s' % (curr_version, __dbversion__)) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
169 |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
170 # CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
171 _step = None |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
172 for step in upgrade_steps: |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
173 notify('performing upgrade step %s' % step) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
174 time.sleep(0.5) |
3906
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
175 |
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
176 api.upgrade(db_uri, repository_path, step) |
3907
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
177 notify('schema upgrade for step %s completed' % (step,)) |
3906
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
178 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
179 _step = step |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
180 |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
181 notify('upgrade to version %s successful' % _step) |
2000
72c525a7e7ad
added migrations from 1.2.X to 1.3
Marcin Kuzminski <marcin@python-works.com>
parents:
1987
diff
changeset
|
182 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
183 def fix_repo_paths(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
184 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
185 Fixes a old rhodecode version path into new one without a '*' |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
186 """ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
187 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
188 paths = self.sa.query(RhodeCodeUi)\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
189 .filter(RhodeCodeUi.ui_key == '/')\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
190 .scalar() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
191 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
192 paths.ui_value = paths.ui_value.replace('*', '') |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
193 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
194 try: |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
195 self.sa.add(paths) |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
196 self.sa.commit() |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3625
diff
changeset
|
197 except Exception: |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
198 self.sa.rollback() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
199 raise |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
200 |
838 | 201 def fix_default_user(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
202 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
203 Fixes a old default user with some 'nicer' default values, |
838 | 204 used mostly for anonymous access |
205 """ | |
206 def_user = self.sa.query(User)\ | |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
207 .filter(User.username == User.DEFAULT_USER)\ |
838 | 208 .one() |
209 | |
210 def_user.name = 'Anonymous' | |
211 def_user.lastname = 'User' | |
212 def_user.email = 'anonymous@rhodecode.org' | |
213 | |
214 try: | |
215 self.sa.add(def_user) | |
216 self.sa.commit() | |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3625
diff
changeset
|
217 except Exception: |
838 | 218 self.sa.rollback() |
219 raise | |
220 | |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
221 def fix_settings(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
222 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
223 Fixes rhodecode settings adds ga_code key for google analytics |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
224 """ |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
225 |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1510
diff
changeset
|
226 hgsettings3 = RhodeCodeSetting('ga_code', '') |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
227 |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
228 try: |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
229 self.sa.add(hgsettings3) |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
230 self.sa.commit() |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3625
diff
changeset
|
231 except Exception: |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
232 self.sa.rollback() |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
233 raise |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
234 |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
235 def admin_prompt(self, second=False): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
236 if not self.tests: |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
237 import getpass |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
238 |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
239 # defaults |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
240 defaults = self.cli_args |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
241 username = defaults.get('username') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
242 password = defaults.get('password') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
243 email = defaults.get('email') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
244 |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
245 def get_password(): |
1266
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
246 password = getpass.getpass('Specify admin password ' |
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
247 '(min 6 chars):') |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
248 confirm = getpass.getpass('Confirm password:') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
249 |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
250 if password != confirm: |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
251 log.error('passwords mismatch') |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
252 return False |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
253 if len(password) < 6: |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
254 log.error('password is to short use at least 6 characters') |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
255 return False |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
256 |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
257 return password |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
258 if username is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
259 username = raw_input('Specify admin username:') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
260 if password is None: |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
261 password = get_password() |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
262 if not password: |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
263 #second try |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
264 password = get_password() |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
265 if not password: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
266 sys.exit() |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
267 if email is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
268 email = raw_input('Specify admin email:') |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
471
diff
changeset
|
269 self.create_user(username, password, email, True) |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
270 else: |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
271 log.info('creating admin and regular test users') |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
272 from rhodecode.tests import TEST_USER_ADMIN_LOGIN, \ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
273 TEST_USER_ADMIN_PASS, TEST_USER_ADMIN_EMAIL, \ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
274 TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, \ |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
275 TEST_USER_REGULAR_EMAIL, TEST_USER_REGULAR2_LOGIN, \ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
276 TEST_USER_REGULAR2_PASS, TEST_USER_REGULAR2_EMAIL |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
277 |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
278 self.create_user(TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
279 TEST_USER_ADMIN_EMAIL, True) |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
280 |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
281 self.create_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
282 TEST_USER_REGULAR_EMAIL, False) |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
283 |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
284 self.create_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS, |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
285 TEST_USER_REGULAR2_EMAIL, False) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
286 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
287 def create_ui_settings(self, repo_store_path): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
288 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
289 Creates ui settings, fills out hooks |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
290 and disables dotencode |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
291 """ |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
292 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
293 #HOOKS |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1399
diff
changeset
|
294 hooks1_key = RhodeCodeUi.HOOK_UPDATE |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
295 hooks1_ = self.sa.query(RhodeCodeUi)\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
296 .filter(RhodeCodeUi.ui_key == hooks1_key).scalar() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
297 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
298 hooks1 = RhodeCodeUi() if hooks1_ is None else hooks1_ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
299 hooks1.ui_section = 'hooks' |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
300 hooks1.ui_key = hooks1_key |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
301 hooks1.ui_value = 'hg update >&2' |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
302 hooks1.ui_active = False |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
303 self.sa.add(hooks1) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
304 |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1399
diff
changeset
|
305 hooks2_key = RhodeCodeUi.HOOK_REPO_SIZE |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
306 hooks2_ = self.sa.query(RhodeCodeUi)\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
307 .filter(RhodeCodeUi.ui_key == hooks2_key).scalar() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
308 hooks2 = RhodeCodeUi() if hooks2_ is None else hooks2_ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
309 hooks2.ui_section = 'hooks' |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
310 hooks2.ui_key = hooks2_key |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
311 hooks2.ui_value = 'python:rhodecode.lib.hooks.repo_size' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
312 self.sa.add(hooks2) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
313 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
314 hooks3 = RhodeCodeUi() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
315 hooks3.ui_section = 'hooks' |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1399
diff
changeset
|
316 hooks3.ui_key = RhodeCodeUi.HOOK_PUSH |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
317 hooks3.ui_value = 'python:rhodecode.lib.hooks.log_push_action' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
318 self.sa.add(hooks3) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
319 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
320 hooks4 = RhodeCodeUi() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
321 hooks4.ui_section = 'hooks' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
322 hooks4.ui_key = RhodeCodeUi.HOOK_PRE_PUSH |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
323 hooks4.ui_value = 'python:rhodecode.lib.hooks.pre_push' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
324 self.sa.add(hooks4) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
325 |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
326 hooks5 = RhodeCodeUi() |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
327 hooks5.ui_section = 'hooks' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
328 hooks5.ui_key = RhodeCodeUi.HOOK_PULL |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
329 hooks5.ui_value = 'python:rhodecode.lib.hooks.log_pull_action' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
330 self.sa.add(hooks5) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
331 |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
332 hooks6 = RhodeCodeUi() |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
333 hooks6.ui_section = 'hooks' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
334 hooks6.ui_key = RhodeCodeUi.HOOK_PRE_PULL |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
335 hooks6.ui_value = 'python:rhodecode.lib.hooks.pre_pull' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
336 self.sa.add(hooks6) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
337 |
1694
1450ceb36aa6
enabled largefiles extension by default in rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
1634
diff
changeset
|
338 # enable largefiles |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
339 largefiles = RhodeCodeUi() |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
340 largefiles.ui_section = 'extensions' |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
341 largefiles.ui_key = 'largefiles' |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
342 largefiles.ui_value = '' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
343 self.sa.add(largefiles) |
1694
1450ceb36aa6
enabled largefiles extension by default in rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
1634
diff
changeset
|
344 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
345 # set default largefiles cache dir, defaults to |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
346 # /repo location/.cache/largefiles |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
347 largefiles = RhodeCodeUi() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
348 largefiles.ui_section = 'largefiles' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
349 largefiles.ui_key = 'usercache' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
350 largefiles.ui_value = os.path.join(repo_store_path, '.cache', |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
351 'largefiles') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
352 self.sa.add(largefiles) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
353 |
2705
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
354 # enable hgsubversion disabled by default |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
355 hgsubversion = RhodeCodeUi() |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
356 hgsubversion.ui_section = 'extensions' |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
357 hgsubversion.ui_key = 'hgsubversion' |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
358 hgsubversion.ui_value = '' |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
359 hgsubversion.ui_active = False |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
360 self.sa.add(hgsubversion) |
2705
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
361 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
362 # enable hggit disabled by default |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
363 hggit = RhodeCodeUi() |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
364 hggit.ui_section = 'extensions' |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
365 hggit.ui_key = 'hggit' |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
366 hggit.ui_value = '' |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
367 hggit.ui_active = False |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
368 self.sa.add(hggit) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
369 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
370 def create_auth_plugin_options(self, skip_existing=False): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
371 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
372 Create default auth plugin settings, and make it active |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
373 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
374 :param skip_existing: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
375 """ |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
376 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
377 for k, v, t in [('auth_plugins', 'rhodecode.lib.auth_modules.auth_rhodecode', 'list'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
378 ('auth_rhodecode_enabled', 'True', 'bool')]: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
379 if skip_existing and RhodeCodeSetting.get_by_name(k) != None: |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
380 log.debug('Skipping option %s' % k) |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
381 continue |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
382 setting = RhodeCodeSetting(k, v, t) |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
383 self.sa.add(setting) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
384 |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
385 def create_default_options(self, skip_existing=False): |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
386 """Creates default settings""" |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
387 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
388 for k, v, t in [ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
389 ('default_repo_enable_locking', False, 'bool'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
390 ('default_repo_enable_downloads', False, 'bool'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
391 ('default_repo_enable_statistics', False, 'bool'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
392 ('default_repo_private', False, 'bool'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
393 ('default_repo_type', 'hg', 'unicode')]: |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
394 |
3889
b84c83b651de
replace equality comparision to None
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
395 if skip_existing and RhodeCodeSetting.get_by_name(k) is not None: |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
396 log.debug('Skipping option %s' % k) |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
397 continue |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
398 setting = RhodeCodeSetting(k, v, t) |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
399 self.sa.add(setting) |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
400 |
1985
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
401 def fixup_groups(self): |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3733
diff
changeset
|
402 def_usr = User.get_default_user() |
1985
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
403 for g in RepoGroup.query().all(): |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
404 g.group_name = g.get_new_name(g.name) |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
405 self.sa.add(g) |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
406 # get default perm |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
407 default = UserRepoGroupToPerm.query()\ |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
408 .filter(UserRepoGroupToPerm.group == g)\ |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
409 .filter(UserRepoGroupToPerm.user == def_usr)\ |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
410 .scalar() |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
411 |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
412 if default is None: |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
413 log.debug('missing default permission for group %s adding' % g) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
414 perm_obj = RepoGroupModel()._create_default_perms(g) |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3671
diff
changeset
|
415 self.sa.add(perm_obj) |
1985
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
416 |
2798
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
417 def reset_permissions(self, username): |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
418 """ |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
419 Resets permissions to default state, usefull when old systems had |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
420 bad permissions, we must clean them up |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
421 |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
422 :param username: |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
423 """ |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
424 default_user = User.get_by_username(username) |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
425 if not default_user: |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
426 return |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
427 |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
428 u2p = UserToPerm.query()\ |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
429 .filter(UserToPerm.user == default_user).all() |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
430 fixed = False |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
431 if len(u2p) != len(Permission.DEFAULT_USER_PERMISSIONS): |
2798
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
432 for p in u2p: |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
433 Session().delete(p) |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
434 fixed = True |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
435 self.populate_default_permissions() |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
436 return fixed |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
437 |
3309
b3cf4539d1bd
Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents:
3232
diff
changeset
|
438 def update_repo_info(self): |
b3cf4539d1bd
Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents:
3232
diff
changeset
|
439 RepoModel.update_repoinfo() |
b3cf4539d1bd
Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents:
3232
diff
changeset
|
440 |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
441 def config_prompt(self, test_repo_path='', retries=3): |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
442 defaults = self.cli_args |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
443 _path = defaults.get('repos_location') |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
444 if retries == 3: |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
445 log.info('Setting up repositories config') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
446 |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
447 if _path is not None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
448 path = _path |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
449 elif not self.tests and not test_repo_path: |
1896
12135cff4c77
more user friendly message for repo path on setup
Marcin Kuzminski <marcin@python-works.com>
parents:
1835
diff
changeset
|
450 path = raw_input( |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
451 'Enter a valid absolute path to store repositories. ' |
1896
12135cff4c77
more user friendly message for repo path on setup
Marcin Kuzminski <marcin@python-works.com>
parents:
1835
diff
changeset
|
452 'All repositories in that path will be added automatically:' |
12135cff4c77
more user friendly message for repo path on setup
Marcin Kuzminski <marcin@python-works.com>
parents:
1835
diff
changeset
|
453 ) |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
454 else: |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
455 path = test_repo_path |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
456 path_ok = True |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
457 |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
458 # check proper dir |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
327
diff
changeset
|
459 if not os.path.isdir(path): |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
460 path_ok = False |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
461 log.error('Given path %s is not a valid directory' % (path,)) |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
462 |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
463 elif not os.path.isabs(path): |
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
464 path_ok = False |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
465 log.error('Given path %s is not an absolute path' % (path,)) |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
466 |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
467 # check if path is at least readable. |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
468 if not os.access(path, os.R_OK): |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
469 path_ok = False |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
470 log.error('Given path %s is not readable' % (path,)) |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
471 |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
472 # check write access, warn user about non writeable paths |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
473 elif not os.access(path, os.W_OK) and path_ok: |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
474 log.warn('No write permission to given path %s' % (path,)) |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
475 if not ask_ok('Given path %s is not writeable, do you want to ' |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
476 'continue with read only mode ? [y/n]' % (path,)): |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
477 log.error('Canceled by user') |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
478 sys.exit(-1) |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
479 |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
480 if retries == 0: |
1399
4134af931e91
Added info about sys.exit cause
Marcin Kuzminski <marcin@python-works.com>
parents:
1299
diff
changeset
|
481 sys.exit('max retries reached') |
3625
260a7a01b054
follow Python conventions for boolean values
Mads Kiilerich <madski@unity3d.com>
parents:
3309
diff
changeset
|
482 if not path_ok: |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
483 retries -= 1 |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
484 return self.config_prompt(test_repo_path, retries) |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
485 |
2918
ce8572f45c85
use normpath when comparing paths used to determine if directory is a symlink, it's a part of pull-request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2907
diff
changeset
|
486 real_path = os.path.normpath(os.path.realpath(path)) |
2819
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
487 |
2918
ce8572f45c85
use normpath when comparing paths used to determine if directory is a symlink, it's a part of pull-request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2907
diff
changeset
|
488 if real_path != os.path.normpath(path): |
2819
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
489 if not ask_ok(('Path looks like a symlink, Rhodecode will store ' |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
490 'given path as %s ? [y/n]') % (real_path,)): |
2819
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
491 log.error('Canceled by user') |
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
492 sys.exit(-1) |
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
493 |
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
494 return real_path |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
495 |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
496 def create_settings(self, path): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
497 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
498 self.create_ui_settings(path) |
673
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
657
diff
changeset
|
499 |
3909
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
500 ui_config = [ |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
501 ('web', 'push_ssl', 'false'), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
502 ('web', 'allow_archive', 'gz zip bz2'), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
503 ('web', 'allow_push', '*'), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
504 ('web', 'baseurl', '/'), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
505 ('paths', '/', path), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
506 #('phases', 'publish', 'false') |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
507 ] |
3911
7cca0d07c12b
fix: add UI settings to session
Marcin Kuzminski <marcin@python-works.com>
parents:
3910
diff
changeset
|
508 for section, key, value in ui_config: |
3909
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
509 ui_conf = RhodeCodeUi() |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
510 setattr(ui_conf, 'ui_section', section) |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
511 setattr(ui_conf, 'ui_key', key) |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
512 setattr(ui_conf, 'ui_value', value) |
3911
7cca0d07c12b
fix: add UI settings to session
Marcin Kuzminski <marcin@python-works.com>
parents:
3910
diff
changeset
|
513 self.sa.add(ui_conf) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
514 |
3909
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
515 settings = [ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
516 ('realm', 'RhodeCode', 'unicode'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
517 ('title', '', 'unicode'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
518 ('ga_code', '', 'unicode'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
519 ('show_public_icon', True, 'bool'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
520 ('show_private_icon', True, 'bool'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
521 ('stylify_metatags', False, 'bool'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
522 ('dashboard_items', 100, 'int'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
523 ('admin_grid_items', 25, 'int'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
524 ('show_version', True, 'bool'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
525 ('use_gravatar', True, 'bool'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
526 ('gravatar_url', User.DEFAULT_GRAVATAR_URL, 'unicode'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
527 ('clone_uri_tmpl', Repository.DEFAULT_CLONE_URI, 'unicode'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
528 ('update_url', RhodeCodeSetting.DEFAULT_UPDATE_URL, 'unicode'), |
3909
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
529 ] |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
530 for key, val, type_ in settings: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
531 sett = RhodeCodeSetting(key, val, type_) |
3909
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
532 self.sa.add(sett) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
533 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
534 self.create_auth_plugin_options() |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
535 self.create_default_options() |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
536 |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
327
diff
changeset
|
537 log.info('created ui config') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
538 |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
471
diff
changeset
|
539 def create_user(self, username, password, email='', admin=False): |
1976 | 540 log.info('creating user %s' % username) |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
541 UserModel().create_or_update(username, password, email, |
2513
388843a3a3c0
Updated create_or_update method to not change API key when password is not updated
Marcin Kuzminski <marcin@python-works.com>
parents:
2285
diff
changeset
|
542 firstname='RhodeCode', lastname='Admin', |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
543 active=True, admin=admin, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4028
diff
changeset
|
544 extern_type="rhodecode") |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
545 |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
546 def create_default_user(self): |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
547 log.info('creating default user') |
1634
1d904d972c47
User usermodel instead of db model to manage accounts
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
548 # create default user for handling default permissions. |
4028
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
549 user = UserModel().create_or_update(username=User.DEFAULT_USER, |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
550 password=str(uuid.uuid1())[:20], |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
551 email='anonymous@rhodecode.org', |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
552 firstname='Anonymous', |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
553 lastname='User') |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
554 # based on configuration options activate/deactive this user which |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
555 # controlls anonymous access |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
556 if self.cli_args.get('public_access') is False: |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
557 log.info('Public access disabled') |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
558 user.active = False |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
559 Session().add(user) |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
560 Session().commit() |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
561 |
239
b18f89d6d17f
Adde draft for permissions systems, made all needed decorators, and checks. For future usage in the system.
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
562 def create_permissions(self): |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
563 """ |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
564 Creates all permissions defined in the system |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
565 """ |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
566 # module.(access|create|change|delete)_[name] |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
567 # module.(none|read|write|admin) |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3733
diff
changeset
|
568 log.info('creating permissions') |
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3733
diff
changeset
|
569 PermissionModel(self.sa).create_permissions() |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
570 |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
571 def populate_default_permissions(self): |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
572 """ |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
573 Populate default permissions. It will create only the default |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
574 permissions that are missing, and not alter already defined ones |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
575 """ |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
576 log.info('creating default user permissions') |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
577 PermissionModel(self.sa).create_default_permissions(user=User.DEFAULT_USER) |
2827
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
578 |
3232
99c093d1a142
run waitress check on startup
Marcin Kuzminski <marcin@python-works.com>
parents:
3148
diff
changeset
|
579 @staticmethod |
99c093d1a142
run waitress check on startup
Marcin Kuzminski <marcin@python-works.com>
parents:
3148
diff
changeset
|
580 def check_waitress(): |
2827
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
581 """ |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
582 Function executed at the end of setup |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
583 """ |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
584 if not __py_version__ >= (2, 6): |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
585 notify('Python2.5 detected, please switch ' |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
586 'egg:waitress#main -> egg:Paste#http ' |
2907
0b86972de820
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2827
diff
changeset
|
587 'in your .ini file') |