From: W. Trevor King Date: Wed, 19 Nov 2008 12:57:57 +0000 (-0500) Subject: Moved bug.new_bug code into bugdir.BugDir.new_bug. X-Git-Tag: 1.0.0~144 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=35b7aaa33c1826d7b39dc8a0f32100f5c0c5788d;p=be.git Moved bug.new_bug code into bugdir.BugDir.new_bug. Also removed explicit comparisons from beweb/controllers.py, since they are now built into the Bug.__cmp__ method. --- diff --git a/Bugs-Everywhere-Web/beweb/controllers.py b/Bugs-Everywhere-Web/beweb/controllers.py index e3d555b..6773aec 100644 --- a/Bugs-Everywhere-Web/beweb/controllers.py +++ b/Bugs-Everywhere-Web/beweb/controllers.py @@ -4,9 +4,7 @@ import cherrypy import turbogears from turbogears import controllers, expose, validate, redirect, identity -from libbe.bugdir import (tree_root, cmp_severity, new_bug, new_comment, - NoRootEntry) -from libbe import names +from libbe.bugdir import tree_root, new_bug, new_comment, NoRootEntry from config import projects from prest import PrestHandler, provide_action @@ -94,10 +92,7 @@ class Bug(PrestHandler): bug_tree = project_tree(project) bugs = list(bug_tree.list()) if sort_by is None: - def cmp_date(bug1, bug2): - return -cmp(bug1.time, bug2.time) - bugs.sort(cmp_date) - bugs.sort(cmp_severity) + bugs.sort() return {"project_id" : project, "project_name" : projects[project][0], "bugs" : bugs, diff --git a/becommands/new.py b/becommands/new.py index d09d048..0f9928a 100644 --- a/becommands/new.py +++ b/becommands/new.py @@ -16,7 +16,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Create a new bug""" from libbe import cmdutil, names -from libbe.bug import new_bug __desc__ = __doc__ def execute(args): @@ -43,7 +42,7 @@ def execute(args): if len(args) != 1: raise cmdutil.UserError("Please supply a summary message") dir = cmdutil.bug_tree() - bug = new_bug(dir) + bug = dir.new_bug() bug.summary = args[0] bug.save() bugs = (dir.list()) diff --git a/libbe/bug.py b/libbe/bug.py index a14f7fd..4cb53c2 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -216,14 +216,6 @@ class Bug(object): comments.sort(cmp_time) return comments -def new_bug(dir, uuid=None): - bug = dir.new_bug(uuid) - bug.creator = bug.rcs.get_user_id() - bug.severity = "minor" - bug.status = "open" - bug.time = time.time() - return bug - def new_comment(bug, body=None): comm = bug.new_comment() comm.From = comm.rcs.get_user_id() diff --git a/libbe/bugdir.py b/libbe/bugdir.py index cf8cba5..41f0fec 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -195,6 +195,10 @@ class BugDir: self.rcs.mkdir(path) bug = Bug(self.bugs_path, None, self.rcs, self) bug.uuid = uuid + bug.creator = self.rcs.get_user_id() + bug.severity = "minor" + bug.status = "open" + bug.time = time.time() return bug class InvalidValue(ValueError):