#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 , 15 years ago
This one makes the author parameter optional:
-
trac/ticket/model.py
# HG changeset patch # Parent 8eceeb03a8628e8dc127eaf2920cc83b616f7df6 diff -r 8eceeb03a862 trac/ticket/model.py
a b 234 234 235 235 return self.id 236 236 237 def save_changes(self, author , comment=None, when=None, db=None, cnum=''):237 def save_changes(self, author=None, comment=None, when=None, db=None, cnum=''): 238 238 """ 239 239 Store ticket changes in the database. The ticket must already exist in 240 240 the database. Returns False if there were no changes to save, True -
trac/ticket/tests/model.py
diff -r 8eceeb03a862 trac/ticket/tests/model.py
a b 135 135 self.assertEqual('', comment_change[3]) 136 136 self.assertEqual('', comment_change[4]) 137 137 138 def test_can_save_ticket_without_explicit_username(self): 139 ticket = Ticket(self.env) 140 ticket.insert() 141 ticket['summary'] = 'another summary' 142 143 ticket.save_changes() 144 145 for change in ticket.get_changelog(): 146 self.assertEqual(None, change[1]) 138 147 139 148 def test_ticket_default_values(self): 140 149 """
comment:3 by , 15 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 , 15 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 , 15 years ago
Just noticed that the patches still apply without fuzz so I guess they are ready for commit.
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 by , 15 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