[djangodb commit] r679 - in trunk/misc/patrick: admintest django_bookmarks django_bookmarks/bookmarks django_bookma...

0 views
Skip to first unread message

codesite...@google.com

unread,
Dec 8, 2008, 5:54:29 AM12/8/08
to compute...@googlegroups.com
Author: PatrickChan7
Date: Mon Dec 8 02:39:38 2008
New Revision: 679

Added:
trunk/misc/patrick/django_bookmarks/
trunk/misc/patrick/django_bookmarks/__init__.py
trunk/misc/patrick/django_bookmarks/bookmarks/
trunk/misc/patrick/django_bookmarks/bookmarks/__init__.py
trunk/misc/patrick/django_bookmarks/bookmarks/models.py
trunk/misc/patrick/django_bookmarks/bookmarks/urls.py
trunk/misc/patrick/django_bookmarks/bookmarks/views.py
trunk/misc/patrick/django_bookmarks/local_settings.py
trunk/misc/patrick/django_bookmarks/manage.py
trunk/misc/patrick/django_bookmarks/settings.py
trunk/misc/patrick/django_bookmarks/sqlite3 (contents, props changed)
trunk/misc/patrick/django_bookmarks/templates/
trunk/misc/patrick/django_bookmarks/templates/main_page.html
trunk/misc/patrick/django_bookmarks/templates/user_page.html
trunk/misc/patrick/django_bookmarks/urls.py
Modified:
trunk/misc/patrick/admintest/settings.py
trunk/misc/patrick/admintest/urls.py
trunk/misc/patrick/wjContact/contacts/models.py

Log:
django bookmark book review

Modified: trunk/misc/patrick/admintest/settings.py
==============================================================================
--- trunk/misc/patrick/admintest/settings.py (original)
+++ trunk/misc/patrick/admintest/settings.py Mon Dec 8 02:39:38 2008
@@ -32,7 +32,7 @@

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
-USE_I18N = True
+USE_I18N = False

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"

Modified: trunk/misc/patrick/admintest/urls.py
==============================================================================
--- trunk/misc/patrick/admintest/urls.py (original)
+++ trunk/misc/patrick/admintest/urls.py Mon Dec 8 02:39:38 2008
@@ -12,6 +12,7 @@
# to INSTALLED_APPS to enable admin documentation:
(r'^admin/doc/', include('django.contrib.admindocs.urls')),

+ (r'^admin/contacts/report$', 'admintest.contacts.admin_views.report'),
# Uncomment the next line to enable the admin:
(r'^admin/(.*)', admin.site.root),
)

Added: trunk/misc/patrick/django_bookmarks/__init__.py
==============================================================================

Added: trunk/misc/patrick/django_bookmarks/bookmarks/__init__.py
==============================================================================

Added: trunk/misc/patrick/django_bookmarks/bookmarks/models.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/django_bookmarks/bookmarks/models.py Mon Dec 8
02:39:38 2008
@@ -0,0 +1,13 @@
+from django.db import models
+from django.contrib.auth.models import User
+
+# Create your models here.
+from django.db import models
+
+class Link(models.Model):
+ url = models.URLField(unique=True)
+
+class Bookmark(models.Model):
+ title = models.CharField(max_length=200)
+ user = models.ForeignKey(User)
+ link = models.ForeignKey(Link)

Added: trunk/misc/patrick/django_bookmarks/bookmarks/urls.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/django_bookmarks/bookmarks/urls.py Mon Dec 8
02:39:38 2008
@@ -0,0 +1,7 @@
+from django.conf.urls.defaults import *
+from bookmarks.views import *
+
+urlpatterns = patterns('',
+ (r'^$', main_page),
+ (r'^user/(\w+)/$', user_page),
+)

Added: trunk/misc/patrick/django_bookmarks/bookmarks/views.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/django_bookmarks/bookmarks/views.py Mon Dec 8
02:39:38 2008
@@ -0,0 +1,46 @@
+from django.http import HttpResponse, Http404
+from django.contrib.auth.models import User
+from django.template import Context
+from django.template.loader import get_template
+
+"""
+def main_page(request):
+ output = '''
+ <html>
+ <head><title>%s</title></head>
+ <body>
+ <h1>%s</h1><p>%s</p>
+ </body>
+ </html>
+ ''' % ( 'Django Bookmarks',
+ 'Welcome to Django Bookmarks',
+ 'Where you can store and share bookmarks!')
+ return HttpResponse(output)
+"""
+
+
+def main_page(request):
+ template = get_template('main_page.html')
+ variables = Context({
+ 'head_title': 'Django Bookmarks',
+ 'page_title': 'Welcome to Django Bookmarks',
+ 'page_body': 'Where you can store and share bookmarks!'
+ })
+ output = template.render(variables)
+ return HttpResponse(output)
+
+def user_page(request, username):
+ try:
+ user = User.objects.get(username=username)
+ except User.DoesNotExist:
+ raise Http404('Requested user not found.')
+
+ bookmarks = user.bookmark_set.all()
+
+ template = get_template('user_page.html')
+ variables = Context({
+ 'username': username,
+ 'bookmarks': bookmarks
+ })
+ output = template.render(variables)
+ return HttpResponse(output)

