merge changes from master
This commit is contained in:
parent
5837997b7d
commit
8e85694895
85
content/migrations/0005_auto_20171219_1032.py
Normal file
85
content/migrations/0005_auto_20171219_1032.py
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.7 on 2017-12-19 10:32
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import markdownx.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('content', '0004_auto_20171218_1149'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunSQL(
|
||||||
|
[
|
||||||
|
('delete from content_resource where "resourceID" not in (select id from resources);', None),
|
||||||
|
('delete from content_resource where "contentID" not in (select id from content);', None),
|
||||||
|
('delete from person_content where "personID" not in (select id from people);', None),
|
||||||
|
('delete from person_content where "contentID" not in (select id from content);', None),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='content',
|
||||||
|
name='resources',
|
||||||
|
field=models.ManyToManyField(related_name='content', through='content.ContentResource', to='content.Resources'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='people',
|
||||||
|
name='content',
|
||||||
|
field=models.ManyToManyField(related_name='people', through='content.PersonContent', to='content.Content'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='people',
|
||||||
|
name='resources',
|
||||||
|
field=models.ManyToManyField(related_name='people', through='content.PersonResource', to='content.Resources'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='content',
|
||||||
|
name='body',
|
||||||
|
field=markdownx.models.MarkdownxField(blank=True, default='', null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='content',
|
||||||
|
name='parentid',
|
||||||
|
field=models.IntegerField(blank=True, db_column='parentID', editable=False, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='contentresource',
|
||||||
|
name='contentid',
|
||||||
|
field=models.ForeignKey(db_column='contentID', on_delete=django.db.models.deletion.CASCADE, to='content.Content'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='contentresource',
|
||||||
|
name='resourceid',
|
||||||
|
field=models.ForeignKey(db_column='resourceID', on_delete=django.db.models.deletion.CASCADE, to='content.Resources'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='personcontent',
|
||||||
|
name='contentid',
|
||||||
|
field=models.ForeignKey(db_column='contentID', on_delete=django.db.models.deletion.CASCADE, to='content.Content'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='personcontent',
|
||||||
|
name='personid',
|
||||||
|
field=models.ForeignKey(db_column='personID', on_delete=django.db.models.deletion.CASCADE, to='content.People'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='personresource',
|
||||||
|
name='personid',
|
||||||
|
field=models.ForeignKey(db_column='personID', on_delete=django.db.models.deletion.CASCADE, to='content.People'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='personresource',
|
||||||
|
name='resourceid',
|
||||||
|
field=models.ForeignKey(db_column='resourceID', on_delete=django.db.models.deletion.CASCADE, to='content.Resources'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='resources',
|
||||||
|
name='type',
|
||||||
|
field=models.IntegerField(choices=[(1, 'Resources'), (2, 'Images'), (3, 'Links')]),
|
||||||
|
),
|
||||||
|
]
|
|
@ -83,9 +83,15 @@ class Content(models.Model):
|
||||||
featured = models.BooleanField(default=False)
|
featured = models.BooleanField(default=False)
|
||||||
view = models.ForeignKey("Views", null=True, blank=True, db_column="view", editable=False)
|
view = models.ForeignKey("Views", null=True, blank=True, db_column="view", editable=False)
|
||||||
place = models.CharField(max_length=255, null=True, blank=True)
|
place = models.CharField(max_length=255, null=True, blank=True)
|
||||||
parentid = models.IntegerField(null=True, db_column='parentID', blank=True, editable=False) # delete
|
|
||||||
parents = models.ManyToManyField('Content', through='ContentContent', related_name="children")
|
parents = models.ManyToManyField('Content', through='ContentContent', related_name="children")
|
||||||
|
|
||||||
|
resources = models.ManyToManyField('Resources', through='ContentResource', related_name="content")
|
||||||
|
|
||||||
|
# delete after migration
|
||||||
|
parentid = models.IntegerField(null=True, db_column='parentID', blank=True, editable=False)
|
||||||
|
|
||||||
|
# end of delte
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
@ -116,6 +122,12 @@ class Content(models.Model):
|
||||||
if self.image:
|
if self.image:
|
||||||
return settings.IMAGE_PREFIX + self.image
|
return settings.IMAGE_PREFIX + self.image
|
||||||
|
|
||||||
|
def links(self):
|
||||||
|
return self.resources.filter(type=3).order_by('orderno')
|
||||||
|
|
||||||
|
def images(self):
|
||||||
|
return self.resources.filter(type=2).exclude(href=self.image).order_by('orderno')
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
if self.shortname:
|
if self.shortname:
|
||||||
parts = []
|
parts = []
|
||||||
|
@ -162,8 +174,11 @@ class ContentKeyword(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class ContentResource(models.Model):
|
class ContentResource(models.Model):
|
||||||
contentid = models.IntegerField(db_column='contentID') # Field name made lowercase.
|
contentid = models.ForeignKey('Content', db_column='contentID')
|
||||||
resourceid = models.IntegerField(db_column='resourceID') # Field name made lowercase.
|
resourceid = models.ForeignKey('Resources', db_column='resourceID')
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.resource.href
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
# managed = False
|
# managed = False
|
||||||
|
@ -202,14 +217,20 @@ class People(models.Model): #not used
|
||||||
bio = models.TextField(blank=True, null=True)
|
bio = models.TextField(blank=True, null=True)
|
||||||
type = models.IntegerField()
|
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:
|
class Meta:
|
||||||
# managed = False
|
# managed = False
|
||||||
db_table = 'people'
|
db_table = 'people'
|
||||||
|
|
||||||
|
|
||||||
class PersonContent(models.Model):
|
class PersonContent(models.Model):
|
||||||
personid = models.IntegerField(db_column='personID') # Field name made lowercase.
|
personid = models.ForeignKey("people", db_column="personID")
|
||||||
contentid = models.IntegerField(db_column='contentID') # Field name made lowercase.
|
contentid = models.ForeignKey("content", db_column="contentID")
|
||||||
level = models.IntegerField()
|
level = models.IntegerField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -218,8 +239,8 @@ class PersonContent(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class PersonResource(models.Model):
|
class PersonResource(models.Model):
|
||||||
personid = models.IntegerField(db_column='personID') # Field name made lowercase.
|
personid = models.ForeignKey("people", db_column="personID")
|
||||||
resourceid = models.IntegerField(db_column='resourceID') # Field name made lowercase.
|
resourceid = models.ForeignKey("resources", db_column="resourceID")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
# managed = False
|
# managed = False
|
||||||
|
@ -244,6 +265,29 @@ class Resources(models.Model):
|
||||||
dateadded = models.DateTimeField(db_column='dateAdded', null=True, blank=True) # Field name made lowercase.
|
dateadded = models.DateTimeField(db_column='dateAdded', null=True, blank=True) # Field name made lowercase.
|
||||||
orderno = models.IntegerField(db_column='orderNo', blank=True, null=True) # Field name made lowercase.
|
orderno = models.IntegerField(db_column='orderNo', blank=True, null=True) # Field name made lowercase.
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
href = self.href
|
||||||
|
if not href.startswith('http') and not href.startswith('/'):
|
||||||
|
href = '/' + href
|
||||||
|
if href.startswith('/'):
|
||||||
|
href = 'https://studio.camp' + href
|
||||||
|
return href
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_image(self):
|
||||||
|
if self.mime:
|
||||||
|
return self.mime.lower() in ('gif', 'jpeg', 'jpg', 'png')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_audio(self):
|
||||||
|
if self.mime:
|
||||||
|
return self.mime.lower() in ('mp3', 'ogg')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_video(self):
|
||||||
|
if self.mime:
|
||||||
|
return self.mime.lower() in ('ogv', 'mp4')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
# managed = False
|
# managed = False
|
||||||
db_table = 'resources'
|
db_table = 'resources'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user