예제 #1
0
class SharedShareholder( PartyRelationship ):
    """Relation from a shared organization to a shareholder"""
    using_options( tablename = 'party_relationship_shares', inheritance = 'multi' )
    established_from = ManyToOne( 'Organization', required = True, ondelete = 'cascade', onupdate = 'cascade' )
    established_to = ManyToOne( 'Party', required = True, ondelete = 'cascade', onupdate = 'cascade' )
    shares = Field( Integer() )

    class Admin( PartyRelationship.Admin ):
        verbose_name = _('Shareholder structure')
        verbose_name_plural = _('Shareholder structures')
        list_display = ['established_from', 'established_to', 'shares',]
        list_search = ['established_from.full_name', 'established_to.full_name']
        field_attributes = {'established_from':{'name':_('Organization')},
                            'established_to':{'name':_('Shareholder')}}

    class ShareholderAdmin( Admin ):
        verbose_name = _('Shareholder')
        list_display = ['established_to', 'shares', 'from_date', 'thru_date']
        form_display = ['established_to', 'shares', 'from_date', 'thru_date', 'comment']
        form_size = (500, 300)

    class SharedAdmin( Admin ):
        verbose_name = _('Shares')
        verbose_name_plural = _('Shares')
        list_display = ['established_from', 'shares', 'from_date', 'thru_date']
        form_display = ['established_from', 'shares', 'from_date', 'thru_date', 'comment']
        form_size = (500, 300)
예제 #2
0
class Release(Entity):
    """Logically groups all files that belong to a certain release, such as
    parts of a movie, subtitles."""

    identifier = Field(String(100), index=True)

    movie = ManyToOne('Movie')
    status = ManyToOne('Status')
    quality = ManyToOne('Quality')
    files = ManyToMany('File',
                       cascade='all, delete-orphan',
                       single_parent=True)
    info = OneToMany('ReleaseInfo', cascade='all, delete-orphan')

    def to_dict(self, deep={}, exclude=[]):
        orig_dict = super(Release, self).to_dict(deep=deep, exclude=exclude)

        new_info = {}
        for info in orig_dict.get('info', []):

            value = info['value']
            try:
                value = int(info['value'])
            except:
                pass

            new_info[info['identifier']] = value

        orig_dict['info'] = new_info

        return orig_dict
예제 #3
0
class DirectedDirector( PartyRelationship ):
    """Relation from a directed organization to a director"""
    using_options( tablename = 'party_relationship_dir', inheritance = 'multi' )
    established_from = ManyToOne( 'Organization', required = True, ondelete = 'cascade', onupdate = 'cascade' )
    established_to = ManyToOne( 'Party', required = True, ondelete = 'cascade', onupdate = 'cascade' )
    title = Field( Unicode( 256 ) )
    represented_by = OneToMany( 'RepresentedRepresentor', inverse = 'established_to' )

    class Admin( PartyRelationship.Admin ):
        verbose_name = _('Direction structure')
        verbose_name_plural = _('Direction structures')
        list_display = ['established_from', 'established_to', 'title', 'represented_by']
        list_search = ['established_from.full_name', 'established_to.full_name']
        field_attributes = {'established_from':{'name':_('Organization')},
                            'established_to':{'name':_('Director')}}

    class DirectorAdmin( Admin ):
        verbose_name = _('Director')
        list_display = ['established_to', 'title', 'from_date', 'thru_date']
        form_display = ['established_to', 'title', 'from_date', 'thru_date', 'represented_by', 'comment']

    class DirectedAdmin( Admin ):
        verbose_name = _('Directed organization')
        list_display = ['established_from', 'title', 'from_date', 'thru_date']
        form_display = ['established_from', 'title', 'from_date', 'thru_date', 'represented_by', 'comment']
