software powering 0xdb.org and Pad.ma is called pandora now

This commit is contained in:
j 2010-02-16 15:52:34 +05:30
commit 7c0e365a0a
46 changed files with 30 additions and 21 deletions

0
pandora/app/__init__.py Normal file
View file

12
pandora/app/admin.py Normal file
View file

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from django.contrib import admin
import models
class PageAdmin(admin.ModelAdmin):
search_fields = ['name', 'body']
admin.site.register(models.Page, PageAdmin)

13
pandora/app/models.py Normal file
View file

@ -0,0 +1,13 @@
from django.db import models
# Create your models here.
class Page(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=1024, unique=True)
body = models.TextField(blank=True)
def __unicode__(self):
return self.name

23
pandora/app/tests.py Normal file
View file

@ -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
"""}

28
pandora/app/views.py Normal file
View file

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext
from django.conf import settings
from oxdjango.shortcuts import json_response, render_to_json_response, get_object_or_404_json
import models
def index(request):
context = RequestContext(request, {'settings':settings})
return render_to_response('index.html', context)
def api_getPage(request):
data = json.loads(request.POST['data'])
name = data['page']
page = get_object_or_404_json(models.Archive, name=name)
response = json_response({'name': page.name, 'body': page.body})
return render_to_json_response(response)
return render_to_response('site.js', context, mimetype="application/javascript")
def site_js(request):
pages = models.Page.objects.all()
context = RequestContext(request, {'settings':settings, 'pages': pages})
return render_to_response('site.js', context, mimetype="application/javascript")