Example #1
0
 def add_project(self, project):
     r = TeamProjectRelationship.get(team_id=self.id,
                                     project_id=project.id)
     if not r:
         TeamProjectRelationship.create(team_id=self.id,
                                        project_id=project.id)
         return True
Example #2
0
 def test_add_and_delete_team_project_relationship(self):
     team_id = 2222
     project_id = 33333
     rl = TeamProjectRelationship.create(team_id=team_id,
                                         project_id=project_id)
     relationship = TeamProjectRelationship.get(team_id=team_id,
                                                project_id=project_id)
     ok_(rl.id == relationship.id)
     rl.delete()
Example #3
0
 def test_add_and_delete_team_project_relationship(self):
     team_id = 2222
     project_id = 33333
     rl = TeamProjectRelationship.create(team_id=team_id,
                                         project_id=project_id)
     relationship = TeamProjectRelationship.get(team_id=team_id,
                                                project_id=project_id)
     ok_(rl.id == relationship.id)
     rl.delete()
Example #4
0
    def test_delete_team_project_relationship_by_project_id(self):
        team_id = 2222
        project_id = 2222
        rl = TeamProjectRelationship.create(team_id=team_id,
                                            project_id=project_id)
        relationship = TeamProjectRelationship.get(team_id=team_id,
                                                   project_id=project_id)
        ok_(rl.id == relationship.id)

        TeamProjectRelationship.deletes(project_id=project_id)
        relationship = TeamProjectRelationship.get(team_id=team_id,
                                                   project_id=project_id)
        ok_(relationship is None)
Example #5
0
    def test_delete_team_project_relationship_by_project_id(self):
        team_id = 2222
        project_id = 2222
        rl = TeamProjectRelationship.create(team_id=team_id,
                                            project_id=project_id)
        relationship = TeamProjectRelationship.get(team_id=team_id,
                                                   project_id=project_id)
        ok_(rl.id == relationship.id)

        TeamProjectRelationship.deletes(project_id=project_id)
        relationship = TeamProjectRelationship.get(team_id=team_id,
                                                   project_id=project_id)
        ok_(relationship is None)
Example #6
0
    def delete(self):
        from vilya.models.nteam import TeamProjectRelationship
        shutil.rmtree(self.git_real_path, ignore_errors=True)
        for hook in self.hooks:
            hook.destroy()
        ProjectWatcher.deletes(project_id=self.id)
        store.execute("delete from codedouban_projects "
                      "where project_id=%s", (self.id,))
        store.commit()
        self.clear_mc(self.id)

        CodeDoubanProject._flush_project_ids_by_owner(self.owner_id)
        rs = TeamProjectRelationship.gets(project_id=self.id)
        for r in rs:
            r.delete()
Example #7
0
    def delete(self):
        from vilya.models.nteam import TeamProjectRelationship
        shutil.rmtree(self.git_real_path, ignore_errors=True)
        for hook in self.hooks:
            hook.destroy()
        ProjectWatcher.deletes(project_id=self.id)
        store.execute("delete from codedouban_projects "
                      "where project_id=%s", (self.id,))
        store.commit()
        self.clear_mc(self.id)

        CodeDoubanProject._flush_project_ids_by_owner(self.owner_id)
        rs = TeamProjectRelationship.gets(project_id=self.id)
        for r in rs:
            r.delete()
Example #8
0
 def delete(self):
     TeamProjectRelationship.deletes(team_id=self.id)
     TeamUserRelationship.deletes(team_id=self.id)
     del self.profile
     store.execute("delete from team where team_id=%s", (self.uid,))
     store.commit()
Example #9
0
 def remove_project(self, project):
     r = TeamProjectRelationship.get(team_id=self.id,
                                     project_id=project.id)
     if r:
         r.delete()
         return True
Example #10
0
 def gets_by_project_id(cls, project_id):
     return [cls.get(tpr.team_id)
             for tpr in TeamProjectRelationship.gets(project_id=project_id)]
Example #11
0
 def project_ids(self):
     rs = TeamProjectRelationship.gets(team_id=self.id)
     return [r.project_id for r in rs]
Example #12
0
 def is_project(self, project_id):
     r = TeamProjectRelationship.get(team_id=self.id, project_id=project_id)
     return True if r else False
Example #13
0
 def n_projects(self):
     return TeamProjectRelationship.count(team_id=self.id)