def get_teamMember_by_teamUserId_userId(self, team_user_id, user_id): # for team user global permission if team_user_id == 0: teamMember = query_first(TeamMember, team_user_id, 'teammember_s_teamUserId_userId', [team_user_id, user_id]) return teamMember team_userprofile = GsuserManager.get_userprofile_by_id(team_user_id) if team_userprofile and team_userprofile.is_team_account == 0: return None teamMember = query_first(TeamMember, team_user_id, 'teammember_s_teamUserId_userId', [team_user_id, user_id]) if not teamMember: return None teamMember.user = GsuserManager.get_userprofile_by_id(user_id) teamMember.team_user = team_userprofile return teamMember
def get_notifmessage_by_userId_notifType_relativeId( self, user_id, notif_type, relative_id): notifMessage = query_first( NotifMessage, user_id, 'notifmessage_s_toUserId_notifType_relativeId', [user_id, notif_type, relative_id]) return notifMessage
def get_branchPermission_by_repoId_refname(self, repo_id, refname): branchPermission = query_first(BranchPermission, repo_id, 'branchpermission_s_repoId_refname', [repo_id, refname]) if not branchPermission: return None user_permission_set = self.list_permissionItem_by_setId(branchPermission.user_permission_set_id, repo_id) group_permission_set = self.list_permissionItem_by_setId(branchPermission.group_permission_set_id, repo_id) branchPermission.user_permission_set = user_permission_set branchPermission.group_permission_set = group_permission_set return branchPermission
def get_repoPermission_by_repoId(self, repo_id): repoPermission = query_first(RepoPermission, repo_id, 'repopermission_s_repoId', [repo_id]) if not repoPermission: return None user_permission_set = self.list_permissionItem_by_setId(repoPermission.user_permission_set_id, repo_id) group_permission_set = self.list_permissionItem_by_setId(repoPermission.group_permission_set_id, repo_id) repoPermission.user_permission_set = user_permission_set repoPermission.group_permission_set = group_permission_set return repoPermission
def get_permissionItem_by_setId_userId(self, set_id, user_id): if set_id == 0: return None permissionItem = query_first(PermissionItem, set_id, 'permissionitem_s_setId_userId', [set_id, user_id]) if not permissionItem: return None permissionItem.userprofile = GsuserManager.get_userprofile_by_id(permissionItem.user_id) if permissionItem.permission in PERMISSION.VIEW: permissionItem.permission_view = PERMISSION.VIEW[permissionItem.permission] return permissionItem
def get_permissionItem_by_setId_groupId(self, set_id, group_id): if set_id == 0: return None permissionItem = query_first(PermissionItem, set_id, 'permissionitem_s_setId_groupId', [set_id, group_id]) if not permissionItem: return None permissionItem.group = self.get_teamGroup_by_id(group_id) if permissionItem.permission in PERMISSION.VIEW: permissionItem.permission_view = PERMISSION.VIEW[permissionItem.permission] return permissionItem
def unstar_repo(self, user_id, repo_id): repo = RepoManager.get_repo_by_id(repo_id) if repo is None: return False star = query_first(Star, user_id, 'star_s_repo', [user_id, repo_id]) if star is not None: star.visibly = 1 star.save() repo.star = repo.star - 1 if repo.star < 0: repo.star = 0 repo.save() return True
def star_repo(self, user_id, repo_id): repo = RepoManager.get_repo_by_id(repo_id) if repo is None: return False star = query_first(Star, user_id, 'star_s_repo', [user_id, repo_id]) if star is None: star = Star() star.user_id = user_id star.star_user_id = 0 star.star_repo_id = repo_id star.save() repo.star = repo.star + 1 repo.save() return True
def get_notifsetting_by_userId(self, user_id): notifSetting = query_first(NotifSetting, user_id, 'notifsetting_s_userId', [user_id]) if not notifSetting: userprofile = GsuserManager.get_userprofile_by_id(user_id) if not userprofile: return None notifSetting = NotifSetting( user_id = user_id, notif_types = 'all', notif_fqcy = 0, email = userprofile.email, ) notifSetting.save() return notifSetting
def get_notifsetting_by_userId(self, user_id): notifSetting = query_first(NotifSetting, user_id, 'notifsetting_s_userId', [user_id]) if not notifSetting: userprofile = GsuserManager.get_userprofile_by_id(user_id) if not userprofile: return None notifSetting = NotifSetting( user_id=user_id, notif_types='all', notif_fqcy=0, email=userprofile.email, ) notifSetting.save() return notifSetting
def is_stared_repo(self, user_id, repo_id): repo = RepoManager.get_repo_by_id(repo_id) if repo is None: return False star = query_first(Star, user_id, 'star_s_repo', [user_id, repo_id]) return star is not None
def get_childrepo_by_user_forkrepo(self, user, repo): child_repo = query_first(Repo, None, 'repo_s_userId_forkrepoId', [user.id, repo.id]) return child_repo
def get_groupMember_by_teamGroupId_memberUserId(self, group_id, member_user_id): groupMember = query_first(GroupMember, group_id, 'groupmember_s_groupId_memberUserId', [group_id, member_user_id]) if not groupMember: return None groupMember.member_userprofile = GsuserManager.get_userprofile_by_id(groupMember.member_user_id) return groupMember
def get_notifmessage_by_userId_notifType_relativeId(self, user_id, notif_type, relative_id): notifMessage = query_first(NotifMessage, user_id, 'notifmessage_s_toUserId_notifType_relativeId', [user_id, notif_type, relative_id]) return notifMessage
def get_teamGroup_by_teamUserId_name(self, team_user_id, name): teamGroup = query_first(TeamGroup, team_user_id, 'teamgroup_s_teamUserId_name', [team_user_id, name]) return teamGroup
def get_issue(self, repo_id, id): issue = query_first(Issue, repo_id, 'issue_s_id', [repo_id, id]) issue.fillwith() return issue