예제 #4
0
class Release(Entity):
    """Logically groups all files that belong to a certain release, such as
    parts of a movie, subtitles."""

    last_edit = Field(Integer, default = lambda: int(time.time()), index = True)
    identifier = Field(String(100), index = True)

    movie = ManyToOne('Movie')
    status = ManyToOne('Status')
    quality = ManyToOne('Quality')
    files = ManyToMany('File')
    info = OneToMany('ReleaseInfo', cascade = 'all, delete-orphan')

    def to_dict(self, deep = None, exclude = None):
        if not exclude: exclude = []
        if not deep: deep = {}

        orig_dict = super(Release, self).to_dict(deep = deep, exclude = exclude)

        new_info = {}
        for info in orig_dict.get('info', []):

            value = info['value']
            try: value = int(info['value'])
            except: pass

            new_info[info['identifier']] = value

        orig_dict['info'] = new_info

        return orig_dict
예제 #5
0
파일: model.py 프로젝트: Xice/CouchPotato
class Release(Entity):
    """Logically groups all files that belong to a certain release, such as
    parts of a movie, subtitles."""

    movie = ManyToOne('Movie')
    status = ManyToOne('Status')
    quality = ManyToOne('Quality')
    files = ManyToMany('File')
    history = OneToMany('History')
예제 #6
0
파일: model.py 프로젝트: Xice/CouchPotato
class ProfileType(Entity):
    """"""
    using_options(order_by='order')

    order = Field(Integer)
    finish = Field(Boolean)
    wait_for = Field(Integer)

    quality = ManyToOne('Quality')
    profile = ManyToOne('Profile')
예제 #7
0
class ProfileType(Entity):
    """"""
    using_options(order_by = 'order')

    order = Field(Integer, default = 0, index = True)
    finish = Field(Boolean, default = True)
    wait_for = Field(Integer, default = 0)

    quality = ManyToOne('Quality')
    profile = ManyToOne('Profile')
예제 #8
0
파일: model.py 프로젝트: Xice/CouchPotato
class Movie(Entity):
    """Movie Resource a movie could have multiple releases
    The files belonging to the movie object are global for the whole movie
    such as trailers, nfo, thumbnails"""

    last_edit = Field(Integer)

    library = ManyToOne('Library')
    status = ManyToOne('Status')
    profile = ManyToOne('Profile')
    releases = OneToMany('Release')
    files = ManyToMany('File')
예제 #9
0
class Release(Entity):
    """Logically groups all files that belong to a certain release, such as
    parts of a movie, subtitles."""

    identifier = Field(String(100))

    movie = ManyToOne('Movie')
    status = ManyToOne('Status')
    quality = ManyToOne('Quality')
    files = ManyToMany('File')
    history = OneToMany('History')
    info = OneToMany('ReleaseInfo')
예제 #10
0
class RepresentedRepresentor( Entity ):
    """Relation from a representing party to the person representing the party"""
    using_options( tablename = 'party_representor' )
    from_date = Field( Date(), default = datetime.date.today, required = True, index = True )
    thru_date = Field( Date(), default = end_of_times, required = True, index = True )
    comment = Field( camelot.types.RichText() )
    established_from = ManyToOne( 'Person', required = True, ondelete = 'cascade', onupdate = 'cascade' )
    established_to = ManyToOne( 'DirectedDirector', required = True, ondelete = 'cascade', onupdate = 'cascade' )

    class Admin( EntityAdmin ):
        verbose_name = _('Represented by')
        list_display = ['established_from', 'from_date', 'thru_date']
        form_display = ['established_from', 'from_date', 'thru_date', 'comment']
        field_attributes = {'established_from':{'name':_( 'Name' )}}
예제 #11
0
class Movie(Entity):
    """Movie Resource a movie could have multiple releases
    The files belonging to the movie object are global for the whole movie
    such as trailers, nfo, thumbnails"""

    last_edit = Field(Integer, default = lambda: int(time.time()), index = True)
    type = 'movie'  # Compat tv branch

    library = ManyToOne('Library', cascade = 'delete, delete-orphan', single_parent = True)
    status = ManyToOne('Status')
    profile = ManyToOne('Profile')
    category = ManyToOne('Category')
    releases = OneToMany('Release', cascade = 'all, delete-orphan')
    files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True)
