Пример #1
0
 def tmpl_display_bibdocfile(self, bibdocfile, ln=CFG_SITE_LANG):
     """Returns a formatted representation of this docfile."""
     return self.tmpl_bibdocfile_filelist(
         ln=ln,
         recid=bibdocfile.get_recid(),
         version=bibdocfile.version,
         md=bibdocfile.md,
         name=bibdocfile.name,
         superformat=bibdocfile.get_superformat(),
         subformat=bibdocfile.subformat,
         nice_size_f=nice_size(bibdocfile.get_size()),
         description=bibdocfile.description or '')
Пример #2
0
 def tmpl_display_bibdocfile(self, bibdocfile, ln = CFG_SITE_LANG):
     """Returns a formatted representation of this docfile."""
     return self.tmpl_bibdocfile_filelist(
              ln = ln,
              recid = bibdocfile.get_recid(),
              version = bibdocfile.version,
              md = bibdocfile.md,
              name = bibdocfile.name,
              superformat = bibdocfile.get_superformat(),
              subformat = bibdocfile.subformat,
              nice_size_f = nice_size(bibdocfile.get_size()),
              description = bibdocfile.description or ''
            )
Пример #3
0
def format_element(bfo):
    """
    Prints buttons to download all photos for each size
    """
    current_bibrecdoc = BibRecDocs(bfo.recID)
    if len(current_bibrecdoc.bibdocs) < 2:
        # If we have less than 2 photos, there is no point in displaying the
        # "Download all" buttons
        return
    wrapper = '''<style>
                #downloadallphotos {
                    clear: both;
                    font-size: small;
                    color: #555444;
                    margin-left: 10px;
                }
                #downloadallphotos a {
                    border-radius: 5px;
                    box-shadow: 1px 1px 1px 1px #CCCCCC;
                    color: #222222;
                    display: inline-block;
                    margin: 2px 5px;
                    padding: 3px;
                    text-decoration: none;
                    background-color: #E6E6FA;
                }
                #downloadallphotos a:hover {
                    background: -moz-linear-gradient(center top , #3A3A3A 0%, #7D7E7D 100%) repeat scroll 0 0 rgba(0, 0, 0, 0);
                    color: #fff;
                }
                </style>'''
    wrapper += '''<div id="downloadallphotos">Download all pictures:'''
    buttons = ''
    for (size, internal_size) in CFG_BIBDOCFILE_SUBFORMATS_TRANSLATIONS:
        total = current_bibrecdoc.get_total_size_latest_version(
            bfo.user_info, internal_size)
        # don't display the button if the size will be 0
        if total:
            buttons += '<a %(original)s href="%(site)s/record/%(recID)s/files/allfiles-%(size)s">%(size)s (%(total)s)</a>' \
                % {'original': size == 'original' and 'data-size="Original"' or '',
                   'site': CFG_SITE_URL,
                   'recID': bfo.recID,
                   'size': size,
                   'total': nice_size(total)}
    # If there are no buttons to display, don't display the rest of the HTML
    if buttons:
        return wrapper + buttons
Пример #4
0
 def large_file_notification(sender, deposition=None, deposition_file=None,
                             **kwargs):
     if deposition_file and deposition_file.size > 10485760:
         from invenio.mailutils import send_email
         from invenio.config import CFG_SITE_ADMIN_EMAIL, CFG_SITE_NAME
         from invenio.textutils import nice_size
         from invenio.jinja2utils import render_template_to_string
         current_app.logger.info(deposition_file.__getstate__())
         send_email(
             CFG_SITE_ADMIN_EMAIL,
             CFG_SITE_ADMIN_EMAIL,
             subject="%s: %s file uploaded" % (
                 CFG_SITE_NAME, nice_size(deposition_file.size)
             ),
             content=render_template_to_string(
                 "email_large_file.html",
                 deposition=deposition,
                 deposition_file=deposition_file,
             )
         )