Beispiel #1
0
def view_order_detail(environ, orderid):
    """
    View a specific order.
    """
    user = environ["emapps.user"]
    order = sql_get_order(orderid)
    if order is None:
        return kgi.template_response('404.html', status='404 Not Found')
    elif not (user.username in [order.customer, order.producer]
              or user.has_permission('producer')):
        return kgi.template_response('403.html', status='403 Forbidden',
                                     reason='This is none of your orders.')
    elif environ["REQUEST_METHOD"] == "POST":
        form = cgi.FieldStorage()
        text = form.getfirst("comment", None)
        if text is not None:
            sql_add_comment(orderid, user.username, text)
        return kgi.redirect_response('http://www.electusmatari.com/market/order/%s/'
                                     % orderid)
    else:
        comments = sql_get_comments(orderid)
        return kgi.template_response('market/order_detail.html',
                                     user=user,
                                     current_time=eve_time(),
                                     order=order,
                                     comments=comments)
Beispiel #2
0
def view_order_create(environ):
    user = environ["emapps.user"]
    if environ["REQUEST_METHOD"] == "POST":
        form = cgi.FieldStorage()
        item = form.getfirst("item", '')
        amount = form.getfirst("amount", None)
        price = form.getfirst("price", None)
        expires = form.getfirst("expires", None)
        comment = form.getfirst("comment", '')
        type = form.getfirst("type", "sell")
        if type not in ('sell', 'buy'):
            type = 'sell'
        try:
            amount = int(amount)
            price = float(price)
            expires = int(expires)
        except Exception, e:
            return kgi.template_response('market/error.html',
                                         user=user,
                                         error="The fields amount, price and expires are required.")
        if amount <= 0:
            return kgi.template_response('market/error.html',
                                         user=user,
                                         error='Amount should be positive.')
        sql_create_order(environ["emapps.user"].username,
                         type,
                         item,
                         amount,
                         price,
                         comment,
                         expires)
        return kgi.redirect_response('http://www.electusmatari.com/market/create/')
Beispiel #3
0
def view_order(environ, type):
    form = cgi.FieldStorage()
    user = environ["emapps.user"]
    if environ["REQUEST_METHOD"] == "POST":
        cancel = [field[6:] for field in form.keys()
                  if field.startswith("cancel")]
        if len(cancel) > 0:
            for orderid in cancel:
                sql_cancel_order(user.username, orderid)
            return kgi.redirect_response('http://www.electusmatari.com/market/')
        orders = {}
        for field in form.keys():
            if field.startswith("order"):
                try:
                    orderid = int(field[5:])
                    amount = int(form.getfirst(field))
                except Exception, e:
                    return kgi.template_response('market/error.html',
                                                 user=user,
                                                 error=str(e))
                if orderid not in orders:
                    orders[orderid] = 0
                orders[orderid] += amount
        if len(orders) == 0:
            return kgi.template_response('market/error.html',
                                         user=user,
                                         error="Please enter at least one item to buy.")
        else:
            contractid = sql_save_order(user.username, orders, type)
            if contractid is None:
                return kgi.redirect_response('http://www.electusmatari.com/market/contracts/')
            else:
                return kgi.redirect_response('http://www.electusmatari.com/market/contracts/%i/' % contractid)
Beispiel #4
0
def view_updateavatar(environ):
    """
    Set the avatar to an img.eve.is address.
    """
    user = environ["emapps.user"]
    db = kgi.connect('dbforcer')
    c = db.cursor()
    c.execute("SELECT corp FROM auth_user "
              "WHERE username = %s AND authenticated = 1",
              user.username)
    if c.rowcount == 0:
        return kgi.template_response('403.html',
                                     reason='Not authenticated.')
    api = eveapi.EVEAPIConnection()
    charids = api.eve.CharacterID(names=user.username)
    charid = None
    for char in charids.characters:
        charid = char.characterID
    if charid is None:
        return kgi.redirect_response('http://www.electusmatari.com/auth/')
    db = kgi.connect('dbforums')
    c = db.cursor()
    url = 'http://img.eve.is/serv.asp?s=64&c=%s' % charid
    c.execute("UPDATE mybb_users SET avatar = %s "
              "WHERE LOWER(username) = LOWER(%s)",
              (url, user.username))
    return kgi.redirect_response('http://www.electusmatari.com/auth/')
