Mercurial > kallithea
annotate rhodecode/model/db.py @ 723:bf26b46e82d6 beta
some tests update
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 18 Nov 2010 23:11:51 +0100 |
parents | 1bb0fcdec895 |
children | 49eb69d78988 |
rev | line source |
---|---|
658 | 1 from rhodecode.model.meta import Base |
2 from sqlalchemy import * | |
3 from sqlalchemy.orm import relation, backref | |
4 from sqlalchemy.orm.session import Session | |
5 from vcs.utils.lazy import LazyProperty | |
6 import logging | |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
7 log = logging.getLogger(__name__) |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
8 |
549
f99075170eb4
more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
9 class RhodeCodeSettings(Base): |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
10 __tablename__ = 'rhodecode_settings' |
381
55377fdc1fc6
cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
11 __table_args__ = (UniqueConstraint('app_settings_name'), {'useexisting':True}) |
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:
328
diff
changeset
|
12 app_settings_id = Column("app_settings_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
381
55377fdc1fc6
cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
13 app_settings_name = Column("app_settings_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
55377fdc1fc6
cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
14 app_settings_value = Column("app_settings_value", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
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:
328
diff
changeset
|
15 |
704
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
16 def __init__(self, k, v): |
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
17 self.app_settings_name = k |
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
18 self.app_settings_value = v |
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
19 |
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
20 def __repr__(self): |
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
21 return "<RhodeCodeSetting('%s:%s')>" % (self.app_settings_name, |
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
22 self.app_settings_value) |
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
23 |
549
f99075170eb4
more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
24 class RhodeCodeUi(Base): |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
25 __tablename__ = 'rhodecode_ui' |
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:
328
diff
changeset
|
26 __table_args__ = {'useexisting':True} |
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:
328
diff
changeset
|
27 ui_id = Column("ui_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
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:
328
diff
changeset
|
28 ui_section = Column("ui_section", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
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:
328
diff
changeset
|
29 ui_key = Column("ui_key", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
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:
328
diff
changeset
|
30 ui_value = Column("ui_value", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
392
b27d32cb3157
Implemented hooks system,
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
31 ui_active = Column("ui_active", BOOLEAN(), nullable=True, unique=None, default=True) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
32 |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
33 |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
34 class User(Base): |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
35 __tablename__ = 'users' |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
36 __table_args__ = (UniqueConstraint('username'), UniqueConstraint('email'), {'useexisting':True}) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
37 user_id = Column("user_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
89
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
38 username = Column("username", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
39 password = Column("password", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
40 active = Column("active", BOOLEAN(), nullable=True, unique=None, default=None) |
303
3a66e7421a99
db model fix, added repo instance to cached repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
41 admin = Column("admin", BOOLEAN(), nullable=True, unique=None, default=False) |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
42 name = Column("name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
43 lastname = Column("lastname", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
44 email = Column("email", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
45 last_login = Column("last_login", DATETIME(timezone=False), nullable=True, unique=None, default=None) |
704
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
46 is_ldap = Column("is_ldap", BOOLEAN(), nullable=False, unique=None, default=False) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
47 |
704
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
48 user_log = relation('UserLog', cascade='all') |
26237de9b613
Added settings model, and Exceptions lib.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
49 user_perms = relation('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id", cascade='all') |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
50 |
713
1bb0fcdec895
fixed #72 show warning on removal when user still is owner of existing repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
51 repositories = relation('Repository') |
1bb0fcdec895
fixed #72 show warning on removal when user still is owner of existing repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
52 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
53 @LazyProperty |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
54 def full_contact(self): |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
55 return '%s %s <%s>' % (self.name, self.lastname, self.email) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
56 |
232
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
57 def __repr__(self): |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
414
diff
changeset
|
58 return "<User('id:%s:%s')>" % (self.user_id, self.username) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
59 |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
60 def update_lastlogin(self): |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
61 """Update user lastlogin""" |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
62 import datetime |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
63 |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
64 try: |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
65 session = Session.object_session(self) |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
66 self.last_login = datetime.datetime.now() |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
67 session.add(self) |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
68 session.commit() |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
69 log.debug('updated user %s lastlogin', self.username) |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
70 except Exception: |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
71 session.rollback() |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
72 |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
73 |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
74 class UserLog(Base): |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
75 __tablename__ = 'user_logs' |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
76 __table_args__ = {'useexisting':True} |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
77 user_log_id = Column("user_log_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
78 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=None, default=None) |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
536
diff
changeset
|
79 repository_id = Column("repository_id", INTEGER(length=None, convert_unicode=False, assert_unicode=None), ForeignKey(u'repositories.repo_id'), nullable=False, unique=None, default=None) |
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
536
diff
changeset
|
80 repository_name = Column("repository_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
81 user_ip = Column("user_ip", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
89
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
82 action = Column("action", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
b2c38dee135a
Model update for sqlalchemy 0.6.0
Marcin Kuzminski <marcin@python-works.com>
parents:
62
diff
changeset
|
83 action_date = Column("action_date", DATETIME(timezone=False), nullable=True, unique=None, default=None) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
84 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
85 user = relation('User') |
536
39203995f2c4
made action logger more global, to be used in other places to log other actions.
Marcin Kuzminski <marcin@python-works.com>
parents:
530
diff
changeset
|
86 repository = relation('Repository') |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
87 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
88 class Repository(Base): |
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
89 __tablename__ = 'repositories' |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
90 __table_args__ = (UniqueConstraint('repo_name'), {'useexisting':True},) |
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
91 repo_id = Column("repo_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
92 repo_name = Column("repo_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
93 repo_type = Column("repo_type", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=False, unique=False, default=None) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
94 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=False, default=None) |
242
5da4ef115006
Added lastlogin to user after login, model db update
Marcin Kuzminski <marcin@python-works.com>
parents:
239
diff
changeset
|
95 private = Column("private", BOOLEAN(), nullable=True, unique=None, default=None) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
96 description = Column("description", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
503
diff
changeset
|
97 fork_id = Column("fork_id", INTEGER(), ForeignKey(u'repositories.repo_id'), nullable=True, unique=False, default=None) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
98 |
242
5da4ef115006
Added lastlogin to user after login, model db update
Marcin Kuzminski <marcin@python-works.com>
parents:
239
diff
changeset
|
99 user = relation('User') |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
503
diff
changeset
|
100 fork = relation('Repository', remote_side=repo_id) |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
101 repo_to_perm = relation('RepoToPerm', cascade='all') |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
704
diff
changeset
|
102 stats = relation('Statistics', cascade='all', uselist=False) |
667
56a8434a88cc
fixes #51 deleting a repo didn't delete it's dependent db entries.
Marcin Kuzminski <marcin@python-works.com>
parents:
658
diff
changeset
|
103 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
414
diff
changeset
|
104 def __repr__(self): |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
105 return "<Repository('%s:%s')>" % (self.repo_id, self.repo_name) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
106 |
234
a0116e944da1
changed naming convention for db modules.
Marcin Kuzminski <marcin@python-works.com>
parents:
232
diff
changeset
|
107 class Permission(Base): |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
108 __tablename__ = 'permissions' |
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
109 __table_args__ = {'useexisting':True} |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
110 permission_id = Column("permission_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
89
diff
changeset
|
111 permission_name = Column("permission_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
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
|
112 permission_longname = Column("permission_longname", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
113 |
232
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
114 def __repr__(self): |
37a832dc4a82
some beaker cache changes, and added repr to models
Marcin Kuzminski <marcin@python-works.com>
parents:
226
diff
changeset
|
115 return "<Permission('%s:%s')>" % (self.permission_id, self.permission_name) |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
116 |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
117 class RepoToPerm(Base): |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
118 __tablename__ = 'repo_to_perm' |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
119 __table_args__ = (UniqueConstraint('user_id', 'repository_id'), {'useexisting':True}) |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
120 repo_to_perm_id = Column("repo_to_perm_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
121 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=None, default=None) |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
122 permission_id = Column("permission_id", INTEGER(), ForeignKey(u'permissions.permission_id'), nullable=False, unique=None, default=None) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
123 repository_id = Column("repository_id", INTEGER(), ForeignKey(u'repositories.repo_id'), nullable=False, unique=None, default=None) |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
124 |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
125 user = relation('User') |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
126 permission = relation('Permission') |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
127 repository = relation('Repository') |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
128 |
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
129 class UserToPerm(Base): |
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
130 __tablename__ = 'user_to_perm' |
414
27f801e03489
fixed escaping for new webhelpers and added perm2user constraint
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
131 __table_args__ = (UniqueConstraint('user_id', 'permission_id'), {'useexisting':True}) |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
132 user_to_perm_id = Column("user_to_perm_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
133 user_id = Column("user_id", INTEGER(), ForeignKey(u'users.user_id'), nullable=False, unique=None, default=None) |
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
134 permission_id = Column("permission_id", INTEGER(), ForeignKey(u'permissions.permission_id'), nullable=False, unique=None, default=None) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
135 |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
136 user = relation('User') |
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
137 permission = relation('Permission') |
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
138 |
493
2256c78afe53
implemented basic autoupdating statistics fetched from database
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
139 class Statistics(Base): |
2256c78afe53
implemented basic autoupdating statistics fetched from database
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
140 __tablename__ = 'statistics' |
2256c78afe53
implemented basic autoupdating statistics fetched from database
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
141 __table_args__ = (UniqueConstraint('repository_id'), {'useexisting':True}) |
2256c78afe53
implemented basic autoupdating statistics fetched from database
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
142 stat_id = Column("stat_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
2256c78afe53
implemented basic autoupdating statistics fetched from database
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
143 repository_id = Column("repository_id", INTEGER(), ForeignKey(u'repositories.repo_id'), nullable=False, unique=True, default=None) |
2256c78afe53
implemented basic autoupdating statistics fetched from database
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
144 stat_on_revision = Column("stat_on_revision", INTEGER(), nullable=False) |
2256c78afe53
implemented basic autoupdating statistics fetched from database
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
145 commit_activity = Column("commit_activity", BLOB(), nullable=False)#JSON data |
2256c78afe53
implemented basic autoupdating statistics fetched from database
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
146 commit_activity_combined = Column("commit_activity_combined", BLOB(), nullable=False)#JSON data |
2256c78afe53
implemented basic autoupdating statistics fetched from database
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
147 languages = Column("languages", BLOB(), nullable=False)#JSON data |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
148 |
667
56a8434a88cc
fixes #51 deleting a repo didn't delete it's dependent db entries.
Marcin Kuzminski <marcin@python-works.com>
parents:
658
diff
changeset
|
149 repository = relation('Repository', single_parent=True) |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
150 |
670
e7c670cc03cb
Adde table for cache invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
667
diff
changeset
|
151 class CacheInvalidation(Base): |
e7c670cc03cb
Adde table for cache invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
667
diff
changeset
|
152 __tablename__ = 'cache_invalidation' |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
153 __table_args__ = (UniqueConstraint('cache_key'), {'useexisting':True}) |
670
e7c670cc03cb
Adde table for cache invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
667
diff
changeset
|
154 cache_id = Column("cache_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
e7c670cc03cb
Adde table for cache invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
667
diff
changeset
|
155 cache_key = Column("cache_key", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
e7c670cc03cb
Adde table for cache invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
667
diff
changeset
|
156 cache_args = Column("cache_args", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
157 cache_active = Column("cache_active", BOOLEAN(), nullable=True, unique=None, default=False) |
670
e7c670cc03cb
Adde table for cache invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
667
diff
changeset
|
158 |
e7c670cc03cb
Adde table for cache invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
667
diff
changeset
|
159 |
692
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
160 def __init__(self, cache_key, cache_args=''): |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
161 self.cache_key = cache_key |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
162 self.cache_args = cache_args |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
163 self.cache_active = False |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
164 |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
165 def __repr__(self): |
cb0d9ce6ac5c
#50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents:
670
diff
changeset
|
166 return "<CacheInvaidation('%s:%s')>" % (self.cache_id, self.cache_key) |