[djangodb commit] r678 - in trunk/misc/patrick/admintest: . computers contacts sales templates templates/admin

0 views
Skip to first unread message

codesite...@google.com

unread,
Nov 17, 2008, 7:54:26 AM11/17/08
to compute...@googlegroups.com
Author: PatrickChan7
Date: Mon Nov 17 04:53:00 2008
New Revision: 678

Added:
trunk/misc/patrick/admintest/computers/
trunk/misc/patrick/admintest/computers/__init__.py
trunk/misc/patrick/admintest/computers/admin.py
trunk/misc/patrick/admintest/computers/models.py
trunk/misc/patrick/admintest/computers/views.py
trunk/misc/patrick/admintest/contacts/
trunk/misc/patrick/admintest/contacts/__init__.py
trunk/misc/patrick/admintest/contacts/admin.py
trunk/misc/patrick/admintest/contacts/models.py
trunk/misc/patrick/admintest/contacts/urls.py
trunk/misc/patrick/admintest/contacts/views.py
trunk/misc/patrick/admintest/sales/
trunk/misc/patrick/admintest/sales/__init__.py
trunk/misc/patrick/admintest/sales/admin.py
trunk/misc/patrick/admintest/sales/models.py
trunk/misc/patrick/admintest/sales/views.py
trunk/misc/patrick/admintest/templates/
trunk/misc/patrick/admintest/templates/admin/
trunk/misc/patrick/admintest/templates/admin/change_list.html1
Modified:
trunk/misc/patrick/admintest/settings.py
trunk/misc/patrick/admintest/urls.py

Log:
added admintest initial commit

Added: trunk/misc/patrick/admintest/computers/__init__.py
==============================================================================

Added: trunk/misc/patrick/admintest/computers/admin.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/computers/admin.py Mon Nov 17 04:53:00 2008
@@ -0,0 +1,20 @@
+from django.contrib import admin
+from admintest.computers.models import *
+
+
+class ComputerAdmin(admin.ModelAdmin):
+ pass
+ #fields =
['first_name', 'last_name', 'address', 'suburb', 'state', 'country', 'email', 'date_added']
+ fieldsets = [
+ #(None, {'fields': ['first_name', 'last_name']}),
+ ('Basics', {'fields':
['cbv_no', 'cpu_type', 'cpu_speed', 'case_type'], 'classes':
['extrapretty']}),
+ ('Specs', {'fields':
['ram', 'hard_drive_size', 'optical_device1', 'optical_device2', 'monitor_type', 'monitor_size'], 'classes':
['expand']}),
+ ('Peripherals', {'fields': ['modem_type', 'usb', 'usb_ports'
], 'classes': ['extrapretty', 'expand']}),
+ ('Others', {'fields':
['distroversion', 'computer_status', 'baseprice', 'extraprice'
], 'classes': ['expand']}),
+ ]
+ #inlines = [ContactInline]
+ search_fields =
('computer_status', 'cpu_type', 'distroversion', 'baseprice')
+
+ list_display =
('cpu_type', 'cpu_speed', 'ram', 'hard_drive_size', 'distroversion', 'id')
+ list_filter =
('computer_status', 'cpu_type', 'distroversion', 'baseprice')
+admin.site.register(Computer, ComputerAdmin)