Beispiel #5
0
def view_check(environ):
    """
    Check all users whether they still can access the forums.

    This paginates the users so it will only check PAGESIZE per
    request, in case the server kills us off early.
    """
    form = cgi.FieldStorage()
    password = form.getfirst("password", "")
    if password != CHECK_PASSWORD:
        return kgi.template_response('403.html', reason='Wrong password.')

    try:
        offset = int(form.getfirst("offset", "0"))
    except ValueError:
        offset = 0

    # Get the alliance list now. On API error, bail out - the API is
    # down then.
    try:
        global alliances
        api = eveapi.EVEAPIConnection()
        alliances = api.eve.AllianceList().alliances
    except Exception, e:
        log.error("Error getting the alliance list, check aborted: %s"
                  % (str(e),))
        return
Beispiel #6
0
def view_orders_create(environ):
    """
    Form to create a new order.
    """
    user = environ["emapps.user"]
    if not user.is_authenticated():
        return kgi.html_response(
            unauthorized(user, 'You need to log in to the forums.')
            )
    if environ["REQUEST_METHOD"] == "POST":
        form = cgi.FieldStorage()
        ordertext = form.getfirst("ordertext", None)
        source = form.getfirst("source", None)
        comment = form.getfirst("comment", "")
        comment = comment.strip()
        if comment == "":
            comment = None
        if None in (ordertext, source):
            return kgi.redirect_response('http://www.electusmatari.com/market/order/create/')
        sql_create_order(user.username, ordertext, source, comment)
        return kgi.redirect_response('http://www.electusmatari.com/market/order/')
    return kgi.template_response('market/order_create.html',
                                 user=environ["emapps.user"],
                                 sources=SOURCES
                                 )
Beispiel #7
0
def view_submit(environ):
    user = environ['emapps.user']
    if environ["REQUEST_METHOD"] == 'POST':
        form = cgi.FieldStorage()
        mail = form.getfirst("mail", "")
        success = add_trace(user, mail)
        if success:
            return kgi.redirect_response('http://www.electusmatari.com/intel/')
        else:
            return kgi.template_response('intel/submit.html',
                                         user=user,
                                         pagetype='malformed',
                                         error=mail)
    return kgi.template_response('intel/submit.html',
                                 user=environ['emapps.user'],
                                 pagetype="normal")
Beispiel #8
0
def view_market(environ):
    user = environ["emapps.user"]
    table = []
    for (charname, staname, volentered, volremaining, minvolume, typename,
         range, wallet, duration, escrow,
         price, bid, issued) in list(csv.reader(file(MORDERFILE))):
        if int(bid) == 0:
            continue
        b = tempita.bunch()
        
        b.update({'pilot': charname,
                  'station': staname,
                  'volentered': int(volentered),
                  'volremaining': int(volremaining),
                  'minvolume': int(minvolume),
                  'typename': typename,
                  'range': int(range),
                  'wallet': wallet,
                  'duration': datetime.timedelta(days=int(duration)),
                  'escrow': escrow,
                  'price': float(price),
                  'bid': bid,
                  'issued': datetime.datetime.utcfromtimestamp(int(issued))})
        table.append(b)
    return kgi.template_response('gradient/marketorders.html',
                                 user=user,
                                 orders=table)
