summaryrefslogtreecommitdiff
path: root/project/kiwipycon/talk
diff options
context:
space:
mode:
authorMadhusudan.C.S2009-10-30 15:09:12 +0530
committerMadhusudan.C.S2009-10-30 15:09:12 +0530
commitf89410559c20dd88d78ccd6b9d24e7941da9d5ff (patch)
tree3ad4fb64efc7523d1f3065e0dd03693871d6ce55 /project/kiwipycon/talk
parent75f0773685ef0724d8ccc1eb1aab16bba55cd7a7 (diff)
downloadscipycon-f89410559c20dd88d78ccd6b9d24e7941da9d5ff.tar.gz
scipycon-f89410559c20dd88d78ccd6b9d24e7941da9d5ff.tar.bz2
scipycon-f89410559c20dd88d78ccd6b9d24e7941da9d5ff.zip
Added all the files from kiwipycon and the changes made for SciPy.in.
Diffstat (limited to 'project/kiwipycon/talk')
-rw-r--r--project/kiwipycon/talk/__init__.py0
-rw-r--r--project/kiwipycon/talk/admin.py23
-rw-r--r--project/kiwipycon/talk/forms.py62
-rw-r--r--project/kiwipycon/talk/migrations/0001_initial.py68
-rw-r--r--project/kiwipycon/talk/migrations/__init__.py0
-rw-r--r--project/kiwipycon/talk/models.py73
-rw-r--r--project/kiwipycon/talk/templatetags/__init__.py1
-rw-r--r--project/kiwipycon/talk/templatetags/talk_extras.py8
-rw-r--r--project/kiwipycon/talk/views.py183
9 files changed, 418 insertions, 0 deletions
diff --git a/project/kiwipycon/talk/__init__.py b/project/kiwipycon/talk/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/kiwipycon/talk/__init__.py
diff --git a/project/kiwipycon/talk/admin.py b/project/kiwipycon/talk/admin.py
new file mode 100644
index 0000000..73c8d6a
--- /dev/null
+++ b/project/kiwipycon/talk/admin.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+#django.contrib
+from django.contrib import admin
+
+#kiwipycon
+from .models import Talk
+
+class TalkAdmin(admin.ModelAdmin):
+ list_display = ('title', 'speaker', 'topic', 'duration', 'audience', 'approved')
+ list_filter = ('approved', 'audience', 'topic', 'speaker')
+ search_fields = ('slug', 'title', 'abstract')
+ prepopulate_from = {'slug': ('title',)}
+ fieldsets = (
+ ('Details', {
+ 'fields': ('slug', 'title', 'abstract', 'speaker')
+ }),
+ ('Information', {
+ 'fields': ('topic', 'duration', 'audience', 'approved')
+ }),
+ )
+admin.site.register(Talk, TalkAdmin)
diff --git a/project/kiwipycon/talk/forms.py b/project/kiwipycon/talk/forms.py
new file mode 100644
index 0000000..5059285
--- /dev/null
+++ b/project/kiwipycon/talk/forms.py
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+#django
+from django import forms
+
+#django.contrib
+from django.contrib.auth.models import User
+
+#tagging
+from tagging.forms import TagField
+
+#kiwipycon
+#from .models import TOPIC_CHOICES
+from .models import DURATION_CHOICES
+from .models import AUDIENCE_CHOICES
+
+
+class TalkSubmitForm(forms.Form):
+ """Submit talk form
+ """
+ authors_bio = forms.CharField(widget=forms.Textarea, required=True,
+ label=u'Author(s) and short bio',
+ help_text=u'(include a bit about your qualifications regarding your presentation topic)')
+ contact = forms.EmailField(required=True, label=u'E-Mail ID',
+ help_text=u'Provide your email ID',
+ max_length=1024,
+ widget=forms.TextInput(attrs={'size':'50'}))
+ title = forms.CharField(required=True, label=u'Talk title',
+ help_text=u'Title of proposed presentation',
+ max_length=1024,
+ widget=forms.TextInput(attrs={'size':'50'}))
+ abstract = forms.CharField(widget=forms.Textarea, required=True,
+ help_text=u'Summary of proposed presentation (around 30 words)')
+# outline = forms.CharField(widget=forms.Textarea, required=True,
+# help_text=u'Outline of proposed presentation (around 200 words)')
+# topic = forms.ChoiceField(choices=TOPIC_CHOICES,
+# label=u'Topic', help_text=u'Select one of the available options or enter other topic')
+# topic_other = forms.CharField(label=u'Other topic',
+# help_text=u'Description of your topic',
+# max_length=255,
+# required=False,
+# widget=forms.TextInput(attrs={'size':'50'}))
+ topic = forms.CharField(label=u'Topic',
+ help_text=u'Description of your topic or comma separated tags',
+ max_length=255,
+ required=False,
+ widget=forms.TextInput(attrs={'size':'50'}))
+ duration = forms.ChoiceField(choices=DURATION_CHOICES, required=True,
+ label=u'Preferred timeslot', help_text=u'Select preferred time slot')
+ audience = forms.ChoiceField(choices=AUDIENCE_CHOICES, label=u'Itended audience',
+ help_text=u'Select one of the available options or enter other type of intended audience')
+# audience_other = forms.CharField(label=u'Other intended audience',
+# help_text=u'Description of intended audience (ie. Discordians)',
+# max_length=128,
+# required=False,
+# widget=forms.TextInput(attrs={'size':'50'}))
+# tags = TagField(max_length=255,
+# widget=forms.TextInput(attrs={'size':'50'}))
+
+class TalkEditForm(TalkSubmitForm):
+ id = forms.CharField(widget=forms.HiddenInput)
diff --git a/project/kiwipycon/talk/migrations/0001_initial.py b/project/kiwipycon/talk/migrations/0001_initial.py
new file mode 100644
index 0000000..961abcf
--- /dev/null
+++ b/project/kiwipycon/talk/migrations/0001_initial.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+
+from south.db import db
+from django.db import models
+from project.kiwipycon.talk.models import *
+
+class Migration:
+
+ def forwards(self, orm):
+
+ # Adding model 'Talk'
+ db.create_table('talk_talk', (
+ ('id', models.AutoField(primary_key=True)),
+ ('slug', models.SlugField()),
+ ('speaker', models.ForeignKey(orm['auth.User'])),
+ ('authors_bio', models.TextField()),
+ ('contact', models.CharField(max_length=1024)),
+ ('title', models.CharField(max_length=1024)),
+ ('abstract', models.TextField()),
+ ('outline', models.TextField()),
+ ('topic', models.CharField(blank=True, max_length=255)),
+ ('topic_other', models.CharField(max_length=255, blank=True)),
+ ('duration', models.CharField(max_length=3)),
+ ('audience', models.CharField(blank=True, max_length=32)),
+ ('audience_other', models.CharField(max_length=128, blank=True)),
+ ('approved', models.BooleanField(default=False)),
+ ('submitted', models.DateTimeField(auto_now_add=True)),
+ ('last_mod', models.DateTimeField(auto_now=True)),
+ ('tags', TagField(blank=True)),
+ ))
+ db.send_create_signal('talk', ['Talk'])
+
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'Talk'
+ db.delete_table('talk_talk')
+
+
+
+ models = {
+ 'auth.user': {
+ '_stub': True,
+ 'id': ('models.AutoField', [], {'primary_key': 'True'})
+ },
+ 'talk.talk': {
+ 'abstract': ('models.TextField', [], {}),
+ 'approved': ('models.BooleanField', [], {'default': 'False'}),
+ 'audience': ('models.CharField', [], {'blank': 'True', 'max_length': '32'}),
+ 'audience_other': ('models.CharField', [], {'max_length': '128', 'blank': 'True'}),
+ 'authors_bio': ('models.TextField', [], {}),
+ 'contact': ('models.CharField', [], {'max_length': '1024'}),
+ 'duration': ('models.CharField', [], {'max_length': '3'}),
+ 'id': ('models.AutoField', [], {'primary_key': 'True'}),
+ 'last_mod': ('models.DateTimeField', [], {'auto_now': 'True'}),
+ 'outline': ('models.TextField', [], {}),
+ 'slug': ('models.SlugField', [], {}),
+ 'speaker': ('models.ForeignKey', ['User'], {}),
+ 'submitted': ('models.DateTimeField', [], {'auto_now_add': 'True'}),
+ 'tags': ('TagField', [], {'blank': 'True'}),
+ 'title': ('models.CharField', [], {'max_length': '1024'}),
+ 'topic': ('models.CharField', [], {'blank': 'True', 'max_length': '255'}),
+ 'topic_other': ('models.CharField', [], {'max_length': '255', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['talk']
diff --git a/project/kiwipycon/talk/migrations/__init__.py b/project/kiwipycon/talk/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/kiwipycon/talk/migrations/__init__.py
diff --git a/project/kiwipycon/talk/models.py b/project/kiwipycon/talk/models.py
new file mode 100644
index 0000000..62ae89b
--- /dev/null
+++ b/project/kiwipycon/talk/models.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+#django
+from django.db import models
+from django.contrib.auth.models import User
+
+#tagging
+from tagging import register
+from tagging.fields import TagField
+from tagging.utils import parse_tag_input
+
+DURATION_CHOICES = (
+ ('10', 'Lightning Talk (10 mins)'),
+ ('20', 'Short Talk (20 mins)'),
+ ('30', 'Standard Talk (30 mins)'),
+ )
+
+AUDIENCE_CHOICES = (
+ ('nonprogrammers', 'non-programmer'),
+ ('beginers', 'beginning programmer'),
+ ('intermediate', 'intermediate programmer'),
+ ('advanced', 'advanced programmer'),
+ )
+
+#TOPIC_CHOICES = (
+# ('Core Python', 'Core Python'),
+# ('Other implementations: Jython, IronPython, PyPy, and Stackless', 'Other implementations: Jython, IronPython, PyPy, and Stackless'),
+# ('Python libraries and extensions', 'Python libraries and extensions'),
+# ('Python 3k', 'Python 3k'),
+# ('Databases', 'Databases'),
+# ('Documentation', 'Documentation'),
+# ('GUI Programming', 'GUI Programming'),
+# ('Game Programming', 'Game Programming'),
+# ('Network Programming', 'Network Programming'),
+# ('Open Source Python projects', 'Open Source Python projects'),
+# ('Packaging Issues', 'Packaging Issues'),
+# ('Programming Tools', 'Programming Tools'),
+# ('Project Best Practices', 'Project Best Practices'),
+# ('Embedding and Extending', 'Embedding and Extending'),
+# ('Science and Maths', 'Science and Maths'),
+# ('Web-based Systems', 'Web-based Systems'),
+#)
+
+class Talk(models.Model):
+ """Defines talks at *PyCon"""
+ slug = models.SlugField()
+ speaker = models.ForeignKey(User)
+ authors_bio = models.TextField()
+ contact = models.EmailField()
+ title = models.CharField(max_length=1024)
+ abstract = models.TextField()
+# outline = models.TextField()
+ topic = models.CharField(max_length=255,
+ #choices=TOPIC_CHOICES,
+ blank=True)
+ #topic_other = models.CharField(max_length=255, blank=True)
+ duration = models.CharField(max_length=3, choices=DURATION_CHOICES)
+ audience = models.CharField(max_length=32, choices=AUDIENCE_CHOICES, blank=True)
+# audience_other = models.CharField(max_length=128, blank=True)
+ approved = models.BooleanField(default=False)
+ submitted = models.DateTimeField(auto_now_add=True)
+ last_mod = models.DateTimeField(auto_now=True)
+# tags = TagField(blank=True)
+
+ def __unicode__(self):
+ return self.title
+
+ def get_tag_list(self):
+ return parse_tag_input(self.tags)
+
+# register(Talk) # saving talk failed - see:
+# http://code.google.com/p/django-tagging/issues/detail?id=152
diff --git a/project/kiwipycon/talk/templatetags/__init__.py b/project/kiwipycon/talk/templatetags/__init__.py
new file mode 100644
index 0000000..792d600
--- /dev/null
+++ b/project/kiwipycon/talk/templatetags/__init__.py
@@ -0,0 +1 @@
+#
diff --git a/project/kiwipycon/talk/templatetags/talk_extras.py b/project/kiwipycon/talk/templatetags/talk_extras.py
new file mode 100644
index 0000000..e28f2bf
--- /dev/null
+++ b/project/kiwipycon/talk/templatetags/talk_extras.py
@@ -0,0 +1,8 @@
+from django import template
+
+register = template.Library()
+
+def choice(choices, value):
+ return choices[value]
+
+register.filter('choice', choice)
diff --git a/project/kiwipycon/talk/views.py b/project/kiwipycon/talk/views.py
new file mode 100644
index 0000000..a11be54
--- /dev/null
+++ b/project/kiwipycon/talk/views.py
@@ -0,0 +1,183 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+# python imports
+from urlparse import urlparse
+
+# django
+from django.conf import settings
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from django.core.urlresolvers import reverse
+from django.views.generic.list_detail import object_list
+from django.views.generic.list_detail import object_detail
+
+from django.contrib.auth.decorators import login_required
+from django.contrib.auth.forms import AuthenticationForm
+from django.contrib.auth.models import User
+
+# PIL
+from PIL import Image
+
+# tagging
+from tagging.models import Tag
+
+#kiwipycon
+from project.kiwipycon.utils import set_message_cookie
+from project.kiwipycon.utils import slugify
+from project.kiwipycon.user.models import UserProfile
+from project.kiwipycon.user.forms import RegisterForm
+from project.kiwipycon.user.utils import kiwipycon_createuser
+
+from .models import Talk
+from .forms import TalkSubmitForm
+from .forms import TalkEditForm
+from .models import DURATION_CHOICES
+from .models import AUDIENCE_CHOICES
+
+def list_talks(request):
+ objects = Talk.objects.filter(approved=True)
+ extra_context = dict(count=objects.count())
+ return object_list(request, objects, extra_context=extra_context)
+
+def talk(request, id):
+ objects = Talk.objects.filter(approved=True)
+ audience = {}
+ for choice in AUDIENCE_CHOICES:
+ audience[choice[0]] = choice[1]
+ extra_context = dict(choices=audience)
+ return object_detail(request, objects, id, extra_context=extra_context)
+
+@login_required
+def edit_talk(request, id, template_name='talk/edit-talk.html'):
+ '''Allows users that submitted a talk to edit it until the talk is approved.
+ '''
+ talk = Talk.objects.get(pk=id)
+
+ if talk.approved == True:
+ redirect_to = reverse('kiwipycon_account')
+ return set_message_cookie(redirect_to,
+ msg = u'Sorry but you cannot edit the talk once'\
+ + ' it has been accepted.')
+ if talk.speaker != request.user:
+ redirect_to = reverse('kiwipycon_account')
+ return set_message_cookie(redirect_to,
+ msg = u'Redirected to account because the talk you selected' \
+ + ' is not your own.')
+
+ if request.method == 'POST':
+ form = TalkEditForm(data=request.POST)
+ if form.is_valid():
+ talk.slug = slugify(form.data.get('title'))
+ talk.authors_bio = form.data.get('authors_bio')
+ talk.contact = form.data.get('contact')
+ talk.title = form.data.get('title')
+ talk.abstract = form.data.get('abstract')
+ talk.outline = form.data.get('outline')
+ talk.topic = form.data.get('topic')
+ talk.topic_other = form.data.get('topic_other')
+ talk.duration = form.data.get('duration')
+ talk.audience = form.data.get('audience')
+ talk.audience_other = form.data.get('audience_other')
+ talk.tags = form.data.get('tags')
+ talk.save()
+ # Saved.. redirect
+ redirect_to = reverse('kiwipycon_account')
+ return set_message_cookie(redirect_to,
+ msg = u'Your changes have been saved.')
+ else:
+ form = TalkEditForm(initial={
+ 'id' : id,
+ 'authors_bio' : talk.authors_bio,
+ 'contact' : talk.contact,
+ 'title' : talk.title,
+ 'abstract' : talk.abstract,
+ 'outline' : talk.outline,
+ 'topic' : talk.topic,
+ 'topic_other' : talk.topic_other,
+ 'duration' : talk.duration,
+ 'audience' : talk.audience,
+ 'audience_other' : talk.audience_other,
+ 'tags' : talk.tags,
+ })
+
+ return render_to_response(template_name, RequestContext(request, locals()))
+
+@login_required()
+def submit_talk(request, template_name='talk/submit-talk.html'):
+ '''Allows user to edit profile
+ '''
+ user = request.user
+ if user.is_authenticated():
+ try:
+ profile = user.get_profile()
+ except:
+ profile, new = UserProfile.objects.get_or_create(user=user)
+ if new:
+ profile.save()
+ message = None
+
+ if request.method == 'POST':
+ talk_form = TalkSubmitForm(data=request.POST)
+
+ register_form = RegisterForm(data=request.POST,
+ files=request.FILES)
+
+ if request.POST.get('action', None) == 'login':
+ login_form = AuthenticationForm(data=request.POST)
+ if login_form.is_valid():
+
+ from django.contrib.auth import login
+ login(request, login_form.get_user())
+
+ redirect_to = reverse('kiwipycon_submit_talk')
+ return set_message_cookie(redirect_to,
+ msg = u'You have been logged in.')
+
+ if request.POST.get('action', None) == 'register':
+ # add the new user
+ if register_form.is_valid():
+
+ user = kiwipycon_createuser(request, register_form.data)
+
+ if talk_form.is_valid():
+ if user.is_authenticated():
+ title = talk_form.data.get('title')
+ talk = Talk.objects.create(
+ slug = slugify(title),
+ speaker = User.objects.get(pk=user.id),
+ authors_bio = talk_form.data.get('authors_bio'),
+ contact = talk_form.data.get('contact'),
+ title = talk_form.data.get('title'),
+ abstract = talk_form.data.get('abstract'),
+ outline = talk_form.data.get('outline'),
+ topic = talk_form.data.get('topic'),
+ topic_other = talk_form.data.get('topic_other'),
+ duration = talk_form.data.get('duration'),
+ audience = talk_form.data.get('audience'),
+ audience_other = talk_form.data.get('audience_other'),
+ approved = False,
+ tags = talk_form.data.get('tags'))
+ talk.save()
+ # Saved, ... redirect back to account
+ redirect_to = reverse('kiwipycon_account')
+ return set_message_cookie(redirect_to,
+ msg = u'Thanks, your talk has been submitted.')
+ else:
+ redirect_to = reverse('kiwipycon_submit_talk')
+ return set_message_cookie(redirect_to,
+ msg = u'Something is wrong here.')
+
+ else:
+ talk_form = TalkSubmitForm()
+ register_form = RegisterForm()
+ login_form = AuthenticationForm()
+
+
+ return render_to_response(template_name, RequestContext(request, {
+ 'talk_form': talk_form,
+ 'register_form' : register_form,
+ 'message' : message,
+ 'login_form' : login_form
+ }))
+