Mercurial > kallithea
comparison rhodecode/model/db.py @ 1585:56276c716599 beta
Remove dead code
author | Nicolas VINOT <aeris@imirhil.fr> |
---|---|
date | Sat, 01 Oct 2011 16:38:51 +0200 |
parents | 3338a0994472 |
children | 2ccb32ddcfd7 |
comparison
equal
deleted
inserted
replaced
1584:3338a0994472 | 1585:56276c716599 |
---|---|
501 logs = relationship('UserLog', cascade='all') | 501 logs = relationship('UserLog', cascade='all') |
502 | 502 |
503 def __repr__(self): | 503 def __repr__(self): |
504 return "<%s('%s:%s')>" % (self.__class__.__name__, | 504 return "<%s('%s:%s')>" % (self.__class__.__name__, |
505 self.repo_id, self.repo_name) | 505 self.repo_id, self.repo_name) |
506 | |
507 @staticmethod | |
508 def create(name, description, repo_type, private, owner, group, clone): | |
509 try: | |
510 repo = Repository() | |
511 repo.repo_name = name | |
512 repo.clone_uri = clone | |
513 repo.repo_type = repo_type | |
514 repo.user = owner | |
515 repo.private = private | |
516 repo.description = description | |
517 repo.group = group | |
518 | |
519 Session.add(repo) | |
520 Session.commit() | |
521 | |
522 RepoToPerm.create(repo, owner, Permission.get_by_name('repository.write')) | |
523 return repo | |
524 except: | |
525 log.error(traceback.format_exc()) | |
526 Session.rollback() | |
527 raise | |
528 | 506 |
529 @classmethod | 507 @classmethod |
530 def by_repo_name(cls, repo_name): | 508 def by_repo_name(cls, repo_name): |
531 q = cls.query().filter(cls.repo_name == repo_name) | 509 q = cls.query().filter(cls.repo_name == repo_name) |
532 | 510 |
854 | 832 |
855 user = relationship('User') | 833 user = relationship('User') |
856 permission = relationship('Permission') | 834 permission = relationship('Permission') |
857 repository = relationship('Repository') | 835 repository = relationship('Repository') |
858 | 836 |
859 @staticmethod | |
860 def create(repo, user, p): | |
861 try: | |
862 perm = RepoToPerm() | |
863 perm.repository = repo | |
864 perm.user = user | |
865 perm.permission = p | |
866 | |
867 Session.add(perm) | |
868 Session.commit() | |
869 | |
870 return perm | |
871 except: | |
872 log.error(traceback.format_exc()) | |
873 Session.rollback() | |
874 raise | |
875 | |
876 class UserToPerm(Base, BaseModel): | 837 class UserToPerm(Base, BaseModel): |
877 __tablename__ = 'user_to_perm' | 838 __tablename__ = 'user_to_perm' |
878 __table_args__ = (UniqueConstraint('user_id', 'permission_id'), {'extend_existing':True}) | 839 __table_args__ = (UniqueConstraint('user_id', 'permission_id'), {'extend_existing':True}) |
879 user_to_perm_id = Column("user_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) | 840 user_to_perm_id = Column("user_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) |
880 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None) | 841 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None, default=None) |