Ignore:
Timestamp:
12 Mar 2013, 22:18:44 (12 years ago)
Author:
Henrik Bettermann
Message:

Show file viewlet in slip only if file exists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9987 r10020  
    222222        table_data = []
    223223        for viewlet in fm.viewlets:
    224             f_label = Paragraph(trans(viewlet.label, lang), ENTRY1_STYLE)
    225             img_path = getattr(getUtility(IExtFileStore).getFileByContext(
    226                 view.context, attr=viewlet.download_name), 'name', None)
    227             f_text = Paragraph(trans(_('(not provided)'),lang), ENTRY1_STYLE)
    228             if img_path is None:
    229                 pass
    230             elif not img_path[-4:] in ('.jpg', '.JPG'):
    231                 # reportlab requires jpg images, I think.
    232                 f_text = Paragraph('%s (not displayable)' % (
    233                     viewlet.title,), ENTRY1_STYLE)
    234             else:
    235                 f_text = Image(img_path, width=2*cm, height=1*cm, kind='bound')
    236             table_data.append([f_label, f_text])
     224            if viewlet.file_exists:
     225                # Show viewlet only if file exists
     226                f_label = Paragraph(trans(viewlet.label, lang), ENTRY1_STYLE)
     227                img_path = getattr(getUtility(IExtFileStore).getFileByContext(
     228                    view.context, attr=viewlet.download_name), 'name', None)
     229                #f_text = Paragraph(trans(_('(not provided)'),lang), ENTRY1_STYLE)
     230                if img_path is None:
     231                    pass
     232                elif not img_path[-4:] in ('.jpg', '.JPG'):
     233                    # reportlab requires jpg images, I think.
     234                    f_text = Paragraph('%s (not displayable)' % (
     235                        viewlet.title,), ENTRY1_STYLE)
     236                else:
     237                    f_text = Image(img_path, width=2*cm, height=1*cm, kind='bound')
     238                table_data.append([f_label, f_text])
    237239        if table_data:
    238240            # safety belt; empty tables lead to problems.
Note: See TracChangeset for help on using the changeset viewer.