Ejemplo n.º 1
0
def print_multiple_cards():
  """Print multiple cards.

  GET Params:
    really - Will only actually print the Cards if this is present and
        evaluates to True.

  POST Document:
    JSON encoded list of dicts, containing CardInfo fields.
    e.g.:
      [ {"name": "Kevin", "taskid": 42, "hours": 8, "description": ""},
      {"name": "Kevin", "taskid": 43, "risk": "U", "description": ""} ]

  """
  decoded_params = request.get_json(force=True)
  if type(decoded_params) is not list:
    abort(400, 'Malformed request')

  infos = [card_info.from_dict(params) for params in decoded_params]
  pdf = render.render_multiple_cards_pdf(infos)

  really = bool(request.args.get('really', False))
  if really:
    print_queue.send_to_print_queue(pdf)
    return "Added to queue\n"

  else:
    return "Ok, but not queued (use 'really' param)\n"
Ejemplo n.º 2
0
def render_multiple_cards():
  """Render multiple Cards.

  POST Document:
    JSON encoded list of dicts, containing CardInfo fields.
    e.g.:
      [ {"name": "Kevin", "taskid": 42, "hours": 8, "description": ""},
      {"name": "Kevin", "taskid": 43, "risk": "U", "description": ""} ]

  Returns:
    Rendered multi-page PDF document.
  """
  decoded_params = request.get_json(force=True)
  if type(decoded_params) is not list:
    abort(400, 'Malformed request')

  infos = [card_info.from_dict(params) for params in decoded_params]
  pdf = render.render_multiple_cards_pdf(infos)

  response = make_response(pdf)
  response.headers['Content-Type'] = 'application/pdf'
  return response