Beispiel #9
0
def view_order_edit(environ, orderid):
    """
    Edit a specific order.
    """
    user = environ["emapps.user"]
    order = sql_get_order(orderid)
    if order is None:
        return kgi.redirect_response('http://www.electusmatari.com/market/order/')
    if environ["REQUEST_METHOD"] == "POST":
        form = cgi.FieldStorage()
        customer = form.getfirst('customer')
        source = form.getfirst('source')
        state = form.getfirst('state')
        producer = form.getfirst('producer')
        if producer == '':
            producer = None
        price = form.getfirst('price')
        if price == '':
            price = None
        ordertext = form.getfirst('ordertext')
        if None not in (customer, source, state, ordertext):
            sql_update_order(orderid, customer=customer, source=source,
                             state=state, producer=producer, price=price,
                             ordertext=ordertext)
        return kgi.redirect_response('http://www.electusmatari.com/market/order/%s/'
                                     % orderid)
    return kgi.template_response('market/order_edit.html',
                                 user=user,
                                 order=order,
                                 sources=SOURCES,
                                 states=STATES)
Beispiel #10
0
def view_info(environ):
    """
    Show authentication status.
    """
    user = environ["emapps.user"]
    if not user.is_authenticated():
        return kgi.html_response(
            unauthorized(user, 'You need to log in to the forums.')
            )
    db = kgi.connect('dbforcer')
    c = db.cursor()
    c.execute("SELECT last_attempt, message, authenticated, disabled "
              "FROM auth_user WHERE username = %s LIMIT 1",
              (user.username,))
    if c.rowcount == 1:
        (last_attempt, message, authenticated, disabled) = c.fetchone()
    else:
        (last_attempt, message, authenticated, disabled) = (None, None,
                                                            None, None)
    return kgi.template_response('auth/info.html',
                                 user=user,
                                 last_attempt=last_attempt,
                                 message=message,
                                 authenticated=authenticated,
                                 disabled=disabled)
Beispiel #11
0
def view_recentcomments(environ):
    user = environ['emapps.user']
    return kgi.template_response('gallery/comments.html',
                                 user=user,
                                 current_time=eve_time(),
                                 breadcrumbs=[],
                                 comments=get_recent_comments()
                                 )
Beispiel #12
0
def view_prices(environ):
    user = environ["emapps.user"]
    data = simplejson.dumps([[row[0], float(row[1])]
                             for row
                             in csv.reader(file(PRICESFILE))])
    return kgi.template_response('gradient/pricelist.html',
                                 user=user,
                                 data=data)
def view_rc(environ):
    update_rc(environ)
    page = kgi.paginate('standings_rc',
                        dbname='dbforcer',
                        extra='ORDER BY date DESC, entity ASC')
    return kgi.template_response('standings/rc.html',
                                 user=environ['emapps.user'],
                                 current_time=eve_time(),
                                 page=page)
Beispiel #14
0
def view_price_comparison(environ):
    user = environ["emapps.user"]
    data = simplejson.dumps([[tn, float(prod), float(heim), long(vol),
                              float(jita), last]
                             for (tn, prod, heim, vol, jita, last)
                             in list(csv.reader(file(PRICESFILE)))])
    return kgi.template_response('gradient/price_comparison.html',
                                 user=user,
                                 data=data)
Beispiel #15
0
def view_stats(environ):
    db = kgi.connect('dbforcer')
    c = db.cursor()
    c.execute("SELECT COUNT(*) AS c, submitter "
              "FROM locator_trace "
              "GROUP BY submitter "
              "ORDER BY c DESC")
    return kgi.template_response('intel/stats.html',
                                 user=environ['emapps.user'],
                                 stats=c.fetchall())
Beispiel #16
0
def view_pi(environ):
    user = environ["emapps.user"]
    data = simplejson.dumps([[tn, float(index), float(prod), float(profit),
                              long(mov), float(jita_index), float(jita_prod)]
                             for (tn, index, prod, profit, mov, jita_index,
                                  jita_prod)
                             in list(csv.reader(file(PLANETFILE)))])
    return kgi.template_response('gradient/pi.html',
                                 user=user,
                                 data=data)
