Changeset 2668 in products for quintagroup.gdocs.spreadsheet/trunk
- Timestamp:
- Jul 13, 2010 6:49:11 PM (14 years ago)
- Location:
- quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet/browser/viewworksheetview.py
r2667 r2668 52 52 """ 53 53 """ 54 table = '' 54 55 feed = self.getFeed(ssh_id, wsh_id, startrow_idx) 55 56 if isinstance(feed, SpreadsheetsListFeed): 56 indx_keys = filter(None, [elem['select_title'] for elem in self.context.title_column]) 57 titles_columns = filter(None, [self.context.order_columns[int(i)] for i in indx_keys]) 58 59 # Prepare table 60 table = "<table id=\"sshwsh\">" 61 table += "<tr>" 62 table += ''.join(["<th>%s</th>" % key for key in titles_columns]) 63 table += "</tr>" 64 for i, entry in enumerate(feed.entry): 65 if i+1 > startrow_idx: 66 td_row = "<tr>" 67 for key in titles_columns: 68 td_row += "<td>%s</td>" \ 69 % (not (entry.custom[key].text == 'None') and entry.custom[key].text or '') 70 td_row += "</tr>\n" 71 table += td_row 72 table += "</table>" 73 else: 74 table = '' 57 # akc is a list of keys of all columns. The context is GSpreadsheet content type 58 akc = self.context.all_keys_columns 59 # key_title_columns is list of tuples with two elements (column_key, column_title or column_key) 60 key_title_columns = [(e['column_key'], e['column_title'] or e['column_key']) 61 for e in self.context.order_columns if e['column_key'] in akc] 62 if key_title_columns: 63 # Prepare table 64 table = "<table id=\"sshwsh\">" 65 table += "<tr>" 66 table += ''.join(["<th>%s</th>" % el[1] for el in key_title_columns]) 67 table += "</tr>" 68 for i, entry in enumerate(feed.entry): 69 if i >= startrow_idx: 70 td_row = "<tr>" 71 for key in zip(*key_title_columns)[0]: 72 td_row += "<td>%s</td>" \ 73 % (not (entry.custom[key].text == 'None') and entry.custom[key].text or '') 74 td_row += "</tr>\n" 75 table += td_row 76 table += "</table>" 75 77 return table 76 78 … … 84 86 try: 85 87 feed = self.sh_client.GetListFeed(ssh_id, wksht_id=wsh_id, query=self.query) 86 self.context. order_columns = len(feed.entry) and feed.entry[0].custom.keys() or []88 self.context.all_keys_columns = len(feed.entry) and feed.entry[0].custom.keys() or [] 87 89 except Exception: 88 90 logException('GetListFeed function call: ' -
quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet/content/gspreadsheet.py
r2667 r2668 10 10 from Products.DataGridField import DataGridField, DataGridWidget 11 11 from Products.DataGridField.SelectColumn import SelectColumn 12 from Products.DataGridField.Column import Column 12 13 13 14 from quintagroup.gdocs.spreadsheet import spreadsheetMessageFactory as _ … … 52 53 53 54 DataGridField( 54 name=' title_column',55 name='order_columns', 55 56 searchable = True, 56 57 languageIndependent=True, 57 58 storage=atapi.AnnotationStorage(), 58 columns=(" select_title",),59 columns=("column_key", "column_title"), 59 60 widget = DataGridWidget( 60 61 label = _( 61 u'label_ title_column',62 default=u' Titles ofcolumns'),62 u'label_order_column', 63 default=u'Ordering columns'), 63 64 description=_( 64 u'help_ title_column',65 default=u"Choose titles of columns"),65 u'help_order_column', 66 default=u"Choose keys of columns and enter them titles"), 66 67 columns={ 67 'select_title' : SelectColumn("Titles of columns", vocabulary="getTitleColumnVocabulary"), 68 'column_key' : SelectColumn("Key of column", vocabulary="getKeyColumnVocabulary"), 69 'column_title' : Column("Title of column"), 68 70 }, 69 71 ), … … 83 85 84 86 class GSpreadsheet(base.ATCTContent): 85 """ Lets you select google spreadsheet worksheet id and choose title of columns"""87 """ Lets you select google spreadsheet id, worksheet id, choose keys of columns and define them title """ 86 88 implements(IGSpreadsheet) 87 89 … … 89 91 schema = GSpreadsheetSchema 90 92 91 order_columns = []93 all_keys_columns = [] 92 94 title = atapi.ATFieldProperty('title') 93 95 description = atapi.ATFieldProperty('description') 94 96 spreadsheet_id = atapi.ATFieldProperty('spreadsheet_id') 95 97 worksheet_id = atapi.ATFieldProperty('worksheet_id') 96 title_column = atapi.ATFieldProperty('title_column')98 order_columns = atapi.ATFieldProperty('order_columns') 97 99 98 100 # -*- Your ATSchema to Python Property Bridges Here ... -*- 99 101 100 def get TitleColumnVocabulary(self):101 """ Get a list of titles of columns """102 def getKeyColumnVocabulary(self): 103 """ Get a list of keys of columns """ 102 104 return atapi.DisplayList( 103 ([( '%s'%i, t) for i,t in enumerate(self.order_columns)])105 ([(t, t) for t in self.all_keys_columns]) 104 106 ) 105 107
Note: See TracChangeset
for help on using the changeset viewer.