Added: trunk/misc/patrick/admintest/computers/models.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/computers/models.py Mon Nov 17 04:53:00
2008
@@ -0,0 +1,176 @@
+from django.db import models
+
+# Create your models here.
+
+class Computer(models.Model):
+ CPU_TYPES = (
+ ('p3', 'PIII'),
+ ('p4', 'P4'),
+ ('cel', 'Celeron'),
+ ('amd', 'AMD'),
+ )
+ CPU_SPEEDS = (
+ ('450', '450'),
+ ('550', '550'),
+ ('667', '667'),
+ ('600', '600'),
+ ('633', '633'),
+ ('650', '650'),
+ ('667', '667'),
+ ('700', '700'),
+ ('733', '733'),
+ ('766', '766'),
+ ('800', '800'),
+ ('833', '833'),
+ ('866', '866'),
+ ('900', '900'),
+ ('930', '930'),
+ ('933', '933'),
+ ('1000', '1000'),
+ ('1100', '1100'),
+ ('1200', '1200'),
+ ('1400', '1400'),
+ ('1500', '1500'),
+ ('1600', '1600'),
+ ('1700', '1700'),
+ ('1800', '1800'),
+ ('1900', '1900'),
+ ('2100', '2100'),
+ ('2200', '2200'),
+ ('2300', '2400'),
+ ('2500', '2600'),
+ ('2700', '2700'),
+ ('2800', '2800'),
+ ('2900', '2900'),
+ ('3000', '3000'),
+ ('3100', '3100'),
+ ('3200', '3200'),
+ )
+ CASE_TYPES = (
+ ('tower', 'Desktop - Tower'),
+ ('flat', 'Desktop - Horizontal'),
+ ('laptop', 'Laptop'),
+ )
+ RAM_AMOUNTS = (
+ ('128', '128'),
+ ('192', '192'),
+ ('256', '256'),
+ ('384', '384'),
+ ('512', '512'),
+ ('1Gb', '1Gb'),
+ )
+ HARD_DRIVE_SIZES = (
+ ('6.4','6.4'),
+ ('8', '8'),
+ ('10', '10'),
+ ('13', '13'),
+ ('20', '20'),
+ ('10', '10'),
+ ('40', '40'),
+ ('80', '80'),
+ ('100', '100'),
+ ('120','120'),
+ ('160','160'),
+ ('200', '200'),
+ ('250', '250'),
+ ('320', '320'),
+ )
+ STATUS_CHOICES = (
+ ('in_shop', 'In Shop'),
+ ('being_built', 'Being Built'),
+ ('testing', 'Being Tested'),
+ )
+ #cbv_no = models.AutoField(primary_key=False)
+ cbv_no = models.CharField(max_length=3)
+ cpu_type = models.CharField(max_length=3, choices = CPU_TYPES)
+ cpu_speed = models.CharField(max_length=4, choices = CPU_SPEEDS)
+ case_type = models.CharField(max_length=6, choices = CASE_TYPES)
+ ram = models.CharField(max_length=3, choices = RAM_AMOUNTS)
+ hard_drive_size = models.CharField(max_length=3, choices =
HARD_DRIVE_SIZES)
+ optical_device1 = models.CharField(max_length=50)
+ optical_device2 = models.CharField(max_length=50)
+ monitor_type = models.CharField(max_length=50)
+ monitor_size = models.CharField(max_length=50)
+ modem_type = models.CharField(max_length=50)
+ usb = models.CharField(max_length=50)
+ usb_ports = models.CharField(max_length=50)
+ distroversion = models.CharField(max_length=50)
+ computer_status = models.CharField(max_length=12, choices =
STATUS_CHOICES,
+ default = "in_shop")
+ baseprice = models.CharField(max_length=50)
+ extraprice = models.CharField(max_length=50)
+
+ def __str__(self):
+ return "%s %s Processor, %s Ram, %s Gb HDD, %s (%s)" %
(self.cpu_type,
+ self.cpu_speed, self.ram, self.hard_drive_size, self.case_type,
+ self.computer_status)
+ ## Give the computer_class model an "Admin Interface" so that staff
users
+ ## can add new computers if they wish.
+ class Admin:
+ pass
+
+###=======================================================================
+## Provides details about a 'type' of computer ie, a particular set of
+## components.
+## At any particular point in time, three of these
+## can be flagged as basic, standard, or upgrade.
+##class ComputerType(models.Model):
+## computer_type_id = models.AutoField(primary_key=True)
+## cpu_type = models.CharField(max_length=50)
+## cpu_speed = models.CharField(max_length=50)
+## case_type = models.CharField(max_length=50)
+## ram = models.CharField(max_length=50)
+## hard_drive_size = models.CharField(max_length=50)
+## optical_device1 = models.CharField(max_length=50)
+## optical_device2 = models.CharField(max_length=50)
+##
+## monitor_type = models.CharField(max_length=50)
+## monitor_size = models.CharField(max_length=50)
+##
+## modem_type = models.CharField(max_length=50)
+## usb = models.CharField(max_length=50)
+## usb_ports = models.CharField(max_length=50)
+##
+##
+##
+## distroversion = models.CharField(max_length=50)
+## computer_status = models.CharField(max_length=50)
+## computer_description = models.CharField(max_length=50)#not in final
version
+## def __str__(self):
+## return self.computer_description
+## # Give the computer_class model an "Admin Interface" so that staff
users
+## # can add new classses of computer if they wish.
+## class Admin:
+## pass
+##
+##Provides details about an individual computer
+##class ActualComputer(models.Model):
+## cbvid = models.AutoField(primary_key=True)
+## computer_type = models.ForeignKey(ComputerType)
+## status = models.CharField(max_length=50)
+## description = models.CharField(max_length=50)#not in final version
+## user_pwd = models.CharField(max_length=50, default = 'cbvsys')
+## dialup_pwd = models.CharField(max_length=50)
+## qa_date = models.DateTimeField()
+## from wjContact.contacts.models import Contact
+## qa_by = models.ForeignKey(Contact)
+## def __str__(self):
+## return self.description
+## class Admin:
+## list_display =
('cbvid', 'computer_type', 'status', 'description')
+## list_filter = ['status', 'computer_type']
+## search_fields = ['description', 'cbvid' ]
+##
+##
+## Lists the components that go into a computer or class of computer
+##class Component(models.Model):
+## component_id = models.AutoField(primary_key=True)
+## componentclass = models.CharField(max_length=50)
+## componenttype = models.CharField(max_length=50)
+## component_price = models.CharField(max_length=50)
+## def __str__(self):
+## return self.componenttype
+## # Give the computer_components model an "Admin Interface" so that
staff users
+## # can add new computer components if they wish.
+## class Admin:
+## pass

