diff --git a/mgmt/models.py b/mgmt/models.py index 6048b63..dd3a604 100644 --- a/mgmt/models.py +++ b/mgmt/models.py @@ -20,7 +20,7 @@ class Object(models.Model): return self.name class Project(Object): - repo = models.CharField(_("Repository"),max_length=64) + repo = models.CharField(_("Repository"),null=True,max_length=64) git_link = models.CharField(_("Link to Git repo"), max_length=32,null=True) admins = models.ManyToManyField(User,related_name='admin_projects',verbose_name=_("Admins")) team = models.ManyToManyField(User,related_name='in_projects',verbose_name=_("Team")) diff --git a/pygit/chart.py b/pygit/chart.py index 9056317..51bf01d 100644 --- a/pygit/chart.py +++ b/pygit/chart.py @@ -58,7 +58,11 @@ class Chart(object): def draw(self,lst,color=(0.9,0.2,0.2),place=0): pc = self.places[place] - pc.set_scale(len(lst)-1,max(lst)) + if lst: + M=max(lst) + else: + M=1 + pc.set_scale(len(lst)-1,M) pc.cx.new_path() pc.cx.set_source_rgb(*color) pc.move_to(0,lst[0]) diff --git a/pygit/pygit.py b/pygit/pygit.py index f13d44f..6b724d9 100644 --- a/pygit/pygit.py +++ b/pygit/pygit.py @@ -137,6 +137,8 @@ def group_by_date(lst): dt = time.localtime(time.mktime(tp)-time.altzone) return time.strftime("%d.%m", dt) d = [(c.authored_date, c) for c in lst] + if not d: + return [] d.sort() d = [(date(e[0]),e[1]) for e in d] prev = d[0][0] diff --git a/pygit/views.py b/pygit/views.py index 4cad285..6e88fa5 100644 --- a/pygit/views.py +++ b/pygit/views.py @@ -47,17 +47,21 @@ def one_repo(request,rid,branch='master'): cid = cs[0][0] dirs,files = pygit.root_tree(rid,branch) dates,n_commits,files_s,lines,inss,dels = cached_stats(rid,branch,cid) - print dates - - cht = Chart(900,200,n=2) - cht.set_scale(1,len(inss)-1,max(max(inss),max(dels))) - cht.draw(n_commits,place=0,color=(0.9,0.9,0.2)) - cht.draw(files_s,place=0,color=(0.3,0.3,0.3)) - cht.draw(inss,place=1,color=(0.2,0.2,0.9)) - cht.draw(dels,place=1,color=(0.9,0.2,0.2)) -# cht.draw(lines,place=1,color=(0.2,0.9,0.2)) - cht.labels(dates) - chart = cht.finish(cid) + + if inss: + cht = Chart(900,200,n=2) + mi = max(inss) + md = max(dels) + cht.set_scale(1,len(inss)-1,max(mi,md)) + cht.draw(n_commits,place=0,color=(0.9,0.9,0.2)) + cht.draw(files_s,place=0,color=(0.3,0.3,0.3)) + cht.draw(inss,place=1,color=(0.2,0.2,0.9)) + cht.draw(dels,place=1,color=(0.9,0.2,0.2)) + # cht.draw(lines,place=1,color=(0.2,0.9,0.2)) + cht.labels(dates) + chart = cht.finish(cid) + else: + chart = '' return render_it('repo.html', {'description': dsc,