Added submissions page.
authorShantanu <shantanu@fossee.in>
Thu, 03 Sep 2009 17:31:12 +0530
changeset 17 08a47999f316
parent 16 a5bbfbe5feb1
child 18 07408d1ced76
Added submissions page.
template/submission.html
upload/form.py
upload/forms.py
upload/models.py
upload/views.py
urls.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/template/submission.html	Thu Sep 03 17:31:12 2009 +0530
@@ -0,0 +1,68 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<title>OCR</title>
+<meta name="keywords" content="" />
+<meta name="description" content="" />
+<link href="/style.css" rel="stylesheet" type="text/css" media="screen" />
+<script type="text/javascript" language="JavaScript">
+function check(form) {
+  var ext = form.sourcefile;
+  ext = ext.substring(ext.length-3,ext.length);
+  ext = ext.toLowerCase();
+  if(ext != 'txt') {
+    alert('You selected a .'+ext+
+          ' file; please select a .jpg file instead!');
+    return false; }
+  else
+    return true; }
+</script>
+</head>
+<body>
+<div id="header">
+	<div id="logo">
+		<h1><a href="#">Spoken Tutorials Competition</a></h1>
+		<h2><a href="http://www.iitb.ac.in/">By IITB</a></h2>		
+	</div>	
+</div>
+<!-- start page -->
+<div id="page">	
+	<!-- start content -->	
+	<div id="content">
+		<p class="center">
+		{% block content %}		
+			<table>
+			<tr>
+			<th> Name </th>	
+			<th> Email-id </th>				
+			<th> Language </th>	
+			<th> Age </th>	
+			<th> Phone Number </th>	
+			<th> Category </th>	
+			<th> File </th>	
+			</tr>
+			{% for participant in participants %}
+			  <tr>
+			    <td>{{ participant.name }}</td>
+			    <td>{{ participant.email }}</td>				    	    
+			    <td>{{ participant.language }}</td>			    
+			    <td>{{ participant.phonenumber }}</td>
+			    <td>{{ participant.age }}</td>
+			    <td>{{ participant.category }}</td>
+			    <td>{{ file }}</td>
+			  </tr>
+            {% endfor %}
+			</table>
+		{% endblock %}
+		</p>
+	</div>
+	<!-- end content -->	
+	<div style="clear: both;">&nbsp;</div>
+</div>
+<!-- end page -->
+<div id="footer">	
+	<p class="credit">Powered by the <a href="http://fossee.in/">FOSSEE</a> group, IITB</p>
+</div>
+</body>
+</html>
--- a/upload/form.py	Thu Sep 03 00:17:30 2009 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-attrs_dict = { 'class': 'required' }
-
-#form for file field, lets you upload file
-class FileForm(forms.Form):	
-	file = forms.FileField()
-
-#form for creating a editable box, out of the content of the file
-class Uploaded_fileForm(forms.Form):
-	content = forms.CharField(widget=forms.Textarea(attrs=attrs_dict),label=_(u'content'))
--- a/upload/forms.py	Thu Sep 03 00:17:30 2009 +0530
+++ b/upload/forms.py	Thu Sep 03 17:31:12 2009 +0530
@@ -3,6 +3,18 @@
 from spoken_tut.upload.models import Participant
 
 class ParticipantForm(forms.ModelForm):
+    def clean(self):
+        """Cleaner for validating Other language field.
+        """
+        cleaned_data = self.cleaned_data
+        lang = cleaned_data['language']
+        other_lang = cleaned_data['other_lang']
+        accept = cleaned_data['accept']
+        if lang == 'Other' and not other_lang:
+            raise forms.ValidationError('Please fill in the other language field.')
+        if accept:
+            raise forms.ValidationError('You need to accept the terms and condition for uploading the data.')
+
 	class Meta:
 		model = Participant
 
--- a/upload/models.py	Thu Sep 03 00:17:30 2009 +0530
+++ b/upload/models.py	Thu Sep 03 17:31:12 2009 +0530
@@ -8,6 +8,7 @@
     ('Bengali', 'Bengali'),
     ('Bodo', 'Bodo'),
     ('Dogri', 'Dogri'),
+    ('English', 'English')
     ('Gujarati', 'Gujarati'),
     ('Hindi', 'Hindi'),
     ('Kannada', 'Kannada'),
@@ -26,19 +27,22 @@
     ('Tamil', 'Tamil'),
     ('Telugu', 'Telugu'),
     ('Urdu', 'Urdu'),
+    ('Other', 'Other')
     )
 
 	CATEGORY_CHOICES = (
 		('Student at IIT','Student at IIT'),
-    ('Staff and family','Staff and family'),
-    ('Faculty and family','Faculty and family'),
-    ('Others','Others'),
-	  )
+        ('Staff and family','Staff and family'),
+        ('Faculty and family','Faculty and family'),
+        ('Others','Others'),
+	    )
 
 	name = models.CharField(max_length = 50)
 	email = models.EmailField()
 	filename = models.FileField(upload_to='videos/%Y/%m/%d')
 	language = models.CharField(max_length = 20, choices=LANGUAGE_CHOICES)
+	other_lang = models.CharField(max_length = 256, verbose_name='If Others, specify')
 	phonenumber = models.CharField(max_length=15)
 	age = models.IntegerField(max_length=3)
-	category = models.CharField(max_length = 80, choices=CATEGORY_CHOICES)
+	category = models.CharField(max_length = 80, choices=CATEGORY_CHOICES)	
+
--- a/upload/views.py	Thu Sep 03 00:17:30 2009 +0530
+++ b/upload/views.py	Thu Sep 03 17:31:12 2009 +0530
@@ -26,3 +26,9 @@
     c = Context()
     return render_to_response(template_name,
 			  {'form': ParticipantForm(), 'value': True,})
+			  
+def submission(request, template_name='submission.html'):
+    '''
+        view to return the submitted videos
+    '''
+    pass
--- a/urls.py	Thu Sep 03 00:17:30 2009 +0530
+++ b/urls.py	Thu Sep 03 17:31:12 2009 +0530
@@ -16,6 +16,6 @@
     # Uncomment the next line to enable the admin:
     # (r'^admin/(.*)', admin.site.root),
 	(r'^$','spoken_tut.upload.views.upload_file'),
-	(r'^download/$','spoken_tut.upload.views.file_archive'),
+	(r'^submission/$','spoken_tut.upload.views.submission'),
 	(r'^(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
 )