Added: trunk/misc/patrick/admintest/computers/views.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/computers/views.py Mon Nov 17 04:53:00 2008
@@ -0,0 +1 @@
+# Create your views here.

Added: trunk/misc/patrick/admintest/contacts/__init__.py
==============================================================================

Added: trunk/misc/patrick/admintest/contacts/admin.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/contacts/admin.py Mon Nov 17 04:53:00 2008
@@ -0,0 +1,32 @@
+from django.contrib import admin
+from admintest.contacts.models import *
+
+
+class ContactInline(admin.TabularInline):
+ model = Volunteer
+
+class ContactAdmin(admin.ModelAdmin):
+ pass
+ #fields =
['first_name', 'last_name', 'address', 'suburb', 'state', 'country', 'email', 'date_added']
+ fieldsets = [
+ #(None, {'fields': ['first_name', 'last_name']}),
+ ('Name', {'fields':
['first_name', 'last_name'], 'classes': ['extrapretty']}),
+ ('Address Details', {'fields':
['address', 'suburb', 'state', 'postcode', 'country'], 'classes':
['expand']}),
+ ('Contact Details', {'fields': ['email', ], 'classes':
['extrapretty', 'expand']}),
+ ('Misc', {'fields': ['date_added', ], 'classes': ['expand']}),
+ ]
+ #inlines = [ContactInline]
+ search_fields = ('postcode', 'first_name')
+
+ list_display = ('first_name', 'last_name', 'suburb', 'email', 'id')
+ list_filter = ('suburb', 'date_added', 'country', 'first_name')
+admin.site.register(Contact, ContactAdmin)
+
+class VolunteerAdmin(ContactAdmin):
+ pass
+admin.site.register(Volunteer, VolunteerAdmin)
+
+class RecipientAdmin(ContactAdmin):
+ list_filter = ('suburb', 'date_added', 'country', 'first_name')
+ list_filter +=
('has_attended_training', 'concession_checked_by', 'concession_type')
+admin.site.register(Recipient, RecipientAdmin)

