[CalendarServer-changes] [12692] CalendarServer/trunk/calendarserver/webadmin

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:19:58 PDT 2014


Revision: 12692
          http://trac.calendarserver.org//changeset/12692
Author:   wsanchez at apple.com
Date:     2014-02-13 18:12:08 -0800 (Thu, 13 Feb 2014)
Log Message:
-----------
Rework slots logic a bit

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/webadmin/principals.py
    CalendarServer/trunk/calendarserver/webadmin/principals.xhtml

Modified: CalendarServer/trunk/calendarserver/webadmin/principals.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/principals.py	2014-02-14 01:40:49 UTC (rev 12691)
+++ CalendarServer/trunk/calendarserver/webadmin/principals.py	2014-02-14 02:12:08 UTC (rev 12692)
@@ -26,7 +26,7 @@
 ]
 
 from twisted.internet.defer import inlineCallbacks, returnValue
-from twisted.web.template import tags, renderer
+from twisted.web.template import tags as html, renderer
 
 from .resource import PageElement, TemplateResource
 
@@ -150,7 +150,7 @@
 
             for value in values:
                 if not noValues:
-                    yield tags.br()
+                    yield html.br()
 
                 yield one(value)
 
@@ -212,45 +212,102 @@
     return request._search_terms
 
 
-
+#
+# This should work when we switch to twext.who
+#
 def slotsForRecord(record):
-    def one(value):
-        if value is None:
+    def asText(obj):
+        if obj is None:
             return u"(no value)"
         else:
             try:
-                return unicode(value)
+                return unicode(obj)
             except UnicodeDecodeError:
                 try:
-                    return unicode(repr(value))
+                    return unicode(repr(obj))
                 except UnicodeDecodeError:
                     return u"(error rendering value)"
 
-    def many(values):
+    def joinWithBR(elements):
         noValues = True
 
-        for value in values:
+        for element in elements:
             if not noValues:
-                yield tags.br()
+                yield html.br()
 
-            yield one(value)
+            yield asText(element)
 
             noValues = False
 
         if noValues:
             yield u"(no values)"
 
+
+    # slots = {}
+
+    # for field, values in record.fields.iteritems():
+    #     if not record.service.fieldName.isMultiValue(field):
+    #         values = (values,)
+
+    #     slots[field.name] = joinWithBR(asText(value) for value in values)
+
+    # return slots
+
     return {
         u"service": (
             u"{record.service.__class__.__name__}: {record.service.realmName}"
             .format(record=record)
         ),
-        u"uid": one(record.uid),
-        u"guid": one(record.guid),
-        u"record_type": one(record.recordType),
-        u"short_names": many(record.shortNames),
-        u"full_names": one(record.fullName),
-        u"email_addresses": many(record.emailAddresses),
-        u"calendar_user_addresses": many(record.calendarUserAddresses),
-        u"server_id": one(record.serverID),
+        u"uid": joinWithBR((record.uid,)),
+        u"guid": joinWithBR((record.guid,)),
+        u"recordType": joinWithBR((record.recordType,)),
+        u"shortNames": joinWithBR(record.shortNames),
+        u"fullNames": joinWithBR((record.fullName,)),
+        u"emailAddresses": joinWithBR(record.emailAddresses),
+        u"calendarUserAddresses": joinWithBR(record.calendarUserAddresses),
+        u"serverID": joinWithBR((record.serverID,)),
     }
+
+
+
+# def slotsForRecord(record):
+#     def one(value):
+#         if value is None:
+#             return u"(no value)"
+#         else:
+#             try:
+#                 return unicode(value)
+#             except UnicodeDecodeError:
+#                 try:
+#                     return unicode(repr(value))
+#                 except UnicodeDecodeError:
+#                     return u"(error rendering value)"
+
+#     def many(values):
+#         noValues = True
+
+#         for value in values:
+#             if not noValues:
+#                 yield html.br()
+
+#             yield one(value)
+
+#             noValues = False
+
+#         if noValues:
+#             yield u"(no values)"
+
+#     return {
+#         u"service": (
+#             u"{record.service.__class__.__name__}: {record.service.realmName}"
+#             .format(record=record)
+#         ),
+#         u"uid": one(record.uid),
+#         u"guid": one(record.guid),
+#         u"record_type": one(record.recordType),
+#         u"short_names": many(record.shortNames),
+#         u"full_names": one(record.fullName),
+#         u"email_addresses": many(record.emailAddresses),
+#         u"calendar_user_addresses": many(record.calendarUserAddresses),
+#         u"server_id": one(record.serverID),
+#     }

Modified: CalendarServer/trunk/calendarserver/webadmin/principals.xhtml
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/principals.xhtml	2014-02-14 01:40:49 UTC (rev 12691)
+++ CalendarServer/trunk/calendarserver/webadmin/principals.xhtml	2014-02-14 02:12:08 UTC (rev 12692)
@@ -25,7 +25,6 @@
       <thead>
         <tr class="record">
           <th class="record_full_name">Full name</th>
-          <th class="record_uid">UID</th>
           <th class="record_type">Record Type</th>
           <th class="record_short_name">Short Name</th>
           <th class="record_email">Email Address</th>
@@ -33,11 +32,10 @@
       </thead>
       <tbody>
         <tr class="record" t:render="search_results_row"><t:attr name="onclick">window.open("./<t:slot name="uid" />");</t:attr>
-          <td class="record_full_name"><t:slot name="full_names" /></td>
-          <td class="record_uid"><t:slot name="uid" /></td>
-          <td class="record_type"><t:slot name="record_type" /></td>
-          <td class="record_short_name"><t:slot name="short_names" /></td>
-          <td class="record_email"><t:slot name="email_addresses" /></td>
+          <td class="record_full_name"><t:slot name="fullNames" /></td>
+          <td class="record_type"><t:slot name="recordType" /></td>
+          <td class="record_short_name"><t:slot name="shortNames" /></td>
+          <td class="record_email"><t:slot name="emailAddresses" /></td>
         </tr>
       </tbody>
     </table>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/ee4e76f3/attachment.html>


More information about the calendarserver-changes mailing list