Show More
@@ -0,0 +1,85 b'' | |||
|
1 | import logging | |
|
2 | ||
|
3 | from sqlalchemy import * | |
|
4 | ||
|
5 | from rhodecode.model import init_model_encryption, meta | |
|
6 | from rhodecode.lib.utils2 import safe_str | |
|
7 | from rhodecode.lib.dbmigrate.versions import _reset_base, notify | |
|
8 | ||
|
9 | log = logging.getLogger(__name__) | |
|
10 | ||
|
11 | ||
|
12 | def get_all_settings(models): | |
|
13 | settings = { | |
|
14 | 'rhodecode_' + result.app_settings_name: result.app_settings_value | |
|
15 | for result in models.RhodeCodeSetting.query() | |
|
16 | } | |
|
17 | return settings | |
|
18 | ||
|
19 | ||
|
20 | def get_ui_by_section_and_key(models, section, key): | |
|
21 | q = models.RhodeCodeUi.query() | |
|
22 | q = q.filter(models.RhodeCodeUi.ui_section == section) | |
|
23 | q = q.filter(models.RhodeCodeUi.ui_key == key) | |
|
24 | return q.scalar() | |
|
25 | ||
|
26 | ||
|
27 | def create_ui_section_value(models, Session, section, val, key=None, active=True): | |
|
28 | new_ui = models.RhodeCodeUi() | |
|
29 | new_ui.ui_section = section | |
|
30 | new_ui.ui_value = val | |
|
31 | new_ui.ui_active = active | |
|
32 | new_ui.ui_key = key | |
|
33 | ||
|
34 | Session().add(new_ui) | |
|
35 | return new_ui | |
|
36 | ||
|
37 | ||
|
38 | def create_or_update_ui( | |
|
39 | models, Session, section, key, value=None, active=None): | |
|
40 | ui = get_ui_by_section_and_key(models, section, key) | |
|
41 | if not ui: | |
|
42 | active = True if active is None else active | |
|
43 | create_ui_section_value( | |
|
44 | models, Session, section, value, key=key, active=active) | |
|
45 | else: | |
|
46 | if active is not None: | |
|
47 | ui.ui_active = active | |
|
48 | if value is not None: | |
|
49 | ui.ui_value = value | |
|
50 | Session().add(ui) | |
|
51 | ||
|
52 | ||
|
53 | def upgrade(migrate_engine): | |
|
54 | """ | |
|
55 | Upgrade operations go here. | |
|
56 | Don't create your own engine; bind migrate_engine to your metadata | |
|
57 | """ | |
|
58 | _reset_base(migrate_engine) | |
|
59 | from rhodecode.lib.dbmigrate.schema import db_4_4_0_1 | |
|
60 | init_model_encryption(db_4_4_0_1) | |
|
61 | fixups(db_4_4_0_1, meta.Session) | |
|
62 | ||
|
63 | ||
|
64 | def downgrade(migrate_engine): | |
|
65 | meta = MetaData() | |
|
66 | meta.bind = migrate_engine | |
|
67 | ||
|
68 | ||
|
69 | def fixups(models, Session): | |
|
70 | current_settings = get_all_settings(models) | |
|
71 | ||
|
72 | svn_proxy_enabled = safe_str(current_settings.get( | |
|
73 | 'rhodecode_proxy_subversion_http_requests', 'False')) | |
|
74 | svn_proxy_url = current_settings.get( | |
|
75 | 'rhodecode_subversion_http_server_url', '') | |
|
76 | ||
|
77 | create_or_update_ui( | |
|
78 | models, Session, 'vcs_svn_proxy', 'http_requests_enabled', | |
|
79 | value=svn_proxy_enabled) | |
|
80 | ||
|
81 | create_or_update_ui( | |
|
82 | models, Session, 'vcs_svn_proxy', 'http_server_url', | |
|
83 | value=svn_proxy_url) | |
|
84 | ||
|
85 | Session().commit() |
@@ -1,63 +1,63 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2010-2016 RhodeCode GmbH |
|
4 | 4 | # |
|
5 | 5 | # This program is free software: you can redistribute it and/or modify |
|
6 | 6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
7 | 7 | # (only), as published by the Free Software Foundation. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU Affero General Public License |
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 | # |
|
17 | 17 | # This program is dual-licensed. If you wish to learn more about the |
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | """ |
|
22 | 22 | |
|
23 | 23 | RhodeCode, a web based repository management software |
|
24 | 24 | versioning implementation: http://www.python.org/dev/peps/pep-0386/ |
|
25 | 25 | """ |
|
26 | 26 | |
|
27 | 27 | import os |
|
28 | 28 | import sys |
|
29 | 29 | import platform |
|
30 | 30 | |
|
31 | 31 | VERSION = tuple(open(os.path.join( |
|
32 | 32 | os.path.dirname(__file__), 'VERSION')).read().split('.')) |
|
33 | 33 | |
|
34 | 34 | BACKENDS = { |
|
35 | 35 | 'hg': 'Mercurial repository', |
|
36 | 36 | 'git': 'Git repository', |
|
37 | 37 | 'svn': 'Subversion repository', |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | CELERY_ENABLED = False |
|
41 | 41 | CELERY_EAGER = False |
|
42 | 42 | |
|
43 | 43 | # link to config for pylons |
|
44 | 44 | CONFIG = {} |
|
45 | 45 | |
|
46 | 46 | # Populated with the settings dictionary from application init in |
|
47 | 47 | # rhodecode.conf.environment.load_pyramid_environment |
|
48 | 48 | PYRAMID_SETTINGS = {} |
|
49 | 49 | |
|
50 | 50 | # Linked module for extensions |
|
51 | 51 | EXTENSIONS = {} |
|
52 | 52 | |
|
53 | 53 | __version__ = ('.'.join((str(each) for each in VERSION[:3]))) |
|
54 |
__dbversion__ = 5 |
|
|
54 | __dbversion__ = 58 # defines current db version for migrations | |
|
55 | 55 | __platform__ = platform.system() |
|
56 | 56 | __license__ = 'AGPLv3, and Commercial License' |
|
57 | 57 | __author__ = 'RhodeCode GmbH' |
|
58 | 58 | __url__ = 'http://rhodecode.com' |
|
59 | 59 | |
|
60 | 60 | is_windows = __platform__ in ['Windows'] |
|
61 | 61 | is_unix = not is_windows |
|
62 | 62 | is_test = False |
|
63 | 63 | disable_error_handler = False |
General Comments 0
You need to be logged in to leave comments.
Login now