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