예제 #12
0
class PartyContactMechanism( Entity ):
    using_options( tablename = 'party_contact_mechanism' )

    def __new__(cls, *args, **kwargs):
        party_contact_mechanism = super(PartyContactMechanism, cls).__new__(cls, *args, **kwargs)
        setattr(party_contact_mechanism, '_contact_mechanism_mechanism', None)
        return party_contact_mechanism

    party = ManyToOne( 'Party', required = True, ondelete = 'cascade', onupdate = 'cascade' )
    contact_mechanism = ManyToOne( 'ContactMechanism', required = True, ondelete = 'cascade', onupdate = 'cascade' )
    from_date = Field( Date(), default = datetime.date.today, required = True, index = True )
    thru_date = Field( Date(), default = end_of_times, index = True )
    comment = Field( Unicode( 256 ) )

    def _get_contact_mechanism_mechanism(self):
        if self._contact_mechanism_mechanism != None:
            return self._contact_mechanism_mechanism
        return self.mechanism

    def _set_contact_mechanism_mechanism(self, mechanism):
        self._contact_mechanism_mechanism = mechanism
        if mechanism != None:
            if self.contact_mechanism:
                self.contact_mechanism.mechanism = mechanism
            else:
                self.contact_mechanism = ContactMechanism( mechanism=mechanism )

    #
    # A property to get and set the mechanism attribute of the
    # related contact mechanism object
    #
    contact_mechanism_mechanism = property( _get_contact_mechanism_mechanism,
                                            _set_contact_mechanism_mechanism )

    @ColumnProperty
    def mechanism( self ):
        return sql.select( [ContactMechanism.mechanism],
                           whereclause = (ContactMechanism.id==self.contact_mechanism_id))

    @ColumnProperty
    def party_name( self ):
        return sql.select( [Party.full_name],
                           whereclause = (Party.id==self.party_id))

    def __unicode__( self ):
        return unicode( self.contact_mechanism )

    Admin = PartyContactMechanismAdmin
예제 #13
0
class ReleaseInfo(Entity):
    """Properties that can be bound to a file for off-line usage"""

    identifier = Field(String(50), index = True)
    value = Field(Unicode(255), nullable = False)

    release = ManyToOne('Release')
예제 #14
0
class RenameHistory(Entity):
    """Remembers from where to where files have been moved."""

    old = Field(Unicode(255))
    new = Field(Unicode(255))

    file = ManyToOne('File')
예제 #15
0
class LibraryInfo(Entity):
    """"""

    identifier = Field(String(50))
    value = Field(Unicode(255), nullable=False)

    library = ManyToOne('Library')
예제 #16
0
class ContactMechanism( Entity ):
    using_options( tablename = 'contact_mechanism' )
    mechanism = Field( camelot.types.VirtualAddress( 256 ), required = True )
    party_address = ManyToOne( 'PartyAddress', ondelete = 'set null', onupdate = 'cascade' )
    party_contact_mechanisms = OneToMany( 'PartyContactMechanism' )

    def __unicode__( self ):
        if self.mechanism:
            return u'%s : %s' % ( self.mechanism[0], self.mechanism[1] )

    class Admin( EntityAdmin ):
        form_size = ( 700, 150 )
        verbose_name = _('Contact mechanism')
        list_display = ['mechanism']
        form_display = Form( ['mechanism', 'party_address'] )
        field_attributes = {'mechanism':{'minimal_column_width':25}}

        def get_depending_objects(self, contact_mechanism ):
            for party_contact_mechanism in contact_mechanism.party_contact_mechanisms:
                if party_contact_mechanism not in PartyContactMechanism.query.session.new:
                    party_contact_mechanism.expire( ['mechanism'] )
                    yield party_contact_mechanism
                    party = party_contact_mechanism.party
                    if party and party not in Party.query.session.new:
                        party.expire(['email', 'phone'])
                        yield party
예제 #17
0
class FileProperty(Entity):
    """Properties that can be bound to a file for off-line usage"""

    identifier = Field(String(20), index = True)
    value = Field(Unicode(255), nullable = False)

    file = ManyToOne('File')
예제 #18
0
class Language(Entity):
    """"""

    identifier = Field(String(20), index = True)
    label = Field(Unicode)

    titles = ManyToOne('LibraryTitle')
