From 4b29603d79cc1f79c66786684f27ec9abfbaa825 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Mon, 17 Oct 2011 01:34:04 +0200 Subject: Initial commit --- main/__init__.py | 0 main/admin.py | 4 ++++ main/models.py | 24 ++++++++++++++++++++++++ main/signals.py | 0 main/tests.py | 23 +++++++++++++++++++++++ main/urls.py | 4 ++++ main/views.py | 13 +++++++++++++ 7 files changed, 68 insertions(+) create mode 100644 main/__init__.py create mode 100644 main/admin.py create mode 100644 main/models.py create mode 100644 main/signals.py create mode 100644 main/tests.py create mode 100644 main/urls.py create mode 100644 main/views.py (limited to 'main') diff --git a/main/__init__.py b/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/main/admin.py b/main/admin.py new file mode 100644 index 0000000..093f769 --- /dev/null +++ b/main/admin.py @@ -0,0 +1,4 @@ +from main.models import Tag +from django.contrib import admin + +admin.site.register(Tag) diff --git a/main/models.py b/main/models.py new file mode 100644 index 0000000..8ecddec --- /dev/null +++ b/main/models.py @@ -0,0 +1,24 @@ +from django.db import models + +class Tag(models.Model): + name = models.CharField(primary_key=True, max_length=200) + + def __unicode__(self): + return self.name + +class Activity(models.Model): + ACTCATEGORY_CHOICES = ( + ('blog', 'Blog post'), + ('project', 'Project page'), + ('link', 'Link'), + ) + ACTTYPE_CHOICES = ( + ('add', 'Add'), + ('edit', 'Edit'), + ('delete', 'Delete'), + ) + date = models.DateTimeField(auto_now=True) + actcategory = models.CharField(max_length=100, choices=ACTCATEGORY_CHOICES) + actdescription = models.CharField(max_length=500) + acttype = models.CharField(max_length=6) + objpk = models.CharField(max_length=300, null=True) diff --git a/main/signals.py b/main/signals.py new file mode 100644 index 0000000..e69de29 diff --git a/main/tests.py b/main/tests.py new file mode 100644 index 0000000..2247054 --- /dev/null +++ b/main/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/main/urls.py b/main/urls.py new file mode 100644 index 0000000..9f861b5 --- /dev/null +++ b/main/urls.py @@ -0,0 +1,4 @@ +from django.conf.urls.defaults import * + +urlpatterns = patterns('main.views', + (r'^$', 'index')) diff --git a/main/views.py b/main/views.py new file mode 100644 index 0000000..91e20dd --- /dev/null +++ b/main/views.py @@ -0,0 +1,13 @@ +from django.http import HttpResponse +from django.shortcuts import render_to_response +from django.template import Context, loader +from main.models import Activity + +def index(request): + activity_list = Activity.objects.all().order_by("-date")[:5] + t = loader.get_template("home.html") + c = Context({ + "activitylist": activity_list, + }) + + return HttpResponse(t.render(c)) -- cgit v1.2.3-54-g00ecf