Exemplo n.º 1
0
        def setForm(param_name, blob_info):
            add_form, edit_form = params[param_name]

            if blob_info:
                form = edit_form(
                    initial={
                        'name':
                        '<a href="%(url)s">%(name)s</a>' % {
                            'name':
                            blob_info.filename,
                            'url':
                            redirects.getDownloadBlobRedirectWithGet(
                                blob_info,
                                params,
                                scope_path=entity.key().id_or_name(),
                                type=param_name)
                        },
                        'size':
                        defaultfilters.filesizeformat(blob_info.size),
                        'uploaded':
                        blob_info.creation.strftime(self.DATETIME_FORMAT),
                    })
            else:
                form = add_form()

            context[param_name] = form
Exemplo n.º 2
0
def as_gci_task_ws(context, comment):
    """Returns a HTML representation of a GCI task's work submissions.
  """

    context['ws'] = comment
    context['ws_id'] = comment.key().id_or_name()

    if comment.upload_of_work:
        blob_key = comment.upload_of_work.key()

        blob = blobstore.BlobInfo.get(blob_key)
        if blob:
            context['ws_file_blob_key'] = blob_key
            context['ws_file_name'] = blob.filename
            context['ws_file_size'] = blob.size
            context['ws_file_download_url'] = \
                redirects.getDownloadBlobRedirectWithGet(
                    blob, {'url_name': 'gci/work_submission'})

    return context
Exemplo n.º 3
0
def as_gci_task_ws(context, comment):
  """Returns a HTML representation of a GCI task's work submissions.
  """

  context['ws'] =  comment
  context['ws_id'] = comment.key().id_or_name()

  if comment.upload_of_work:
    blob_key = comment.upload_of_work.key()

    blob = blobstore.BlobInfo.get(blob_key)
    if blob:
      context['ws_file_blob_key'] = blob_key
      context['ws_file_name'] = blob.filename
      context['ws_file_size'] = blob.size
      context['ws_file_download_url'] = \
          redirects.getDownloadBlobRedirectWithGet(
              blob, {'url_name': 'gci/work_submission'})

  return context
Exemplo n.º 4
0
        def setForm(param_name, blob_info):
            add_form, edit_form = params[param_name]

            if blob_info:
                form = edit_form(
                    initial={
                        "name": '<a href="%(url)s">%(name)s</a>'
                        % {
                            "name": blob_info.filename,
                            "url": redirects.getDownloadBlobRedirectWithGet(
                                blob_info, params, scope_path=entity.key().id_or_name(), type=param_name
                            ),
                        },
                        "size": defaultfilters.filesizeformat(blob_info.size),
                        "uploaded": blob_info.creation.strftime(self.DATETIME_FORMAT),
                    }
                )
            else:
                form = add_form()

            context[param_name] = form