コード例 #1
0
    def make_foreign_key(cls, nullable=False):
        return models.ForeignKey(
            cls,
            blank=nullable,
            null=nullable,
        )

MetadataSubjectTestTextMetadata = TextMetadata.make_model(
    MetadataSubjectTest,
    'metadata',
    fkey=MetadataSubjectTest.make_foreign_key(nullable=True)
)

MetadataSubjectTestPackageEntry = PackageEntry.make_model(
    MetadataSubjectTest,
    'metadata',
    fkey=MetadataSubjectTest.make_foreign_key(nullable=True)
)

# See if overriding as much as possible works
TestImageMetadata = ImageMetadata.make_model(
    MetadataSubjectTest,
    'metadata',
    model_name='TestImageMetadata',
    table='frobnik',
    id_column='foobles',
    fkey=MetadataSubjectTest.make_foreign_key(nullable=True),
)


class PackageTest(TestCase):
コード例 #2
0
    ## METADATA ##

    class Meta:
        if hasattr(settings, 'PODCAST_DB_TABLE'):
            db_table = settings.PODCAST_DB_TABLE
        ordering = ['-date_submitted']
        get_latest_by = 'date_submitted'
        app_label = 'uryplayer'


# Automagic metadata models #

PodcastPackageEntry = PackageEntry.make_model(
    Podcast,
    'uryplayer',
    'PodcastPackageEntry',
    getattr(settings, 'PODCAST_PACKAGE_ENTRY_DB_TABLE', None),
    getattr(settings, 'PODCAST_PACKAGE_ENTRY_DB_ID_COLUMN', None),
    fkey=Podcast.make_foreign_key()
)

PodcastTextMetadata = TextMetadata.make_model(
    Podcast,
    'uryplayer',
    'PodcastTextMetadata',
    getattr(settings, 'PODCAST_TEXT_METADATA_DB_TABLE', None),
    getattr(settings, 'PODCAST_TEXT_METADATA_DB_ID_COLUMN', None),
    fkey=Podcast.make_foreign_key(nullable=True)
)

PodcastImageMetadata = ImageMetadata.make_model(
    Podcast,