Beispiel #17
0
def view_voters(environ):
    user = environ["emapps.user"]
    members = pickle.load(file(MEMBERFILE))
    voters = [name for name, details in members.items()
              if 'Employee' in details['titles']
              or 'Director' in details['titles']]
    voters.sort(lambda a, b: cmp(a.lower(), b.lower()))
    return kgi.template_response('gradient/voters.html',
                                 user=user,
                                 voters=voters)
def view_standings(environ):
    update_rc(environ)
    positive = []
    negative = []
    for (tid, subject, edittime, prefix, editor) in get_threads(standings_forums[environ["org"]]):
        p = parse_subject(subject)
        if p is None:
            continue
        (entity, ticker, standing, comments, internal) = p
        standing = normalize_standing(standing)
        if standing == 0:
            continue
        b = tempita.bunch(entity=entity,
                          ticker=ticker,
                          standing=standing,
                          comments=comments,
                          tid=tid)
        if standing > 0:
            positive.append(b)
        else:
            negative.append(b)
    positive.sort(lambda a, b: cmp(a.entity.lower(), b.entity.lower()))
    negative.sort(lambda a, b: cmp(a.entity.lower(), b.entity.lower()))
    form = cgi.FieldStorage()
    format = form.getfirst("format", "html")
    if (format == 'igb'
        or (format == 'html'
            and environ["HTTP_USER_AGENT"].startswith("EVE-minibrowser"))):
        return kgi.template_response('standings/list_igb.html',
                              positive=positive,
                              negative=negative)
    elif format == 'xml':
        return kgi.template_response('standings/list_xml.html',
                                     header=[('Content-Type', 'text/xml')],
                                     standings=positive + negative)
    else:
        return kgi.template_response('standings/list.html',
                                     user=environ['emapps.user'],
                                     current_time=eve_time(),
                                     positive=positive,
                                     negative=negative)
Beispiel #19
0
def view_contracts_single(environ, contractid):
    user = environ["emapps.user"]
    contract = sql_get_contract(contractid)
    if contract is None:
        return kgi.template_response('404.html', status='404 Not Found')
    elif not contract_owned_by(user.username, contract):
        return kgi.template_response('403.html', status='403 Forbidden',
                                     reason='This is none of your contracts.')
    elif environ["REQUEST_METHOD"] == "POST":
        form = cgi.FieldStorage()
        text = form.getfirst("comment", None)
        if text is not None:
            sql_add_comment(contractid, user.username, text)
        return kgi.redirect_response('http://www.electusmatari.com/market/contracts/%s/'
                                     % contractid)
    else:
        comments = sql_get_comments(contractid)
        return kgi.template_response('market/contract.html',
                                     user=user,
                                     contract=contract,
                                     comments=comments)
def standings_check(environ):
    user = environ['emapps.user']
    if not user.has_permission(environ["org"]):
        return kgi.html_response(
            unauthorized(user, 'You are not authorized.')
            )
    tids = {}
    bogus = []
    to_set = []
    to_diplo = []
    to_act = {}
    now = datetime.datetime.utcnow()
    for (tid, subject, edittime, prefix, editor) in get_threads(standings_forums[environ["org"]]):
        try:
            edittime = datetime.datetime.utcfromtimestamp(edittime)
        except:
            edittime = now
        p = parse_subject(subject)
        if p is None:
            bogus.append((subject, tid))
        else:
            (entity, ticker, standing, comments, internal) = p
            tids.setdefault(entity, [])
            tids[entity].append((subject, tid))
            if prefix in PREFIX_TOSET:
                age = (now - edittime).days
                to_set.append((subject, tid, age))
            elif prefix in PREFIX_DIPLO:
                age = (now - edittime).days
                to_diplo.append((subject, tid, age))
            elif prefix in PREFIX_ACT:
                age = (now - edittime).days
                if editor is None:
                    editor = "None?"
                to_act.setdefault(editor, [])
                to_act[editor].append((subject, tid, age))
    dups = []
    for (entity, threads) in tids.items():
        if len(threads) > 1:
            dups.append((entity, threads))
    bogus.sort()
    dups.sort()
    to_act = to_act.items()
    to_act.sort(lambda a, b: cmp((a[0].lower(), a[1]), (b[0].lower(), b[1])))
    return kgi.template_response('standings/check.html',
                                 user=environ["emapps.user"],
                                 current_time=eve_time(),
                                 to_diplo=to_diplo,
                                 to_set=to_set,
                                 to_act=to_act,
                                 bogus=bogus,
                                 dups=dups)
