##// END OF EJS Templates
dbmigrate: fixed migration problems
super-admin -
r5166:f519a80b default
parent child Browse files
Show More
@@ -447,7 +447,7 b' class UserGroup(Base, BaseModel):'
447 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
447 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
448 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
448 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
449 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
449 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
450 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
450 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
451
451
452 user = relationship('User')
452 user = relationship('User')
453
453
@@ -449,7 +449,7 b' class UserGroup(Base, BaseModel):'
449 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
449 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
450 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
450 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
451 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
451 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
452 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
452 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
453
453
454 user = relationship('User')
454 user = relationship('User')
455
455
@@ -472,7 +472,7 b' class UserGroup(Base, BaseModel):'
472 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
472 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
473 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
473 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
474 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
474 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
475 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
475 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
476
476
477 user = relationship('User')
477 user = relationship('User')
478
478
@@ -471,7 +471,7 b' class UserGroup(Base, BaseModel):'
471 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
471 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
472 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
472 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
473 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
473 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
474 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
474 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
475
475
476 user = relationship('User')
476 user = relationship('User')
477
477
@@ -471,7 +471,7 b' class UserGroup(Base, BaseModel):'
471 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
471 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
472 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
472 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
473 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
473 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
474 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
474 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
475
475
476 user = relationship('User')
476 user = relationship('User')
477
477
@@ -505,7 +505,7 b' class UserGroup(Base, BaseModel):'
505 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
505 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
506 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
506 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
507 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
507 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
508 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
508 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
509
509
510 user = relationship('User')
510 user = relationship('User')
511
511
@@ -516,7 +516,7 b' class UserGroup(Base, BaseModel):'
516 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
516 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
517 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
517 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
518 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
518 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
519 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
519 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
520
520
521 user = relationship('User')
521 user = relationship('User')
522
522
@@ -517,7 +517,7 b' class UserGroup(Base, BaseModel):'
517 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
517 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
518 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
518 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
519 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
519 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
520 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
520 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
521
521
522 user = relationship('User')
522 user = relationship('User')
523
523
@@ -523,7 +523,7 b' class UserGroup(Base, BaseModel):'
523 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
523 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
524 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
524 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
525 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
525 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
526 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
526 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
527
527
528 user = relationship('User')
528 user = relationship('User')
529
529
@@ -523,7 +523,7 b' class UserGroup(Base, BaseModel):'
523 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
523 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
524 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
524 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
525 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
525 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
526 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
526 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
527
527
528 user = relationship('User')
528 user = relationship('User')
529
529
@@ -544,7 +544,7 b' class UserGroup(Base, BaseModel):'
544 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
544 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
545 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
545 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
546 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
546 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
547 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
547 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
548
548
549 user = relationship('User')
549 user = relationship('User')
550
550
@@ -554,7 +554,7 b' class UserGroup(Base, BaseModel):'
554 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
554 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
555 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
555 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
556 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
556 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
557 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
557 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
558
558
559 user = relationship('User')
559 user = relationship('User')
560
560
@@ -595,7 +595,7 b' class UserGroup(Base, BaseModel):'
595 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
595 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
596 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
596 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
597 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
597 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
598 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
598 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
599
599
600 user = relationship('User')
600 user = relationship('User')
601
601
@@ -595,7 +595,7 b' class UserGroup(Base, BaseModel):'
595 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
595 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
596 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
596 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
597 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
597 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
598 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
598 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
599
599
600 user = relationship('User')
600 user = relationship('User')
601
601
@@ -596,7 +596,7 b' class UserGroup(Base, BaseModel):'
596 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
596 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
597 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
597 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
598 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
598 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
599 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
599 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
600
600
601 user = relationship('User')
601 user = relationship('User')
602
602
@@ -596,7 +596,7 b' class UserGroup(Base, BaseModel):'
596 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
596 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
597 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
597 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
598 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
598 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
599 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
599 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
600
600
601 user = relationship('User')
601 user = relationship('User')
602
602
@@ -602,7 +602,7 b' class UserGroup(Base, BaseModel):'
602 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
602 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
603 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
603 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
604 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
604 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
605 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
605 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
606
606
607 user = relationship('User')
607 user = relationship('User')
608
608
@@ -719,7 +719,7 b' class UserGroup(Base, BaseModel):'
719 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
719 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
720 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
720 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
721 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
721 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
722 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
722 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
723
723
724 user = relationship('User')
724 user = relationship('User')
725
725
@@ -41,6 +41,7 b' from beaker.cache import cache_region, r'
41 from webob.exc import HTTPNotFound
41 from webob.exc import HTTPNotFound
42 from zope.cachedescriptors.property import Lazy as LazyProperty
42 from zope.cachedescriptors.property import Lazy as LazyProperty
43
43
44 from rhodecode.lib import enc_utils
44 from rhodecode.translation import _
45 from rhodecode.translation import _
45
46
46 from rhodecode.lib.vcs import get_backend
47 from rhodecode.lib.vcs import get_backend
@@ -69,7 +70,7 b' log = logging.getLogger(__name__)'
69
70
70 # this is propagated from .ini file beaker.session.secret
71 # this is propagated from .ini file beaker.session.secret
71 # and initialized at environment.py
72 # and initialized at environment.py
72 ENCRYPTION_KEY = None
73 ENCRYPTION_KEY: bytes = b''
73
74
74 # used to sort permissions by types, '#' used here is not allowed to be in
75 # used to sort permissions by types, '#' used here is not allowed to be in
75 # usernames, and it's very early in sorted string.printable table.
76 # usernames, and it's very early in sorted string.printable table.
@@ -106,30 +107,38 b' class EncryptedValue(TypeDecorator):'
106 impl = String
107 impl = String
107
108
108 def process_bind_param(self, value, dialect):
109 def process_bind_param(self, value, dialect):
109 if not value:
110 """
110 return value
111 Setter for storing value
111 if value.startswith('enc$aes$'):
112 """
112 # protect against double encrypting if someone manually starts doing
113 import rhodecode
113 raise ValueError('value needs to be in unencrypted format, ie. '
114 'not starting with enc$aes$')
115 return 'enc$aes$%s' % AESCipher(ENCRYPTION_KEY).encrypt(value)
116
117 def process_result_value(self, value, dialect):
118 if not value:
114 if not value:
119 return value
115 return value
120
116
121 parts = value.split('$', 3)
117 # protect against double encrypting if values is already encrypted
122 if not len(parts) == 3:
118 if value.startswith('enc$aes$') \
123 # probably not encrypted values
119 or value.startswith('enc$aes_hmac$') \
120 or value.startswith('enc2$'):
121 raise ValueError('value needs to be in unencrypted format, '
122 'ie. not starting with enc$ or enc2$')
123
124 algo = rhodecode.CONFIG.get('rhodecode.encrypted_values.algorithm') or 'aes'
125 bytes_val = enc_utils.encrypt_value(value, enc_key=ENCRYPTION_KEY, algo=algo)
126 return safe_str(bytes_val)
127
128 def process_result_value(self, value, dialect):
129 """
130 Getter for retrieving value
131 """
132
133 import rhodecode
134 if not value:
124 return value
135 return value
125 else:
136
126 if parts[0] != 'enc':
137 enc_strict_mode = rhodecode.ConfigGet().get_bool('rhodecode.encrypted_values.strict', missing=True)
127 # parts ok but without our header ?
128 return value
129
138
130 # at that stage we know it's our encryption
139 bytes_val = enc_utils.decrypt_value(value, enc_key=ENCRYPTION_KEY, strict_mode=enc_strict_mode)
131 decrypted_data = AESCipher(ENCRYPTION_KEY).decrypt(parts[2])
140
132 return decrypted_data
141 return safe_str(bytes_val)
133
142
134
143
135 class BaseModel(object):
144 class BaseModel(object):
@@ -742,7 +751,7 b' class UserGroup(Base, BaseModel):'
742 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
751 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
743 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
752 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
744 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
753 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
745 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
754 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
746
755
747 user = relationship('User')
756 user = relationship('User')
748
757
@@ -1303,7 +1303,7 b' class UserGroup(Base, BaseModel):'
1303 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1303 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1304 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1304 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1305 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1305 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1306 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1306 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1307
1307
1308 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1308 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1309 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1309 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
@@ -1307,7 +1307,7 b' class UserGroup(Base, BaseModel):'
1307 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1307 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1308 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1308 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1309 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1309 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1310 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1310 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1311
1311
1312 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1312 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1313 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1313 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
@@ -1314,7 +1314,7 b' class UserGroup(Base, BaseModel):'
1314 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1314 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1315 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1315 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1316 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1316 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1317 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1317 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1318
1318
1319 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1319 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1320 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1320 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
@@ -1316,7 +1316,7 b' class UserGroup(Base, BaseModel):'
1316 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1316 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1317 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1317 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1318 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1318 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1319 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1319 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1320
1320
1321 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1321 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1322 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1322 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
@@ -1316,7 +1316,7 b' class UserGroup(Base, BaseModel):'
1316 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1316 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1317 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1317 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1318 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1318 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1319 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1319 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1320
1320
1321 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1321 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1322 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1322 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
@@ -1333,7 +1333,7 b' class UserGroup(Base, BaseModel):'
1333 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1333 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1334 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1334 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1335 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1335 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1336 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1336 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1337
1337
1338 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1338 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1339 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1339 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
@@ -1386,7 +1386,7 b' class UserGroup(Base, BaseModel):'
1386 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1386 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1387 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1387 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1388 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1388 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1389 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1389 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1390
1390
1391 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1391 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1392 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1392 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
@@ -1392,7 +1392,7 b' class UserGroup(Base, BaseModel):'
1392 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1392 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1393 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1393 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1394 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1394 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1395 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1395 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1396
1396
1397 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1397 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1398 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1398 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
@@ -1415,7 +1415,7 b' class UserGroup(Base, BaseModel):'
1415 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1415 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1416 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1416 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1417 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1417 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1418 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1418 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1419
1419
1420 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1420 user_group_review_rules = relationship('RepoReviewRuleUserGroup', cascade='all')
1421 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1421 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
@@ -1035,7 +1035,7 b' class UserGroup(Base, BaseModel):'
1035 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1035 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1036 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1036 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1037 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1037 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1038 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1038 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1039
1039
1040 user = relationship('User')
1040 user = relationship('User')
1041
1041
@@ -1036,7 +1036,7 b' class UserGroup(Base, BaseModel):'
1036 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1036 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1037 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1037 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1038 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1038 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1039 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1039 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1040
1040
1041 user = relationship('User')
1041 user = relationship('User')
1042
1042
@@ -1035,7 +1035,7 b' class UserGroup(Base, BaseModel):'
1035 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1035 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1036 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1036 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1037 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1037 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1038 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1038 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1039
1039
1040 user = relationship('User')
1040 user = relationship('User')
1041
1041
@@ -1037,7 +1037,7 b' class UserGroup(Base, BaseModel):'
1037 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1037 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1038 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1038 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1039 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1039 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1040 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1040 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1041
1041
1042 user = relationship('User')
1042 user = relationship('User')
1043
1043
@@ -1037,7 +1037,7 b' class UserGroup(Base, BaseModel):'
1037 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1037 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1038 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1038 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1039 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1039 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1040 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1040 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1041
1041
1042 user = relationship('User')
1042 user = relationship('User')
1043
1043
@@ -1080,7 +1080,7 b' class UserGroup(Base, BaseModel):'
1080 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1080 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1081 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1081 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1082 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1082 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1083 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1083 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1084
1084
1085 user = relationship('User')
1085 user = relationship('User')
1086
1086
@@ -1081,7 +1081,7 b' class UserGroup(Base, BaseModel):'
1081 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1081 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1082 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1082 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1083 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1083 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1084 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1084 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1085
1085
1086 user = relationship('User')
1086 user = relationship('User')
1087
1087
@@ -1242,7 +1242,7 b' class UserGroup(Base, BaseModel):'
1242 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1242 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1243 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1243 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
1244 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1244 user_user_group_to_perm = relationship('UserUserGroupToPerm', cascade='all')
1245 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm ', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1245 user_group_user_group_to_perm = relationship('UserGroupUserGroupToPerm', primaryjoin="UserGroupUserGroupToPerm.target_user_group_id==UserGroup.users_group_id", cascade='all')
1246
1246
1247 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1247 user = relationship('User', primaryjoin="User.user_id==UserGroup.user_id")
1248
1248
@@ -35,7 +35,7 b' def upgrade(migrate_engine):'
35 username.create(table=tbl)
35 username.create(table=tbl)
36
36
37 _Session = meta.Session()
37 _Session = meta.Session()
38 ## after adding that column fix all usernames
38 # after adding that column fix all usernames
39 users_log = _Session.query(db_1_5_0.UserLog)\
39 users_log = _Session.query(db_1_5_0.UserLog)\
40 .options(joinedload(db_1_5_0.UserLog.user))\
40 .options(joinedload(db_1_5_0.UserLog.user))\
41 .options(joinedload(db_1_5_0.UserLog.repository)).all()
41 .options(joinedload(db_1_5_0.UserLog.repository)).all()
@@ -45,7 +45,7 b' def upgrade(migrate_engine):'
45 _Session.add(entry)
45 _Session.add(entry)
46 _Session.commit()
46 _Session.commit()
47
47
48 #alter username to not null
48 # alter username to not null
49 tbl_name = db_1_5_0.UserLog.__tablename__
49 tbl_name = db_1_5_0.UserLog.__tablename__
50 tbl = Table(tbl_name,
50 tbl = Table(tbl_name,
51 MetaData(bind=migrate_engine), autoload=True,
51 MetaData(bind=migrate_engine), autoload=True,
@@ -74,19 +74,18 b' def get_by_name(cls, key):'
74
74
75 def fixups(models, _SESSION):
75 def fixups(models, _SESSION):
76 # ** create default permissions ** #
76 # ** create default permissions ** #
77 #=====================================
77
78 for p in models.Permission.PERMS:
78 for p in models.Permission.PERMS:
79 if not get_by_key(models.Permission, p[0]):
79 if not get_by_key(models.Permission, p[0]):
80 new_perm = models.Permission()
80 new_perm = models.Permission()
81 new_perm.permission_name = p[0]
81 new_perm.permission_name = p[0]
82 new_perm.permission_longname = p[0] #translation err with p[1]
82 new_perm.permission_longname = p[0] # translation err with p[1]
83 print('Creating new permission %s' % p[0])
83 print('Creating new permission %s' % p[0])
84 _SESSION().add(new_perm)
84 _SESSION().add(new_perm)
85
85
86 _SESSION().commit()
86 _SESSION().commit()
87
87
88 # ** populate default permissions ** #
88 # ** populate default permissions ** #
89 #=====================================
90
89
91 user = models.User.query().filter(models.User.username == 'default').scalar()
90 user = models.User.query().filter(models.User.username == 'default').scalar()
92
91
@@ -100,9 +99,10 b' def fixups(models, _SESSION):'
100 return '.'.join(perm_name.split('.')[:1])
99 return '.'.join(perm_name.split('.')[:1])
101
100
102 perms = models.UserToPerm.query().filter(models.UserToPerm.user == user).all()
101 perms = models.UserToPerm.query().filter(models.UserToPerm.user == user).all()
103 defined_perms_groups = map(
102 defined_perms_groups = list(map(
104 _get_group, (x.permission.permission_name for x in perms))
103 _get_group, (x.permission.permission_name for x in perms)))
105 log.debug('GOT ALREADY DEFINED:%s', perms)
104 perms_show = [p.__dict__ for p in perms]
105 log.debug('GOT ALREADY DEFINED:%s', perms_show)
106 DEFAULT_PERMS = models.Permission.DEFAULT_USER_PERMISSIONS
106 DEFAULT_PERMS = models.Permission.DEFAULT_USER_PERMISSIONS
107
107
108 # for every default permission that needs to be created, we check if
108 # for every default permission that needs to be created, we check if
@@ -70,14 +70,18 b' def downgrade(migrate_engine):'
70 meta.bind = migrate_engine
70 meta.bind = migrate_engine
71
71
72
72
73 def get_by_key(cls, key):
74 return cls.query().filter(cls.permission_name == key).scalar()
75
76
73 def fixups(models, _SESSION):
77 def fixups(models, _SESSION):
74 # ** create default permissions ** #
78 # ** create default permissions ** #
75 #=====================================
79 #=====================================
76 for p in models.Permission.PERMS:
80 for p in models.Permission.PERMS:
77 if not models.Permission.get_by_key(p[0]):
81 if not get_by_key(models.Permission, p[0]):
78 new_perm = models.Permission()
82 new_perm = models.Permission()
79 new_perm.permission_name = p[0]
83 new_perm.permission_name = p[0]
80 new_perm.permission_longname = p[0] #translation err with p[1]
84 new_perm.permission_longname = p[0] # translation err with p[1]
81 _SESSION().add(new_perm)
85 _SESSION().add(new_perm)
82
86
83 _SESSION().commit()
87 _SESSION().commit()
@@ -97,8 +101,7 b' def fixups(models, _SESSION):'
97 return '.'.join(perm_name.split('.')[:1])
101 return '.'.join(perm_name.split('.')[:1])
98
102
99 perms = models.UserToPerm.query().filter(models.UserToPerm.user == user).all()
103 perms = models.UserToPerm.query().filter(models.UserToPerm.user == user).all()
100 defined_perms_groups = map(_get_group,
104 defined_perms_groups = list(map(_get_group, (x.permission.permission_name for x in perms)))
101 (x.permission.permission_name for x in perms))
102 log.debug('GOT ALREADY DEFINED:%s', perms)
105 log.debug('GOT ALREADY DEFINED:%s', perms)
103 DEFAULT_PERMS = models.Permission.DEFAULT_USER_PERMISSIONS
106 DEFAULT_PERMS = models.Permission.DEFAULT_USER_PERMISSIONS
104
107
@@ -10,6 +10,7 b' from sqlalchemy.engine import reflection'
10 from sqlalchemy.sql import text
10 from sqlalchemy.sql import text
11
11
12 from rhodecode.lib.dbmigrate.versions import _reset_base
12 from rhodecode.lib.dbmigrate.versions import _reset_base
13 from rhodecode.lib.hash_utils import sha1_safe
13 from rhodecode.lib.utils2 import safe_str
14 from rhodecode.lib.utils2 import safe_str
14 from rhodecode.model import meta, init_model_encryption
15 from rhodecode.model import meta, init_model_encryption
15
16
@@ -69,11 +70,9 b' def downgrade(migrate_engine):'
69 def _generate_repo_name_hashes(models, op, session):
70 def _generate_repo_name_hashes(models, op, session):
70 repositories = models.Repository.get_all()
71 repositories = models.Repository.get_all()
71 for repository in repositories:
72 for repository in repositories:
72 hash_ = hashlib.sha1(safe_str(repository.repo_name)).hexdigest()
73 hash_ = sha1_safe(repository.repo_name)
73 params = {'hash': hash_, 'id': repository.repo_id}
74 params = {'hash': hash_, 'id': repository.repo_id}
74 query = text(
75 query = text('UPDATE repositories SET repo_name_hash = :hash WHERE repo_id = :id').bindparams(**params)
75 'UPDATE repositories SET repo_name_hash = :hash'
76 ' WHERE repo_id = :id').bindparams(**params)
77 op.execute(query)
76 op.execute(query)
78 session().commit()
77 session().commit()
79
78
@@ -117,15 +117,19 b' class AESCipher(object):'
117 def validate_and_decrypt_data(enc_data, enc_key, enc_strict_mode=False, safe=True):
117 def validate_and_decrypt_data(enc_data, enc_key, enc_strict_mode=False, safe=True):
118 enc_data = safe_str(enc_data)
118 enc_data = safe_str(enc_data)
119
119
120 if '$' not in enc_data:
121 # probably not encrypted values
122 return enc_data
123
120 parts = enc_data.split('$', 3)
124 parts = enc_data.split('$', 3)
121 if len(parts) != 3:
125 if len(parts) != 3:
122 raise ValueError(f'Encrypted Data has invalid format, expected {KEY_FORMAT}, got {parts}')
126 raise ValueError(f'Encrypted Data has invalid format, expected {KEY_FORMAT}, got {parts}, org value: {enc_data}')
123
127
124 enc_type = parts[1]
128 enc_type = parts[1]
125 enc_data_part = parts[2]
129 enc_data_part = parts[2]
126
130
127 if parts[0] != 'enc':
131 if parts[0] != 'enc':
128 # parts ok but without our header ?
132 # parts ok but without our header?
129 return enc_data
133 return enc_data
130
134
131 # at that stage we know it's our encryption
135 # at that stage we know it's our encryption
General Comments 0
You need to be logged in to leave comments. Login now