Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 3f161d4e5deedbd88c6458e317e76ee945f27215 @q committed Sep 4, 2011
@@ -0,0 +1,5 @@
+*.pyc
+.idea/*
+local_settings.py
+*.db
+.DS_Store
No changes.
No changes.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,10 @@
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+def server_error(request, template_name='500.html'):
+ """
+ 500 error handler.
+
+ Templates: `500.html`
+ """
+ return render_to_response(template_name, context_instance=RequestContext(request))
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+from django.core.management import execute_manager
+import imp
+try:
+ imp.find_module('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" % __file__)
+ sys.exit(1)
+
+import settings
+
+if __name__ == "__main__":
+ execute_manager(settings)
@@ -0,0 +1,181 @@
+# Django settings for lolaws project.
+import os
+PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+ # ('Your Name', 'your_email@example.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+ 'NAME': 'lolaws.db', # Or path to database file if using sqlite3.
+ 'USER': '', # Not used with sqlite3.
+ 'PASSWORD': '', # Not used with sqlite3.
+ 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
+ 'PORT': '', # 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/New_York'
+
+# 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 filesystem path to the directory that will hold user-uploaded files.
+# Example: "/home/media/media.lawrence.com/media/"
+MEDIA_ROOT = ''
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
+MEDIA_URL = '/media/'
+
+# 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: "/home/media/media.lawrence.com/static/"
+STATIC_ROOT = os.path.realpath(os.path.join(PROJECT_ROOT, "static_filez"))
+
+# URL prefix for static files.
+# Example: "http://media.lawrence.com/static/"
+STATIC_URL = 'http://BUCKETNAME.s3.amazonaws.com/'
+
+# URL prefix for admin static files -- CSS, JavaScript and images.
+# Make sure to use a trailing slash.
+# Examples: "http://foo.com/static/admin/", "/static/admin/".
+ADMIN_MEDIA_PREFIX = '/static/admin/'
+
+# 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.
+)
+
+# 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 = 'e4(!l7s%k+augrntypmwgvje6lvrgk9ygezz#1tqb0y*2s3ln5'
+
+# 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',
+)
+
+ROOT_URLCONF = 'lolaws.urls'
+
+TEMPLATE_DIRS = (
+ os.path.join(PROJECT_ROOT, "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',
+
+ # external
+ 'storages',
+ 'django_ses',
+ 'django_extensions',
+
+ # disapp
+ 'lolaws.core',
+ 'lolaws.uploadr',
+
+)
+
+# 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.
+# 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,
+ 'handlers': {
+ 'mail_admins': {
+ 'level': 'ERROR',
+ 'class': 'django.utils.log.AdminEmailHandler'
+ }
+ },
+ 'loggers': {
+ 'django.request': {
+ 'handlers': ['mail_admins'],
+ 'level': 'ERROR',
+ 'propagate': True,
+ },
+ }
+}
+
+
+# s3 storage
+STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
+
+#DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
+DEFAULT_FILE_STORAGE = 'storages.backends.s3.S3Storage'
+
+AWS_ACCESS_KEY_ID = "SETME"
+AWS_SECRET_ACCESS_KEY = "SETME"
+AWS_STORAGE_BUCKET_NAME = "SETME"
+
+from S3 import CallingFormat
+AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
+AWS_HEADERS = {
+ 'Cache-Control': 'max-age=86400',
+}
+
+EMAIL_BACKEND = 'django_ses.SESBackend'
+DEFAULT_FROM_EMAIL = 'lolaws <YOUR@EMAIL.LOL>'
+EMAIL_SUBJECT_PREFIX = '[lolaws] '
+
+try:
+ from local_settings import *
+except ImportError:
+ pass
@@ -0,0 +1,3 @@
+lol 404<br/>
+
+<a href="{% url uploadr-upload %}">Upload!</a><br/>
@@ -0,0 +1,3 @@
+lol 500<br/>
+
+<a href="{% url uploadr-upload %}">Upload!</a><br/>
@@ -0,0 +1,20 @@
+<html>
+ <head>
+ <title>lolaws {% block title %}lolaws{% endblock %}</title>
+ <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/960.css">
+ </head>
+ <body>
+ <header>
+ <nav>
+ <div class="container_16 clearfix">
+ <a href="{% url uploadr-upload %}">Upload Image!</a> | <a href="{% url uploadr-all %}">View All!</a>
+ </div>
+ </nav>
+ </header>
+ <div class="container container_16">
+ <div class="grid_16">
+ {% block content %}{% endblock %}
+ </div>
+ </div>
+ </body>
+</html>
@@ -0,0 +1,11 @@
+{% extends "base.html" %}
+
+{% block title %}- everything!{% endblock %}
+
+{% block content %}
+{% for upload in filez %}
+ {{ upload.upload_date }}<br>
+ <img src="{{ upload.image.url }}" width="80%"><br/>
+{% endfor %}
+
+{% endblock %}
@@ -0,0 +1,20 @@
+{% extends "base.html" %}
+
+{% block title %}- success!{% endblock %}
+
+{% block content %}
+ <h2>Image Uploaded!</h2>
+ <img src="{{ upload.image.url }}" width="50%"><br/>
+
+ {% if message %}
+ <h3 style="color:{{ color }};">{{ message }}</h3>
+ {% endif %}
+ <h3>Email this image to someone:</h3>
+ <form method="POST" action="">
+ {% csrf_token %}
+ {{ form.as_p }}
+ <button type="submit" class="pretty-button">GO-GO-GADGET SPAM!</button>
+ </form>
+
+ <a href="{% url uploadr-upload %}">Upload Another!</a>
+{% endblock %}
@@ -0,0 +1,19 @@
+{% extends "base.html" %}
+
+{% block title %}- uploadr{% endblock %}
+
+{% block content %}
+ <form method="POST" action="" enctype="multipart/form-data">
+ {% csrf_token %}
+ {{ form.as_p }}
+ <button type="submit" class="pretty-button">TO 'THE CLOUD!'</button>
+ </form>
+<br/>
+
+{% for upload in recent_uploads %}
+ {{ upload.upload_date }}<br>
+ <img src="{{ upload.image.url }}" width="50%"><br/>
+ <br/>
+{% endfor %}
+
+{% endblock %}
No changes.
@@ -0,0 +1,8 @@
+from django.contrib import admin
+
+from lolaws.uploadr.models import StoredImage
+
+class StoredImageAdmin(admin.ModelAdmin):
+ list_display = ('image','upload_date')
+
+admin.site.register(StoredImage, StoredImageAdmin)
@@ -0,0 +1,10 @@
+from django import forms
+
+from lolaws.uploadr.models import StoredImage
+
+class StoredImageUploadForm(forms.ModelForm):
+ class Meta:
+ model = StoredImage
+
+class EmailImageForm(forms.Form):
+ address = forms.EmailField(required=True)
@@ -0,0 +1,9 @@
+from django.db import models
+
+# Create your models here.
+class StoredImage(models.Model):
+ image = models.ImageField(upload_to="filez")
+ upload_date = models.DateTimeField(auto_now_add=True)
+
+ class Meta:
+ ordering = ['-upload_date']
@@ -0,0 +1,8 @@
+from django.conf.urls.defaults import patterns, url
+from lolaws.uploadr.views import *
+
+urlpatterns = patterns('',
+ url(r'^$', view=upload, name='uploadr-upload'),
+ url(r'^success/(?P<image_id>\d+)/', view=success, name='uploadr-success'),
+ url(r'^all/$', view=all, name='uploadr-all'),
+)
Oops, something went wrong.

0 comments on commit 3f161d4

Please sign in to comment.