|
|
@ -1,10 +1,12 @@ |
|
|
|
from couchpotato.core.helpers.encoding import toUnicode |
|
|
|
from elixir.entity import Entity |
|
|
|
from elixir.fields import Field |
|
|
|
from elixir.options import options_defaults, using_options |
|
|
|
from elixir.relationships import ManyToMany, OneToMany, ManyToOne |
|
|
|
from libs.elixir.relationships import OneToOne |
|
|
|
from sqlalchemy.types import Integer, Unicode, UnicodeText, Boolean, Float, \ |
|
|
|
String |
|
|
|
String, TypeDecorator |
|
|
|
import json |
|
|
|
|
|
|
|
options_defaults["shortnames"] = True |
|
|
|
|
|
|
@ -16,6 +18,16 @@ options_defaults["shortnames"] = True |
|
|
|
__session__ = None |
|
|
|
|
|
|
|
|
|
|
|
class JsonType(TypeDecorator): |
|
|
|
impl = UnicodeText |
|
|
|
|
|
|
|
def process_bind_param(self, value, dialect): |
|
|
|
return toUnicode(json.dumps(value)) |
|
|
|
|
|
|
|
def process_result_value(self, value, dialect): |
|
|
|
return json.loads(value) |
|
|
|
|
|
|
|
|
|
|
|
class Movie(Entity): |
|
|
|
"""Movie Resource a movie could have multiple releases |
|
|
|
The files belonging to the movie object are global for the whole movie |
|
|
@ -35,11 +47,10 @@ class Library(Entity): |
|
|
|
|
|
|
|
year = Field(Integer) |
|
|
|
identifier = Field(String(20), index = True) |
|
|
|
rating = Field(Float) |
|
|
|
|
|
|
|
plot = Field(UnicodeText) |
|
|
|
tagline = Field(UnicodeText(255)) |
|
|
|
info = Field(UnicodeText) |
|
|
|
info = Field(JsonType) |
|
|
|
|
|
|
|
status = ManyToOne('Status') |
|
|
|
movies = OneToMany('Movie') |
|
|
|