Added: trunk/misc/patrick/admintest/contacts/models.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/contacts/models.py Mon Nov 17 04:53:00 2008
@@ -0,0 +1,75 @@
+from django.db import models
+from django.db import models
+
+# Create your models here.
+
+class Contact(models.Model):
+ first_name = models.CharField(max_length=30)
+ last_name = models.CharField(max_length=20)
+
+ address = models.CharField(max_length=200)
+ suburb = models.CharField(max_length=40)
+ state = models.CharField(max_length=40)
+ postcode = models.CharField(max_length=40)
+ country = models.CharField(max_length=40)
+
+ email = models.EmailField(blank=True)
+ date_added = models.DateTimeField()
+
+ class Meta:
+ abstract = False
+ def __str__(self):
+ """
+ This is what will be shown in the Admin interface, amongst other
+ places. If we migrate to a later version of django, may want to
look
+ into using __unicode__ here rather than __str__.
+ """
+ return "%s %s hash:%s" % (self.first_name, self.last_name,
self.__hash__())
+ def __hash__(self):
+ """hash for Contact class. Useful for the set operations involving
Contacts"""
+ return self.id
+
+class Volunteer(Contact):
+ HOURS_CHOICES = (
+ ('monday_am', 'Monday Mornings'),
+ ('monday_pm', 'Monday Afternoons'),
+ ('tuesday_am', 'Tuesday Mornings'),
+ ('tuesday_pm', 'Tuesday Afternoons'),
+ )
+ INTERESTS = (
+ ('front_desk', 'Front Desk'),
+ ('build_room', 'Build Room'),
+ ('training', 'Training'),
+ ('administration', 'Administration'),
+ ('other', 'Other'),
+ )
+ hours = models.CharField(max_length=10, choices=HOURS_CHOICES)
+ interests = models.CharField(max_length=20, choices=INTERESTS)
+
+class Recipient(Contact):
+ CONCESSION_TYPES = (
+ ('healthcare', 'Healthcare Card'),
+ ('student', 'Student'),
+ ('other', 'Other'),
+ )
+ INTERNET_TYPES = (
+ ('none', 'None'),
+ ('broadband', 'Broadband'),
+ ('dialup', 'Dialup'),
+ )
+ concession_type = models.CharField(max_length=10,
choices=CONCESSION_TYPES)
+ concession_checked_by = models.ForeignKey(Volunteer)
+ #referring_org = models.ForeignKey(Group)
+ install_windows = models.BooleanField()
+ stay_with_linux = models.BooleanField()
+ survey_contact = models.BooleanField()
+ have_not_used_a_computer = models.BooleanField()
+ can_type_documents = models.BooleanField()
+ can_use_keyboard_and_mouse = models.BooleanField()
+ can_use_email = models.BooleanField()
+ can_use_internet = models.BooleanField()
+ has_attended_training = models.BooleanField()
+ internet_type = models.CharField(max_length=9, choices=INTERNET_TYPES)
+ aggression_rating = models.CharField(max_length=30)
+ isp = models.CharField(max_length=30, choices=INTERNET_TYPES)
+

Added: trunk/misc/patrick/admintest/contacts/urls.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/contacts/urls.py Mon Nov 17 04:53:00 2008
@@ -0,0 +1,8 @@
+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('',
+ # Example:
+ # (r'^admintest/', include('admintest.foo.urls')),
+
+ # Uncomment this for admin:
+)

Added: trunk/misc/patrick/admintest/contacts/views.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/contacts/views.py Mon Nov 17 04:53:00 2008
@@ -0,0 +1 @@
+# Create your views here.

Added: trunk/misc/patrick/admintest/sales/__init__.py
==============================================================================

Added: trunk/misc/patrick/admintest/sales/admin.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/sales/admin.py Mon Nov 17 04:53:00 2008
@@ -0,0 +1,4 @@
+from django.contrib import admin
+from admintest.sales.models import *
+
+admin.site.register(Sale)

Added: trunk/misc/patrick/admintest/sales/models.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/sales/models.py Mon Nov 17 04:53:00 2008
@@ -0,0 +1,15 @@
+from django.db import models
+
+# Create your models here.
+
+from django.db import models
+from admintest.computers.models import Computer
+from admintest.contacts.models import Recipient
+
+
+class Sale(models.Model):
+ computer = models.ForeignKey(Computer)
+ recipient = models.ForeignKey(Recipient)
+
+ def __str__(self):
+ return "Computer %s sold to %s" % (self.computer, self.recipient)

Added: trunk/misc/patrick/admintest/sales/views.py
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/sales/views.py Mon Nov 17 04:53:00 2008
@@ -0,0 +1 @@
+# Create your views here.

