Commits

Tetsuya Morimoto committed e336eef

changed to be able to use whitespace as separator
fixed to handle when non integer value is given

Comments (0)

Files changed (5)

     def validate_ticket(self, req, ticket):
         if self.has_ticket_refs(ticket):
             _prop = ("ticket-custom", "ticketref.label")
-            for _id in ticket[TICKETREF].split(","):
-                ref_id = int(_id.strip())
+            for _id in ticket[TICKETREF].replace(",", " ").split():
                 try:
+                    ref_id = int(_id)
                     assert ref_id != ticket.id
                     Ticket(self.env, ref_id)
+                except ValueError:
+                    msg = _("Input only numbers for ticket ID: %s") % _id
+                    yield self.env.config.get(*_prop), msg
                 except AssertionError:
-                    msg = _("Ticket %s is this ticket id, remove it.") % ref_id
+                    msg = _("Ticket %s is this ticket ID, remove it.") % ref_id
                     yield self.env.config.get(*_prop), msg
                 except Exception, err:
                     yield self.env.config.get(*_prop), err

ticketref/locale/ja/LC_MESSAGES/ticketref.mo

Binary file modified.

ticketref/locale/ja/LC_MESSAGES/ticketref.po

 "Project-Id-Version: TracTicketReferencePlugin 0.1.0\n"
 "Report-Msgid-Bugs-To: http://trac-"
 "hacks.org/wiki/TracTicketReferencePlugin\n"
-"POT-Creation-Date: 2012-01-19 17:55+0900\n"
+"POT-Creation-Date: 2012-01-22 15:09+0900\n"
 "PO-Revision-Date: 2012-01-17 16:07+0900\n"
 "Last-Translator: Tetsuya Morimoto\n"
 "Language-Team: ja <LL@li.org>\n"
 "Generated-By: Babel 0.9.6\n"
 
 #: ticketref/api.py:99
-#, python-format
-msgid "Ticket %s is this ticket id, remove it."
+msgid "Input only numbers for ticket ID: %s"
+msgstr "チケット ID には数字のみを入力してください: %s"
+
+#: ticketref/api.py:102
+msgid "Ticket %s is this ticket ID, remove it."
 msgstr "チケット %s はこのチケットなので削除してください。"
 
-#: ticketref/web_ui.py:59 ticketref/web_ui.py:71 ticketref/web_ui.py:74
-#: ticketref/web_ui.py:84
+#: ticketref/web_ui.py:59 ticketref/web_ui.py:72 ticketref/web_ui.py:75
+#: ticketref/web_ui.py:85
 msgid "Relationships"
 msgstr "関連"
 
-#: ticketref/web_ui.py:120
+#: ticketref/web_ui.py:132
 msgid "Open new ticket with relationships"
 msgstr "このチケットに関連付けて新しいチケットを登録する"
 
-#: ticketref/web_ui.py:122
+#: ticketref/web_ui.py:134
 msgid "New"
 msgstr "登録"
 

ticketref/locale/messages.pot

 #, fuzzy
 msgid ""
 msgstr ""
-"Project-Id-Version: TracTicketReferencePlugin 0.1.0\n"
+"Project-Id-Version: TracTicketReferencePlugin 0.2.0\n"
 "Report-Msgid-Bugs-To: http://trac-"
 "hacks.org/wiki/TracTicketReferencePlugin\n"
-"POT-Creation-Date: 2012-01-19 17:55+0900\n"
+"POT-Creation-Date: 2012-01-22 15:09+0900\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 
 #: ticketref/api.py:99
 #, python-format
-msgid "Ticket %s is this ticket id, remove it."
+msgid "Input only numbers for ticket ID: %s"
 msgstr ""
 
-#: ticketref/web_ui.py:59 ticketref/web_ui.py:71 ticketref/web_ui.py:74
-#: ticketref/web_ui.py:84
+#: ticketref/api.py:102
+#, python-format
+msgid "Ticket %s is this ticket ID, remove it."
+msgstr ""
+
+#: ticketref/web_ui.py:59 ticketref/web_ui.py:72 ticketref/web_ui.py:75
+#: ticketref/web_ui.py:85
 msgid "Relationships"
 msgstr ""
 
-#: ticketref/web_ui.py:120
+#: ticketref/web_ui.py:132
 msgid "Open new ticket with relationships"
 msgstr ""
 
-#: ticketref/web_ui.py:122
+#: ticketref/web_ui.py:134
 msgid "New"
 msgstr ""
 

ticketref/utils.py

     set([1, 3, 5])
     >>> cnv_text2list(",  1,3,")
     set([1, 3])
+    >>> cnv_text2list("1 3")
+    set([1, 3])
+    >>> cnv_text2list("  1 3    5")
+    set([1, 3, 5])
+    >>> cnv_text2list(",  1 3 ")
+    set([1, 3])
+    >>> cnv_text2list("#1 3")
+    set([])
+    >>> cnv_text2list("1 a")
+    set([])
     """
     refs = set([])
     if refs_text:
-        refs_text = refs_text.strip(" ,")
-    if refs_text:
-        refs = set([int(id_.strip()) for id_ in refs_text.split(",")])
+        refs_seq = refs_text.replace(",", " ").split()
+        try:
+            refs = set([int(id_) for id_ in refs_seq])
+        except ValueError:
+            pass
     return refs
 
 def cnv_list2text(refs):