Beispiel #21
0
def view_info(environ):
    user = environ['emapps.user']
    if environ['REQUEST_METHOD'] == 'POST':
        # FIXME! Check FC permission here.
        form = cgi.FieldStorage()
        optitle = form.getfirst("title")
        db = kgi.connect('dbforcer')
        c = db.cursor()
        c.execute("INSERT INTO opwarn_list (title) VALUES (%s)",
                  (optitle,))
        return kgi.redirect_response('http://www.electusmatari.com/ops/')
    return kgi.template_response('ops/info.html',
                                 user=user)
Beispiel #22
0
def view_corp(environ):
    """
    Show the members of your corp.
    """
    user = environ["emapps.user"]
    db = kgi.connect('dbforcer')
    c = db.cursor()
    c.execute("SELECT corp FROM auth_user "
              "WHERE username = %s AND authenticated = 1",
              user.username)
    if c.rowcount == 0:
        return kgi.template_response('auth/corp.html',
                                     user=environ['emapps.user'],
                                     error="You are not authenticated.")
    corpname = c.fetchone()[0]
    c.execute("SELECT username FROM auth_user "
              "WHERE corp = %s "
              " AND authenticated = 1 "
              "ORDER BY username ASC",
              corpname)
    apiusers = [x for (x,) in c.fetchall()]
    db2 = kgi.connect('dbforums')
    c2 = db2.cursor()
    c2.execute("SELECT username, usertitle FROM mybb_users "
               "WHERE CONCAT(',', usergroup, ',', additionalgroups, ',') "
               "      LIKE '%,56,%' "
               "ORDER BY username ASC")
    c2.execute("SELECT username, lastactive FROM mybb_users")
    active = dict((username, datetime.datetime.utcfromtimestamp(lastactive))
                  for (username, lastactive) in c2.fetchall())
    users = [(username, active[username], False)
             for username in apiusers]
    users.sort(lambda a, b: cmp(a[0].lower(), b[0].lower()))
    return kgi.template_response('auth/corp.html',
                                 user=user,
                                 corp=corpname,
                                 error=None,
                                 users=users,
                                 now=datetime.datetime.utcnow())
Beispiel #23
0
def view_orders(environ, own=False):
    """
    View orders - your own, or those assigned to you.
    """
    user = environ['emapps.user']
    form = cgi.FieldStorage()
    if environ["REQUEST_METHOD"] == 'POST':
        orderid = form.getfirst("orderid", None)
        action = form.getfirst("action", None)
        if None in (orderid, action):
            return kgi.redirect_response('http://www.electusmatari.com/market/order/')
        order = sql_get_order(orderid)
        if action == 'cancel':
            if order.customer == user.username:
                sql_drop_order(orderid)
            return kgi.redirect_response('http://www.electusmatari.com/market/order/')
        elif action == 'claim':
            if oder.state == 'unclaimed':
                sql_update_order(orderid, state='claimed',
                                 producer=user.username)
            return kgi.redirect_response('http://www.electusmatari.com/market/order/unclaimed/')
        elif action == 'markdelivered':
            if user.username == order.producer:
                sql_update_order(orderid, state='delivered')
            return kgi.redirect_response('http://www.electusmatari.com/market/order/')
        elif action == 'markdone':
            if user.username == order.producer:
                sql_update_order(orderid, state='done')
            return kgi.redirect_response('http://www.electusmatari.com/market/order/')
        return kgi.redirect_response('http://www.electusmatari.com/market/order/')
    if own:
        title = 'Your Buy Orders'
        orders = sql_get_own_orderlist(user.username)
    else:
        title = 'Buy Requests'
        producer = user.username
        allowed_sources = sql_get_sources(user)
        requested_sources = form.getlist('source')
        sources = [source for source in allowed_sources
                   if len(requested_sources) == 0
                   or source in requested_sources]
        states = form.getlist('state')
        orders = sql_get_orderlist(producer=producer,
                                   sources=sources,
                                   states=states)
    return kgi.template_response('market/order_list.html',
                                 user=user,
                                 current_time=eve_time(),
                                 orders=orders,
                                 title=title,
                                 states=STATES)
