Beispiel #1
0
 def add_watch(cls, proj_id, user_id):
     try:
         ProjectWatcher.create(project_id=proj_id,
                               user_id=user_id)
     except IntegrityError:
         return None
     repo_watch_signal.send(
         cls.get(proj_id), project_id=proj_id, author=user_id)
Beispiel #2
0
 def add_watch(cls, proj_id, user_id):
     try:
         ProjectWatcher.create(project_id=proj_id,
                               user_id=user_id)
     except IntegrityError:
         return None
     repo_watch_signal.send(
         cls.get(proj_id), project_id=proj_id, author=user_id)
Beispiel #3
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()
Beispiel #4
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()
Beispiel #5
0
 def get_watched_projects_by_user(cls, user, sortby=None):
     rs = ProjectWatcher.gets(user_id=user)
     ids = [r.project_id for r in rs]
     results = cls.gets(ids)
     if sortby:
         results.sort(key=lambda proj:
                      proj.repo.get_last_update_timestamp(), reverse=True)
     return results
Beispiel #6
0
 def get_watched_projects_by_user(cls, user, sortby=None):
     rs = ProjectWatcher.gets(user_id=user)
     ids = [r.project_id for r in rs]
     results = cls.gets(ids)
     if sortby:
         results.sort(key=lambda proj:
                      proj.repo.get_last_update_timestamp(), reverse=True)
     return results
Beispiel #7
0
 def get_watch_user_ids(cls, project_id):
     rs = ProjectWatcher.gets(project_id=project_id)
     return [r.user_id for r in rs]
Beispiel #8
0
 def has_watched(cls, proj_id, user):
     w = ProjectWatcher.get(user_id=user.name, project_id=proj_id)
     return True if w else False
Beispiel #9
0
 def del_watch(cls, proj_id, user_id):
     w = ProjectWatcher.get(user_id=user_id, project_id=proj_id)
     if w:
         w.delete()
Beispiel #10
0
 def get_watched_count(cls, proj_id):
     return ProjectWatcher.count(project_id=proj_id)
Beispiel #11
0
 def get_watch_user_ids(cls, project_id):
     rs = ProjectWatcher.gets(project_id=project_id)
     return [r.user_id for r in rs]
Beispiel #12
0
 def has_watched(cls, proj_id, user):
     w = ProjectWatcher.get(user_id=user.name, project_id=proj_id)
     return True if w else False
Beispiel #13
0
 def del_watch(cls, proj_id, user_id):
     w = ProjectWatcher.get(user_id=user_id, project_id=proj_id)
     if w:
         w.delete()
Beispiel #14
0
 def get_watched_count(cls, proj_id):
     return ProjectWatcher.count(project_id=proj_id)