diff options
Diffstat (limited to 'scipy')
-rw-r--r-- | scipy/__init__.py | 0 | ||||
-rw-r--r-- | scipy/forms.py | 36 | ||||
-rw-r--r-- | scipy/settings.py | 166 | ||||
-rw-r--r-- | scipy/templates/login.html | 12 | ||||
-rw-r--r-- | scipy/templates/profile.html | 5 | ||||
-rw-r--r-- | scipy/templates/register.html | 10 | ||||
-rw-r--r-- | scipy/templates/registration/password_change_done.html | 8 | ||||
-rw-r--r-- | scipy/templates/registration/password_change_form.html | 7 | ||||
-rw-r--r-- | scipy/templates/upload-document.html | 12 | ||||
-rw-r--r-- | scipy/urls.py | 22 | ||||
-rw-r--r-- | scipy/views.py | 99 | ||||
-rw-r--r-- | scipy/wsgi.py | 35 |
12 files changed, 412 insertions, 0 deletions
diff --git a/scipy/__init__.py b/scipy/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/scipy/__init__.py diff --git a/scipy/forms.py b/scipy/forms.py new file mode 100644 index 0000000..a1e9e61 --- /dev/null +++ b/scipy/forms.py @@ -0,0 +1,36 @@ +from django import forms +from django.db import models +from django.contrib.auth.models import User +from django.contrib.auth.forms import UserCreationForm, UserChangeForm + +from website.models import Paper + +class UserLoginForm(forms.Form): + username = forms.CharField( + widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Username'}), + label='' + ) + password = forms.CharField( + widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'Password'}), + label='' + ) + +class UserRegisterForm(UserCreationForm): + + class Meta: + model = User + fields = ('first_name', 'last_name', 'email', 'username', 'password1', 'password2') + + +class UserProfileForm(UserChangeForm): + password = forms.CharField(widget=forms.PasswordInput()) + password1 = forms.CharField(widget=forms.PasswordInput()) + class Meta: + model = User + fields = ('first_name', 'last_name', 'email', 'username') + +class DocumentUploadForm(forms.ModelForm): + + class Meta: + model = Paper + exclude = ('user', 'verified') diff --git a/scipy/settings.py b/scipy/settings.py new file mode 100644 index 0000000..e0d3451 --- /dev/null +++ b/scipy/settings.py @@ -0,0 +1,166 @@ +# Django settings for scipy project. +from os.path import * +from local import * + + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + # ('Your Name', 'your_email@example.com'), +) + +PROJDIR = abspath(dirname(__file__)) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': 'scipy', # Or path to database file if using sqlite3. + # The following settings are not used with sqlite3: + 'USER': 'root', + 'PASSWORD': db_pass, + 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. + 'PORT': '', # Set to empty string for default. + } +} + +# Hosts/domain names that are valid for this site; required if DEBUG is False +# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts +ALLOWED_HOSTS = [] + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# In a Windows environment this must be set to your system time zone. +TIME_ZONE = 'Asia/Calcutta' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'en-us' + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# If you set this to False, Django will not format dates, numbers and +# calendars according to the current locale. +USE_L10N = True + +# If you set this to False, Django will not use timezone-aware datetimes. +USE_TZ = True + +# Absolute filesystem path to the directory that will hold user-uploaded files. +# Example: "/var/www/example.com/media/" +MEDIA_ROOT = join(PROJDIR, '../static') + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash. +# Examples: "http://example.com/media/", "http://media.example.com/" +MEDIA_URL = '/static/downloads/' + +# Absolute path to the directory static files should be collected to. +# Don't put anything in this directory yourself; store your static files +# in apps' "static/" subdirectories and in STATICFILES_DIRS. +# Example: "/var/www/example.com/static/" +STATIC_ROOT = '' + +# URL prefix for static files. +# Example: "http://example.com/static/", "http://static.example.com/" +STATIC_URL = '/static/' + +# Additional locations of static files +STATICFILES_DIRS = ( + # Put strings here, like "/home/html/static" or "C:/www/django/static". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. + join(PROJDIR, '../website/static'), + join(PROJDIR, '../static'), +) + +# List of finder classes that know how to find static files in +# various locations. +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +# 'django.contrib.staticfiles.finders.DefaultStorageFinder', +) + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 'rgrma_y4i*q(uv6pfu6=n^6d#9ll0d$xm_w9k_+im^0jsdfy0i' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + # Uncomment the next line for simple clickjacking protection: + # 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +ROOT_URLCONF = 'scipy.urls' + +# Python dotted path to the WSGI application used by Django's runserver. +WSGI_APPLICATION = 'scipy.wsgi.application' + +TEMPLATE_DIRS = ( + # 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. + join(PROJDIR, 'templates'), + join(PROJDIR, '../website/templates'), +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.staticfiles', + # Uncomment the next line to enable the admin: + 'django.contrib.admin', + # Uncomment the next line to enable admin documentation: + # 'django.contrib.admindocs', + 'website', +) + +# A sample logging configuration. The only tangible logging +# performed by this configuration is to send an email to +# the site admins on every HTTP 500 error when DEBUG=False. +# See http://docs.djangoproject.com/en/dev/topics/logging for +# more details on how to customize your logging configuration. +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + } + }, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + } + }, + 'loggers': { + 'django.request': { + 'handlers': ['mail_admins'], + 'level': 'ERROR', + 'propagate': True, + }, + } +} diff --git a/scipy/templates/login.html b/scipy/templates/login.html new file mode 100644 index 0000000..76964b1 --- /dev/null +++ b/scipy/templates/login.html @@ -0,0 +1,12 @@ +{% extends 'page.html' %} +{% block content %} +<div class="large-6 large-centered columns"> + <form class="form-signin" action="/accounts/login/" method="POST" enctype="multipart/form-data"> {% csrf_token %} + <h3 class="form-signin-heading">Please sign in</h3> + {{ form.as_p }} + <input type="hidden" name = "next" value="{{ next }}"> + <button class="success expand" type="submit">Sign in</button> + </form> + <h6>Dont have an scipy account? <a href="/accounts/register"><u>Register Here.</u></a></h6> +</div> +{% endblock %} diff --git a/scipy/templates/profile.html b/scipy/templates/profile.html new file mode 100644 index 0000000..f6c629a --- /dev/null +++ b/scipy/templates/profile.html @@ -0,0 +1,5 @@ +<h3>Register</h3> +<form action="/accounts/profile/" method="POST"> {% csrf_token %} + {{ form.as_p }} + <input type="submit" value="Update"> +</form> diff --git a/scipy/templates/register.html b/scipy/templates/register.html new file mode 100644 index 0000000..07014ae --- /dev/null +++ b/scipy/templates/register.html @@ -0,0 +1,10 @@ +{% extends 'page.html' %} +{% block content %} +<div class="large-6 large-centered columns"> + <form class="form-register" action="/accounts/register/" method="POST"> {% csrf_token %} + <h3 class="form-signin-heading">Please enter your details . . .</h3> + {{ form.as_p }} + <button class="success expand" type="submit">Sign Up</button> + </form> +</div> +{% endblock %} diff --git a/scipy/templates/registration/password_change_done.html b/scipy/templates/registration/password_change_done.html new file mode 100644 index 0000000..a02b3c4 --- /dev/null +++ b/scipy/templates/registration/password_change_done.html @@ -0,0 +1,8 @@ +<div class="container"> + <div class="form-password"> + <h2>Password Changed Successfully</h2> + <p style="color: #ffffff; text-align: center"> + Click <a href="/bazaar"><b>here</b></a> to go back to dashboard. + </p> + </div> +</div> diff --git a/scipy/templates/registration/password_change_form.html b/scipy/templates/registration/password_change_form.html new file mode 100644 index 0000000..1d54042 --- /dev/null +++ b/scipy/templates/registration/password_change_form.html @@ -0,0 +1,7 @@ +<div class="container"> + <form class="form-password" action="/accounts/password-change/" method="POST"> {% csrf_token %} + <h2 class="form-signin-heading">Password Change . . .</h2> + {{ form.as_p }} + <button class="btn btn-lg btn-inverse btn-block" type="submit">Change Password</button> + </form> +</div> <!-- container --> diff --git a/scipy/templates/upload-document.html b/scipy/templates/upload-document.html new file mode 100644 index 0000000..f72ebb3 --- /dev/null +++ b/scipy/templates/upload-document.html @@ -0,0 +1,12 @@ +{% extends 'page.html' %} +{% block content %} +<div class="large-6 large-centered columns"> + <form class="form-signin" action="/accounts/upload-document/" method="POST" enctype="multipart/form-data"> {% csrf_token %} + <h3 class="form-signin-heading">Upload your abstract</h3> + {{ form }} + <input type="hidden" name = "next" value="{{ next }}"> + <button class="success expand" type="submit">Submit</button> + </form> + <h6>Dont have an scipy account? <a href="/accounts/register"><u>Register Here.</u></a></h6> +</div> +{% endblock %} diff --git a/scipy/urls.py b/scipy/urls.py new file mode 100644 index 0000000..6f7c247 --- /dev/null +++ b/scipy/urls.py @@ -0,0 +1,22 @@ +from django.conf.urls import patterns, include, url + +from django.contrib import admin +admin.autodiscover() + +urlpatterns = patterns('', + + # Website urls + url(r'^2013/', include('website.urls', namespace='website')), + url(r'^', include('website.urls', namespace='website')), + # Accounts urls + url(r'accounts/login/$', 'scipy.views.user_login'), + url(r'accounts/logout/$', 'scipy.views.user_logout'), + url(r'accounts/register/$', 'scipy.views.user_register'), + url(r'accounts/profile/$', 'scipy.views.user_profile'), + url(r'accounts/upload-document/$', 'scipy.views.upload_document', name='upload-document'), + # Reusing the admin password reset + url(r'accounts/password-change/$', 'django.contrib.auth.views.password_change', name='password_change'), + url(r'accounts/password-change/done/$', 'django.contrib.auth.views.password_change_done', name='password_change_done'), + # Uncomment the next line to enable the admin: + url(r'^admin/', include(admin.site.urls)), +) diff --git a/scipy/views.py b/scipy/views.py new file mode 100644 index 0000000..cccbdd2 --- /dev/null +++ b/scipy/views.py @@ -0,0 +1,99 @@ +from django.http import HttpResponse, HttpResponseRedirect +from django.core.context_processors import csrf +from django.shortcuts import render_to_response +from django.contrib.auth.models import User +from django.contrib.auth import authenticate, login, logout +from django.contrib.auth.decorators import login_required + +from scipy.forms import UserLoginForm, UserRegisterForm, UserProfileForm, DocumentUploadForm + +# User Login View +def user_login(request): + if request.user.is_anonymous(): + if request.method == 'POST': + username = request.POST['username'] + password = request.POST['password'] + user = authenticate(username=username, password=password) + if user is not None: + if user.is_active: + login(request, user) + return HttpResponseRedirect(request.POST['next']) + else: + return HttpResponse("Not active") + else: + return HttpResponse("Invalid username or password") + else: + form = UserLoginForm() + + next = '/accounts/upload-document/' + if 'next' in request.GET: + next = request.GET['next'] + + context = {} + context.update(csrf(request)) + context['form'] = form + context['next'] = next + return render_to_response('login.html', context) + else: + return HttpResponseRedirect('/accounts/upload-document') + +# User Logout View +def user_logout(request): + logout(request) + return HttpResponseRedirect('/2013') + +# User Register View +def user_register(request): + if request.user.is_anonymous(): + if request.method == 'POST': + form = UserRegisterForm(request.POST) + if form.is_valid: + form.save() + return HttpResponseRedirect('/accounts/upload-document') + else: + form = UserRegisterForm() + context = {} + context.update(csrf(request)) + context['form'] = form + return render_to_response('register.html', context) + else: + return HttpResponseRedirect('/accounts/upload-document') + +# User Profile View +def user_profile(request): + if request.user.is_authenticated(): + context = {} + context.update(csrf(request)) + context['form'] = UserProfileForm(instance=request.user) + return render_to_response('profile.html', context) + else: + return HttpResponseRedirect('/accounts/login?next=/accounts/profile') + +# Document Upload View +@login_required +def upload_document(request): + if request.method == 'POST': + form = DocumentUploadForm(request.POST, request.FILES) + if form.is_valid(): + data = form.save(commit=False) + data.user = request.user + data.verified = False + data.save() + return HttpResponseRedirect("/2013/call-for-papers/?status=up") + else: + context = {} + context.update(csrf(request)) + context['form'] = form + return render_to_response('upload-document.html', context) + else: + form = DocumentUploadForm() + + context = {} + context.update(csrf(request)) + context['form'] = DocumentUploadForm() + return render_to_response('upload-document.html', context) + + + + + diff --git a/scipy/wsgi.py b/scipy/wsgi.py new file mode 100644 index 0000000..3e48e88 --- /dev/null +++ b/scipy/wsgi.py @@ -0,0 +1,35 @@ +""" +WSGI config for scipy project. + +This module contains the WSGI application used by Django's development server +and any production WSGI deployments. It should expose a module-level variable +named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover +this application via the ``WSGI_APPLICATION`` setting. + +Usually you will have the standard Django WSGI application here, but it also +might make sense to replace the whole Django WSGI application with a custom one +that later delegates to the Django one. For example, you could introduce WSGI +middleware here, or combine a Django application with an application of another +framework. + +""" +import os +import sys + +sys.path.append("/Site/SciPy-India/scipy2013/") + +# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks +# if running multiple sites in the same mod_wsgi process. To fix this, use +# mod_wsgi daemon mode with each site in its own daemon process, or use +# os.environ["DJANGO_SETTINGS_MODULE"] = "scipy.settings" +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "scipy.settings") + +# This application object is used by any WSGI server configured to use this +# file. This includes Django's development server, if the WSGI_APPLICATION +# setting points here. +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() + +# Apply WSGI middleware here. +# from helloworld.wsgi import HelloWorldApplication +# application = HelloWorldApplication(application) |