mark all models as managed, use Boolean or flags, fill dateadded

This commit is contained in:
j 2017-12-09 12:52:15 +01:00
parent 909a0d97ee
commit 9e2e37b645
2 changed files with 190 additions and 190 deletions

View File

@ -21,7 +21,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'acrolike', 'db_table': 'acrolike',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -36,7 +36,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'acronym', 'db_table': 'acronym',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -49,7 +49,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'audios', 'db_table': 'audios',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -68,7 +68,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'comments', 'db_table': 'comments',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -80,7 +80,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'content_content', 'db_table': 'content_content',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -92,7 +92,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'content_keyword', 'db_table': 'content_keyword',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -104,7 +104,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'content_resource', 'db_table': 'content_resource',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -116,7 +116,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'content_types', 'db_table': 'content_types',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -128,7 +128,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'keywords', 'db_table': 'keywords',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -146,7 +146,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'people', 'db_table': 'people',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -159,7 +159,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'person_content', 'db_table': 'person_content',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -171,7 +171,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'person_resource', 'db_table': 'person_resource',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -190,7 +190,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'resources', 'db_table': 'resources',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -210,7 +210,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'videos', 'db_table': 'videos',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
@ -222,7 +222,7 @@ class Migration(migrations.Migration):
], ],
options={ options={
'db_table': 'views', 'db_table': 'views',
'managed': False, 'managed': True,
}, },
), ),
migrations.CreateModel( migrations.CreateModel(

View File

@ -5,89 +5,39 @@ from django.conf import settings
from django.db import models from django.db import models
from django.urls import reverse from django.urls import reverse
# Create your models here.
class Acrolike(models.Model):
title = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'acrolike'
class Acronym(models.Model):
name = models.CharField(max_length=255, blank=True, null=True)
c = models.CharField(max_length=50, blank=True, null=True)
a = models.CharField(max_length=50, blank=True, null=True)
m = models.CharField(max_length=50, blank=True, null=True)
p = models.CharField(max_length=50, blank=True, null=True)
class Meta:
managed = False
db_table = 'acronym'
class Audios(models.Model):
filename = models.CharField(max_length=255)
title = models.CharField(max_length=255, blank=True, null=True)
description = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'audios'
class Comments(models.Model): #not used
comment = models.TextField()
name = models.CharField(max_length=150, blank=True, null=True)
email = models.CharField(max_length=255, blank=True, null=True)
personid = models.IntegerField(db_column='personID', blank=True, null=True) # Field name made lowercase.
dateadded = models.DateTimeField(db_column='dateAdded', auto_now_add=True)
datemodified = models.DateTimeField(db_column='dateModified', blank=True, null=True, auto_now=True)
parentid = models.IntegerField(db_column='parentID', blank=True, null=True)
parent = models.ForeignKey('Comments', null=True, blank=True, related_name='comments', db_index=True, db_column='parentId')
content = models.ForeignKey('Content', null=True, blank=True, related_name='comments', db_index=True, db_column='contentID')
ip = models.CharField(db_column='IP', max_length=50, blank=True, null=True) # Field name made lowercase.
class Meta:
managed = False
db_table = 'comments'
class Content(models.Model): class Content(models.Model):
published = models.BooleanField(default=False)
view = models.ForeignKey("Views", null=True, blank=True, db_column="view")
parent = models.ForeignKey('Content', null=True, blank=True, related_name='children', db_index=True, db_column='parentId')
type = models.ForeignKey("ContentTypes", db_column="type") type = models.ForeignKey("ContentTypes", db_column="type")
shortname = models.CharField(db_column='shortName', max_length=255) # Field name made lowercase. shortname = models.CharField(db_column='shortName', max_length=255)
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
header = models.TextField(blank=True, null=True) header = models.TextField(blank=True, null=True)
body = models.TextField(blank=True, null=True) body = models.TextField(blank=True, null=True)
schedule = models.TextField(blank=True, null=True) schedule = models.TextField(blank=True, null=True)
schedulebutton = models.CharField(db_column='scheduleButton', max_length=255, blank=True, null=True) # Field name made lowercase. schedulebutton = models.CharField(db_column='scheduleButton', max_length=255, blank=True, null=True)
optbtn2 = models.CharField(db_column='optBtn2', max_length=127, blank=True, null=True) # Field name made lowercase. optbtn2 = models.CharField(db_column='optBtn2', max_length=127, blank=True, null=True)
opttext2 = models.TextField(db_column='optText2', blank=True, null=True) # Field name made lowercase. opttext2 = models.TextField(db_column='optText2', blank=True, null=True)
optbtn3 = models.CharField(db_column='optBtn3', max_length=127, blank=True, null=True) # Field name made lowercase. optbtn3 = models.CharField(db_column='optBtn3', max_length=127, blank=True, null=True)
opttext3 = models.TextField(db_column='optText3', blank=True, null=True) # Field name made lowercase. opttext3 = models.TextField(db_column='optText3', blank=True, null=True)
technotes = models.TextField(db_column='technotes', blank=True, null=True) technotes = models.TextField(db_column='technotes', blank=True, null=True)
image = models.CharField(max_length=150, blank=True, null=True) image = models.CharField(max_length=150, blank=True, null=True)
postedby = models.CharField(db_column='postedBy', max_length=50, blank=True, null=True) # Field name made lowercase. postedby = models.CharField(db_column='postedBy', max_length=50, blank=True, null=True)
datestart = models.DateField(db_column='dateStart', blank=True, null=True) # Field name made lowercase. datestart = models.DateField(db_column='dateStart', blank=True, null=True)
dateend = models.DateField(db_column='dateEnd', blank=True, null=True) # Field name made lowercase. dateend = models.DateField(db_column='dateEnd', blank=True, null=True)
dateadded = models.DateTimeField(db_column='dateAdded', auto_now_add=True) dateadded = models.DateTimeField(db_column='dateAdded', auto_now_add=True, null=True)
datemodified = models.DateTimeField(db_column='dateModified', blank=True, null=True, auto_now=True) datemodified = models.DateTimeField(db_column='dateModified', blank=True, null=True, auto_now=True)
published = models.BooleanField()
view = models.ForeignKey("Views", null=True, blank=True, db_column="view")
place = models.CharField(max_length=255, null=True, blank=True) place = models.CharField(max_length=255, null=True, blank=True)
parent = models.ForeignKey('Content', null=True, blank=True, related_name='children', db_index=True, db_column='parentId')
resources = models.ManyToManyField('Resources', through='ContentResource', related_name="content") resources = models.ManyToManyField('Resources', through='ContentResource', related_name="content")
def __unicode__(self): def __unicode__(self):
return self.title or 'Untitled' return self.title or 'Untitled'
class Meta: class Meta:
managed = True
db_table = 'content' db_table = 'content'
@property @property
@ -99,109 +49,29 @@ class Content(models.Model):
if self.shortname: if self.shortname:
return reverse('content', kwargs={'shortname': self.shortname}) return reverse('content', kwargs={'shortname': self.shortname})
''' def links(self):
class ContentContent(models.Model): return self.resources.filter(type=3).order_by('orderno')
contentid1 = models.ForeignKey('Content', db_column='contentID1', related_name='child')
contentid2 = models.ForeignKey('Content', db_column='contentID2', related_name='parent')
def __unicode__(self):
return "%s is child of %s" % (self.contentid1.title, self.contentid2.title,)
class Meta:
managed = False
db_table = 'content_content'
'''
class ContentKeyword(models.Model):
contentid = models.ForeignKey('Content', db_column='contentID')
resourceid = models.ForeignKey('Keywords', db_column='keywordID')
class Meta:
managed = False
db_table = 'content_keyword'
class ContentResource(models.Model):
content = models.ForeignKey('Content', db_column='contentID')
resource = models.ForeignKey('Resources', db_column='resourceID')
def __unicode__(self):
return self.resource.href
class Meta:
managed = False
db_table = 'content_resource'
class ContentTypes(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
def __unicode__(self):
return self.name
class Meta:
managed = False
db_table = 'content_types'
class Keywords(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'keywords'
class People(models.Model): #not used
name = models.CharField(max_length=255, blank=True, null=True)
email = models.CharField(max_length=255, blank=True, null=True)
location = models.CharField(max_length=255, blank=True, null=True)
login = models.CharField(max_length=100, blank=True, null=True)
password = models.CharField(max_length=16, blank=True, null=True)
href = models.CharField(max_length=255, blank=True, null=True)
bio = models.TextField(blank=True, null=True)
type = models.IntegerField()
resources = models.ManyToManyField('Resources', through='PersonResource', related_name='people')
content = models.ManyToManyField('Content', through='PersonContent', related_name='people')
class Meta:
managed = False
db_table = 'people'
class PersonContent(models.Model):
personid = models.ForeignKey("people", db_column="personID")
contentid = models.ForeignKey("content", db_column="contentID")
level = models.IntegerField()
class Meta:
managed = False
db_table = 'person_content'
class PersonResource(models.Model):
personid = models.ForeignKey("people", db_column="personID")
resourceid = models.ForeignKey("resources", db_column="resourceID")
class Meta:
managed = False
db_table = 'person_resource'
def images(self):
return self.resources.filter(type=2).exclude(href=self.image).order_by('orderno')
class Resources(models.Model): class Resources(models.Model):
type = models.IntegerField()
TYPE_CHOICES = (
(1, "Resources"),
(2, "Images"),
(3, "Links"),
)
type = models.IntegerField(choices=TYPE_CHOICES)
href = models.CharField(max_length=255) href = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True) description = models.TextField(blank=True, null=True)
mime = models.CharField(max_length=10, blank=True, null=True) mime = models.CharField(max_length=10, blank=True, null=True)
width = models.IntegerField(blank=True, null=True) width = models.IntegerField(blank=True, null=True)
height = models.IntegerField(blank=True, null=True) height = models.IntegerField(blank=True, null=True)
istech = models.IntegerField(db_column='isTech') # Field name made lowercase. istech = models.BooleanField(db_column='isTech')
dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase. dateadded = models.DateTimeField(db_column='dateAdded', auto_now_add=True, null=True)
orderno = models.IntegerField(db_column='orderNo', blank=True, null=True) # Field name made lowercase. orderno = models.IntegerField(db_column='orderNo', blank=True, null=True)
def __unicode__(self): def __unicode__(self):
return self.href return self.href
@ -230,28 +100,42 @@ class Resources(models.Model):
return self.mime.lower() in ('ogv', 'mp4') return self.mime.lower() in ('ogv', 'mp4')
class Meta: class Meta:
managed = False
db_table = 'resources' db_table = 'resources'
'''
class ContentContent(models.Model):
contentid1 = models.ForeignKey('Content', db_column='contentID1', related_name='child')
contentid2 = models.ForeignKey('Content', db_column='contentID2', related_name='parent')
class Videos(models.Model): # not used def __unicode__(self):
sha1 = models.CharField(max_length=50) return "%s is child of %s" % (self.contentid1.title, self.contentid2.title,)
href = models.CharField(max_length=255)
title = models.TextField(blank=True, null=True)
description = models.TextField(blank=True, null=True)
width = models.IntegerField(blank=True, null=True)
height = models.IntegerField(blank=True, null=True)
duration = models.IntegerField(blank=True, null=True)
thumbno = models.IntegerField(db_column='thumbNo') # Field name made lowercase.
image = models.CharField(max_length=255, blank=True, null=True)
contentid = models.IntegerField(blank=True, null=True)
class Meta: class Meta:
managed = False managed = False
db_table = 'videos' db_table = 'content_content'
'''
def image_url(self): class ContentResource(models.Model):
return settings.IMAGE_PREFIX + self.image content = models.ForeignKey('Content', db_column='contentID')
resource = models.ForeignKey('Resources', db_column='resourceID')
def __unicode__(self):
return self.resource.href
class Meta:
db_table = 'content_resource'
class ContentTypes(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
def __unicode__(self):
return self.name
class Meta:
db_table = 'content_types'
class Views(models.Model): class Views(models.Model):
@ -262,6 +146,122 @@ class Views(models.Model):
return self.name return self.name
class Meta: class Meta:
managed = False
db_table = 'views' db_table = 'views'
# unused but has values in db
class Acrolike(models.Model):
title = models.CharField(max_length=255)
class Meta:
db_table = 'acrolike'
class Acronym(models.Model):
name = models.CharField(max_length=255, blank=True, null=True)
c = models.CharField(max_length=50, blank=True, null=True)
a = models.CharField(max_length=50, blank=True, null=True)
m = models.CharField(max_length=50, blank=True, null=True)
p = models.CharField(max_length=50, blank=True, null=True)
class Meta:
db_table = 'acronym'
class People(models.Model):
name = models.CharField(max_length=255, blank=True, null=True)
email = models.CharField(max_length=255, blank=True, null=True)
location = models.CharField(max_length=255, blank=True, null=True)
login = models.CharField(max_length=100, blank=True, null=True)
password = models.CharField(max_length=16, blank=True, null=True)
href = models.CharField(max_length=255, blank=True, null=True)
bio = models.TextField(blank=True, null=True)
type = models.IntegerField()
resources = models.ManyToManyField('Resources', through='PersonResource', related_name='people')
content = models.ManyToManyField('Content', through='PersonContent', related_name='people')
def __unicode__(self):
return self.name
class Meta:
db_table = 'people'
class PersonContent(models.Model):
personid = models.ForeignKey("people", db_column="personID")
contentid = models.ForeignKey("content", db_column="contentID")
level = models.IntegerField()
class Meta:
db_table = 'person_content'
class PersonResource(models.Model):
personid = models.ForeignKey("people", db_column="personID")
resourceid = models.ForeignKey("resources", db_column="resourceID")
class Meta:
db_table = 'person_resource'
class Videos(models.Model):
sha1 = models.CharField(max_length=50)
href = models.CharField(max_length=255)
title = models.TextField(blank=True, null=True)
description = models.TextField(blank=True, null=True)
width = models.IntegerField(blank=True, null=True)
height = models.IntegerField(blank=True, null=True)
duration = models.IntegerField(blank=True, null=True)
thumbno = models.IntegerField(db_column='thumbNo')
image = models.CharField(max_length=255, blank=True, null=True)
contentid = models.IntegerField(blank=True, null=True)
class Meta:
db_table = 'videos'
def image_url(self):
return settings.IMAGE_PREFIX + self.image
# UNUSED
class Audios(models.Model):
filename = models.CharField(max_length=255)
title = models.CharField(max_length=255, blank=True, null=True)
description = models.TextField(blank=True, null=True)
class Meta:
db_table = 'audios'
class Comments(models.Model):
comment = models.TextField()
name = models.CharField(max_length=150, blank=True, null=True)
email = models.CharField(max_length=255, blank=True, null=True)
personid = models.IntegerField(db_column='personID', blank=True, null=True)
dateadded = models.DateTimeField(db_column='dateAdded', auto_now_add=True, null=True)
datemodified = models.DateTimeField(db_column='dateModified', blank=True, null=True, auto_now=True)
parentid = models.IntegerField(db_column='parentID', blank=True, null=True)
parent = models.ForeignKey('Comments', null=True, blank=True, related_name='comments', db_index=True, db_column='parentId')
content = models.ForeignKey('Content', null=True, blank=True, related_name='comments', db_index=True, db_column='contentID')
ip = models.CharField(db_column='IP', max_length=50, blank=True, null=True)
class Meta:
db_table = 'comments'
class Keywords(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
class Meta:
db_table = 'keywords'
class ContentKeyword(models.Model):
content = models.ForeignKey('Content', db_column='contentID')
keyword = models.ForeignKey('Keywords', db_column='keywordID')
class Meta:
db_table = 'content_keyword'