예제 #19
0
    class Type3Status(
            Entity, ):
        """
        Status Pattern
        .. attribute:: status_datetime For statuses that occur at a specific point in time
        .. attribute:: status_from_date For statuses that require a date range
        .. attribute:: from_date When a status was enacted or set
        """
        using_options(tablename=t3_status_name.lower(),
                      metadata=metadata,
                      collection=collection)
        __metaclass__ = Type3StatusMeta

        status_datetime = Field(Date, required=False)
        status_from_date = Field(Date, required=False)
        status_thru_date = Field(Date, required=False)
        from_date = Field(Date, required=True, default=datetime.date.today)
        thru_date = Field(Date, required=True, default=end_of_times)

        status_for = ManyToOne(
            statusable_entity,  #required = True,
            ondelete='cascade',
            onupdate='cascade')

        if not enumeration:
            classified_by = ManyToOne(t3_status_type_name,
                                      required=True,
                                      ondelete='cascade',
                                      onupdate='cascade')
        else:
            classified_by = Field(Enumeration(enumeration),
                                  required=True,
                                  index=True)

        class Admin(EntityAdmin):
            verbose_name = statusable_entity + ' Status'
            verbose_name_plural = statusable_entity + ' Statuses'
            list_display = [
                'status_from_date', 'status_thru_date', 'classified_by'
            ]
            verbose_name = statusable_entity + ' Status'
            if verbose_entity_name is not None:
                verbose_name = verbose_entity_name + ' Status'

        def __unicode__(self):
            return u'Status'
예제 #20
0
파일: model.py 프로젝트: Xice/CouchPotato
class LibraryTitle(Entity):
    """"""

    title = Field(Unicode)
    default = Field(Boolean)

    language = OneToMany('Language')
    libraries = ManyToOne('Library')
예제 #21
0
class History(Entity):
    """History of actions that are connected to a certain release,
    such as, renamed to, downloaded, deleted, download subtitles etc"""

    added = Field(Integer)
    message = Field(UnicodeText())
    type = Field(Unicode(50))

    release = ManyToOne('Release')
예제 #22
0
class Media(Entity):
    """Media Resource could have multiple releases
    The files belonging to the media object are global for the whole media
    such as trailers, nfo, thumbnails"""

    type = Field(String(10), default="movie", index=True)
    last_edit = Field(Integer, default=lambda: int(time.time()), index=True)

    library = ManyToOne('Library',
                        cascade='delete, delete-orphan',
                        single_parent=True)
    status = ManyToOne('Status')
    profile = ManyToOne('Profile')
    category = ManyToOne('Category')
    releases = OneToMany('Release', cascade='all, delete-orphan')
    files = ManyToMany('File',
                       cascade='all, delete-orphan',
                       single_parent=True)
예제 #23
0
class LibraryTitle(Entity):
    """"""
    using_options(order_by='-default')

    title = Field(Unicode)
    default = Field(Boolean)

    language = OneToMany('Language')
    libraries = ManyToOne('Library')
예제 #24
0
class SupplierCustomer( PartyRelationship ):
    """Relation from supplier to customer"""
    using_options( tablename = 'party_relationship_suppl', inheritance = 'multi' )
    established_from = ManyToOne( 'Party', required = True, ondelete = 'cascade', onupdate = 'cascade' )
    established_to = ManyToOne( 'Party', required = True, ondelete = 'cascade', onupdate = 'cascade' )

    class Admin( PartyRelationship.Admin ):
        verbose_name = _('Supplier - Customer')
        list_display = ['established_from', 'established_to', 'from_date', 'thru_date']

    class CustomerAdmin( EntityAdmin ):
        verbose_name = _('Customer')
        list_display = ['established_to', ]
        form_display = ['established_to', 'comment', 'from_date', 'thru_date']
        field_attributes = {'established_to':{'name':_( 'Name' )}}

    class SupplierAdmin( EntityAdmin ):
        verbose_name = _('Supplier')
        list_display = ['established_from', ]
        form_display = ['established_from', 'comment', 'from_date', 'thru_date']
        field_attributes = {'established_from':{'name':_( 'Name' )}}
예제 #25
0
파일: model.py 프로젝트: Xice/CouchPotato
class File(Entity):
    """File that belongs to a release."""

    path = Field(Unicode(255), nullable=False, unique=True)
    part = Field(Integer, default=1)

    type = ManyToOne('FileType')
    properties = OneToMany('FileProperty')

    history = OneToMany('RenameHistory')
    movie = ManyToMany('Movie')
    release = ManyToMany('Release')
    library = ManyToMany('Library')
