py::qodb::models::Album Class Reference

Inheritance diagram for py::qodb::models::Album:

Inheritance graph
[legend]

List of all members.

Public Member Functions

def create_qoid
def build_authors_raw
def build_authors_str
def rebuild_authors_str
def rebuild_all_strs
def is_nextout
def is_latestout
def belongs_to_library

Public Attributes

 authors_raw
 authors_str
 drawers_raw
 drawers_str

Static Public Attributes

tuple qoid = Qoid()
tuple name = StringField()
tuple series = models.ForeignKey(Series)
tuple volume = models.SmallIntegerField()
tuple catalog = models.ForeignKey(CatalogVersion, null=True)
list search_field = ["name", "authors_str", "drawers_str"]
tuple matching = StringField()
tuple authors_raw = StringField()
tuple drawers_raw = StringField()
tuple authors_str = StringField()
tuple drawers_str = StringField()
tuple authors = property(_get_authors,_set_authors)
tuple authors_entities = property(_get_authors_entities,_set_authors_entities)
tuple drawers = property(_get_drawers,_set_drawers)
tuple drawers_entities = property(_get_drawers_entities,_set_drawers_entities)
tuple published_date = models.CharField( maxlength=10, blank=True )
tuple ean = models.CharField( maxlength=13, blank=True )
tuple isbn = models.CharField( maxlength=10, blank=True )
tuple guiding_price = Price(default=0)
tuple published_date_obj = property(_get_published_date_obj)
tuple published_date_str = property(_get_published_date_str)
tuple created_by_user = models.BooleanField(default=False)
tuple deletable = property(_get_deletable)

Private Member Functions

def _authors_from_value
def _set_authors
def _get_authors
def _get_authors_entities
def _set_authors_entities
def _set_drawers
def _get_drawers
def _get_drawers_entities
def _set_drawers_entities
def _get_published_date_obj
def _get_published_date_str
def _get_deletable


Member Function Documentation

def py::qodb::models::Album::create_qoid (   model,
  series,
  name,
  ensure_new = True,
  props 
)

00341                                                                          :
00342                 if "ean" in props and props["ean"] :
00343                         id = props["ean"]
00344                 elif "isbn" in props and props["isbn"] :
00345                         id = props["isbn"]
00346                 else :
00347                         volume = ""
00348                         if "volume" in props and props["volume"] is not None :
00349                                 volume = str(props["volume"]).replace("-","MINUS")
00350                         id = "%s%s%s" % (series.qoid,qo.utils.make_qoid(name) or "DEFAULT",volume)
00351                 if ensure_new :
00352                         cont = True
00353                         nid = id
00354                         c = 0
00355                         while cont :
00356                                 try :
00357                                         model.objects.get(qoid=nid)
00358                                 except model.DoesNotExist :
00359                                         cont = False
00360                                 else :
00361                                         nid = "%s@%d" % (id,c)
00362                                         c += 1
00363                                         cont = True
00364                         id = nid
00365                 return id
00366 
00367         @staticmethod
        def build_authors_raw( values ) :

def py::qodb::models::Album::build_authors_raw (   values  ) 

00368                                         :
00369                 if isinstance(values, (str, unicode)) :
00370                         values = values.strip().split(" ")
00371                 return " %s " % " ".join(sorted(values))
00372         @staticmethod
        def build_authors_str( authors ) :

def py::qodb::models::Album::build_authors_str (   authors  ) 

00373                                          :
00374                 return ", ".join(sorted([author.name for author in authors]))
00375 
        def _authors_from_value( self, value ) :

def py::qodb::models::Album::_authors_from_value (   self,
  value 
) [private]

