# HG changeset patch # User Madhusudan.C.S # Date 1253818662 -19800 # Node ID 4e819dd96e1fb81ec6510f7782a9fd24b5aa86e2 # Parent 7358eeae14d805c439d436e041b983f735f84482 Restructured and revamped the entire settings. diff -r 7358eeae14d8 -r 4e819dd96e1f conference/__init__.py diff -r 7358eeae14d8 -r 4e819dd96e1f conference/forms.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conference/forms.py Fri Sep 25 00:27:42 2009 +0530 @@ -0,0 +1,16 @@ +from django import forms +from django.contrib.auth.models import User +from django.utils.translation import ugettext_lazy as _ + +from content.models import Participant + + +class ParticipantForm(forms.ModelForm): + class Meta: + model = Participant + +class LoginForm(forms.Form): + username = forms.CharField(max_length=30, label=_(u'username')) + + password = forms.CharField(max_length=50,widget=forms.PasswordInput, + label=_("Enter New Password")) diff -r 7358eeae14d8 -r 4e819dd96e1f conference/models.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conference/models.py Fri Sep 25 00:27:42 2009 +0530 @@ -0,0 +1,34 @@ +from datetime import datetime + +from django.contrib.auth.models import User, UserManager +from django.db import models +from django.forms import ModelForm +from django.utils.translation import ugettext_lazy as _ + + +class Participant(models.Model): + """Model for holding details of participants + """ + + PARTICIPANT_CATEGORY = ( + ('Student','Student'), + ('Corporate Staff','Corporate Staff'), + ('Teacher','Teacher'), + ('Others','Others'), + ) + + username = models.ForeignKey(User, unique=True, related_name='profile') + + email = models.EmailField(_("Email Address"),unique=True) + + category = models.CharField(max_length = 80, choices=PARTICIPANT_CATEGORY,) + + organisation = models.CharField(_("Organisation"),max_length=200,blank = True,null = True) + + attending_conf = models.BooleanField(verbose_name="Will you attend conference?") + + attending_tut = models.BooleanField(verbose_name="Will you attend tutorial session?") + + attending_sprint = models.BooleanField(verbose_name="Will you attend sprint?") + + paper_submission = models.BooleanField(verbose_name="Do you want to Submit paper?") diff -r 7358eeae14d8 -r 4e819dd96e1f conference/tests.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conference/tests.py Fri Sep 25 00:27:42 2009 +0530 @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff -r 7358eeae14d8 -r 4e819dd96e1f conference/views.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conference/views.py Fri Sep 25 00:27:42 2009 +0530 @@ -0,0 +1,104 @@ +import datetime +import re +import time + +from django.contrib.auth import authenticate +from django.contrib.auth import login +from django.contrib.auth.models import User +from django.http import HttpResponse +from django.http import HttpResponseRedirect +from django.shortcuts import render_to_response +from django.template import Context +from django.template import RequestContext +from django.template import loader +from django.utils.translation import gettext_lazy as _ + +from content.forms import ParticipantForm +from content.models import Participant + + +def makemsg(username,url): + """ + Email body to be sent to user. + """ + msg = _("\ +Dear %(username)s,\n\n\ +\ +Thank you for registering with us. Please visit this url:\n\n\ +%(url)s\n\n\ +to complete the registration\n\n\ +regards\n\ +PyCon India 2009 Team\ +") %{'username': username,'url': url} + return msg + +def home_page(request, template_name='index.html'): + return render_to_response(template_name) + +def logout(request): + print request.user.username + if request.user.is_authenticated(): + print request.user.username + logout(request) + return HttpResponseRedirect('/') + +def register(request): + """Register function. + """ + + if request.user.is_authenticated(): + msg = _("You are already registered") + return HttpResponseRedirect("/2009/message/%s/" % msg) + + if request.POST: + # On POST method. + form = ParticipantForm(request.POST) + if form.is_valid(): + # If form is clean and has no errors. + fm = form.cleaned_data + if len(fm['username']) > 30 or len(fm['username']) < 4: + # Username should be > 4 characters and less that 30 characters. + form.errors['username']=[_("User Name must be 4-30 characters long")] + else: + r = re.compile(r"[A-Za-z0-9_]") + for alph in fm['username']: + # Check if every character of the username is either an + # alphabet or numeral. + if not r.match(alph): + form.errors['username']=[_("Invalid character %s in Username") %(alph)] + if not form.errors: + test = User.objects.filter(username__iexact=fm['username']) + # Check if username already exists. + if test: + form.errors['username'] = [("Username registered, try something else")] + # Check if the email id has already been in use. + teste = User.objects.filter(email__iexact=fm['email']) + if teste: + form.errors['email'] = [_("Email registered. Try something else")] + else: + # If username is found in the temporary registration database + # then show pending error message. + teste1 = User.objects.filter(email__iexact=fm['email']) + if teste1: + form.errors['email'] = [("Username pending registration. Try tomorrow")] + if not form.errors: + # If all goes well then push into database. + new_reg = form.save() + #new_reg.save() + return HttpResponseRedirect("/regthank/%i/" % new_reg.id) + else: + # On the GET method. + form = ParticipantForm() + return render_to_response("register.html", + { "form":form, }, context_instance=RequestContext(request)) + + +def regthank(request,id): + """Function displayed after registration is successful. + """ + p = Participant.objects.get(pk=id) + t = loader.get_template("regthank.html") + c = RequestContext(request, + {"p":p, + }) + return HttpResponse(t.render(c)) diff -r 7358eeae14d8 -r 4e819dd96e1f manage.py diff -r 7358eeae14d8 -r 4e819dd96e1f settings.py --- a/settings.py Thu Sep 24 15:20:30 2009 +0530 +++ b/settings.py Fri Sep 25 00:27:42 2009 +0530 @@ -2,18 +2,18 @@ import os + DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( ('Shantanu Choudary', 'choudhary.shantanu@gmail.com'), - # ('Your Name', 'your_email@domain.com'), ) MANAGERS = ADMINS DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. -DATABASE_NAME = 'participants' # Or path to database file if using sqlite3. +DATABASE_NAME = '../conference' # Or path to database file if using sqlite3. DATABASE_USER = '' # Not used with sqlite3. DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. @@ -36,9 +36,8 @@ # to load the internationalization machinery. USE_I18N = True -AUTH_PROFILE_MODULE = 'content.model.Participant' +ROOT_PATH = os.path.dirname(__file__) -ROOT_PATH = os.path.dirname(__file__) # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = os.path.join(ROOT_PATH, 'site-content') @@ -54,7 +53,7 @@ ADMIN_MEDIA_PREFIX = '/media/' # Make this unique, and don't share it with anybody. -SECRET_KEY = '&l34#62pxee2fb+u&3mz)*z%1p8kujqvxw$7b^!-8&(ias$rzg' +SECRET_KEY = '(ob412sq1npyyuvfi*b@eby$ip=1rfl*l*b%8f4&l@)3iu$&4#' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( @@ -69,10 +68,10 @@ 'django.contrib.auth.middleware.AuthenticationMiddleware', ) -ROOT_URLCONF = 'scipy-in.urls' +ROOT_URLCONF = 'scipy.urls' TEMPLATE_DIRS = ( - os.path.join(ROOT_PATH, 'template'), + os.path.join(ROOT_PATH, 'template'), # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. @@ -83,5 +82,5 @@ 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', - 'scipy-in.content', + 'scipy.conference', ) diff -r 7358eeae14d8 -r 4e819dd96e1f site-content/default.css --- a/site-content/default.css Thu Sep 24 15:20:30 2009 +0530 +++ b/site-content/default.css Fri Sep 25 00:27:42 2009 +0530 @@ -7,7 +7,7 @@ body { margin: 0; padding: 0; - background: #FFFFFF url(/site_media/images/img01.jpg) repeat-x; + background: #FFFFFF url(images/img01.jpg) repeat-x; text-align: justify; font: 15px Arial, Helvetica, sans-serif; color: #626262; @@ -20,7 +20,7 @@ input { padding: 5px; - background: #FEFEFE url(/site_media/images/img13.gif) repeat-x; + background: #FEFEFE url(images/img13.gif) repeat-x; border: 1px solid #626262; font: normal 1em Arial, Helvetica, sans-serif; } @@ -202,13 +202,13 @@ .post .links .more { width: 128px; height: 30px; - background: url(/site_media/images/img03.jpg) no-repeat left center; + background: url(images/img03.jpg) no-repeat left center; } .post .links .comments { width: 152px; height: 30px; - background: url(/site_media/images/img04.jpg) no-repeat left center; + background: url(images/img04.jpg) no-repeat left center; } /* Sidebar */ @@ -227,7 +227,7 @@ #sidebar li { margin-bottom: 10px; - background: url(/site_media/images/img10.gif) no-repeat left bottom; + background: url(images/img10.gif) no-repeat left bottom; } #sidebar li ul { @@ -237,12 +237,12 @@ #sidebar li li { margin: 0; padding-left: 20px; - background: url(/site_media/images/img11.gif) no-repeat 5px 50%; + background: url(images/img11.gif) no-repeat 5px 50%; } #sidebar h2 { padding: 30px 30px 20px 30px; - background: url(/site_media/images/img09.gif) no-repeat; + background: url(images/img09.gif) no-repeat; font-weight: normal; font-size: 1.6em; color: #302D26; @@ -259,7 +259,7 @@ padding: 0px; height: 20px; width: auto; - background: #DFDFDF url(/site_media/images/img14.gif) repeat-x; + background: #DFDFDF url(images/img14.gif) repeat-x; font-weight: bold; } @@ -276,7 +276,7 @@ padding: 5px; width: 150px; height: auto; - background: #FEFEFE url(/site_media/images/img13.gif) repeat-x; + background: #FEFEFE url(images/img13.gif) repeat-x; border: 1px solid #626262; font: normal 1em Arial, Helvetica, sans-serif; } @@ -288,7 +288,7 @@ /* Categories */ #sidebar #categories li { - background: url(/site_media/images/img12.gif) no-repeat left center; + background: url(images/img12.gif) no-repeat left center; } /* Calendar */ @@ -334,7 +334,7 @@ #footer { padding: 50px 0 10px 0; - background: #757575 url(/site_media/images/img08.gif) repeat-x; + background: #757575 url(images/img08.gif) repeat-x; } #footer p { @@ -356,15 +356,15 @@ } #footer .rss { - background: url(/site_media/images/img18.gif) no-repeat left center; + background: url(images/img18.gif) no-repeat left center; } #footer .xhtml { - background: url(/site_media/images/img19.gif) no-repeat left center; + background: url(images/img19.gif) no-repeat left center; } #footer .css { - background: url(/site_media/images/img20.gif) no-repeat left center; + background: url(images/img20.gif) no-repeat left center; } #footer .legal a { diff -r 7358eeae14d8 -r 4e819dd96e1f template/index.html --- a/template/index.html Thu Sep 24 15:20:30 2009 +0530 +++ b/template/index.html Fri Sep 25 00:27:42 2009 +0530 @@ -18,7 +18,7 @@ {% trans "SciPy India 2009" %} - + {% block head %} {% endblock %} @@ -32,7 +32,7 @@