Exemplo n.º 1
0
def list_sheet(request, sheet_slug, chronicle_slug=None, bridge=None):
    if bridge is not None:
        try:
            group = bridge.get_group(chronicle_slug)
        except ObjectDoesNotExist:
            raise Http404
    else:
        group = None

    sheet = get_object_or_404(Sheet, slug=sheet_slug)
    if not can_fullview_sheet(request, sheet):
        return permission_denied(request)

    return render_to_response(
        'characters/list_sheet.html',
        {'sheet':sheet,
         'group':group},
        context_instance=RequestContext(request))
Exemplo n.º 2
0
def download_sheet(request, sheet_slug,
                   chronicle_slug=None, bridge=None):
    if bridge is not None:
        try:
            group = bridge.get_group(chronicle_slug)
        except ObjectDoesNotExist:
            raise Http404
    else:
        group = None

    sheet = get_object_or_404(Sheet, slug=sheet_slug)
    if not can_fullview_sheet(request, sheet):
        return permission_denied(request)

    response = HttpResponse(mimetype="application/gex")
    response['Content-Disposition'] = 'filename=' + sheet_slug + '.gex'
    ve = VampireExporter(sheet)
    response.write(ve)
    return response
Exemplo n.º 3
0
def print_sheet(request, sheet_slug, chronicle_slug=None, bridge=None,
                form_class=PrintOptionsForm):
    if bridge is not None:
        try:
            group = bridge.get_group(chronicle_slug)
        except ObjectDoesNotExist:
            raise Http404
    else:
        group = None

    sheet = get_object_or_404(Sheet, slug=sheet_slug)
    if not can_fullview_sheet(request, sheet):
        return permission_denied(request)

    form = form_class(request.POST or None)
    pprint(form.errors)
    if form.is_valid() and request.method == "POST":
        try:
            return render_to_response(
                'characters/printing/vampire_{}.html'.format(form.cleaned_data['template']),
                {'sheet':sheet,
                 'group':group,
                 'printing':True,
                 'options':form.cleaned_data},
                context_instance=RequestContext(request))
        except TemplateDoesNotExist:
            if 'template' not in form.errors:
                form.errors['template'] = []
            form.errors['template'].append(u'Chosen printing template does not exist')

    return render_to_response(
        'characters/print_sheet_options.html',
        {'form':form,
         'sheet':sheet,
         'group':group,
         'printing':True},
        context_instance=RequestContext(request))