00376                                                :
00377                 authors = []
00378                 fetch_qoid = value
00379                 if self.cache :
00380                         fetch_qoid = []
00381                         for author_qoid in value :
00382                                 if author_qoid in self.cache["authors"] :
00383                                         authors.append(self.cache["authors"][author_qoid])
00384                                 else :
00385                                         fetch_qoid.append(author_qoid)
00386                 if len(fetch_qoid) :
00387                         authors += Author.objects.filter(qoid__in=fetch_qoid)
00388                 return authors
00389         
        def rebuild_authors_str( self, field="authors" ) :

def py::qodb::models::Album::rebuild_authors_str (   self,
  field = "authors" 
)

00390                                                          :
00391                 value = getattr(self, field)
00392                 if value :
00393                         setattr(self, "%s_str"%field, self.build_authors_str(self._authors_from_value(value)))
00394                 else :
00395                         setattr(self, "%s_str"%field, "")
00396 
        def rebuild_all_strs( self ) :

def py::qodb::models::Album::rebuild_all_strs (   self  ) 

00397                                      :
00398                 self.rebuild_authors_str("authors")
00399                 self.rebuild_authors_str("drawers")
00400 
        def _set_authors( self, value ) :

def py::qodb::models::Album::_set_authors (   self,
  value 
) [private]

00401                                         :
00402                 self.authors_raw = self.build_authors_raw(value)
00403                 self.rebuild_authors_str()
        def _get_authors( self ) :

def py::qodb::models::Album::_get_authors (   self  )  [private]

00404                                  :
00405                 return (self.authors_raw or "").strip().split()
        authors = property(_get_authors,_set_authors)

def py::qodb::models::Album::_get_authors_entities (   self,
  field = 'authors' 
) [private]

00408                                                            :
00409                 if len(getattr(self,field)) > 0 :
00410                         return Author.objects.filter(qoid__in=getattr(self,field))
00411                 return []
        def _set_authors_entities( self, authors ) :

def py::qodb::models::Album::_set_authors_entities (   self,
  authors 
) [private]

00412                                                    :
00413                 self.authors_raw = self.build_authors_raw([a.qoid for a in authors])
00414                 self.authors_str = self.build_authors_str(authors)
        authors_entities = property(_get_authors_entities,_set_authors_entities)

def py::qodb::models::Album::_set_drawers (   self,
  value 
) [private]

00417                                         :
00418                 self.drawers_raw = self.build_authors_raw(value)
00419                 self.rebuild_authors_str("drawers")
        def _get_drawers( self ) :

def py::qodb::models::Album::_get_drawers (   self  )  [private]

00420                                  :
00421                 return (self.drawers_raw or "").strip().split()
        drawers = property(_get_drawers,_set_drawers)

def py::qodb::models::Album::_get_drawers_entities (   self  )  [private]

00424                                           :
00425                 return self._get_authors_entities(field='drawers')
        def _set_drawers_entities( self, drawers ) :

def py::qodb::models::Album::_set_drawers_entities (   self,
  drawers 
) [private]

00426                                                    :
00427                 self.drawers_raw = self.build_authors_raw([a.qoid for a in drawers])
00428                 self.drawers_str = self.build_authors_str(drawers)
        drawers_entities = property(_get_drawers_entities,_set_drawers_entities)

def py::qodb::models::Album::_get_published_date_obj (   self  )  [private]

00436                                             :
00437                 value = self.published_date or "0000-00-00"
00438                 [ year, month, day ] = map( int, value.split('-') )
00439                 if year == 0 :
00440                         year = datetime.MINYEAR
00441                 if month == 0 :
00442                         month = 1
00443                 if day == 0 :
00444                         day = 1
00445                 return datetime.date( year, month, day )
        published_date_obj = property(_get_published_date_obj)

def py::qodb::models::Album::_get_published_date_str (   self  )  [private]

00448                                             :
00449                 value = self.published_date or "0000-00-00"
00450                 [ year, month, day ] = map( int, value.split('-') )
00451                 if year > 1900 :
00452                         fmt = '%Y'
00453                         if month != 0 :
00454                                 fmt = '%B '+fmt
00455                                 if day != 0 :
00456                                         fmt = '%d '+fmt
00457                         return qo.utils.decode(self.published_date_obj.strftime(fmt))
        published_date_str = property(_get_published_date_str)

