Пример #1
0
 def search_by_name(cls, name, limit=None):
     if check_project_name(name.strip()):
         return []
     rs = store.execute("select project_id from codedouban_projects "
                        "where lower(project_name) like %s",
                        "%%%s%%" % name.lower())
     project_ids = [pid for pid, in rs]
     return [cls.get(project_id) for project_id in project_ids][:limit]
Пример #2
0
 def search_by_name(cls, name, limit=None):
     if check_project_name(name.strip()):
         return []
     rs = store.execute("select project_id from codedouban_projects "
                        "where lower(project_name) like %s",
                        "%%%s%%" % name.lower())
     project_ids = [pid for pid, in rs]
     return [cls.get(project_id) for project_id in project_ids][:limit]
Пример #3
0
 def test_check_project_name(self):
     assert check_project_name("code") == None
     assert check_project_name("hubothubot") == None
     assert check_project_name("bot" * 50) != None
     assert check_project_name("c ode") != None
     assert check_project_name("我和你") != None
     assert check_project_name("asd/code") != None
     assert check_project_name("/////") != None
Пример #4
0
 def test_check_project_name(self):
     assert check_project_name("code") == None
     assert check_project_name("hubothubot") == None
     assert check_project_name("bot" * 50) != None
     assert check_project_name("c ode") != None
     assert check_project_name("我和你") != None
     assert check_project_name("asd/code") != None
     assert check_project_name("/////") != None
Пример #5
0
 def rename(self, repo_name):
     sql = ("update codedouban_projects set project_name=%s, "
            "git_path=%s where owner_id=%s and project_id=%s")
     if check_project_name(repo_name):
         return False
     if '/' in self.name:
         project_name = "%s/%s" % (self.owner_id, repo_name)
     else:
         project_name = repo_name
     git_path = "%s.git" % project_name
     store.execute(sql, (project_name, git_path, self.owner_id, self.id))
     if self._move(git_path):
         self.git_path = git_path
         self.name = project_name
         store.commit()
     else:
         return False
Пример #6
0
 def rename(self, repo_name):
     sql = ("update codedouban_projects set project_name=%s, "
            "git_path=%s where owner_id=%s and project_id=%s")
     if check_project_name(repo_name):
         return False
     if '/' in self.name:
         project_name = "%s/%s" % (self.owner_id, repo_name)
     else:
         project_name = repo_name
     git_path = "%s.git" % project_name
     store.execute(sql, (project_name, git_path, self.owner_id, self.id))
     if self._move(git_path):
         self.git_path = git_path
         self.name = project_name
         store.commit()
     else:
         return False
Пример #7
0
 def validate(self):
     validators = [check_project_name(self.name, 'Project Name')]
     errors = [error for error in validators if error]
     return errors
Пример #8
0
 def validate(self):
     validators = [check_project_name(self.name, 'Project Name')]
     errors = [error for error in validators if error]
     return errors