Exemple #1
0
def edit(request):
    model = Document, User
    document = Document.objects.filter(user_id=request.user.id).order_by("-docfile")[:1]
    # Handle file upload
    if request.method == "POST":
        form = DocumentForm(request.POST, request.FILES)
        if form.is_valid():
            newdoc = Document(
                user=request.user,
                docfile=request.FILES["docfile"],
                firstname=request.POST["firstname"],
                lastname=request.POST["lastname"],
                address=request.POST["address"],
            )
            newdoc.save()

            # Redirect to the document list after POST
            return redirect("dashboard.views.profiles")
    else:
        form = DocumentForm()  # A empty, unbound form

    # Load documents for the list page

    # Render list page with the documents and the form
    return render_to_response(
        "dashboard/list.html", {"document": document, "form": form}, context_instance=RequestContext(request)
    )
def profile_edit(request, pk):
    newdoc = get_object_or_404(Document, pk=pk)
    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES, instance=newdoc)
        if form.is_valid():
            newdoc = Document(
                user=request.user,
                docfile=request.FILES['docfile'],
                firstname=request.POST['firstname'],
                lastname=request.POST['lastname'],
                address=request.POST['address'],
            )
            newdoc.save()

            # Redirect to the document list after POST
            return redirect('dashboard.views.profiles', pk=newdoc.pk)
    else:
        form = DocumentForm()  # A empty, unbound form

# Load documents for the list page
    document = Document.objects.filter(user_id=request.user.id)

    # Render list page with the documents and the form
    return render_to_response('dashboard/list.html', {
        'document': document,
        'form': form
    },
                              context_instance=RequestContext(request))
Exemple #3
0
def profile_edit(request, pk):
    newdoc = get_object_or_404(Document, pk=pk)
    if request.method == "POST":
        form = DocumentForm(request.POST, request.FILES, instance=newdoc)
        if form.is_valid():
            newdoc = Document(
                user=request.user,
                docfile=request.FILES["docfile"],
                firstname=request.POST["firstname"],
                lastname=request.POST["lastname"],
                address=request.POST["address"],
            )
            newdoc.save()

            # Redirect to the document list after POST
            return redirect("dashboard.views.profiles", pk=newdoc.pk)
    else:
        form = DocumentForm()  # A empty, unbound form

    # Load documents for the list page
    document = Document.objects.filter(user_id=request.user.id)

    # Render list page with the documents and the form
    return render_to_response(
        "dashboard/list.html", {"document": document, "form": form}, context_instance=RequestContext(request)
    )
Exemple #4
0
def trash(request, template_name='django_messages/trash.html'):
    """
    Displays a list of deleted messages.
    Optional arguments:
        ``template_name``: name of the template to use
    Hint: A Cron-Job could periodicly clean up old messages, which are deleted
    by sender and recipient.
    """
    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES )
        if form.is_valid():
            newdoc = Document(user=request.user, docfile = request.FILES['docfile'])
            newdoc.save()

            # Redirect to the document list after POST

    else:
        form = DocumentForm()
   
   # Load documents for the list page
    document = Document.objects.filter(user_id = request.user.id).order_by('-docfile')[:1]

    message_list = Message.objects.trash_for(request.user)
    return render_to_response('django_messages/trash.html', {
        'message_list': message_list, 'document': document, 'form': form
    }, context_instance=RequestContext(request))
Exemple #5
0
def edit(request):
    model = Document, User
    document = Document.objects.filter(
        user_id=request.user.id).order_by('-docfile')[:1]
    # Handle file upload
    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES)
        if form.is_valid():
            newdoc = Document(
                user=request.user,
                docfile=request.FILES['docfile'],
                firstname=request.POST['firstname'],
                lastname=request.POST['lastname'],
                address=request.POST['address'],
            )
            newdoc.save()

            # Redirect to the document list after POST
            return redirect('dashboard.views.profiles')
    else:
        form = DocumentForm()  # A empty, unbound form

# Load documents for the list page

# Render list page with the documents and the form
    return render_to_response('dashboard/list.html', {
        'document': document,
        'form': form
    },
                              context_instance=RequestContext(request))
Exemple #6
0
def edit(request):
    # Handle file upload
    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES )
        if form.is_valid():
            newdoc = Document(user=request.user, docfile = request.FILES['docfile'], firstname = request.POST['firstname'], lastname = request.POST['lastname'], address = request.POST['address'],)
            newdoc.save()

            # Redirect to the document list after POST
            return redirect('dashboard.views.profiles')
    else:
        form = DocumentForm() # A empty, unbound form

   # Load documents for the list page
    document = Document.objects.filter(user_id = request.user.id)[:1]
   

    # Render list page with the documents and the form
    return render_to_response(
        'dashboard/list.html',
        {'document': document, 'form': form},
        context_instance=RequestContext(request)
    )
Exemple #7
0
def inbox(request, template_name='django_messages/inbox.html'):
    """
    Displays a list of received messages for the current user.
    Optional Arguments:
        ``template_name``: name of the template to use.
    """
    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES )
        if form.is_valid():
            newdoc = Document(user=request.user, docfile = request.FILES['docfile'])
            newdoc.save()

            # Redirect to the document list after POST

    else:
        form = DocumentForm()
   
   # Load documents for the list page
    document = Document.objects.filter(user_id = request.user.id).order_by('-docfile')[:1]
    message_list = Message.objects.inbox_for(request.user)
    return render_to_response('django_messages/inbox.html', {
        'message_list': message_list, 'document': document, 'form': form
    }, context_instance=RequestContext(request))