Added the initial proceedings app files and enabled them in both production and development settings.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Thu, 14 Jan 2010 15:54:34 +0530
changeset 84 d01c62c2a628
parent 83 c6557935bc28
child 85 07b48746fe29
Added the initial proceedings app files and enabled them in both production and development settings.
buildout.cfg
project/development.py
project/kiwipycon/proceedings/__init__.py
project/kiwipycon/proceedings/forms.py
project/kiwipycon/proceedings/models.py
project/kiwipycon/proceedings/views.py
project/production.py
--- a/buildout.cfg	Mon Dec 28 23:37:32 2009 +0530
+++ b/buildout.cfg	Thu Jan 14 15:54:34 2010 +0530
@@ -24,6 +24,7 @@
     markdown
     textile
     beautifulsoup
+    MySQL-python
 
 [versions]
 reportlab=2.3
@@ -61,7 +62,7 @@
 
 [django-command-extensions]
 recipe = zerokspot.recipe.git
-repository = git://github.com/django-extensions/django-extensions.git
+repository = http://github.com/django-extensions/django-extensions.git
 
 [south]
 recipe = infrae.subversion
--- a/project/development.py	Mon Dec 28 23:37:32 2009 +0530
+++ b/project/development.py	Thu Jan 14 15:54:34 2010 +0530
@@ -20,18 +20,18 @@
     'project.kiwipycon.talk',
     'project.kiwipycon.registration',
     'project.kiwipycon.sponsor',
+    'project.kiwipycon.proceedings',
     'tagging',
     'basic.blog',
     'basic.inlines',
     'basic.media',
     'django_extensions',
     'south',
-    'registration',
 )
 
-DATABASE_ENGINE = 'mysql'
-DATABASE_NAME = 'conference2009'
-DATABASE_USER = 'root'
+DATABASE_ENGINE = 'sqlite3'
+DATABASE_NAME = '/home/madhu/conference2009.db'
+DATABASE_USER = ''
 DATABASE_PASSWORD = ''
 
 EMAIL_HOST = 'localhost'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project/kiwipycon/proceedings/forms.py	Thu Jan 14 15:54:34 2010 +0530
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+
+from django import forms
+
+
+class ProceedingsForm(forms.Form):
+    """Form for proceedings.
+    """
+
+    title = forms.CharField(required=True, label=u'Title',
+                            widget=forms.TextInput(attrs={'size':'70'}))
+
+    abstract = forms.CharField(
+        widget=forms.Textarea(attrs={'cols': '80', 'rows': '8'}),
+        required=True, label=u'Abstract',
+        help_text=u'Upto 200 words. Content must strictly be in reSt format.')
+
+    body = forms.CharField(
+        widget=forms.Textarea(attrs={'cols': '80', 'rows': '25'}),
+        required=False, label=u'Body', help_text=u'Approximately 7 pages. '
+        'Content must strictly be in reSt format.')
+
+    rst_file = forms.FileField(
+        required=False, label=u'reStructuredText file',
+        help_text=u'The file should contain two sections, one with a heading '
+        "'Abstract' and other with a heading 'Body'.")
+
+    self_author = forms.BooleanField(
+        required=False, label=u'Author(yourself)',
+        help_text=u'Check the field if you are one of the authors')
+
+    additional_authors = forms.CharField(
+        required=False, label=u'Additional Author(s)',
+        help_text=u'User ID of each additional author separated by comma.')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project/kiwipycon/proceedings/models.py	Thu Jan 14 15:54:34 2010 +0530
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+from django.db import models
+from django.contrib.auth.models import User
+
+
+class Paper(models.Model):
+    """Data model for storing proceedings paper.
+    """
+
+    title = models.CharField(max_length=200)
+    abstract = models.TextField()
+    body = models.TextField()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project/kiwipycon/proceedings/views.py	Thu Jan 14 15:54:34 2010 +0530
@@ -0,0 +1,93 @@
+# -*- coding: utf-8 -*-
+
+from django.contrib.auth.decorators import login_required
+from django.contrib.auth.forms import AuthenticationForm
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+from project.kiwipycon.user.forms import RegisterForm
+from project.kiwipycon.proceedings.forms import ProceedingsForm
+
+
+@login_required
+def submit(request, template = 'proceedings/submit.html'):
+    """View to submit the proceedings paper.
+    """
+    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':
+        proceedings_form = ProceedingsForm(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_proceedings')
+                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 proceedings_form.is_valid():
+            if user.is_authenticated():
+                title = proceedings_form.data.get('title')
+
+                # Saved, ... redirect back to account
+                redirect_to = reverse('kiwipycon_account')
+                return set_message_cookie(redirect_to,
+                        msg = u'Thanks, your paper has been submitted.')
+            else:
+                redirect_to = reverse('kiwipycon_submit_proceedings')
+                return set_message_cookie(redirect_to,
+                        msg = u'Something is wrong here.')
+
+    else:
+        proceedings_form = ProceedingsForm()
+        register_form = RegisterForm()
+    login_form = AuthenticationForm()
+
+        
+    proceedings_form = ProceedingsForm()
+    register_form = RegisterForm()
+    login_form = AuthenticationForm()
+
+    context = RequestContext(request, {
+        'proceedings_form': proceedings_form,
+        'register_form' : register_form,
+        'message' : message,
+        'login_form' : login_form
+        })
+
+    return render_to_response(template, context)
+
+
+def edit(request, id, template = 'proceedings/edit.html'):
+    """View to edit the proceedings paper.
+    """
+
+    context = RequestContext(request, {
+        'proceedings_form': proceedings_form,
+        'register_form' : register_form,
+        'message' : message,
+        'login_form' : login_form
+        })
+
+    return render_to_response(template, context)
--- a/project/production.py	Mon Dec 28 23:37:32 2009 +0530
+++ b/project/production.py	Thu Jan 14 15:54:34 2010 +0530
@@ -26,7 +26,6 @@
     'basic.media',
     'django_extensions',
     'south',
-    'registration',
 )
 
 DATABASE_ENGINE = 'mysql'