Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jcnix committed Dec 25, 2010
0 parents commit b7b2e78
Show file tree
Hide file tree
Showing 63 changed files with 2,511 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
@@ -0,0 +1,7 @@
*.pyc
static/media/uploads/*
deploy.sh
rsyncignore
settings.py
localsettings.py

674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions CREDITS
@@ -0,0 +1,10 @@
I'm using Django-SocialAuth for authentication.
http://github.com/uswaretech/Django-Socialauth

These files I got from the SocialAuth project:
static/media/css/openid.css
static/media/css/socialauth.css
static/media/js/jquery-1.2.6.min.js
static/media/js/openid-jquery.js
everything in static/media/images

Empty file added __init__.py
Empty file.
10 changes: 10 additions & 0 deletions apache/django.wsgi
@@ -0,0 +1,10 @@
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'shade.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

sys.path.append('/var/www')

93 changes: 93 additions & 0 deletions localsettings.py.example
@@ -0,0 +1,93 @@
OPENID_REDIRECT_NEXT = '/accounts/openid/done/'

OPENID_SREG = {"requred": "nickname, email, fullname",
"optional":"postcode, country",
"policy_url": ""}

#example should be something more like the real thing, i think
OPENID_AX = [{"type_uri": "http://axschema.org/contact/email",
"count": 1,
"required": True,
"alias": "email"},
{"type_uri": "http://axschema.org/schema/fullname",
"count":1 ,
"required": False,
"alias": "fname"}]

OPENID_AX_PROVIDER_MAP = {'Google': {'email': 'http://axschema.org/contact/email',
'firstname': 'http://axschema.org/namePerson/first',
'lastname': 'http://axschema.org/namePerson/last'},
'Default': {'email': 'http://axschema.org/contact/email',
'fullname': 'http://axschema.org/namePerson',
'nickname': 'http://axschema.org/namePerson/friendly'}
}

TWITTER_CONSUMER_KEY = ''
TWITTER_CONSUMER_SECRET = ''

FACEBOOK_APP_ID = ''
FACEBOOK_API_KEY = ''
FACEBOOK_SECRET_KEY = ''

LINKEDIN_CONSUMER_KEY = ''
LINKEDIN_CONSUMER_SECRET = ''

## if any of this information is desired for your app
FACEBOOK_EXTENDED_PERMISSIONS = (
#'publish_stream',
#'create_event',
#'rsvp_event',
#'sms',
#'offline_access',
#'email',
#'read_stream',
#'user_about_me',
#'user_activites',
#'user_birthday',
#'user_education_history',
#'user_events',
#'user_groups',
#'user_hometown',
#'user_interests',
#'user_likes',
#'user_location',
#'user_notes',
#'user_online_presence',
#'user_photo_video_tags',
#'user_photos',
#'user_relationships',
#'user_religion_politics',
#'user_status',
#'user_videos',
#'user_website',
#'user_work_history',
#'read_friendlists',
#'read_requests',
#'friend_about_me',
#'friend_activites',
#'friend_birthday',
#'friend_education_history',
#'friend_events',
#'friend_groups',
#'friend_hometown',
#'friend_interests',
#'friend_likes',
#'friend_location',
#'friend_notes',
#'friend_online_presence',
#'friend_photo_video_tags',
#'friend_photos',
#'friend_relationships',
#'friend_religion_politics',
#'friend_status',
#'friend_videos',
#'friend_website',
#'friend_work_history',
)


AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'socialauth.auth_backends.OpenIdBackend',
'socialauth.auth_backends.FacebookBackend',
)
11 changes: 11 additions & 0 deletions manage.py
@@ -0,0 +1,11 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)

if __name__ == "__main__":
execute_manager(settings)
121 changes: 121 additions & 0 deletions settings.py.example
@@ -0,0 +1,121 @@
# Django settings for shade project.

import socket
if socket.gethostname() == 'gentoobox':
DEBUG = True
else:
DEBUG = False

TEMPLATE_DEBUG = DEBUG

ADMINS = (
('', ''),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'shade', # Or path to database file if using sqlite3.
'USER': 'postgres', # Not used with sqlite3.
'PASSWORD': 'test', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '5432', # Set to empty string for default. Not used with sqlite3.
}
}

# 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.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# 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

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/var/www/shade/static/media'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/shade/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = ''

# 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',
)

TEMPLATE_CONTEXT_PROCESSORS = (
'shade.social.contexts.my_user',
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.media',
'socialauth.context_processors.facebook_api_key',
)

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',
'openid_consumer.middleware.OpenIDMiddleware',
)

ROOT_URLCONF = 'shade.urls'

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.
'/var/www/shade/templates'
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'shade.social',
'socialauth',
'openid_consumer',
)

AUTH_PROFILE_MODULE = 'social.UserProfile'
LOGIN_REDIRECT_URL = '/dashboard/'
LOGOUT_REDIRECT_URL = '/'
try:
from localsettings import *
except ImportError:
pass

Empty file added social/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions social/contexts.py
@@ -0,0 +1,9 @@
from shade.social.models import User

def my_user(request):
try:
my_user = request.session['user']
return {'my_user': my_user}
except KeyError:
return {}

67 changes: 67 additions & 0 deletions social/forms.py
@@ -0,0 +1,67 @@
from django import forms
from django.contrib.auth.models import User
from django.core.validators import MinLengthValidator
from shade.social.models import UserProfile, Message, Comment, Picture
import hashlib

class SettingsForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ('url', 'gender', 'hometown', 'home_state', 'home_country',
'current_town', 'current_state', 'current_country',
'bio',)

def clean(self):
super(forms.ModelForm, self).clean()
if ' ' in self.cleaned_data['url']:
self._errors['url'] = [u'URL cannot contain spaces.']
return self.cleaned_data

class MessageForm(forms.ModelForm):
class Meta:
model = Message
fields = ('recipient', 'subject', 'body')
widgets = {
'body': forms.Textarea(attrs={'cols': 80, 'rows': 7}),
}

def clean(self):
super(forms.ModelForm, self).clean()
subject = self.cleaned_data['subject']
if subject.isspace():
self.cleaned_data['subject'] = 'No Subject'

recipient = self.cleaned_data['recipient']
author = self.instance.author
if recipient not in author.get_profile().friends.all():
self._errors['url'] = [u'User not in your friends.']

return self.cleaned_data

class CommentForm(forms.ModelForm):
class Meta:
model = Comment
fields = ('post',)
widgets = {
'post': forms.Textarea(attrs={'cols': 80, 'rows': 7}),
}

class AlbumForm(forms.Form):
name = forms.CharField()

class PictureForm(forms.ModelForm):
class Meta:
model = Picture
fields = ('image', 'caption',)

class SearchForm(forms.Form):
name = forms.CharField(required=False)
email = forms.EmailField(required=False)

def clean(self):
name = self.cleaned_data['name']
name_l = name.split(' ')
if len(name_l) != 2:
self._errors['name'] = [u'Use first name and last name']
return self.cleaned_data

0 comments on commit b7b2e78

Please sign in to comment.