Add new modules, delete old testing modules.

portnov [2008-06-18 10:22:46]
Add new modules, delete old testing modules.
Filename
.gitignore
hooks.py
modules/about.py
modules/bug_chart.py
modules/last_comments.py
modules/test1.py
modules/test2.py
modules/testblock.py
diff --git a/.gitignore b/.gitignore
index 4e72520..0d20b64 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1 @@
-.*.swp
-*.swp
 *.pyc
diff --git a/hooks.py b/hooks.py
index f991423..d4bd142 100755
--- a/hooks.py
+++ b/hooks.py
@@ -36,6 +36,7 @@ def hook(func):
     else:
       return func(*r)
   wrapper.__name__ = name
+  wrapper.__doc__ = func.__doc__
   return wrapper


diff --git a/modules/about.py b/modules/about.py
new file mode 100644
index 0000000..8a0b066
--- /dev/null
+++ b/modules/about.py
@@ -0,0 +1,14 @@
+
+weight = 1
+
+def init():
+
+  from django.http import HttpResponse
+
+  @intercept('map_url')
+  def about_page(request):
+    if isinstance(request,HttpResponse):
+      return request
+    if request.path == '/about/':
+      return HttpResponse("<h1>This page is about Projects system.</h1>")
+    return request
diff --git a/modules/bug_chart.py b/modules/bug_chart.py
index 1867947..3b245f4 100755
--- a/modules/bug_chart.py
+++ b/modules/bug_chart.py
@@ -16,7 +16,6 @@ def init():
             (1,1,0.75),
             (0.75,1,0.75),
             (0.75,0.75,0.75)]
-#   labels = ["U","P","W","F","N/A"]
   width,height = 200,300

   def piechart(data,outfile):
@@ -25,11 +24,11 @@ def init():
     centerx,centery = width/2, width/2
     radius = 0.9*min(width,height)/2
     s = sum(data)
+    if s == 0:
+      surf.write_to_png(outfile)
+      return
     n = len(data)
     current_angle = 0
-    cx.set_source_rgb(255,255,255)
-    cx.rectangle(0,0,width,height)
-    cx.fill()
     i=0
     cx.select_font_face("DejaVu Sans", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
     cx.set_font_size(12)
diff --git a/modules/last_comments.py b/modules/last_comments.py
index 702286c..a5e1bdc 100644
--- a/modules/last_comments.py
+++ b/modules/last_comments.py
@@ -3,20 +3,12 @@
 def init():

   from mgmt.models import Comment
+  import mgmt.utils

   @block
   def last_comments():
     def short_comment(comment):
-      def get_url(comment):
-        type = comment.object_type
-        id = comment.object_id
-        if type=='Project':
-          return "/projects/%s/#comment-%s" % (id,comment.id)
-        if type=='Bug':
-          return "/bugs/%s/#comment-%s" % (id,comment.id)
-        if type=='Document':
-          return "/docs/%d/#comment-%s" % (id,comment.id)
-      return "<li><a href='%s'>%s</a></li>" % (get_url(comment),comment.title)
+      return u"<li><a href='%s'>%s</a></li>" % (mgmt.utils.get_comment_url(comment),comment.title)
     b = Block()
     b.name='last_comments'
     b.title = u"Последние комментарии"
diff --git a/modules/test1.py b/modules/test1.py
deleted file mode 100644
index dccef22..0000000
--- a/modules/test1.py
+++ /dev/null
@@ -1,15 +0,0 @@
-
-def init():
-  print "Module <Test> imported."
-
-  @intercept('do_something')
-  def func(s):
-    print "Intercepted."
-    return s
-
-  @hook
-  def my_hook():
-    print "Some event."
-
-
-  my_hook()
diff --git a/modules/test2.py b/modules/test2.py
deleted file mode 100644
index f5d3524..0000000
--- a/modules/test2.py
+++ /dev/null
@@ -1,7 +0,0 @@
-
-def init():
-  print "Test 2 loaded"
-
-  @intercept('my_hook')
-  def on_hook():
-    print "<myhook> intercepted."
diff --git a/modules/testblock.py b/modules/testblock.py
deleted file mode 100644
index be49e4f..0000000
--- a/modules/testblock.py
+++ /dev/null
@@ -1,10 +0,0 @@
-
-def init():
-
-  @block
-  def testblk():
-    b = Block()
-    b.name = "testblk"
-    b.title = "Test block"
-    b.content = "Content of test block."
-    return b
ViewGit