Beispiel #24
0
def view_sales(environ):
    """
    Display all active sell orders.
    """
    form = cgi.FieldStorage()
    user = environ["emapps.user"]
    if user.has_permission('em'):
        if environ["REQUEST_METHOD"] == "POST":
            cancel = [field[6:] for field in form.keys()
                      if field.startswith("cancel")]
            if len(cancel) > 0:
                for orderid in cancel:
                    sql_cancel_order(user.username, orderid)
                return kgi.redirect_response('http://www.electusmatari.com/market/')
            orders = {}
            for field in form.keys():
                if field.startswith("order"):
                    try:
                        orderid = int(field[5:])
                        amount = int(form.getfirst(field))
                    except:
                        return kgi.redirect_response('http://www.electusmatari.com/market/')
                    if orderid not in orders:
                        orders[orderid] = 0
                    orders[orderid] += amount
            if len(orders) == 0:
                return kgi.template_response('market/error.html',
                                             user=user,
                                             error="Please enter at least one item to buy.")
            else:
                sql_save_order(user.username, orders)
                return kgi.redirect_response('http://www.electusmatari.com/market/')
        sales = get_sales(form.getfirst("sort", None))
    else:
        sales = []
    return kgi.template_response('market/sales.html',
                                 user=user,
                                 sales=sales)
Beispiel #25
0
def view_contracts(environ):
    user = environ['emapps.user']
    form = cgi.FieldStorage()
    if environ["REQUEST_METHOD"] == "POST":
        contractid = form.getfirst("contractid", None)
        newstate = form.getfirst("state", None)
        if None in (contractid, newstate):
            return kgi.template_response('market/error.html',
                                         user=user,
                                         error='Bad form data.')
        if newstate not in STATES:
            return kgi.template_response('market/error.html',
                                         user=user,
                                         error='Bad state.')
        contract = sql_get_contract(contractid)
        if contract.handler != user.username:
            return kgi.template_response('403.html', status='403 Forbidden',
                                         reason='This contract is not for you to modify.')
        sql_update_contract(contract.id, state=newstate)
        return kgi.redirect_response('http://www.electusmatari.com/market/contracts/')
    creators = form.getlist('creator')
    queues = form.getlist('queue')
    handlers = form.getlist('handler')
    if len(creators) == 0 and len(handlers) == 0:
        creators = [user.username]
        handlers = [user.username]
    states = form.getlist('state')
    if len(states) == 0:
        states = STATES[:-1]
    return kgi.template_response('market/contract_list.html',
                                 user=user,
                                 states=states,
                                 nextstates=NEXTSTATES,
                                 contracts=get_contracts(user.username,
                                                         creators,
                                                         queues,
                                                         handlers,
                                                         states))
Beispiel #26
0
def view_contracts_create(environ):
    user = environ["emapps.user"]
    if environ["REQUEST_METHOD"] == "POST":
        form = cgi.FieldStorage()
        contracttext = form.getfirst("contracttext", None)
        queue = form.getfirst("queue", None)
        comment = form.getfirst("comment", "")
        comment = comment.strip()
        if comment == "":
            comment = None
        if None in (contracttext, queue):
            return kgi.redirect_response('http://www.electusmatari.com/market/contracts/create/')
        contractid = sql_create_contract(user.username, contracttext)
        if comment is not None:
            sql_add_comment(contractid, user.username, comment)
        return kgi.redirect_response('http://www.electusmatari.com/market/contracts/')
    return kgi.template_response('market/contract_create.html',
                                 user=user)
