changeset 2612:36e0756c78a6

Ticket Update working
author Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
date Tue, 27 May 2014 22:22:55 +0530
parents 4a997d9f5e26
children f0cc5ebc5192
files MoinMoin/forms.py MoinMoin/items/ticket.py
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/forms.py	Fri May 09 15:30:04 2014 -0700
+++ b/MoinMoin/forms.py	Tue May 27 22:22:55 2014 +0530
@@ -351,7 +351,15 @@
     @classmethod
     def _get_choice_specs(cls):
         revs = flaskg.storage.search(cls._query, **cls._query_args)
-        choices = [(rev.meta[ITEMID], rev.meta[NAME][0]) for rev in revs]
+        key = cls.properties['label_meta_key']
+
+        def get_label(rev):
+            label = rev.meta[key]
+            if isinstance(label, list):
+                label = label[0]
+            return label
+        
+        choices = [(rev.meta[ITEMID], get_label(rev)) for rev in revs]
         if cls.optional:
             choices.append((u'', cls.properties['empty_label']))
         return choices
--- a/MoinMoin/items/ticket.py	Fri May 09 15:30:04 2014 -0700
+++ b/MoinMoin/items/ticket.py	Tue May 27 22:22:55 2014 +0530
@@ -23,7 +23,7 @@
                             Reference, BackReference, SelectSubmit)
 from MoinMoin.storage.middleware.protecting import AccessDenied
 from MoinMoin.constants.keys import (ITEMTYPE, CONTENTTYPE, ITEMID, CURRENT,
-                                     SUPERSEDED_BY, SUBSCRIPTIONS, DEPENDS_ON)
+                                     SUPERSEDED_BY, SUBSCRIPTIONS, DEPENDS_ON, NAME)
 from MoinMoin.constants.contenttypes import CONTENTTYPE_USER
 from MoinMoin.items import Item, Contentful, register, BaseModifyForm
 from MoinMoin.items.content import NonExistentContent
@@ -35,8 +35,8 @@
 TICKET_QUERY = Term(ITEMTYPE, ITEMTYPE_TICKET)
 
 Rating = SmallNatural.using(optional=True).with_properties(lower=1, upper=5)
-OptionalTicketReference = Reference.to(TICKET_QUERY).using(optional=True)
-OptionalUserReference = Reference.to(USER_QUERY).using(optional=True).with_properties(empty_label='(Nobody)')
+OptionalTicketReference = Reference.to(TICKET_QUERY).using(optional=True).with_properties(label_meta_key=ITEMID)
+OptionalUserReference = Reference.to(USER_QUERY).using(optional=True).with_properties(empty_label='(Nobody)', label_meta_key=NAME)
 
 
 class TicketMetaForm(Form):