Show More
@@ -145,7 +145,10 b' class BaseModel(object):' | |||||
145 |
|
145 | |||
146 | class RhodeCodeSetting(Base, BaseModel): |
|
146 | class RhodeCodeSetting(Base, BaseModel): | |
147 | __tablename__ = 'rhodecode_settings' |
|
147 | __tablename__ = 'rhodecode_settings' | |
148 | __table_args__ = (UniqueConstraint('app_settings_name'), {'extend_existing': True}) |
|
148 | __table_args__ = ( | |
|
149 | UniqueConstraint('app_settings_name'), | |||
|
150 | {'extend_existing': True} | |||
|
151 | ) | |||
149 | app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
|
152 | app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | |
150 | app_settings_name = Column("app_settings_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
153 | app_settings_name = Column("app_settings_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
151 | _app_settings_value = Column("app_settings_value", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
154 | _app_settings_value = Column("app_settings_value", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
@@ -154,7 +157,6 b' class RhodeCodeSetting(Base, BaseModel):' | |||||
154 | self.app_settings_name = k |
|
157 | self.app_settings_name = k | |
155 | self.app_settings_value = v |
|
158 | self.app_settings_value = v | |
156 |
|
159 | |||
157 |
|
||||
158 | @validates('_app_settings_value') |
|
160 | @validates('_app_settings_value') | |
159 | def validate_settings_value(self, key, val): |
|
161 | def validate_settings_value(self, key, val): | |
160 | assert type(val) == unicode |
|
162 | assert type(val) == unicode | |
@@ -177,8 +179,10 b' class RhodeCodeSetting(Base, BaseModel):' | |||||
177 | self._app_settings_value = safe_unicode(val) |
|
179 | self._app_settings_value = safe_unicode(val) | |
178 |
|
180 | |||
179 | def __repr__(self): |
|
181 | def __repr__(self): | |
180 |
return "<%s('%s:%s')>" % ( |
|
182 | return "<%s('%s:%s')>" % ( | |
181 | self.app_settings_name, self.app_settings_value) |
|
183 | self.__class__.__name__, | |
|
184 | self.app_settings_name, self.app_settings_value | |||
|
185 | ) | |||
182 |
|
186 | |||
183 | @classmethod |
|
187 | @classmethod | |
184 | def get_by_name(cls, ldap_key): |
|
188 | def get_by_name(cls, ldap_key): | |
@@ -215,7 +219,10 b' class RhodeCodeSetting(Base, BaseModel):' | |||||
215 |
|
219 | |||
216 | class RhodeCodeUi(Base, BaseModel): |
|
220 | class RhodeCodeUi(Base, BaseModel): | |
217 | __tablename__ = 'rhodecode_ui' |
|
221 | __tablename__ = 'rhodecode_ui' | |
218 | __table_args__ = (UniqueConstraint('ui_key'), {'extend_existing': True}) |
|
222 | __table_args__ = ( | |
|
223 | UniqueConstraint('ui_key'), | |||
|
224 | {'extend_existing': True} | |||
|
225 | ) | |||
219 |
|
226 | |||
220 | HOOK_UPDATE = 'changegroup.update' |
|
227 | HOOK_UPDATE = 'changegroup.update' | |
221 | HOOK_REPO_SIZE = 'changegroup.repo_size' |
|
228 | HOOK_REPO_SIZE = 'changegroup.repo_size' | |
@@ -262,7 +269,10 b' class RhodeCodeUi(Base, BaseModel):' | |||||
262 |
|
269 | |||
263 | class User(Base, BaseModel): |
|
270 | class User(Base, BaseModel): | |
264 | __tablename__ = 'users' |
|
271 | __tablename__ = 'users' | |
265 | __table_args__ = (UniqueConstraint('username'), UniqueConstraint('email'), {'extend_existing': True}) |
|
272 | __table_args__ = ( | |
|
273 | UniqueConstraint('username'), UniqueConstraint('email'), | |||
|
274 | {'extend_existing': True} | |||
|
275 | ) | |||
266 | user_id = Column("user_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
|
276 | user_id = Column("user_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | |
267 | username = Column("username", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
277 | username = Column("username", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
268 | password = Column("password", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
278 | password = Column("password", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
@@ -448,7 +458,10 b' class UsersGroupMember(Base, BaseModel):' | |||||
448 |
|
458 | |||
449 | class Repository(Base, BaseModel): |
|
459 | class Repository(Base, BaseModel): | |
450 | __tablename__ = 'repositories' |
|
460 | __tablename__ = 'repositories' | |
451 | __table_args__ = (UniqueConstraint('repo_name'), {'extend_existing': True},) |
|
461 | __table_args__ = ( | |
|
462 | UniqueConstraint('repo_name'), | |||
|
463 | {'extend_existing': True}, | |||
|
464 | ) | |||
452 |
|
465 | |||
453 | repo_id = Column("repo_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
|
466 | repo_id = Column("repo_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | |
454 | repo_name = Column("repo_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None) |
|
467 | repo_name = Column("repo_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None) | |
@@ -633,7 +646,6 b' class Repository(Base, BaseModel):' | |||||
633 | grouped[cmt.revision].append(cmt) |
|
646 | grouped[cmt.revision].append(cmt) | |
634 | return grouped |
|
647 | return grouped | |
635 |
|
648 | |||
636 |
|
||||
637 | #========================================================================== |
|
649 | #========================================================================== | |
638 | # SCM CACHE INSTANCE |
|
650 | # SCM CACHE INSTANCE | |
639 | #========================================================================== |
|
651 | #========================================================================== | |
@@ -693,9 +705,12 b' class Repository(Base, BaseModel):' | |||||
693 |
|
705 | |||
694 | class RepoGroup(Base, BaseModel): |
|
706 | class RepoGroup(Base, BaseModel): | |
695 | __tablename__ = 'groups' |
|
707 | __tablename__ = 'groups' | |
696 | __table_args__ = (UniqueConstraint('group_name', 'group_parent_id'), |
|
708 | __table_args__ = ( | |
697 | CheckConstraint('group_id != group_parent_id'), {'extend_existing': True},) |
|
709 | UniqueConstraint('group_name', 'group_parent_id'), | |
698 | __mapper_args__ = {'order_by':'group_name'} |
|
710 | CheckConstraint('group_id != group_parent_id'), | |
|
711 | {'extend_existing': True}, | |||
|
712 | ) | |||
|
713 | __mapper_args__ = {'order_by': 'group_name'} | |||
699 |
|
714 | |||
700 | group_id = Column("group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
|
715 | group_id = Column("group_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | |
701 | group_name = Column("group_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None) |
|
716 | group_name = Column("group_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None) | |
@@ -799,7 +814,6 b' class RepoGroup(Base, BaseModel):' | |||||
799 |
|
814 | |||
800 | return cnt + children_count(self) |
|
815 | return cnt + children_count(self) | |
801 |
|
816 | |||
802 |
|
||||
803 | def get_new_name(self, group_name): |
|
817 | def get_new_name(self, group_name): | |
804 | """ |
|
818 | """ | |
805 | returns new full group name based on parent and new name |
|
819 | returns new full group name based on parent and new name | |
@@ -838,7 +852,9 b' class Permission(Base, BaseModel):' | |||||
838 |
|
852 | |||
839 | class UserRepoToPerm(Base, BaseModel): |
|
853 | class UserRepoToPerm(Base, BaseModel): | |
840 | __tablename__ = 'repo_to_perm' |
|
854 | __tablename__ = 'repo_to_perm' | |
841 | __table_args__ = (UniqueConstraint('user_id', 'repository_id'), {'extend_existing': True}) |
|
855 | __table_args__ = ( | |
|
856 | UniqueConstraint('user_id', 'repository_id'), {'extend_existing': True} | |||
|
857 | ) | |||
842 | repo_to_perm_id = Column("repo_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
|
858 | repo_to_perm_id = Column("repo_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | |
843 | user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None) |
|
859 | user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None) | |
844 | permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None) |
|
860 | permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None) | |
@@ -874,7 +890,10 b' class UserToPerm(Base, BaseModel):' | |||||
874 |
|
890 | |||
875 | class UsersGroupRepoToPerm(Base, BaseModel): |
|
891 | class UsersGroupRepoToPerm(Base, BaseModel): | |
876 | __tablename__ = 'users_group_repo_to_perm' |
|
892 | __tablename__ = 'users_group_repo_to_perm' | |
877 | __table_args__ = (UniqueConstraint('repository_id', 'users_group_id', 'permission_id'), {'extend_existing': True}) |
|
893 | __table_args__ = ( | |
|
894 | UniqueConstraint('repository_id', 'users_group_id', 'permission_id'), | |||
|
895 | {'extend_existing': True} | |||
|
896 | ) | |||
878 | users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
|
897 | users_group_to_perm_id = Column("users_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | |
879 | users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None) |
|
898 | users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None) | |
880 | permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None) |
|
899 | permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None) | |
@@ -908,13 +927,16 b' class UsersGroupToPerm(Base, BaseModel):' | |||||
908 |
|
927 | |||
909 |
|
928 | |||
910 | class UserRepoGroupToPerm(Base, BaseModel): |
|
929 | class UserRepoGroupToPerm(Base, BaseModel): | |
911 | __tablename__ = 'group_to_perm' |
|
930 | __tablename__ = 'user_repo_group_to_perm' | |
912 | __table_args__ = (UniqueConstraint('group_id', 'permission_id'), {'extend_existing': True}) |
|
931 | __table_args__ = ( | |
|
932 | UniqueConstraint('group_id', 'permission_id'), | |||
|
933 | {'extend_existing': True} | |||
|
934 | ) | |||
913 |
|
935 | |||
914 | group_to_perm_id = Column("group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
|
936 | group_to_perm_id = Column("group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | |
915 | user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None) |
|
937 | user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None) | |
|
938 | group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=False, unique=None, default=None) | |||
916 | permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None) |
|
939 | permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None) | |
917 | group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=False, unique=None, default=None) |
|
|||
918 |
|
940 | |||
919 | user = relationship('User') |
|
941 | user = relationship('User') | |
920 | permission = relationship('Permission') |
|
942 | permission = relationship('Permission') | |
@@ -923,7 +945,10 b' class UserRepoGroupToPerm(Base, BaseMode' | |||||
923 |
|
945 | |||
924 | class UsersGroupRepoGroupToPerm(Base, BaseModel): |
|
946 | class UsersGroupRepoGroupToPerm(Base, BaseModel): | |
925 | __tablename__ = 'users_group_repo_group_to_perm' |
|
947 | __tablename__ = 'users_group_repo_group_to_perm' | |
926 | __table_args__ = (UniqueConstraint('group_id', 'permission_id'), {'extend_existing': True}) |
|
948 | __table_args__ = ( | |
|
949 | UniqueConstraint('group_id', 'permission_id'), | |||
|
950 | {'extend_existing': True} | |||
|
951 | ) | |||
927 |
|
952 | |||
928 | users_group_repo_group_to_perm_id = Column("users_group_repo_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
|
953 | users_group_repo_group_to_perm_id = Column("users_group_repo_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | |
929 | users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None) |
|
954 | users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None) | |
@@ -950,9 +975,11 b' class Statistics(Base, BaseModel):' | |||||
950 |
|
975 | |||
951 | class UserFollowing(Base, BaseModel): |
|
976 | class UserFollowing(Base, BaseModel): | |
952 | __tablename__ = 'user_followings' |
|
977 | __tablename__ = 'user_followings' | |
953 | __table_args__ = (UniqueConstraint('user_id', 'follows_repository_id'), |
|
978 | __table_args__ = ( | |
954 |
|
|
979 | UniqueConstraint('user_id', 'follows_repository_id'), | |
955 | , {'extend_existing': True}) |
|
980 | UniqueConstraint('user_id', 'follows_user_id'), | |
|
981 | {'extend_existing': True} | |||
|
982 | ) | |||
956 |
|
983 | |||
957 | user_following_id = Column("user_following_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
|
984 | user_following_id = Column("user_following_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | |
958 | user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None) |
|
985 | user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None) | |
@@ -965,7 +992,6 b' class UserFollowing(Base, BaseModel):' | |||||
965 | follows_user = relationship('User', primaryjoin='User.user_id==UserFollowing.follows_user_id') |
|
992 | follows_user = relationship('User', primaryjoin='User.user_id==UserFollowing.follows_user_id') | |
966 | follows_repository = relationship('Repository', order_by='Repository.repo_name') |
|
993 | follows_repository = relationship('Repository', order_by='Repository.repo_name') | |
967 |
|
994 | |||
968 |
|
||||
969 | @classmethod |
|
995 | @classmethod | |
970 | def get_repo_followers(cls, repo_id): |
|
996 | def get_repo_followers(cls, repo_id): | |
971 | return cls.query().filter(cls.follows_repo_id == repo_id) |
|
997 | return cls.query().filter(cls.follows_repo_id == repo_id) | |
@@ -979,7 +1005,6 b' class CacheInvalidation(Base, BaseModel)' | |||||
979 | cache_args = Column("cache_args", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
1005 | cache_args = Column("cache_args", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
980 | cache_active = Column("cache_active", Boolean(), nullable=True, unique=None, default=False) |
|
1006 | cache_active = Column("cache_active", Boolean(), nullable=True, unique=None, default=False) | |
981 |
|
1007 | |||
982 |
|
||||
983 | def __init__(self, cache_key, cache_args=''): |
|
1008 | def __init__(self, cache_key, cache_args=''): | |
984 | self.cache_key = cache_key |
|
1009 | self.cache_key = cache_key | |
985 | self.cache_args = cache_args |
|
1010 | self.cache_args = cache_args | |
@@ -1122,16 +1147,18 b' class Notification(Base, BaseModel):' | |||||
1122 |
|
1147 | |||
1123 | class UserNotification(Base, BaseModel): |
|
1148 | class UserNotification(Base, BaseModel): | |
1124 | __tablename__ = 'user_to_notification' |
|
1149 | __tablename__ = 'user_to_notification' | |
1125 | __table_args__ = (UniqueConstraint('user_id', 'notification_id'), |
|
1150 | __table_args__ = ( | |
1126 | {'extend_existing': True}) |
|
1151 | UniqueConstraint('user_id', 'notification_id'), | |
1127 | user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), primary_key=True) |
|
1152 | {'extend_existing': True} | |
|
1153 | ) | |||
|
1154 | user_id = Column('user_id', Integer(), ForeignKey('users.user_id'), primary_key=True) | |||
1128 | notification_id = Column("notification_id", Integer(), ForeignKey('notifications.notification_id'), primary_key=True) |
|
1155 | notification_id = Column("notification_id", Integer(), ForeignKey('notifications.notification_id'), primary_key=True) | |
1129 | read = Column('read', Boolean, default=False) |
|
1156 | read = Column('read', Boolean, default=False) | |
1130 | sent_on = Column('sent_on', DateTime(timezone=False), nullable=True, unique=None) |
|
1157 | sent_on = Column('sent_on', DateTime(timezone=False), nullable=True, unique=None) | |
1131 |
|
1158 | |||
1132 | user = relationship('User', lazy="joined") |
|
1159 | user = relationship('User', lazy="joined") | |
1133 | notification = relationship('Notification', lazy="joined", |
|
1160 | notification = relationship('Notification', lazy="joined", | |
1134 |
|
|
1161 | rder_by=lambda: Notification.created_on.desc(),) | |
1135 |
|
1162 | |||
1136 | def mark_as_read(self): |
|
1163 | def mark_as_read(self): | |
1137 | self.read = True |
|
1164 | self.read = True |
General Comments 0
You need to be logged in to leave comments.
Login now