upload/views.py
changeset 18 07408d1ced76
parent 17 08a47999f316
child 20 272dced1685b
equal deleted inserted replaced
17:08a47999f316 18:07408d1ced76
     1 #can add features like: supporting files with specified extensions, making edit box of content better etc.
     1 #can add features like: supporting files with specified extensions, making edit box of content better etc.
     2 from django.http import HttpResponse
     2 from django.http import HttpResponse
     3 from django.template import Context, Template
     3 from django.template import Context, Template
     4 from django.shortcuts import render_to_response
     4 from django.shortcuts import render_to_response
     5 from form import FileForm, Uploaded_fileForm
     5 
     6 from forms import ParticipantForm
     6 from forms import ParticipantForm
     7 import tarfile
     7 from models import Participant
       
     8 
     8 
     9 
     9 #function to read the upoaded file and store it
    10 #function to read the upoaded file and store it
    10 def handle_uploaded_file(f):
    11 def handle_uploaded_file(f):
    11     destination = open(f.name, 'wb+')
    12     destination = open(f.name, 'wb+')
    12     for chunk in f.chunks():
    13     for chunk in f.chunks():
    21             #handle_uploaded_file(request.FILES['file'])
    22             #handle_uploaded_file(request.FILES['file'])
    22             form.save()	   
    23             form.save()	   
    23             return render_to_response(template_name, {'form': form, 'value': False,})
    24             return render_to_response(template_name, {'form': form, 'value': False,})
    24         else:
    25         else:
    25             return render_to_response(template_name, {'form': form, 'value': True,})
    26             return render_to_response(template_name, {'form': form, 'value': True,})
    26     c = Context()
       
    27     return render_to_response(template_name,
    27     return render_to_response(template_name,
    28 			  {'form': ParticipantForm(), 'value': True,})
    28 			  {'form': ParticipantForm(), 'value': True})
    29 			  
    29 			  
    30 def submission(request, template_name='submission.html'):
    30 def submission(request, template_name='submission.html'):
    31     '''
    31     """View to return the submitted videos
    32         view to return the submitted videos
    32     """
    33     '''
    33     context = {
    34     pass
    34         'participants': Participant.objects.all()
       
    35         }
       
    36 
       
    37     return render_to_response(template_name, context)