Modified: trunk/misc/patrick/admintest/settings.py
==============================================================================
--- trunk/misc/patrick/admintest/settings.py (original)
+++ trunk/misc/patrick/admintest/settings.py Mon Nov 17 04:53:00 2008
@@ -1,4 +1,5 @@
# Django settings for admintest project.
+import os

DEBUG = True
TEMPLATE_DEBUG = DEBUG
@@ -9,23 +10,22 @@

MANAGERS = ADMINS

-DATABASE_ENGINE = 'sqlite3'
# 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
-DATABASE_NAME = 'sqlite.db' # Or path to database file if
using sqlite3.
+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://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
-# although not all variations may be possible on all operating systems.
+# 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.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
-# http://blogs.law.harvard.edu/tech/stories/storyReader$15
+# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1
@@ -38,8 +38,9 @@
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

-# URL that handles the media served from MEDIA_ROOT.
-# Example: "http://media.lawrence.com"
+# 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
@@ -48,7 +49,7 @@
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
-SECRET_KEY = 'p6lthd$68wza)_*d4fo!d&&a)+icz!%048o880o%_fp-qgo@80'
+SECRET_KEY = 'w2#+-s^vkk2zh0m$9h*p^ead53dlm&@0o)7g_^2$1$*b+y6rtc'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
@@ -61,7 +62,6 @@
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.middleware.doc.XViewMiddleware',
)

ROOT_URLCONF = 'admintest.urls'
@@ -70,6 +70,7 @@
# 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 = (
@@ -78,5 +79,8 @@
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
- 'admintest.polls',
+ 'django.contrib.admindocs',
+ 'admintest.contacts',
+ 'admintest.computers',
+ 'admintest.sales',
)

Added: trunk/misc/patrick/admintest/templates/admin/change_list.html1
==============================================================================
--- (empty file)
+++ trunk/misc/patrick/admintest/templates/admin/change_list.html1 Mon Nov
17 04:53:00 2008
@@ -0,0 +1,39 @@
+{% extends "admin/base_site.html" %}
+{% load adminmedia admin_list i18n %}
+
+{% block stylesheet %}{% admin_media_prefix %}css/changelists.css{%
endblock %}
+
+{% block bodyclass %}change-list{% endblock %}
+
+{% block coltype %}flex{% endblock %}
+
+{% block content %}
+abc
+<div id="content-main">
+{% block object-tools %}
+{% if has_add_permission %}
+<ul class="object-tools"><li><a href="add/{% if is_popup %}?_popup=1{%
endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as
name %}Add {{ name }}{% endblocktrans %}</a></li></ul>
+{% endif %}
+{% endblock %}
+eyx
+<div class="module{% if cl.has_filters %} filtered{% endif %}"
id="changelist">
+{% block search %}{% search_form cl %}{% endblock %}
+{% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
+
+{% block filters %}
+{% if cl.has_filters %}
+<div id="changelist-filter">
+<h2>{% trans 'Filter' %}</h2>
+{% for spec in cl.filter_specs %}
+ {% admin_list_filter cl spec %}
+{% endfor %}
+</div>
+xxx
+{% endif %}
+{% endblock %}
+
+{% block result_list %}{% result_list cl %}{% endblock %}
+{% block pagination %}{% pagination cl %}{% endblock %}
+</div>
+</div>
+{% endblock %}

Modified: trunk/misc/patrick/admintest/urls.py
==============================================================================
--- trunk/misc/patrick/admintest/urls.py (original)
+++ trunk/misc/patrick/admintest/urls.py Mon Nov 17 04:53:00 2008
@@ -1,10 +1,17 @@
from django.conf.urls.defaults import *

+# Uncomment the next two lines to enable the admin:
+from django.contrib import admin
+admin.autodiscover()
+
urlpatterns = patterns('',
# Example:
- # (r'^admintest/', include('admintest.foo.urls')),
+ #(r'^admintest/', include('admintest.foo.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 this for admin:
- (r'^admin/', include('django.contrib.admin.urls')),
- (r'^polls/', 'polls')),
+ # Uncomment the next line to enable the admin:
+ (r'^admin/(.*)', admin.site.root),
)

Reply all
Reply to author
Forward
0 new messages