コード例 #1
0
ファイル: tags.py プロジェクト: truonghn/infoshopkeeper
class Titletag(SQLObjectWithFormGlue):
    _connection = db.conn()
    when_tagged = DateCol(default=now)
    tagkey = StringCol()
    tagvalue = StringCol()
    tagcategory = ForeignKey('Tagcategory')
    parent = ForeignKey('Title', dbName='title_id')
コード例 #2
0
class Transaction(SQLObjectWithFormGlue):
	_table = "transactionLog"
	_connection = db.conn() 
	action=StringCol()
	amount=FloatCol()
	date=DateTimeCol(default=now)
	schedule = StringCol()            
	info =StringCol()
	owner =StringCol()
	cashier =StringCol() 

	def object_to_form(self):
		self.extracolumns()
		return SQLObjectWithFormGlue.object_to_form(self)

	def extracolumns(self):
		pass

	def void(self):
		pass

	def get_info(self):
		if 'tostring' in dir(self.info):
			return self.info.tostring()
		else:
			return self.info
コード例 #3
0
ファイル: emprunt.py プロジェクト: truonghn/infoshopkeeper
class Emprunt(SQLObjectWithFormGlue):
    _connection = db.conn()
    borrower = ForeignKey("Member")
    item = ForeignKey("Book")
    return_date = DateTimeCol(default=None)
    date = DateTimeCol(default=now)

    def object_to_form(self):
        self.extracolumns()
        return SQLObjectWithFormGlue.object_to_form(self)

    def checkin(self):
        self.return_date = now()
        return 1

    def getBorrower(self):
        return self.borrower

    def getItem(self):
        return self.item

    def getItemTitle(self):
        return self.item.getTitle()

    def extracolumns(self):
        pass

    def void(self):
        pass

    def get_info(self):
        if 'tostring' in dir(self.info):
            return self.info.tostring()
        else:
            return self.info
コード例 #4
0
ファイル: member.py プロジェクト: truonghn/infoshopkeeper
class Member(SQLObjectWithFormGlue):
    _connection = db.conn() 
    first_name = StringCol()
    last_name = StringCol()
    e_mail = StringCol()
    phone = StringCol()
    paid = StringCol()
コード例 #5
0
import pkg_resources
pkg_resources.require("TurboGears")

from turbogears import update_config, start_server, config
import cherrypy
cherrypy.lowercase_api = True
from os.path import *
import sys
sys.path.append('../')
from components import db

# first look on the command line for a desired config file,
# if it's not on the command line, then
# look for setup.py in this directory. If it's not there, this script is
# probably installed
if len(sys.argv) > 1:
    update_config(configfile=sys.argv[1],
                  modulename="infoshopkeeperonline.config")
elif exists(join(dirname(__file__), "setup.py")):
    update_config(configfile="dev.cfg",
                  modulename="infoshopkeeperonline.config")
else:
    update_config(configfile="prod.cfg",
                  modulename="infoshopkeeperonline.config")

config.update({'sqlobject.dburi': db.conn()})

from infoshopkeeperonline.controllers import Root

start_server(Root())
コード例 #6
0
ファイル: tags.py プロジェクト: truonghn/infoshopkeeper
class Tagcategory(SQLObjectWithFormGlue):
    _connection = db.conn()
    description = StringCol()
コード例 #7
0
class Section(SQLObjectWithFormGlue):
    _connection = db.conn()
    sectionName = StringCol()
    sectionDescription = StringCol()
    titles = RelatedJoin('Title')
コード例 #8
0
class Title(SQLObjectWithFormGlue,Tagable):
	class sqlmeta:
  	    fromDatabase = True
	_connection = db.conn()
	books = MultipleJoin('Book')
	author = RelatedJoin('Author')
	tags= MultipleJoin('Titletag')
	categorys = MultipleJoin('Category')
	sections = RelatedJoin('Section')
	kind = ForeignKey('Kind')
	listTheseKeys=('kind')
	tagclass=Titletag
	
	def copies_in_status(self,status):
		i=0
		for b in self.books:
			if b.status==status:
				i=i+1
		return i

	def authors_as_string(self):
		return string.join ([a.author_name for a in self.author],",")

	def categories_as_string(self):
		return string.join ([c.categoryName for c in self.categorys],",")

	def distributors(self):
		return list(sets.Set([b.distributor for b in self.books]))

	def distributors_as_string(self):
		distributors=self.distributors()
		if distributors is not None:
			distributors=[d for d in distributors if d is not None]
			return string.join(distributors,", ")
		else:
			return ""

	
	def last_book_inventoried(self):
		last_book=dummybook()
		for b in self.books:
			b.dummy=False
			if last_book.dummy==False:
				if b.inventoried_when > last_book.inventoried_when:
					last_book=b
			else:
				last_book=b
		return last_book
	

	
	def first_book_inventoried(self):
		first_book=dummybook()
		for b in self.books:
			b.dummy=False
			if first_book.dummy==False:
				if b.inventoried_when < first_book.inventoried_when:
					first_book=b
			else:
				first_book=b
		return first_book

	def highest_price_book(self):
		high_book=dummybook()
		for b in self.books:
			b.dummy=False
			
			if high_book.dummy==False:
				if b.listprice > high_book.listprice:
					high_book=b
			else:
				high_book=b
		return high_book


		
	def last_book_sold(self):
		last_book=dummybook()
		for b in self.books:
			b.dummy=False
			if b.status=="SOLD":
				if last_book.dummy==False:
					if b.sold_when > last_book.sold_when:
						last_book=b
				else:
					last_book=b
		return last_book

	def first_book_sold(self):
		first_book=dummybook()
		for b in self.books:
			b.dummy=False
			if b.status=="SOLD":
				if first_book.dummy==False:
					if b.sold_when < first_book.sold_when:
						first_book=b
				else:
					first_book=b
		return first_book
コード例 #9
0
ファイル: category.py プロジェクト: truonghn/infoshopkeeper
class Category(SQLObjectWithFormGlue):
    _connection = db.conn()
    title = ForeignKey('Title')
    categoryName = StringCol()
コード例 #10
0
ファイル: kind.py プロジェクト: truonghn/infoshopkeeper
class Kind(SQLObjectWithFormGlue):
    _connection = db.conn()
    kindName = StringCol()
コード例 #11
0
from turbogears import update_config, start_server, config
import cherrypy
cherrypy.lowercase_api = True
from os.path import *
import sys
sys.path.append('../')
from components import db




# first look on the command line for a desired config file,
# if it's not on the command line, then
# look for setup.py in this directory. If it's not there, this script is
# probably installed
if len(sys.argv) > 1:
    update_config(configfile=sys.argv[1], 
        modulename="infoshopkeeperonline.config")
elif exists(join(dirname(__file__), "setup.py")):
    update_config(configfile="dev.cfg",modulename="infoshopkeeperonline.config")
else:
    update_config(configfile="prod.cfg",modulename="infoshopkeeperonline.config")

config.update({'sqlobject.dburi':db.conn()})


from infoshopkeeperonline.controllers import Root

start_server(Root())
コード例 #12
0
ファイル: author.py プロジェクト: truonghn/infoshopkeeper
class Author(SQLObjectWithFormGlue):
    _connection = db.conn()
    titles = RelatedJoin('Title')
    author_name = StringCol(length=40, alternateID=True, default="Anonymous")