Added: trunk/misc/patrick/django_bookmarks/local_settings.py
==============================================================================

Added: trunk/misc/patrick/django_bookmarks/manage.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/django_bookmarks/manage.py Mon Dec 8 02:39:38 2008
@@ -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)

Added: trunk/misc/patrick/django_bookmarks/settings.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/django_bookmarks/settings.py Mon Dec 8 02:39:38 2008
@@ -0,0 +1,82 @@
+# Django settings for django_bookmarks project.
+import os.path
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+ # ('Your Name', 'your_...@domain.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASE_ENGINE = 'sqlite3'
# 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = 'sqlite3' # 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.
+DATABASE_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.
+# 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
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = ''
+
+# 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 = ''
+
+# 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 = '9_6eaw*uc4!129)l7cc@zw6jj*1f1ylrsb5pu-qw(4@%a)_bv$'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+# 'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+)
+
+ROOT_URLCONF = 'django_bookmarks.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.
+ os.path.join(os.path.dirname(__file__), 'templates'),
+)
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django_bookmarks.bookmarks',
+)

Added: trunk/misc/patrick/django_bookmarks/sqlite3
==============================================================================
Binary file. No diff available.

Added: trunk/misc/patrick/django_bookmarks/templates/main_page.html
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/django_bookmarks/templates/main_page.html Mon Dec 8
02:39:38 2008
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <title>{{ head_title }}</title>
+ </head>
+ <body>
+ <h1>{{ page_title }}</h1>
+ <p>{{ page_body }}</p>
+ </body>
+</html>

Added: trunk/misc/patrick/django_bookmarks/templates/user_page.html
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/django_bookmarks/templates/user_page.html Mon Dec 8
02:39:38 2008
@@ -0,0 +1,18 @@
+<html>
+ <head>
+ <title>Django Bookmarks - User: {{ username }}</title>
+ </head>
+ <body>
+ <h1>Bookmarks for {{ username }}</h1>
+ {% if bookmarks %}
+ <ul>
+ {% for bookmark in bookmarks %}
+ <li><a href="{{ bookmark.link.url }}">
+ {{ bookmark.title }}</a></li>
+ {% endfor %}
+ </ul>
+ {% else %}
+ <p>No bookmarks found.</p>
+ {% endif %}
+ </body>
+</html>

Added: trunk/misc/patrick/django_bookmarks/urls.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/django_bookmarks/urls.py Mon Dec 8 02:39:38 2008
@@ -0,0 +1,24 @@
+from django.conf.urls.defaults import *
+from bookmarks.views import *
+
+# Uncomment the next two lines to enable the admin:
+# from django.contrib import admin
+# admin.autodiscover()
+
+urlpatterns = patterns('',
+ # Example:
+ (r'^$', include('django_bookmarks.bookmarks.urls')),
+
+ # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
+ # to INSTALLED_APPS to enable admin documentation:
+ # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+ # Uncomment the next line to enable the admin:
+ # (r'^admin/(.*)', admin.site.root),
+ (r'^login/$', 'django.contrib.auth.views.login'),
+)
+
+urlpatterns = patterns('',
+ (r'^$', main_page),
+ (r'^user/(\w+)/$', user_page),
+)

Modified: trunk/misc/patrick/wjContact/contacts/models.py
==============================================================================
--- trunk/misc/patrick/wjContact/contacts/models.py (original)
+++ trunk/misc/patrick/wjContact/contacts/models.py Mon Dec 8 02:39:38 2008
@@ -2,19 +2,12 @@

# Create your models here.

-class Suburb(models.Model):
- post_code = models.CharField(maxlength=100, primary_key=True)
- suburb = models.CharField(maxlength=100)
- def __str__(self):
- return self.post_code
- class Admin:
- pass

class Contact(models.Model):
first_name = models.CharField(maxlength=30)
last_name = models.CharField(maxlength=20)
address = models.CharField(maxlength=200)
- suburb = models.CharField(maxlength=40)
+ postcode = models.CharField(maxlength=40)
state = models.USStateField()
country = models.CharField(maxlength=40)
email = models.EmailField()
@@ -105,17 +98,17 @@

class Admin:
## What columns will we display in the change-list page?
- list_display =
('__str__', 'get_my_contact_types', 'address', 'suburb')
+ list_display =
('__str__', 'get_my_contact_types', 'address', 'postcode')

"""Set list_filter to activate filters in the right sidebar of the
change list page of the admin. This should be a list of field
names,
and each specified field should be either a
BooleanField, CharField, DateField, DateTimeField, IntegerField or
ForeignKey."""
- list_filter = ('address', 'suburb', 'first_name', 'id')
+ list_filter = ('address', 'postcode', 'first_name', 'id')


- search_fields = ('suburb', 'first_name')
+ search_fields = ('postcode', 'first_name')
## How will the fieldsets be set-up on the actual add/edit page
for an
## individual item?
fields = (
@@ -124,7 +117,7 @@
}),
('Address Details', {
'classes': 'collapse',
- 'fields' : ('address', 'suburb', 'state', 'country', 'email')
+ 'fields' : ('address', 'postcode', 'state', 'country', 'email')
}),
('Date', {
'fields': ('date_added',)

Reply all
Reply to author
Forward
0 new messages