def view_reputation(environ):
    db = kgi.connect('dbforums')
    c = db.cursor()
    c.execute("SELECT u.uid, u.username, addu.uid, addu.username, "
              "       r.reputation, r.dateline, r.comments, r.pid "
              "FROM mybb_reputation r "
              "     INNER JOIN mybb_users u ON r.uid = u.uid "
              "     INNER JOIN mybb_users addu ON r.adduid = addu.uid "
              "ORDER BY r.dateline DESC "
              "LIMIT 23")
    reputation = [(uid, username, adduid, addusername, reputation,
                   datetime.datetime.utcfromtimestamp(dateline),
                   comments, pid)
                  for (uid, username, adduid, addusername, reputation,
                       dateline, comments, pid)
                  in c.fetchall()]
    return kgi.template_response('forums/reputation.html',
                                 user=environ["emapps.user"],
                                 reputation=reputation)
Beispiel #28
0
def view_listing(environ):
    form = cgi.FieldStorage()
    needle = form.getfirst("search", "")
    extra = ""
    extra_args = []
    if needle != "":
        extra += ("WHERE target LIKE %s "
                  "   OR system LIKE %s "
                  "   OR station LIKE %s "
                  "   OR agent LIKE %s "
                  "   OR submitter LIKE %s ")
        extra_args.extend(["%%%s%%" % needle] * 5)
    extra += "ORDER BY ts DESC, id DESC"
    page = kgi.paginate('locator_trace', dbname='dbforcer',
                        extra=extra, extra_args=extra_args)
    return kgi.template_response('intel/listing.html',
                                 user=environ['emapps.user'],
                                 current_time=eve_time(),
                                 traces=page,
                                 search=needle)
Beispiel #29
0
def emapps(environ, start_response):
    log = logging.getLogger()
    log.setLevel(logging.DEBUG)
    dbh = DBLogHandler()
    dbh.setLevel(logging.DEBUG)
    formatter = logging.Formatter("%(asctime)s %(name)-10s %(levelname)-10s "
                                  "%(message)s",
                                  "%Y-%m-%d %H:%M:%S")
    dbh.setFormatter(formatter)
    log.addHandler(dbh)

    environ['emapps.user'] = User(*mybb_auth.mybb_auth())
    app = wsgiref.util.shift_path_info(environ)
    if app == 'apps':
        data = kgi.dispatch(environ, start_response,
                            [('', lambda environ: kgi.template_response('apps.html', user=environ["emapps.user"]))])
    elif app == 'standings':
        import standings
        data = standings.standingsapp(environ, start_response)
    elif app == 'intel':
        import intel
        data = intel.intelapp(environ, start_response)
    elif app == 'market':
        import market
        data = market.marketapp(environ, start_response)
    elif app == 'oldadmin':
        import admin
        data = admin.adminapp(environ, start_response)
    elif app == 'gradient':
        import gradient
        data = gradient.grdapp(environ, start_response)
    elif app == 'gallery':
        import gallery
        data = gallery.galleryapp(environ, start_response)
    elif app == 'forumtools':
        import forums
        data = forums.forumsapp(environ, start_response)
    else:
        start_response('404 Not Found', [('Content-Type', 'text/html')])
        data = notfound().encode("utf-8")
    return data
Beispiel #30
0
def view_rfund(environ):
    user = environ["emapps.user"]

    categories = {}

    for typename, category, quantity in csv.reader(file(csvfile)):
        if category not in categories:
            categories[category] = []
        categories[category].append((typename, humane(int(quantity))))

    cats = categories.keys()
    cats.sort()

    data = []
    for cat in cats:
        types = categories[cat]
        types.sort()
        data.append((cat, types))

    return kgi.template_response('market/reimbursementfund.html',
                                 user=user,
                                 data=data)