def py::qodb::models::Album::is_nextout (   self  ) 

returns True if it's a next out (not yet published)
00462                                :
00463                 """
00464                 returns True if it's a next out (not yet published)
00465                 """
00466                 return self.published_date_obj > datetime.date.today()
00467 
        def is_latestout( self ) :

def py::qodb::models::Album::is_latestout (   self  ) 

returns True if it's a latest out
00468                                  :
00469                 """
00470                 returns True if it's a latest out
00471                 """
00472                 return not self.is_nextout() and self.published_date_obj >= (datetime.date.today() - qocfg.get_latestOut_time())
00473         
        def belongs_to_library( self, library_id ) :

def py::qodb::models::Album::belongs_to_library (   self,
  library_id 
)

00474                                                    :
00475                 return self.albumcopy_set.filter(library=library_id).count() > 0
00476 
        def _get_deletable( self ) :

def py::qodb::models::Album::_get_deletable (   self  )  [private]

00477                                    :
00478                 return self.created_by_user and self.album_copy_set.count() == 0
        deletable = property(_get_deletable)


Member Data Documentation

tuple py::qodb::models::Album::qoid = Qoid() [static]

tuple py::qodb::models::Album::name = StringField() [static]

tuple py::qodb::models::Album::series = models.ForeignKey(Series) [static]

tuple py::qodb::models::Album::volume = models.SmallIntegerField() [static]

tuple py::qodb::models::Album::catalog = models.ForeignKey(CatalogVersion, null=True) [static]

Reimplemented from py::qodb::models::catalog_interface.

list py::qodb::models::Album::search_field = ["name", "authors_str", "drawers_str"] [static]

Reimplemented from py::qodb::models::catalog_interface.

tuple py::qodb::models::Album::matching = StringField() [static]

Reimplemented from py::qodb::models::catalog_interface.

tuple py::qodb::models::Album::authors_raw = StringField() [static]

tuple py::qodb::models::Album::drawers_raw = StringField() [static]

tuple py::qodb::models::Album::authors_str = StringField() [static]

tuple py::qodb::models::Album::drawers_str = StringField() [static]

tuple py::qodb::models::Album::authors = property(_get_authors,_set_authors) [static]

tuple py::qodb::models::Album::authors_entities = property(_get_authors_entities,_set_authors_entities) [static]

tuple py::qodb::models::Album::drawers = property(_get_drawers,_set_drawers) [static]

tuple py::qodb::models::Album::drawers_entities = property(_get_drawers_entities,_set_drawers_entities) [static]

tuple py::qodb::models::Album::published_date = models.CharField( maxlength=10, blank=True ) [static]

tuple py::qodb::models::Album::ean = models.CharField( maxlength=13, blank=True ) [static]

tuple py::qodb::models::Album::isbn = models.CharField( maxlength=10, blank=True ) [static]

tuple py::qodb::models::Album::guiding_price = Price(default=0) [static]

tuple py::qodb::models::Album::published_date_obj = property(_get_published_date_obj) [static]

tuple py::qodb::models::Album::published_date_str = property(_get_published_date_str) [static]

tuple py::qodb::models::Album::created_by_user = models.BooleanField(default=False) [static]

Reimplemented from py::qodb::models::catalog_interface.

tuple py::qodb::models::Album::deletable = property(_get_deletable) [static]

Reimplemented from py::qodb::models::catalog_interface.

py::qodb::models::Album::authors_raw

py::qodb::models::Album::authors_str

py::qodb::models::Album::drawers_raw

py::qodb::models::Album::drawers_str


The documentation for this class was generated from the following file:
Generated on Tue Oct 9 20:40:33 2007 for Qomics by  doxygen 1.5.3