From 8ae852654134ffc972f69249a0463d6ef9260a40 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 10 Apr 2012 17:50:31 +0530 Subject: [PATCH] first commit, db models migrated, admin sort've works --- campdjango/__init__.py | 0 campdjango/base/__init__.py | 0 campdjango/base/models.py | 18 +++ campdjango/base/tests.py | 23 ++++ campdjango/base/views.py | 1 + campdjango/camp/__init__.py | 0 campdjango/camp/admin.py | 22 ++++ campdjango/camp/models.py | 215 +++++++++++++++++++++++++++++++++++ campdjango/camp/tests.py | 16 +++ campdjango/camp/views.py | 1 + campdjango/campdjango.sqlite | Bin 0 -> 35840 bytes campdjango/manage.py | 25 ++++ campdjango/secret.txt | 1 + campdjango/settings.py | 177 ++++++++++++++++++++++++++++ campdjango/urls.py | 18 +++ 15 files changed, 517 insertions(+) create mode 100644 campdjango/__init__.py create mode 100644 campdjango/base/__init__.py create mode 100644 campdjango/base/models.py create mode 100644 campdjango/base/tests.py create mode 100644 campdjango/base/views.py create mode 100644 campdjango/camp/__init__.py create mode 100644 campdjango/camp/admin.py create mode 100644 campdjango/camp/models.py create mode 100644 campdjango/camp/tests.py create mode 100644 campdjango/camp/views.py create mode 100644 campdjango/campdjango.sqlite create mode 100644 campdjango/manage.py create mode 100644 campdjango/secret.txt create mode 100644 campdjango/settings.py create mode 100644 campdjango/urls.py diff --git a/campdjango/__init__.py b/campdjango/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/campdjango/base/__init__.py b/campdjango/base/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/campdjango/base/models.py b/campdjango/base/models.py new file mode 100644 index 0000000..2345cd2 --- /dev/null +++ b/campdjango/base/models.py @@ -0,0 +1,18 @@ +from django.db import models +import datetime + +class BaseModel(models.Model): + changed = models.DateTimeField(null=True, editable=False) + created = models.DateTimeField(null=True, editable=False) + + def save(self, *args, **kwargs): + if not self.id: + self.created = datetime.datetime.today() + self.changed = datetime.datetime.today() + if self.created == None: + self.created = self.changed + super(BaseModel, self).save(*args, **kwargs) + + class Meta: + abstract = True + diff --git a/campdjango/base/tests.py b/campdjango/base/tests.py new file mode 100644 index 0000000..2247054 --- /dev/null +++ b/campdjango/base/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/campdjango/base/views.py b/campdjango/base/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/campdjango/base/views.py @@ -0,0 +1 @@ +# Create your views here. diff --git a/campdjango/camp/__init__.py b/campdjango/camp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/campdjango/camp/admin.py b/campdjango/camp/admin.py new file mode 100644 index 0000000..1a0ec4e --- /dev/null +++ b/campdjango/camp/admin.py @@ -0,0 +1,22 @@ +from django.contrib import admin +from models import * + +''' +class SubdomainInline(admin.StackedInline): + model = Subdomain + +class DomainAliasInline(admin.StackedInline): + model = DomainAlias + +class ServerAdmin(admin.ModelAdmin): + pass +''' + +class ContentAdmin(admin.ModelAdmin): + save_on_top = True +# inlines = [SubdomainInline, DomainAliasInline] +# list_display = ('url', 'server', 'manage_nameserver', 'domain_registrar', 'email', 'is_active') +# list_editable = ('server', 'manage_nameserver', 'domain_registrar', 'email', 'is_active') + + +admin.site.register(Content, ContentAdmin) diff --git a/campdjango/camp/models.py b/campdjango/camp/models.py new file mode 100644 index 0000000..ffae772 --- /dev/null +++ b/campdjango/camp/models.py @@ -0,0 +1,215 @@ +# This is an auto-generated Django model module. +# You'll have to do the following manually to clean this up: +# * Rearrange models' order +# * Make sure each model has one field with primary_key=True +# Feel free to rename the models, but don't rename db_table values or field names. +# +# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]' +# into your database. + +from django.db import models + +class Acrolike(models.Model): + id = models.IntegerField(primary_key=True) + title = models.CharField(max_length=765) + + class Meta: + db_table = u'acrolike' + +class Acronym(models.Model): + id = models.IntegerField(primary_key=True) + name = models.CharField(max_length=765, blank=True) + c = models.CharField(max_length=150, blank=True) + a = models.CharField(max_length=150, blank=True) + m = models.CharField(max_length=150, blank=True) + p = models.CharField(max_length=150, blank=True) + + class Meta: + db_table = u'acronym' + +class Audios(models.Model): + id = models.IntegerField(primary_key=True) + filename = models.CharField(max_length=765) + title = models.CharField(max_length=765, blank=True) + description = models.TextField(blank=True) + + class Meta: + db_table = u'audios' + +class Comments(models.Model): + id = models.IntegerField(primary_key=True) + comment = models.TextField() + name = models.CharField(max_length=450, blank=True) + email = models.CharField(max_length=765, blank=True) + personid = models.ForeignKey("People", null=True, db_column='personID', blank=True) # Field name made lowercase. + dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase. + datemodified = models.DateTimeField(null=True, db_column='dateModified', blank=True) # Field name made lowercase. + parentid = models.ForeignKey("Comments", null=True, db_column='parentID', blank=True) # Field name made lowercase. + contentid = models.ForeignKey("Content", db_column='contentID') # Field name made lowercase. + ip = models.CharField(max_length=150, db_column='IP', blank=True) # Field name made lowercase. + + class Meta: + db_table = u'comments' + +class Content(models.Model): + id = models.IntegerField(primary_key=True) + shortname = models.CharField(max_length=765, db_column='shortName') # Field name made lowercase. + title = models.CharField(max_length=765) + header = models.TextField(blank=True) + body = models.TextField(blank=True) + schedule = models.TextField(blank=True) + schedulebutton = models.CharField(max_length=765, db_column='scheduleButton', blank=True) # Field name made lowercase. + optbtn2 = models.CharField(max_length=381, db_column='optBtn2', blank=True) # Field name made lowercase. + opttext2 = models.TextField(db_column='optText2', blank=True) # Field name made lowercase. + optbtn3 = models.CharField(max_length=381, db_column='optBtn3', blank=True) # Field name made lowercase. + opttext3 = models.TextField(db_column='optText3', blank=True) # Field name made lowercase. + technotes = models.TextField() + image = models.CharField(max_length=450, blank=True) + postedby = models.CharField(max_length=150, db_column='postedBy', blank=True) # Field name made lowercase. + datestart = models.DateField(null=True, db_column='dateStart', blank=True) # Field name made lowercase. + dateend = models.DateField(null=True, db_column='dateEnd', blank=True) # Field name made lowercase. + dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase. + datemodified = models.DateTimeField(null=True, db_column='dateModified', blank=True) # Field name made lowercase. + type = models.ForeignKey("ContentTypes", db_column="type") + published = models.IntegerField() + related_content = models.ManyToManyField("Content", through="ContentContent", related_name="related_contents", blank=True) + keywords = models.ManyToManyField("Keywords", through="ContentKeyword", blank=True) + resources = models.ManyToManyField("Resources", through="ContentResource", blank=True) + view = models.ForeignKey("Views", null=True, blank=True, db_column="view") + parentid = models.ForeignKey("Content", db_column='parentId') # Field name made lowercase. + + def __unicode__(self): + return self.title + + class Meta: + db_table = u'content' + +class ContentContent(models.Model): + id = models.IntegerField(primary_key=True) + contentid1 = models.ForeignKey("Content", db_column='contentID1', related_name="related1") # Field name made lowercase. + contentid2 = models.ForeignKey("Content", db_column='contentID2', related_name="related2") # Field name made lowercase. + + class Meta: + db_table = u'content_content' + +class ContentKeyword(models.Model): + id = models.IntegerField(primary_key=True) + contentid = models.ForeignKey("Content", db_column='contentID') # Field name made lowercase. + keywordid = models.ForeignKey("Keywords", db_column='keywordID') # Field name made lowercase. + + class Meta: + db_table = u'content_keyword' + +class ContentResource(models.Model): + id = models.IntegerField(primary_key=True) + contentid = models.ForeignKey("Content", db_column='contentID') # Field name made lowercase. + resourceid = models.ForeignKey("Resources", db_column='resourceID') # Field name made lowercase. + + class Meta: + db_table = u'content_resource' + +class ContentTypes(models.Model): + id = models.IntegerField(primary_key=True) + name = models.CharField(max_length=765) + description = models.TextField(blank=True) + + def __unicode__(self): + return self.name + + class Meta: + db_table = u'content_types' + +class Keywords(models.Model): + id = models.IntegerField(primary_key=True) + name = models.CharField(max_length=765) + description = models.TextField(blank=True) + + def __unicode__(self): + return self.name + + class Meta: + db_table = u'keywords' + +class People(models.Model): + id = models.IntegerField(primary_key=True) + name = models.CharField(max_length=765, blank=True) + email = models.CharField(max_length=765, blank=True) + location = models.CharField(max_length=765, blank=True) + login = models.CharField(max_length=300, blank=True) + password = models.CharField(max_length=48, blank=True) + href = models.CharField(max_length=765, blank=True) + bio = models.TextField(blank=True) + content = models.ManyToManyField("Content", through="PersonContent", blank=True) + resources = models.ManyToManyField("Resources", through="PersonResource", blank=True) + type = models.IntegerField() + + def __unicode__(self): + return "%s: %s" (self.name, self.email, ) + class Meta: + db_table = u'people' + +class PersonContent(models.Model): + id = models.IntegerField(primary_key=True) + personid = models.ForeignKey("People", db_column='personID') # Field name made lowercase. + contentid = models.ForeignKey("Content", db_column='contentID') # Field name made lowercase. + level = models.IntegerField() + + class Meta: + db_table = u'person_content' + +class PersonResource(models.Model): + id = models.IntegerField(primary_key=True) + personid = models.ForeignKey("People", db_column='personID') # Field name made lowercase. + resourceid = models.ForeignKey("Resources", db_column='resourceID') # Field name made lowercase. + + class Meta: + db_table = u'person_resource' + +class Resources(models.Model): + id = models.IntegerField(primary_key=True) + type = models.IntegerField() + href = models.CharField(max_length=765) + description = models.TextField(blank=True) + mime = models.CharField(max_length=30, blank=True) + width = models.IntegerField(null=True, blank=True) + height = models.IntegerField(null=True, blank=True) + istech = models.IntegerField(db_column='isTech') # Field name made lowercase. + dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase. + orderno = models.IntegerField(null=True, db_column='orderNo', blank=True) # Field name made lowercase. + + def __unicode__(self): + return "%d: %s" % (self.id, self.href) + + class Meta: + db_table = u'resources' + +class Videos(models.Model): + id = models.IntegerField(primary_key=True) + sha1 = models.CharField(max_length=150) + href = models.CharField(max_length=765) + title = models.TextField(blank=True) + description = models.TextField(blank=True) + width = models.IntegerField(null=True, blank=True) + height = models.IntegerField(null=True, blank=True) + duration = models.IntegerField(null=True, blank=True) + thumbno = models.IntegerField(db_column='thumbNo') # Field name made lowercase. + image = models.CharField(max_length=765, blank=True) + contentid = models.ForeignKey("Content", null=True, blank=True) + + def __unicode__(self): + return self.title + + class Meta: + db_table = u'videos' + +class Views(models.Model): + id = models.IntegerField(primary_key=True) + name = models.CharField(max_length=765) + href = models.CharField(max_length=765, blank=True) + + def __unicode__(self): + return self.name + + class Meta: + db_table = u'views' + diff --git a/campdjango/camp/tests.py b/campdjango/camp/tests.py new file mode 100644 index 0000000..501deb7 --- /dev/null +++ b/campdjango/camp/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/campdjango/camp/views.py b/campdjango/camp/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/campdjango/camp/views.py @@ -0,0 +1 @@ +# Create your views here. diff --git a/campdjango/campdjango.sqlite b/campdjango/campdjango.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..eecc9dfbe00adeb65dba695c4166b23bb0ca2e7a GIT binary patch literal 35840 zcmeHPUu+yl8K2qNy|pj)IsS9qB#z_tU7X}_oZKHfe;T6JNe>8d9Ad`;SBPVMw{|YM zf4w`0*y+pJQdJ45yzo-0B9N*o5AcF2AUseB!3#pb6GEbhQjp*QA&^j2frOZuo&9_3 z^CgXuW6#Q-oB8IOZ@&3`JF|P=H*<40rt@`OT`E_LT3t;65kLr@S5*K&l>OrmdJW(d zvOM{4<{e~LHVVc+7?v2p{Mb<5& z5z^^>Rs+_xs{!lZ(I6JIY(R8yaT7%xtZJvFuFa z^fLMd`Wl)=pF~j<6h0FEB>Yl%SNN{*hVZIT#jO0|2(*PjScGHHyV8aYD!a?g^>?68 zgriUCchqb$ z`POwd);eWnd>n2Z_rOoBW2{@WrBUwM3~HnLNdru!wz*1CUaWxM0_A|!5{Z|l=Yj!c zZhUJ*jlnr_G$`Ht`~UW>CR{Q{V5cL%zyI%a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