##// END OF EJS Templates
Added associated classes into child models
marcink -
r2522:17893d61 beta
parent child Browse files
Show More
@@ -34,6 +34,8 b' log = logging.getLogger(__name__)'
34
34
35 class ChangesetStatusModel(BaseModel):
35 class ChangesetStatusModel(BaseModel):
36
36
37 cls = ChangesetStatus
38
37 def __get_changeset_status(self, changeset_status):
39 def __get_changeset_status(self, changeset_status):
38 return self._get_instance(ChangesetStatus, changeset_status)
40 return self._get_instance(ChangesetStatus, changeset_status)
39
41
@@ -41,6 +41,8 b' log = logging.getLogger(__name__)'
41
41
42 class ChangesetCommentsModel(BaseModel):
42 class ChangesetCommentsModel(BaseModel):
43
43
44 cls = ChangesetComment
45
44 def __get_changeset_comment(self, changeset_comment):
46 def __get_changeset_comment(self, changeset_comment):
45 return self._get_instance(ChangesetComment, changeset_comment)
47 return self._get_instance(ChangesetComment, changeset_comment)
46
48
@@ -40,6 +40,8 b' log = logging.getLogger(__name__)'
40
40
41 class NotificationModel(BaseModel):
41 class NotificationModel(BaseModel):
42
42
43 cls = Notification
44
43 def __get_notification(self, notification):
45 def __get_notification(self, notification):
44 if isinstance(notification, Notification):
46 if isinstance(notification, Notification):
45 return notification
47 return notification
@@ -42,6 +42,8 b' class PermissionModel(BaseModel):'
42 Permissions model for RhodeCode
42 Permissions model for RhodeCode
43 """
43 """
44
44
45 cls = Permission
46
45 def get_permission(self, permission_id, cache=False):
47 def get_permission(self, permission_id, cache=False):
46 """
48 """
47 Get's permissions by id
49 Get's permissions by id
@@ -40,6 +40,8 b' log = logging.getLogger(__name__)'
40
40
41 class PullRequestModel(BaseModel):
41 class PullRequestModel(BaseModel):
42
42
43 cls = PullRequest
44
43 def get_all(self, repo):
45 def get_all(self, repo):
44 repo = self._get_repo(repo)
46 repo = self._get_repo(repo)
45 return PullRequest.query().filter(PullRequest.other_repo == repo).all()
47 return PullRequest.query().filter(PullRequest.other_repo == repo).all()
@@ -48,6 +48,8 b' log = logging.getLogger(__name__)'
48
48
49 class RepoModel(BaseModel):
49 class RepoModel(BaseModel):
50
50
51 cls = Repository
52
51 def __get_users_group(self, users_group):
53 def __get_users_group(self, users_group):
52 return self._get_instance(UsersGroup, users_group,
54 return self._get_instance(UsersGroup, users_group,
53 callback=UsersGroup.get_by_group_name)
55 callback=UsersGroup.get_by_group_name)
@@ -34,6 +34,8 b' log = logging.getLogger(__name__)'
34
34
35 class RepositoryPermissionModel(BaseModel):
35 class RepositoryPermissionModel(BaseModel):
36
36
37 cls = UserRepoToPerm
38
37 def get_user_permission(self, repository, user):
39 def get_user_permission(self, repository, user):
38 repository = self._get_repo(repository)
40 repository = self._get_repo(repository)
39 user = self._get_user(user)
41 user = self._get_user(user)
@@ -39,6 +39,8 b' log = logging.getLogger(__name__)'
39
39
40 class ReposGroupModel(BaseModel):
40 class ReposGroupModel(BaseModel):
41
41
42 cls = RepoGroup
43
42 def __get_users_group(self, users_group):
44 def __get_users_group(self, users_group):
43 return self._get_instance(UsersGroup, users_group,
45 return self._get_instance(UsersGroup, users_group,
44 callback=UsersGroup.get_by_group_name)
46 callback=UsersGroup.get_by_group_name)
@@ -59,6 +59,7 b' PERM_WEIGHTS = {'
59
59
60
60
61 class UserModel(BaseModel):
61 class UserModel(BaseModel):
62 cls = User
62
63
63 def get(self, user_id, cache=False):
64 def get(self, user_id, cache=False):
64 user = self.sa.query(User)
65 user = self.sa.query(User)
@@ -82,6 +83,9 b' class UserModel(BaseModel):'
82 "get_user_%s" % username))
83 "get_user_%s" % username))
83 return user.scalar()
84 return user.scalar()
84
85
86 def get_by_email(self, email, cache=False, case_insensitive=False):
87 return User.get_by_email(email, case_insensitive, cache)
88
85 def get_by_api_key(self, api_key, cache=False):
89 def get_by_api_key(self, api_key, cache=False):
86 return User.get_by_api_key(api_key, cache)
90 return User.get_by_api_key(api_key, cache)
87
91
@@ -44,6 +44,9 b' class UsersGroupModel(BaseModel):'
44 def get(self, users_group_id, cache=False):
44 def get(self, users_group_id, cache=False):
45 return UsersGroup.get(users_group_id)
45 return UsersGroup.get(users_group_id)
46
46
47 def get_group(self, users_group):
48 return self.__get_users_group(users_group)
49
47 def get_by_name(self, name, cache=False, case_insensitive=False):
50 def get_by_name(self, name, cache=False, case_insensitive=False):
48 return UsersGroup.get_by_group_name(name, cache, case_insensitive)
51 return UsersGroup.get_by_group_name(name, cache, case_insensitive)
49
52
General Comments 0
You need to be logged in to leave comments. Login now