#9217 closed enhancement (fixed)
Make comment optional for ticket.save_changes
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 0.12 |
Component: | ticket system | Version: | 0.12dev |
Severity: | minor | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Ticket.save_changes currently requires an explicit specification of username and comment. However both arguments are actually optional as you can pass None and everything will work as well so I propose to declare them as optional which makes it a nicer API.
Attachments (0)
Change History (7)
comment:2 by , 14 years ago
This one makes the author parameter optional:
# HG changeset patch # Parent 8eceeb03a8628e8dc127eaf2920cc83b616f7df6 diff -r 8eceeb03a862 trac/ticket/model.py --- a/trac/ticket/model.py Sun Apr 11 15:50:40 2010 +0200 +++ b/trac/ticket/model.py Sun Apr 11 15:58:12 2010 +0200 @@ -234,7 +234,7 @@ return self.id - def save_changes(self, author, comment=None, when=None, db=None, cnum=''): + def save_changes(self, author=None, comment=None, when=None, db=None, cnum=''): """ Store ticket changes in the database. The ticket must already exist in the database. Returns False if there were no changes to save, True diff -r 8eceeb03a862 trac/ticket/tests/model.py --- a/trac/ticket/tests/model.py Sun Apr 11 15:50:40 2010 +0200 +++ b/trac/ticket/tests/model.py Sun Apr 11 15:58:12 2010 +0200 @@ -135,6 +135,15 @@ self.assertEqual('', comment_change[3]) self.assertEqual('', comment_change[4]) + def test_can_save_ticket_without_explicit_username(self): + ticket = Ticket(self.env) + ticket.insert() + ticket['summary'] = 'another summary' + + ticket.save_changes() + + for change in ticket.get_changelog(): + self.assertEqual(None, change[1]) def test_ticket_default_values(self): """
comment:3 by , 14 years ago
Both changes look fine. Have you verified how a change without an author appears in the history? Listed as anonymous?
Please also consider adding directly the changeset comment in the patch, makes the lazy patch integrator happier ;-)
comment:4 by , 14 years ago
The web_ui will render them as 'anonymous' though I did not explicitely test this as the current mock request is not suitable for testing the web_ui with unit tests (will do something about that in the next time).
However I noticed that my checkout was quite old so I'll re-diff with the latest trunk.
comment:5 by , 14 years ago
Just noticed that the patches still apply without fuzz so I guess they are ready for commit.
comment:6 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 by , 14 years ago
Owner: | set to |
---|
Due to #9218 I can't attach the patch so I'll paste it in the comments for now:
This one makes the comment parameter optional:
trac/ticket/model.py
, when=None, db=None, cnum=''):trac/ticket/tests/model.py