From 50c9ae667db6251232f6b3e40418c62a7fe84d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Mart=C3=ADn?= Date: Mon, 20 May 2013 16:16:29 +0200 Subject: [PATCH] Added app database. Added model mod --- minecraftcodex/database/__init__.py | 0 .../database/migrations/0001_initial.py | 34 +++++++++++++++++++ .../database/migrations/__init__.py | 0 minecraftcodex/database/models.py | 1 + minecraftcodex/database/models/__init__.py | 2 ++ minecraftcodex/database/models/mod.py | 28 +++++++++++++++ minecraftcodex/database/tests.py | 16 +++++++++ minecraftcodex/database/views.py | 1 + 8 files changed, 82 insertions(+) create mode 100644 minecraftcodex/database/__init__.py create mode 100644 minecraftcodex/database/migrations/0001_initial.py create mode 100644 minecraftcodex/database/migrations/__init__.py create mode 100644 minecraftcodex/database/models.py create mode 100644 minecraftcodex/database/models/__init__.py create mode 100644 minecraftcodex/database/models/mod.py create mode 100644 minecraftcodex/database/tests.py create mode 100644 minecraftcodex/database/views.py diff --git a/minecraftcodex/database/__init__.py b/minecraftcodex/database/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/minecraftcodex/database/migrations/0001_initial.py b/minecraftcodex/database/migrations/0001_initial.py new file mode 100644 index 0000000..dc31099 --- /dev/null +++ b/minecraftcodex/database/migrations/0001_initial.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'Mod' + db.create_table(u'database_mod', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=256)), + ('url', self.gf('django.db.models.fields.URLField')(max_length=200, blank=True)), + )) + db.send_create_signal('database', ['Mod']) + + + def backwards(self, orm): + # Deleting model 'Mod' + db.delete_table(u'database_mod') + + + models = { + 'database.mod': { + 'Meta': {'ordering': "['name']", 'object_name': 'Mod'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}) + } + } + + complete_apps = ['database'] \ No newline at end of file diff --git a/minecraftcodex/database/migrations/__init__.py b/minecraftcodex/database/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/minecraftcodex/database/models.py b/minecraftcodex/database/models.py new file mode 100644 index 0000000..8517742 --- /dev/null +++ b/minecraftcodex/database/models.py @@ -0,0 +1 @@ +from minecraftcodex.databae.models import * diff --git a/minecraftcodex/database/models/__init__.py b/minecraftcodex/database/models/__init__.py new file mode 100644 index 0000000..deff88b --- /dev/null +++ b/minecraftcodex/database/models/__init__.py @@ -0,0 +1,2 @@ +from database.models import mod +#from database.models import version diff --git a/minecraftcodex/database/models/mod.py b/minecraftcodex/database/models/mod.py new file mode 100644 index 0000000..f126c50 --- /dev/null +++ b/minecraftcodex/database/models/mod.py @@ -0,0 +1,28 @@ +from django.db import models +from django.contrib import admin + + +class Mod(models.Model): + name = models.CharField(max_length=256) + url = models.URLField(blank=True) + + def __unicode__(self): + return "%s" % self.name + + class Meta: + app_label = 'database' + ordering = ['name'] + + +class ModAdmin(admin.ModelAdmin): + list_display = ('name', 'last_version', 'url', ) + list_display_links = ('name', ) + + list_filter = ('name', ) + search_fields = ['name', 'url', ] + ordering = ('name', ) + + def last_version(self, obj): + return '0.0.0' + +admin.site.register(Mod, ModAdmin) diff --git a/minecraftcodex/database/tests.py b/minecraftcodex/database/tests.py new file mode 100644 index 0000000..501deb7 --- /dev/null +++ b/minecraftcodex/database/tests.py @@ -0,0 +1,16 @@ +""" +This file demonstrates writing tests using the unittest module. These will pass +when you run "manage.py test". + +Replace this 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.assertEqual(1 + 1, 2) diff --git a/minecraftcodex/database/views.py b/minecraftcodex/database/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/minecraftcodex/database/views.py @@ -0,0 +1 @@ +# Create your views here.