예제 #26
0
class EmployerEmployee( PartyRelationship ):
    """Relation from employer to employee"""
    using_options( tablename = 'party_relationship_empl', inheritance = 'multi' )
    established_from = ManyToOne( 'Organization', required = True, ondelete = 'cascade', onupdate = 'cascade' )    # the employer
    established_to = ManyToOne( 'Person', required = True, ondelete = 'cascade', onupdate = 'cascade' )            # the employee

    @ColumnProperty
    def first_name( self ):
        return sql.select( [Person.first_name], Person.party_id == self.established_to_party_id )

    @ColumnProperty
    def last_name( self ):
        return sql.select( [Person.last_name], Person.party_id == self.established_to_party_id )

    @ColumnProperty
    def social_security_number( self ):
        return sql.select( [Person.social_security_number], Person.party_id == self.established_to_party_id )

    def __unicode__( self ):
        return u'%s %s %s' % ( unicode( self.established_to ), _('Employed by'),unicode( self.established_from ) )

    class Admin( PartyRelationship.Admin ):
        verbose_name = _('Employment relation')
        verbose_name_plural = _('Employment relations')
        list_filter = ['established_from.name']
        list_search = ['established_from.name', 'established_to.first_name', 'established_to.last_name']

    class EmployeeAdmin( EntityAdmin ):
        verbose_name = _('Employee')
        list_display = ['established_to', 'from_date', 'thru_date']
        form_display = ['established_to', 'comment', 'from_date', 'thru_date']
        field_attributes = {'established_to':{'name':_( 'Name' )}}

    class EmployerAdmin( EntityAdmin ):
        verbose_name = _('Employer')
        list_display = ['established_from', 'from_date', 'thru_date']
        form_display = ['established_from', 'comment', 'from_date', 'thru_date']
        field_attributes = {'established_from':{'name':_( 'Name' )}}
예제 #27
0
class Library(Entity):
    """"""

    year = Field(Integer)
    identifier = Field(String(20), index = True)

    plot = Field(UnicodeText)
    tagline = Field(UnicodeText(255))
    info = Field(JsonType)

    status = ManyToOne('Status')
    movies = OneToMany('Movie', cascade = 'all, delete-orphan')
    titles = OneToMany('LibraryTitle', cascade = 'all, delete-orphan')
    files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True)
예제 #28
0
파일: model.py 프로젝트: Xice/CouchPotato
class Library(Entity):
    """"""

    year = Field(Integer)
    identifier = Field(String(20))
    rating = Field(Float)

    plot = Field(UnicodeText)
    tagline = Field(UnicodeText(255))

    status = ManyToOne('Status')
    movie = OneToMany('Movie')
    titles = OneToMany('LibraryTitle')
    files = ManyToMany('File')
예제 #29
0
class Library(Entity):
    """"""
    using_options(inheritance='multi')

    # For Movies, CPS uses three: omdbapi (no prio !?), tmdb (prio 2) and couchpotatoapi (prio 1)
    type = Field(String(10), default="movie", index=True)
    primary_provider = Field(String(10), default="imdb", index=True)
    year = Field(Integer)
    identifier = Field(String(40), index=True)

    plot = Field(UnicodeText)
    tagline = Field(UnicodeText(255))
    info = Field(JsonType)

    status = ManyToOne('Status')
    media = OneToMany('Media', cascade='all, delete-orphan')
    titles = OneToMany('LibraryTitle', cascade='all, delete-orphan')
    files = ManyToMany('File',
                       cascade='all, delete-orphan',
                       single_parent=True)

    parent = ManyToOne('Library')
    children = OneToMany('Library')
예제 #30
0
class Library(Entity):
    """"""

    year = Field(Integer)
    identifier = Field(String(20))
    rating = Field(Float)

    plot = Field(UnicodeText)
    tagline = Field(UnicodeText(255))

    status = ManyToOne('Status')
    movies = OneToMany('Movie')
    titles = OneToMany('LibraryTitle')
    files = ManyToMany('File')
    info = OneToMany('LibraryInfo')

    def title(self):
        return self.titles[0]['title']