def act_(self): whom = self.input.get("user") assert whom, "please specify a user in the query string" self.model["history"] = self.bank.historyFor(whom) self.model["balance"] = self.bank.balanceFor(whom) if self.input.get("format")=="xml": self.response.contentType = "text/xml" self.write(zebra.fetch("profile-xml", self.model)) else: self.write(zebra.fetch("profile", self.model))
def act_welcome(self): try: a,u = self.fetchUserAndAccount() except: return self.model.update(BoxView(a)) self.model.update(BoxView(u)) self.model["shortname"] = u.server.shortname self.model["message"] = zebra.fetch("eml_welcome", self.model) self.model["subject"] = "Welcome to Cornerhost!" self.model["bcc"] = "*****@*****.**" print >> self, zebra.fetch("frm_mailer", self.model)
def act_welcome(self): try: a, u = self.fetchUserAndAccount() except: return self.model.update(BoxView(a)) self.model.update(BoxView(u)) self.model["shortname"] = u.server.shortname self.model["message"] = zebra.fetch("eml_welcome", self.model) self.model["subject"] = "Welcome to Cornerhost!" self.model["bcc"] = "*****@*****.**" print >> self, zebra.fetch("frm_mailer", self.model)
def list_task(self): #self.model["status"] = "*" tasks = map(BoxView, self.clerk.match(Task)) #, status='open')) self.model["list"] = tasks self.model["opt_area"] = ['asdf'] self.model["opt_status"] = ['open','urgent','active','closed'] print >> self, zebra.fetch("lst_task", self.model)
def prompt(self, message, action, hidden): model = { "message": message, "action": action, "hidden": hidden, } #@TODO: make this return a string self._sess._response.write(zebra.fetch("login", model))
def act_show_category(self): import zdc, zebra if self.input.get("path", "/") == "/": cat = Category() cat.ID = 0 else: cat = self.clerk.match(Category, path=self.input["path"])[0] self.consult(zdc.ObjectView(cat)) self.write(zebra.fetch("dsp_category", self.model))
def act_show_category(self): import zdc, zebra if self.input.get("path","/")== "/": cat = Category() cat.ID = 0 else: cat = self.clerk.match(Category, path=self.input["path"])[0] self.consult(zdc.ObjectView(cat)) self.write(zebra.fetch("dsp_category", self.model))
def toHTML(self, input=None): self.sort() model = {} bv = BoxView(self) for k in bv.keys(): model[k] = bv[k] model["stories"] = [ BoxView(s) for s in [o for o in self.stories if o.status != 'draft'][:NUM_ON_FRONTPAGE] ] return zebra.fetch(self.template, model)
def act_sendpass(self): try: user = self.userClass(email=self.input["email"]) except: self.complain(''' The email address, <b>%s</b>, wasn\'t found in our database.<br> You can <a href="user.py?action=signup">create a new account</a>,<br> or you can try a different email address below. ''' % weblib.request["email"]) self.next = "requestpass" else: self.consult(BoxView(user)) msg = zebra.fetch("eml_sendpass", self.model) zikebase.sendmail(msg) self.msg_sentpass()
def act_sendpass(self): try: user = self.userClass(email=self.input["email"]) except: self.complain( ''' The email address, <b>%s</b>, wasn\'t found in our database.<br> You can <a href="user.py?action=signup">create a new account</a>,<br> or you can try a different email address below. ''' % weblib.request["email"]) self.next = "requestpass" else: self.consult(BoxView(user)) msg = zebra.fetch("eml_sendpass", self.model) zikebase.sendmail(msg) self.msg_sentpass()
def list_task(self): self.model["project"] = self.input.get("project") self.model["status"] = self.input.get("status", "open") self.model["owner"] = self.input.get("owner") self.model["targetDate"] = self.input.get("targetDate") wc = "1=1 " if self.model["project"] in self.model["opt_project"]: wc += "AND project='%s' " % self.model["project"] if self.model["status"] in self.model["opt_status"]: wc += "AND status='%s' " % self.model["status"] if self.model["owner"] in self.model["opt_owner"]: wc += "AND owner='%s' " % self.model["owner"] # @TODO: validate targetdate is real date.. if self.model["targetDate"]: wc += "AND targetDate<='%s' " \ % date.us2sql(self.model["targetDate"]) whereClause = wc self.model["list"] = map(BoxView, self.clerk.match(Task)) print >> RES, zebra.fetch("lst_task", self.model)
def list_task(self): self.model["project"]=self.input.get("project") self.model["status"]=self.input.get("status","open") self.model["owner"]=self.input.get("owner") self.model["targetDate"]=self.input.get("targetDate") wc = "1=1 " if self.model["project"] in self.model["opt_project"]: wc += "AND project='%s' " % self.model["project"] if self.model["status"] in self.model["opt_status"]: wc += "AND status='%s' " % self.model["status"] if self.model["owner"] in self.model["opt_owner"]: wc += "AND owner='%s' " % self.model["owner"] # @TODO: validate targetdate is real date.. if self.model["targetDate"]: wc += "AND targetDate<='%s' " \ % date.us2sql(self.model["targetDate"]) whereClause = wc self.model["list"] = map(BoxView, self.clerk.match(Task)) print >> RES, zebra.fetch("lst_task", self.model)
def act_signup(self): if self.input.get("action") != "save": self.consult(BoxView(userClass())) print >> self.out, zebra.fetch(self.tplDir + "/frm_signup", self.model)
def toAtom(self): self.sort() return zebra.fetch("atom.zb", BoxView(self))
def toRSS(self): self.sort() return zebra.fetch("rss", BoxView(self))
def prompt(self, message, action, hidden): model = {"message": message, "action": action, "hidden": hidden, } #@TODO: make this return a string self._sess._response.write(zebra.fetch("login", model))
only_overdue = REQ.get("overdue") is not None model = {"errors": [], "rows": [], "only_overdue": only_overdue} r = Receivables(SQL, CLERK) coltotals = [0, 0, 0, 0] grandtotal = 0 for acc in r.dueAccounts(): aging = r.separate_ages(acc.aging()) rowtotal = 0 if ((aging[0] + aging[1] + aging[2]) == 0) and only_overdue: continue else: for i in range(len(aging)): coltotals[i] += aging[i] rowtotal += aging[i] grandtotal += aging[i] model["rows"].append({ "aging": aging, "account": acc, "rowtotal": rowtotal }) model["coltotals"] = coltotals model["grandtotal"] = grandtotal print >> RES, zebra.fetch("receivables", model)
import duckbill import zebra from strongbox import BoxView clerk = duckbill.config.makeClerk() data = {"errors":""} data["locked"] = [{ "account": a.account, "brand": a.brand, "balance": a.balance(), } for a in clerk.match(duckbill.Account, status="locked")] data["locked"].sort(lambda a, b: -cmp(a["balance"], b["balance"])) RES.write(zebra.fetch("locked.zb", data))
def act_requestpass(self): print >> self.out, zebra.fetch(self.tplDir + "/frm_requestpass")
only_overdue = REQ.get("overdue") is not None model = {"errors":[], "rows":[], "only_overdue": only_overdue} r = Receivables(SQL, CLERK) coltotals = [0,0,0,0] grandtotal = 0 for acc in r.dueAccounts(): aging = r.separate_ages(acc.aging()) rowtotal = 0 if ((aging[0]+aging[1]+aging[2])==0) and only_overdue: continue else: for i in range(len(aging)): coltotals[i] += aging[i] rowtotal += aging[i] grandtotal += aging[i] model["rows"].append({"aging": aging, "account": acc, "rowtotal": rowtotal}) model["coltotals"] = coltotals model["grandtotal"] = grandtotal print >> RES, zebra.fetch("receivables", model)
def enter(self): import zebra print zebra.fetch("dsp_head")
def act_show_product(self): import zdc, zebra prod = self.clerk.match(Product, code=self.input["code"])[0] self.consult(zdc.ObjectView(prod)) print >> self, zebra.fetch("dsp_product", self.model)
def act_update(self): self.auth.check() self.consult(BoxView(self.auth.user)) import os print >> self.out, zebra.fetch(self.tplDir + "/frm_update", self.model)
def show_channel(self): chan = self.clerk.fetch(Channel, long(self.input["ID"])) model = {"errors": []} model.update(BoxView(chan)) self.write(zebra.fetch("sho_channel", model))
def act_signup(self): if self.input.get("action")!="save": self.consult(BoxView(userClass())) print >> self.out, zebra.fetch(self.tplDir + "/frm_signup", self.model)
def prompt (self, message, action, hidden): wargs = {"message": message, "action": action, "hidden": hidden} print >> self.RES, zebra.fetch("login.zb", wargs)
def act_view(self): import zebra self.model["contents"] = self.cart.q_contents() self.model["total"] = self.cart.subtotal() if not self.silent: self.write(zebra.fetch("dsp_cart", self.model))
def sendCurrentStatement(self): sendmail(zebra.fetch("statement", self.currentStatement()))
# ( http://www.devshed.com/Server_Side/MySQL/MySQLWiz/ ) cur.execute( """ SELECT DATE_FORMAT(e.posted,'%m/%Y') x, SUM(IF(e.event='charge', amount,0)) AS charges, SUM(IF(e.event='payment', amount,0)) AS payments FROM bill_event e, bill_account ba WHERE e.accountID = ba.ID GROUP BY x ORDER BY e.posted """) ## display the chart ######################## print >> RES, zebra.fetch("dsp_head", {"errors":[]}) print >> RES, "<h2>actuals</h2>" print >> RES, "<p><i>These are the amounts actually charged and paid.</i><br>" print >> RES, "The total difference is LOWER than receivables, because it<br>" print >> RES, "subtracts unearned income (people paying for multiple<br>" print >> RES, "months or years at once).</p>" print >> RES, '<table cellspacing="0" cellpadding="2" width="500">' print >> RES, '<tr><th align="left">period</th>' print >> RES, '<th align="right">charges</th>' print >> RES, '<th align="right">payments</th>' print >> RES, '<th align="right">difference</th>' print >> RES, '</tr>'
def check_fetch(self): a = {"a": "x"} assert zebra.fetch("test/junk", {"each": [a]}) == "x\n" assert zebra.fetch("test/junk.zb", {"each": [a]}) == "x\n" assert zebra.fetch("test/xmljunk.zbx", {"each": [a]}) == "x\n"
def _runZebra(self, template): try: print >> self, zebra.fetch(template, self.model) except IOError: self.complain("unable to load %s.zb" % template)
def act_main(self): if self.input.get("msg") in self.MESSAGES: self.model["message"] = self.MESSAGES[self.input["msg"]] self.model["history"] = self.bank.historyFor(self.account.username) self.model["balance"] = self.bank.balanceFor(self.account.username) self.write(zebra.fetch("main", self.model))
import duckbill import zebra from strongbox import BoxView clerk = duckbill.config.makeClerk() data = {"errors": ""} data["locked"] = [{ "account": a.account, "brand": a.brand, "balance": a.balance(), } for a in clerk.match(duckbill.Account, status="locked")] data["locked"].sort(lambda a, b: -cmp(a["balance"], b["balance"])) RES.write(zebra.fetch("locked.zb", data))
def check_fetch(self): a = {"a":"x"} assert zebra.fetch("test/junk", {"each":[a]}) == "x\n" assert zebra.fetch("test/junk.zb", {"each":[a]}) == "x\n" assert zebra.fetch("test/xmljunk.zbx", {"each":[a]}) == "x\n"