Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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))
Exemplo n.º 6
0
    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))
Exemplo n.º 7
0
    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))
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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()
Exemplo n.º 10
0
 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()
Exemplo n.º 11
0
    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)
Exemplo n.º 12
0
    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)
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
 def toAtom(self):
     self.sort()
     return zebra.fetch("atom.zb", BoxView(self))
Exemplo n.º 15
0
 def toRSS(self):
     self.sort()
     return zebra.fetch("rss", BoxView(self))
Exemplo n.º 16
0
 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))
Exemplo n.º 17
0
    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)
Exemplo n.º 18
0
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))
Exemplo n.º 19
0
 def act_requestpass(self):
     print >> self.out, zebra.fetch(self.tplDir + "/frm_requestpass")
Exemplo n.º 20
0
    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)
Exemplo n.º 21
0
 def enter(self):
     import zebra
     print zebra.fetch("dsp_head")
Exemplo n.º 22
0
 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)
Exemplo n.º 23
0
 def act_requestpass(self):
     print >> self.out, zebra.fetch(self.tplDir + "/frm_requestpass")
Exemplo n.º 24
0
 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)
Exemplo n.º 25
0
 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)
Exemplo n.º 26
0
 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)
Exemplo n.º 27
0
 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))
Exemplo n.º 28
0
 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)
Exemplo n.º 29
0
 def prompt (self, message, action, hidden):
     wargs = {"message": message,
              "action": action,
              "hidden": hidden}
     print >> self.RES, zebra.fetch("login.zb", wargs)
Exemplo n.º 30
0
 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))
Exemplo n.º 31
0
 def sendCurrentStatement(self):
     sendmail(zebra.fetch("statement", self.currentStatement()))
Exemplo n.º 32
0
# ( 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>'
Exemplo n.º 33
0
 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"
Exemplo n.º 34
0
 def _runZebra(self, template):
     try:
         print >> self, zebra.fetch(template, self.model)
     except IOError:
         self.complain("unable to load %s.zb" % template)
Exemplo n.º 35
0
 def sendCurrentStatement(self):
     sendmail(zebra.fetch("statement", self.currentStatement()))
Exemplo n.º 36
0
 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))
Exemplo n.º 37
0
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))
Exemplo n.º 38
0
 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"        
Exemplo n.º 39
0
# ( 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>'
Exemplo n.º 40
0
 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))