Exemplo n.º 1
0
    def save_item(self, **kw):

        cur_datetime = date.today()
        if kw["createtime"] == "":
            kw["createtime"] = cur_datetime
        hub.begin()
        if kw["new"]:
            item = BillingItem(
                ItemCode=kw["itemcode"],
                ItemDescription=kw["itemdescription"],
                ItemUnitCost=kw["itemunitcost"],
                ItemType=kw["itemtype"],
                ItemDiscountMaxAllowed=kw["itemdiscountmaxallowed"],
                ItemStatus=kw["itemstatus"],
                ModifyTime=cur_datetime,
                ModifyId="wesley",
                CreateTime=cur_datetime,
                CreateId="wesley",
            )
        else:
            if kw["createtime"] == "":
                createtime = cur_time
            else:
                time_strct = time.strptime(keywords["createtime"], "%Y-%m-%d %H:%M:%S")
                createtime = datetime(
                    time_strct.tm_year,
                    time_strct.tm_mon,
                    time_strct.tm_mday,
                    time_strct.tm_hour,
                    time_strct.tm_min,
                    time_strct.tm_sec,
                )
            item = BillingItem.get(kw["id"])
            item.ItemDescription = kw["itemdescription"]
            item.ItemUnitCost = kw["itemunitcost"]
            item.ItemType = kw["itemtype"]
            item.ItemDiscountMaxAllowed = kw["itemdiscountmaxallowed"]
            item.ItemStatus = kw["itemstatus"]
            item.ModifyTime = cur_datetime
            item.ModifyId = "wesley"
            item.CreateTime = kw["createtime"]
            item.CreateId = kw["createid"]

        hub.commit()
        hub.end()
        turbogears.flash("Changes saved!")
        raise cherrypy.HTTPRedirect(turbogears.url("/billing/edit_item?id=" + str(item.id)))
 def changepassword(self, namespace,
                    oldpassword, newpassword, repeat):
     ns = Namespace.byName(namespace)
     if ns.password != oldpassword:
         msg = INCORRECT_PASSWORD_MSG
     elif newpassword != repeat:
         msg = "The new password didn't match it's repeat."
     else:
         hub.begin()
         ns.password = newpassword
         hub.commit()
         hub.end()
         msg = "Password changed!"
     turbogears.flash(msg)
     url = turbogears.url("/namespace",
                          namespace=namespace,
                          password=ns.password)
     raise cherrypy.HTTPRedirect(url)
Exemplo n.º 3
0
        current.finished = datetime.datetime.now()
        hub.commit()
    except Exception, inst:
        import traceback

        hub.rollback()
        for admin in Group.by_group_name("admin").users:
            util.email(
                admin.email_address,
                "BandRadar <*****@*****.**>",
                "batch error",
                "Batch failed, Andy is on it!\n\n" + traceback.format_exc(),
            )

    log.info("batch finished")
    hub.end()


def send_email(start, finish):
    conn = hub.getConnection()

    users_to_email = set()

    #
    # Gather results for tracked artists. Notify if events added since last update
    #
    artist_email = {}
    results = conn.queryAll(
        """
        select u.id, e.name, e.date, v.name
        from user_acct u, artist_user_acct au, artist a, artist_event ae, event e, venue v