Adds new models to CP.

This commit is contained in:
alshain
2011-02-11 00:27:20 +01:00
parent 34acf6f225
commit 48f62a505c
+39
View File
@@ -0,0 +1,39 @@
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy import create_engine
from sqlalchemy.schema import ThreadLocalMetaData
from elixir import *
# We would like to be able to create this schema in a specific database at
# will, so we can test it easily.
# Make elixir not bind to any session to make this possible.
#
# http://elixir.ematia.de/trac/wiki/Recipes/MultipleDatabasesOneMetadata
__session__ = None
class Resource(Entity):
"""Represents a resource of movies. This recources can be online or
offline."""
name = Field(UnicodeString(255))
path = Field(UnicodeString(255))
class Release(Entity):
"""Logically groups all files that belong to a certain release, such as
parts of a movie, subtitles, nfo, trailers etc."""
files = OneToMany('File')
class File(Entity):
"""File that belongs to a release."""
path = Field(UnicodeString(255))
release = ManyToOne('Release')
# Let's remember the size so we know about offline media.
size = Field(Integer)
type = ManyToOne('FileType')
class FileType(Entity):
"""Types could be trailer, subtitle, movie, partial movie etc."""
name = Field(UnicodeString(255))
files = OneToMany('File')