Anonymous avatar Anonymous committed ae14100

startapp django_restwiki and add model, urls, and templates

Comments (0)

Files changed (7)

Add a comment to this file

django_restwiki/__init__.py

Empty file added.

django_restwiki/admin.py

+from django_restwiki.models import Page
+from django.contrib import admin
+
+class PollAdmin(admin.ModelAdmin):
+    fields = ['content']
+
+admin.site.register(Page, PageAdmin)

django_restwiki/models.py

+from django.db import models
+
+class Page(models.Model):
+    name = models.CharField(max_length=255, unique=True)
+    content = models.TextField()
+    rendered = models.TextField()
+
+    class Meta:
+        ordering = ('name', )
+
+    def __unicode__(self):
+        return self.name
+
+    def save(self, *args, **kwargs):
+        # get name
+        (heading, remain) = content.split('\n', 1)
+        self.name = heading
+        # TODO: use docutils to convert
+        self.rendered = self.content
+        super(Page, self).save(*args, **kwargs)

django_restwiki/templates/django_restwiki/view.html

+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+  <head>
+    <title>{{ page.name }}</title>
+    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+  </head>
+  <body>
+    {{ page.rendered }}
+  </body>
+</html>

django_restwiki/tests.py

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

django_restwiki/urls.py

+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('django_restwiki.views',
+    ('(?P<name>.+)/$', 'view'),
+)
Add a comment to this file

django_restwiki/views.py

Empty file added.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.