Mercurial > kallithea
annotate rhodecode/lib/db_manage.py @ 2978:b84a4ec93ab6 beta
hanlde stripped or removed changesets on changeset info function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 04 Nov 2012 13:16:11 +0100 |
parents | 29630805893d |
children | d3200c58764e |
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 -*- |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
2 """ |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
3 rhodecode.lib.db_manage |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
5 |
838 | 6 Database creation, and setup module for RhodeCode. Used for creation |
7 of database as well as for migration operations | |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
8 |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
9 :created_on: Apr 10, 2010 |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
10 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1783
diff
changeset
|
11 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
12 :license: GPLv3, see COPYING for more details. |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
13 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
14 # 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
|
15 # 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
|
16 # 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
|
17 # (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
|
18 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
19 # 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
|
20 # 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
|
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
22 # 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
|
23 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
24 # 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
|
25 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
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 |
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
|
29 import uuid |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
30 import logging |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
31 from os.path import dirname as dn, join as jn |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
32 |
2827
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
33 from rhodecode import __dbversion__, __py_version__ |
249
bad9ccac26b7
fixed import errors on db_manage
Marcin Kuzminski <marcin@python-works.com>
parents:
243
diff
changeset
|
34 |
1634
1d904d972c47
User usermodel instead of db model to manage accounts
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
35 from rhodecode.model.user import UserModel |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
36 from rhodecode.lib.utils import ask_ok |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
37 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
|
38 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
|
39 RhodeCodeSetting, UserToPerm, DbMigrateVersion, RepoGroup, \ |
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
|
40 UserRepoGroupToPerm |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
41 |
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
|
42 from sqlalchemy.engine import create_engine |
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
|
43 from rhodecode.model.repos_group import ReposGroupModel |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
44 #from rhodecode.model import meta |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
45 from rhodecode.model.meta import Session, Base |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
46 |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
47 |
351
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
48 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
|
49 |
1266
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
50 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
51 def notify(msg): |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
52 """ |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
53 Notification for migrations messages |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
54 """ |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
55 ml = len(msg) + (4 * 2) |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
56 print >> sys.stdout, ('*** %s ***\n%s' % (msg, '*' * ml)).upper() |
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 |
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
|
59 class DbManage(object): |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
60 def __init__(self, log_sql, dbconf, root, tests=False, cli_args={}): |
781
7ae66bddf48d
fixed db manage, to work on other databases than sqlite
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
61 self.dbname = dbconf.split('/')[-1] |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
62 self.tests = tests |
552
2642f128ad46
removed egg info, update files for distutils build
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
63 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
|
64 self.dburi = dbconf |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
65 self.log_sql = log_sql |
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
66 self.db_exists = False |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
67 self.cli_args = cli_args |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
68 self.init_db() |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
69 global ask_ok |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
70 |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
71 if self.cli_args.get('force_ask') is True: |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
72 ask_ok = lambda *args, **kwargs: True |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
73 elif self.cli_args.get('force_ask') is False: |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
74 ask_ok = lambda *args, **kwargs: False |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
75 |
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
76 def init_db(self): |
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
77 engine = create_engine(self.dburi, echo=self.log_sql) |
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
|
78 init_model(engine) |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
79 self.sa = Session() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
80 |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
81 def create_tables(self, override=False): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
82 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
83 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
|
84 """ |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
85 |
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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 if not destroy: |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
92 sys.exit('Nothing done') |
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
|
93 if destroy: |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
94 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
|
95 |
351
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
96 checkfirst = not override |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
97 Base.metadata.create_all(checkfirst=checkfirst) |
1976 | 98 log.info('Created tables for %s' % self.dbname) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
99 |
834
8924ed0e4f36
added current db version into rhodecode,
Marcin Kuzminski <marcin@python-works.com>
parents:
781
diff
changeset
|
100 def set_db_version(self): |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
101 ver = DbMigrateVersion() |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
102 ver.version = __dbversion__ |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
103 ver.repository_id = 'rhodecode_db_migrations' |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
104 ver.repository_path = 'versions' |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
105 self.sa.add(ver) |
1976 | 106 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
|
107 |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
108 def upgrade(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
109 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
110 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
|
111 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
|
112 |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
113 """ |
841
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
114 |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
115 from rhodecode.lib.dbmigrate.migrate.versioning import api |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
116 from rhodecode.lib.dbmigrate.migrate.exceptions import \ |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
117 DatabaseNotControlledError |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
118 |
1835
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
119 if 'sqlite' in self.dburi: |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
120 print ( |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
121 '********************** WARNING **********************\n' |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
122 '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
|
123 'Earlier versions are known to fail on some migrations\n' |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
124 '*****************************************************\n' |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
125 ) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
126 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
|
127 '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
|
128 '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
|
129 if not upgrade: |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
130 sys.exit('Nothing done') |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
131 |
843
3b21ba5f7cb0
fixed path issues in upgrade script
Marcin Kuzminski <marcin@python-works.com>
parents:
841
diff
changeset
|
132 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
|
133 '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
|
134 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
|
135 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
136 try: |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
137 curr_version = api.db_version(db_uri, repository_path) |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
138 msg = ('Found current database under version' |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
139 ' control with version %s' % 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
|
140 |
1299
8eda822931c9
small fixes for interactive prompt in setup
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
141 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
|
142 curr_version = 1 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
143 msg = ('Current database is not under version control. Setting' |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
144 ' as version %s' % 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
|
145 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
|
146 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
147 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
|
148 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
149 if curr_version == __dbversion__: |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
150 sys.exit('This database is already at the newest version') |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
151 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
152 #====================================================================== |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
153 # UPGRADE STEPS |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
154 #====================================================================== |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
155 |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
156 class UpgradeSteps(object): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
157 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
158 Those steps follow schema versions so for example schema |
900
07f248329a3b
updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
890
diff
changeset
|
159 for example schema with seq 002 == step_2 and so on. |
07f248329a3b
updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
890
diff
changeset
|
160 """ |
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 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
162 def __init__(self, klass): |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
163 self.klass = klass |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
164 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
165 def step_0(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
166 # step 0 is the schema upgrade, and than follow proper upgrades |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
167 notify('attempting to do database upgrade to version %s' \ |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
168 % __dbversion__) |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
169 api.upgrade(db_uri, repository_path, __dbversion__) |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
170 notify('Schema upgrade completed') |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
171 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
172 def step_1(self): |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
173 pass |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
174 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
175 def step_2(self): |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
176 notify('Patching repo paths for newer version of RhodeCode') |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
177 self.klass.fix_repo_paths() |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
178 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
179 notify('Patching default user of RhodeCode') |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
180 self.klass.fix_default_user() |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
181 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
182 log.info('Changing ui settings') |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
183 self.klass.create_ui_settings() |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
184 |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
185 def step_3(self): |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
186 notify('Adding additional settings into RhodeCode db') |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
187 self.klass.fix_settings() |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
188 notify('Adding ldap defaults') |
1510
90062009bb1e
added default ldap option into migration
Marcin Kuzminski <marcin@python-works.com>
parents:
1503
diff
changeset
|
189 self.klass.create_ldap_options(skip_existing=True) |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
190 |
1835
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
191 def step_4(self): |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
192 notify('create permissions and fix groups') |
1987
77b5c24f1887
fixed found issues in upgrade script
Marcin Kuzminski <marcin@python-works.com>
parents:
1986
diff
changeset
|
193 self.klass.create_permissions() |
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
|
194 self.klass.fixup_groups() |
1835
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
195 |
2000
72c525a7e7ad
added migrations from 1.2.X to 1.3
Marcin Kuzminski <marcin@python-works.com>
parents:
1987
diff
changeset
|
196 def step_5(self): |
72c525a7e7ad
added migrations from 1.2.X to 1.3
Marcin Kuzminski <marcin@python-works.com>
parents:
1987
diff
changeset
|
197 pass |
2006
34d009e5147a
added clone_uri to API method for creating users
Marcin Kuzminski <marcin@python-works.com>
parents:
2000
diff
changeset
|
198 |
2214
2fd474e63177
Starting RhodeCode 1.4 Branch
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
199 def step_6(self): |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
200 |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
201 notify('re-checking permissions') |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
202 self.klass.create_permissions() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
203 |
2781
d03d51b6541e
migration: set new UI options as in old version
Marcin Kuzminski <marcin@python-works.com>
parents:
2779
diff
changeset
|
204 notify('installing new UI options') |
d03d51b6541e
migration: set new UI options as in old version
Marcin Kuzminski <marcin@python-works.com>
parents:
2779
diff
changeset
|
205 sett4 = RhodeCodeSetting('show_public_icon', True) |
d03d51b6541e
migration: set new UI options as in old version
Marcin Kuzminski <marcin@python-works.com>
parents:
2779
diff
changeset
|
206 Session().add(sett4) |
d03d51b6541e
migration: set new UI options as in old version
Marcin Kuzminski <marcin@python-works.com>
parents:
2779
diff
changeset
|
207 sett5 = RhodeCodeSetting('show_private_icon', True) |
d03d51b6541e
migration: set new UI options as in old version
Marcin Kuzminski <marcin@python-works.com>
parents:
2779
diff
changeset
|
208 Session().add(sett5) |
d03d51b6541e
migration: set new UI options as in old version
Marcin Kuzminski <marcin@python-works.com>
parents:
2779
diff
changeset
|
209 sett6 = RhodeCodeSetting('stylify_metatags', False) |
d03d51b6541e
migration: set new UI options as in old version
Marcin Kuzminski <marcin@python-works.com>
parents:
2779
diff
changeset
|
210 Session().add(sett6) |
d03d51b6541e
migration: set new UI options as in old version
Marcin Kuzminski <marcin@python-works.com>
parents:
2779
diff
changeset
|
211 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
212 notify('fixing old PULL hook') |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
213 _pull = RhodeCodeUi.get_by_key('preoutgoing.pull_logger') |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
214 if _pull: |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
215 _pull.ui_key = RhodeCodeUi.HOOK_PULL |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
216 Session().add(_pull) |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
217 |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
218 notify('fixing old PUSH hook') |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
219 _push = RhodeCodeUi.get_by_key('pretxnchangegroup.push_logger') |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
220 if _push: |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
221 _push.ui_key = RhodeCodeUi.HOOK_PUSH |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
222 Session().add(_push) |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
223 |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
224 notify('installing new pre-push hook') |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
225 hooks4 = RhodeCodeUi() |
2767
7562f46b1e90
More fixes to upgrade procedure,
Marcin Kuzminski <marcin@python-works.com>
parents:
2765
diff
changeset
|
226 hooks4.ui_section = 'hooks' |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
227 hooks4.ui_key = RhodeCodeUi.HOOK_PRE_PUSH |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
228 hooks4.ui_value = 'python:rhodecode.lib.hooks.pre_push' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
229 Session().add(hooks4) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
230 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
231 notify('installing new pre-pull hook') |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
232 hooks6 = RhodeCodeUi() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
233 hooks6.ui_section = 'hooks' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
234 hooks6.ui_key = RhodeCodeUi.HOOK_PRE_PULL |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
235 hooks6.ui_value = 'python:rhodecode.lib.hooks.pre_pull' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
236 Session().add(hooks6) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
237 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
238 notify('installing hgsubversion option') |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
239 # enable hgsubversion disabled by default |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
240 hgsubversion = RhodeCodeUi() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
241 hgsubversion.ui_section = 'extensions' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
242 hgsubversion.ui_key = 'hgsubversion' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
243 hgsubversion.ui_value = '' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
244 hgsubversion.ui_active = False |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
245 Session().add(hgsubversion) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
246 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
247 notify('installing hg git option') |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
248 # enable hggit disabled by default |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
249 hggit = RhodeCodeUi() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
250 hggit.ui_section = 'extensions' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
251 hggit.ui_key = 'hggit' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
252 hggit.ui_value = '' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
253 hggit.ui_active = False |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
254 Session().add(hggit) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
255 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
256 notify('re-check default permissions') |
2795
456a5190f1cc
fix default permissions migrations that can cause troubles for some old users
Marcin Kuzminski <marcin@python-works.com>
parents:
2781
diff
changeset
|
257 default_user = User.get_by_username(User.DEFAULT_USER) |
456a5190f1cc
fix default permissions migrations that can cause troubles for some old users
Marcin Kuzminski <marcin@python-works.com>
parents:
2781
diff
changeset
|
258 perm = Permission.get_by_key('hg.fork.repository') |
456a5190f1cc
fix default permissions migrations that can cause troubles for some old users
Marcin Kuzminski <marcin@python-works.com>
parents:
2781
diff
changeset
|
259 reg_perm = UserToPerm() |
456a5190f1cc
fix default permissions migrations that can cause troubles for some old users
Marcin Kuzminski <marcin@python-works.com>
parents:
2781
diff
changeset
|
260 reg_perm.user = default_user |
456a5190f1cc
fix default permissions migrations that can cause troubles for some old users
Marcin Kuzminski <marcin@python-works.com>
parents:
2781
diff
changeset
|
261 reg_perm.permission = perm |
456a5190f1cc
fix default permissions migrations that can cause troubles for some old users
Marcin Kuzminski <marcin@python-works.com>
parents:
2781
diff
changeset
|
262 Session().add(reg_perm) |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
263 |
2797
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
2795
diff
changeset
|
264 def step_7(self): |
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
|
265 perm_fixes = self.klass.reset_permissions(User.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
|
266 Session().commit() |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
267 if perm_fixes: |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
268 notify('There was an inconsistent state of 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
|
269 'detected for default user. Permissions are now ' |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
270 'reset to the default value for 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
|
271 'Please validate and check 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
|
272 'in admin panel') |
2797
c9baaacb670a
Remove null from revision column as for comments inside pull requests to work properly
Marcin Kuzminski <marcin@python-works.com>
parents:
2795
diff
changeset
|
273 |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
274 upgrade_steps = [0] + range(curr_version + 1, __dbversion__ + 1) |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
275 |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
276 # 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
|
277 _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
|
278 for step in upgrade_steps: |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
279 notify('performing upgrade step %s' % step) |
1716
7d1fc253549e
notification to commit author + gardening
Marcin Kuzminski <marcin@python-works.com>
parents:
1694
diff
changeset
|
280 getattr(UpgradeSteps(self), 'step_%s' % step)() |
1987
77b5c24f1887
fixed found issues in upgrade script
Marcin Kuzminski <marcin@python-works.com>
parents:
1986
diff
changeset
|
281 self.sa.commit() |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
282 _step = step |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
283 |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
284 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
|
285 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
286 def fix_repo_paths(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
287 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
288 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
|
289 """ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
290 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
291 paths = self.sa.query(RhodeCodeUi)\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
292 .filter(RhodeCodeUi.ui_key == '/')\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
293 .scalar() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
294 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
295 paths.ui_value = paths.ui_value.replace('*', '') |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
296 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
297 try: |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
298 self.sa.add(paths) |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
299 self.sa.commit() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
300 except: |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
301 self.sa.rollback() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
302 raise |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
303 |
838 | 304 def fix_default_user(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
305 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
306 Fixes a old default user with some 'nicer' default values, |
838 | 307 used mostly for anonymous access |
308 """ | |
309 def_user = self.sa.query(User)\ | |
310 .filter(User.username == 'default')\ | |
311 .one() | |
312 | |
313 def_user.name = 'Anonymous' | |
314 def_user.lastname = 'User' | |
315 def_user.email = 'anonymous@rhodecode.org' | |
316 | |
317 try: | |
318 self.sa.add(def_user) | |
319 self.sa.commit() | |
320 except: | |
321 self.sa.rollback() | |
322 raise | |
323 | |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
324 def fix_settings(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
325 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
326 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
|
327 """ |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
328 |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1510
diff
changeset
|
329 hgsettings3 = RhodeCodeSetting('ga_code', '') |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
330 |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
331 try: |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
332 self.sa.add(hgsettings3) |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
333 self.sa.commit() |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
334 except: |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
335 self.sa.rollback() |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
336 raise |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
337 |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
338 def admin_prompt(self, second=False): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
339 if not self.tests: |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
340 import getpass |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
341 |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
342 # defaults |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
343 defaults = self.cli_args |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
344 username = defaults.get('username') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
345 password = defaults.get('password') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
346 email = defaults.get('email') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
347 |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
348 def get_password(): |
1266
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
349 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
|
350 '(min 6 chars):') |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
351 confirm = getpass.getpass('Confirm password:') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
352 |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
353 if password != confirm: |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
354 log.error('passwords mismatch') |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
355 return False |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
356 if len(password) < 6: |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
357 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
|
358 return False |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
359 |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
360 return password |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
361 if username is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
362 username = raw_input('Specify admin username:') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
363 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
|
364 password = get_password() |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
365 if not password: |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
366 #second try |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
367 password = get_password() |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
368 if not password: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
369 sys.exit() |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
370 if email is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
371 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
|
372 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
|
373 else: |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
374 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
|
375 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
|
376 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
|
377 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
|
378 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
|
379 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
|
380 |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
381 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
|
382 TEST_USER_ADMIN_EMAIL, True) |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
383 |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
384 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
|
385 TEST_USER_REGULAR_EMAIL, False) |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
386 |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
387 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
|
388 TEST_USER_REGULAR2_EMAIL, False) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
389 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
390 def create_ui_settings(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
391 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
392 Creates ui settings, fills out hooks |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
393 and disables dotencode |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
394 """ |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
395 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
396 #HOOKS |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1399
diff
changeset
|
397 hooks1_key = RhodeCodeUi.HOOK_UPDATE |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
398 hooks1_ = self.sa.query(RhodeCodeUi)\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
399 .filter(RhodeCodeUi.ui_key == hooks1_key).scalar() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
400 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
401 hooks1 = RhodeCodeUi() if hooks1_ is None else hooks1_ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
402 hooks1.ui_section = 'hooks' |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
403 hooks1.ui_key = hooks1_key |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
404 hooks1.ui_value = 'hg update >&2' |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
405 hooks1.ui_active = False |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
406 self.sa.add(hooks1) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
407 |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1399
diff
changeset
|
408 hooks2_key = RhodeCodeUi.HOOK_REPO_SIZE |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
409 hooks2_ = self.sa.query(RhodeCodeUi)\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
410 .filter(RhodeCodeUi.ui_key == hooks2_key).scalar() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
411 hooks2 = RhodeCodeUi() if hooks2_ is None else hooks2_ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
412 hooks2.ui_section = 'hooks' |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
413 hooks2.ui_key = hooks2_key |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
414 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
|
415 self.sa.add(hooks2) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
416 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
417 hooks3 = RhodeCodeUi() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
418 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
|
419 hooks3.ui_key = RhodeCodeUi.HOOK_PUSH |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
420 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
|
421 self.sa.add(hooks3) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
422 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
423 hooks4 = RhodeCodeUi() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
424 hooks4.ui_section = 'hooks' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
425 hooks4.ui_key = RhodeCodeUi.HOOK_PRE_PUSH |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
426 hooks4.ui_value = 'python:rhodecode.lib.hooks.pre_push' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
427 self.sa.add(hooks4) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
428 |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
429 hooks5 = RhodeCodeUi() |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
430 hooks5.ui_section = 'hooks' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
431 hooks5.ui_key = RhodeCodeUi.HOOK_PULL |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
432 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
|
433 self.sa.add(hooks5) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
434 |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
435 hooks6 = RhodeCodeUi() |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
436 hooks6.ui_section = 'hooks' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
437 hooks6.ui_key = RhodeCodeUi.HOOK_PRE_PULL |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
438 hooks6.ui_value = 'python:rhodecode.lib.hooks.pre_pull' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
439 self.sa.add(hooks6) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
440 |
1694
1450ceb36aa6
enabled largefiles extension by default in rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
1634
diff
changeset
|
441 # enable largefiles |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
442 largefiles = RhodeCodeUi() |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
443 largefiles.ui_section = 'extensions' |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
444 largefiles.ui_key = 'largefiles' |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
445 largefiles.ui_value = '' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
446 self.sa.add(largefiles) |
1694
1450ceb36aa6
enabled largefiles extension by default in rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
1634
diff
changeset
|
447 |
2705
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
448 # 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
|
449 hgsubversion = RhodeCodeUi() |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
450 hgsubversion.ui_section = 'extensions' |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
451 hgsubversion.ui_key = 'hgsubversion' |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
452 hgsubversion.ui_value = '' |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
453 hgsubversion.ui_active = False |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
454 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
|
455 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
456 # enable hggit disabled by default |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
457 hggit = RhodeCodeUi() |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
458 hggit.ui_section = 'extensions' |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
459 hggit.ui_key = 'hggit' |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
460 hggit.ui_value = '' |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
461 hggit.ui_active = False |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
462 self.sa.add(hggit) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
463 |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
464 def create_ldap_options(self, skip_existing=False): |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
465 """Creates ldap settings""" |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
466 |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
467 for k, v in [('ldap_active', 'false'), ('ldap_host', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
468 ('ldap_port', '389'), ('ldap_tls_kind', 'PLAIN'), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
469 ('ldap_tls_reqcert', ''), ('ldap_dn_user', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
470 ('ldap_dn_pass', ''), ('ldap_base_dn', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
471 ('ldap_filter', ''), ('ldap_search_scope', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
472 ('ldap_attr_login', ''), ('ldap_attr_firstname', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
473 ('ldap_attr_lastname', ''), ('ldap_attr_email', '')]: |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
474 |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
475 if skip_existing and RhodeCodeSetting.get_by_name(k) != None: |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
476 log.debug('Skipping option %s' % k) |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
477 continue |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
478 setting = RhodeCodeSetting(k, v) |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
479 self.sa.add(setting) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
480 |
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
|
481 def fixup_groups(self): |
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
|
482 def_usr = User.get_by_username('default') |
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
|
483 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
|
484 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
|
485 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
|
486 # 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
|
487 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
|
488 .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
|
489 .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
|
490 .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
|
491 |
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
|
492 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
|
493 log.debug('missing default permission for group %s adding' % 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
|
494 ReposGroupModel()._create_default_perms(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
|
495 |
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
|
496 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
|
497 """ |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
498 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
|
499 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
|
500 |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
501 :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
|
502 :type 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
|
503 """ |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
504 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
|
505 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
|
506 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
|
507 |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
508 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
|
509 .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
|
510 fixed = False |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
511 if len(u2p) != len(User.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
|
512 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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
518 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
|
519 defaults = self.cli_args |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
520 _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
|
521 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
|
522 log.info('Setting up repositories config') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
523 |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
524 if _path is not None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
525 path = _path |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
526 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
|
527 path = raw_input( |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
528 '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
|
529 '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
|
530 ) |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
531 else: |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
532 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
|
533 path_ok = True |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
534 |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
535 # 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
|
536 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
|
537 path_ok = False |
1976 | 538 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
|
539 |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
540 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
|
541 path_ok = False |
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
542 log.error('Given path %s is not an absolute path' % path) |
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
543 |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
544 # check write access |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
545 elif not os.access(path, os.W_OK) and 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
|
546 path_ok = False |
1976 | 547 log.error('No write permission to given path %s' % 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
|
548 |
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
|
549 if retries == 0: |
1399
4134af931e91
Added info about sys.exit cause
Marcin Kuzminski <marcin@python-works.com>
parents:
1299
diff
changeset
|
550 sys.exit('max retries reached') |
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
|
551 if path_ok is False: |
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
|
552 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
|
553 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
|
554 |
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
|
555 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
|
556 |
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
|
557 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
|
558 if not ask_ok(('Path looks like a symlink, Rhodecode will store ' |
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
|
559 'given path as %s ? [y/n]') % (real_path)): |
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
|
560 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
|
561 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
|
562 |
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
|
563 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
|
564 |
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
|
565 def create_settings(self, path): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
566 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
567 self.create_ui_settings() |
673
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
657
diff
changeset
|
568 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
569 #HG UI OPTIONS |
549
f99075170eb4
more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
570 web1 = RhodeCodeUi() |
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
|
571 web1.ui_section = 'web' |
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
|
572 web1.ui_key = 'push_ssl' |
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
|
573 web1.ui_value = 'false' |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
574 |
549
f99075170eb4
more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
575 web2 = RhodeCodeUi() |
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
|
576 web2.ui_section = 'web' |
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
|
577 web2.ui_key = 'allow_archive' |
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
|
578 web2.ui_value = 'gz zip bz2' |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
579 |
549
f99075170eb4
more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
580 web3 = RhodeCodeUi() |
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
|
581 web3.ui_section = 'web' |
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
|
582 web3.ui_key = 'allow_push' |
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
|
583 web3.ui_value = '*' |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
584 |
549
f99075170eb4
more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
585 web4 = RhodeCodeUi() |
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
|
586 web4.ui_section = 'web' |
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
|
587 web4.ui_key = 'baseurl' |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
588 web4.ui_value = '/' |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
589 |
549
f99075170eb4
more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
590 paths = RhodeCodeUi() |
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
|
591 paths.ui_section = 'paths' |
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
|
592 paths.ui_key = '/' |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
593 paths.ui_value = path |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
594 |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
595 phases = RhodeCodeUi() |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
596 phases.ui_section = 'phases' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
597 phases.ui_key = 'publish' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
598 phases.ui_value = False |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
599 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
600 sett1 = RhodeCodeSetting('realm', 'RhodeCode authentication') |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
601 sett2 = RhodeCodeSetting('title', 'RhodeCode') |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
602 sett3 = RhodeCodeSetting('ga_code', '') |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
603 |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
604 sett4 = RhodeCodeSetting('show_public_icon', True) |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
605 sett5 = RhodeCodeSetting('show_private_icon', True) |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
606 sett6 = RhodeCodeSetting('stylify_metatags', False) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
607 |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
608 self.sa.add(web1) |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
609 self.sa.add(web2) |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
610 self.sa.add(web3) |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
611 self.sa.add(web4) |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
612 self.sa.add(paths) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
613 self.sa.add(sett1) |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
614 self.sa.add(sett2) |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
615 self.sa.add(sett3) |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
616 self.sa.add(sett4) |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
617 self.sa.add(sett5) |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2651
diff
changeset
|
618 self.sa.add(sett6) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
619 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
620 self.create_ldap_options() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
621 |
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
|
622 log.info('created ui config') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
623 |
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
|
624 def create_user(self, username, password, email='', admin=False): |
1976 | 625 log.info('creating user %s' % username) |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
626 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
|
627 firstname='RhodeCode', lastname='Admin', |
1634
1d904d972c47
User usermodel instead of db model to manage accounts
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
628 active=True, admin=admin) |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
629 |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
630 def create_default_user(self): |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
631 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
|
632 # create default user for handling default permissions. |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
633 UserModel().create_or_update(username='default', |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
634 password=str(uuid.uuid1())[:8], |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
635 email='anonymous@rhodecode.org', |
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
|
636 firstname='Anonymous', lastname='User') |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
637 |
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
|
638 def create_permissions(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
639 # 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
|
640 # module.(none|read|write|admin) |
1266
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
641 |
2532
19de74e33fb0
Better descriptions of given permission overview in edit user view
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
642 for p in Permission.PERMS: |
1987
77b5c24f1887
fixed found issues in upgrade script
Marcin Kuzminski <marcin@python-works.com>
parents:
1986
diff
changeset
|
643 if not Permission.get_by_key(p[0]): |
1986
367d76f5fcf5
added re-creation of permissions into step4 upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
1985
diff
changeset
|
644 new_perm = Permission() |
367d76f5fcf5
added re-creation of permissions into step4 upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
1985
diff
changeset
|
645 new_perm.permission_name = p[0] |
2532
19de74e33fb0
Better descriptions of given permission overview in edit user view
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
646 new_perm.permission_longname = p[0] |
1986
367d76f5fcf5
added re-creation of permissions into step4 upgrade
Marcin Kuzminski <marcin@python-works.com>
parents:
1985
diff
changeset
|
647 self.sa.add(new_perm) |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
648 |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
649 def populate_default_permissions(self): |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
650 log.info('creating default user permissions') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
651 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2708
diff
changeset
|
652 default_user = User.get_by_username('default') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
653 |
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
|
654 for def_perm in User.DEFAULT_PERMISSIONS: |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2708
diff
changeset
|
655 |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
656 perm = self.sa.query(Permission)\ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
657 .filter(Permission.permission_name == def_perm)\ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
658 .scalar() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
659 if not perm: |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
660 raise Exception( |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
661 'CRITICAL: permission %s not found inside database !!' |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
662 % def_perm |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
663 ) |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
664 if not UserToPerm.query()\ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
665 .filter(UserToPerm.permission == perm)\ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
666 .filter(UserToPerm.user == default_user).scalar(): |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
667 reg_perm = UserToPerm() |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
668 reg_perm.user = default_user |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
669 reg_perm.permission = perm |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
670 self.sa.add(reg_perm) |
2827
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
671 |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
672 def finish(self): |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
673 """ |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
674 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
|
675 """ |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
676 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
|
677 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
|
678 'egg:waitress#main -> egg:Paste#http ' |
2907
0b86972de820
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2827
diff
changeset
|
679 'in your .ini file') |