Permalink
Browse files

For syncing to stormwind.local.

  • Loading branch information...
1 parent 9b4ba42 commit ed756741ae9e851c06892c8fd88e470f745d0227 @livid committed Jun 3, 2011
View
29 api.py
@@ -6,12 +6,14 @@
import time
import datetime
import hashlib
+import logging
import string
import random
import base64
from google.appengine.ext import webapp
from google.appengine.api import memcache
+from google.appengine.api import urlfetch
from google.appengine.ext import db
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template
@@ -31,6 +33,8 @@
from v2ex.babel.da import *
from v2ex.babel.ext.cookies import Cookies
+from django.utils import simplejson as json
+
template.register_template_library('v2ex.templatetags.filters')
@@ -269,6 +273,28 @@ def get(self):
self.response.headers['Content-type'] = 'application/json'
self.response.out.write(output)
+class CurrencyHandler(webapp.RequestHandler):
+ def get(self):
+ codes = ['EUR', 'JPY', 'CNY', 'CHF', 'AUD', 'TWD', 'CAD', 'GBP', 'HKD', 'MYR', 'NZD', 'PHP', 'SGD', 'THB']
+ template_values = {}
+ o = memcache.get('currency.json')
+ if o is not None:
+ pass
+ else:
+ for code in codes:
+ url = 'http://www.google.com/ig/calculator?hl=en&q=1USD=?' + code
+ response = urlfetch.fetch(url)
+ m = re.findall('rhs: "([0-9\.]+)', response.content)
+ if len(m) > 0:
+ value = m[0].strip().replace(' ', '')
+ else:
+ value = 0
+ template_values[code.lower()] = value
+ path = os.path.join(os.path.dirname(__file__), 'tpl', 'api', 'currency.json')
+ o = template.render(path, template_values)
+ memcache.set('currency.json', o, 86400)
+ self.response.headers['Content-type'] = 'application/json'
+ self.response.out.write(o)
def main():
application = webapp.WSGIApplication([
@@ -279,7 +305,8 @@ def main():
('/api/topics/latest.json', TopicsLatestHandler),
('/api/topics/show.json', TopicsShowHandler),
('/api/topics/create.json', TopicsCreateHandler),
- ('/api/members/show.json', MembersShowHandler)
+ ('/api/members/show.json', MembersShowHandler),
+ ('/api/currency.json', CurrencyHandler)
],
debug=True)
util.run_wsgi_app(application)
View
@@ -170,6 +170,9 @@ handlers:
script: queue.py
login: admin
+- url: /money/(.*)
+ script: money.py
+
- url: /sso/(.*)
script: sso.py
View
@@ -278,7 +278,7 @@ def get(self):
else:
q2 = db.GqlQuery("SELECT * FROM Topic ORDER BY last_touched DESC LIMIT 16,50")
topics = []
- IGNORED_RECENT = ['flamewar', 'pointless', 'in', 'autistic', 'chamber']
+ IGNORED_RECENT = ['flamewar', 'pointless', 'in', 'autistic', 'chamber', 'flood']
for topic in q2:
if topic.node_name not in IGNORED_RECENT:
topics.append(topic)
View
@@ -165,6 +165,7 @@ def get(self):
if member.psn is None:
member.psn = ''
template_values['member_psn'] = member.psn
+ template_values['member_btc'] = member.btc
template_values['member_location'] = member.location
if (member.tagline == None):
member.tagline = ''
@@ -345,6 +346,29 @@ def post(self):
template_values['member_psn'] = member_psn
template_values['member_psn_error'] = member_psn_error
template_values['member_psn_error_message'] = member_psn_error_messages[member_psn_error]
+ # Verification: btc
+ member_btc_error = 0
+ member_btc_error_messages = ['',
+ u'BTC 收款地址长度不能超过 40 个字符',
+ u'BTC 收款地址不符合规则'
+ ]
+ member_btc = self.request.get('btc').strip()
+ if (len(member_btc) == 0):
+ member_btc = ''
+ else:
+ if (len(member_btc) > 40):
+ errors = errors + 1
+ member_btc_error = 1
+ else:
+ p = re.compile('^[a-zA-Z0-9]+$')
+ if (p.search(member_btc)):
+ errors = errors
+ else:
+ errors = errors + 1
+ member_btc_error = 2
+ template_values['member_btc'] = member_btc
+ template_values['member_btc_error'] = member_btc_error
+ template_values['member_btc_error_message'] = member_btc_error_messages[member_btc_error]
# Verification: location
member_location_error = 0
member_location_error_messages = ['',
@@ -428,6 +452,7 @@ def post(self):
member.website = member_website
member.twitter = member_twitter
member.psn = member_psn
+ member.btc = member_btc
member.location = member_location
member.tagline = member_tagline
if member.twitter_oauth == 1:
View
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# coding=utf-8
+
+import os
+import re
+import time
+import datetime
+import hashlib
+import string
+import random
+
+from google.appengine.ext import webapp
+from google.appengine.api import memcache
+from google.appengine.ext import db
+from google.appengine.ext.webapp import util
+from google.appengine.ext.webapp import template
+from google.appengine.api.labs import taskqueue
+
+from v2ex.babel import Member
+from v2ex.babel import Counter
+from v2ex.babel import Section
+from v2ex.babel import Node
+from v2ex.babel import Topic
+from v2ex.babel import Reply
+from v2ex.babel import Note
+from v2ex.babel import Notification
+
+from v2ex.babel import SYSTEM_VERSION
+
+from v2ex.babel.security import *
+from v2ex.babel.ua import *
+from v2ex.babel.da import *
+from v2ex.babel.l10n import *
+from v2ex.babel.ext.cookies import Cookies
+
+from v2ex.babel.handlers import BaseHandler
+
+import config
+
+template.register_template_library('v2ex.templatetags.filters')
+
+class MoneyDashboardHandler(BaseHandler):
+ def get(self):
+ if self.member:
+ self.set_title(u'账户查询')
+ self.finalize(template_name='money_dashboard')
+ else:
+ self.redirect('/signin')
+
+def main():
+ application = webapp.WSGIApplication([
+ ('/money/dashboard/?', MoneyDashboardHandler)
+ ],
+ debug=True)
+ util.run_wsgi_app(application)
+
+
+if __name__ == '__main__':
+ main()
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,17 @@
+{
+"USD" : 1,
+"EUR" : {{ eur }},
+"CNY" : {{ cny }},
+"JPY" : {{ jpy }},
+"CHF" : {{ chf }},
+"AUD" : {{ aud }},
+"TWD" : {{ twd }},
+"CAD" : {{ cad }},
+"GBP" : {{ gbp }},
+"HKD" : {{ hkd }},
+"MYR" : {{ myr }},
+"NZD" : {{ nzd }},
+"PHP" : {{ php }},
+"SGD" : {{ sgd }},
+"THB" : {{ thb }}
+}
@@ -70,9 +70,15 @@
{% endif %}</td>
<td width="50%"></td>
</tr>
-
+ {% if one.btc %}
+ <tr>
+ <td width="50%">
+ <span style="line-height: 16px;"><img src="/static/img/btc.png" align="absmiddle" /> &nbsp;<small><a href="http://blockexplorer.com/address/{{ one.btc }}" target="_blank">{{ one.btc }}</a></small></span>
+ </td>
+ <td width="50%"></td>
+ </tr>
+ {% endif %}
</table>
-
</td>
</tr>
</table>
@@ -49,6 +49,9 @@
{% if member_psn_error %}
<li>{{ member_psn_error_message }}</li>
{% endif %}
+ {% if member_btc_error %}
+ <li>{{ member_btc_error_message }}</li>
+ {% endif %}
{% if member_location_error %}
<li>{{ member_location_error_message }}</li>
{% endif %}
@@ -123,6 +126,14 @@
<input type="text" class="sl" name="psn" value="{{ member_psn|escape }}" />
</td>
</tr>
+ <tr>
+ <td align="right">
+ BTC Address
+ </td>
+ <td width="200" align="left">
+ <input type="text" class="sl" name="btc" value="{{ member_btc|escape }}" />
+ </td>
+ </tr>
<tr>
<td align="right">
{{ l10n.language }}
@@ -0,0 +1,58 @@
+{% include 'common/head.html' %}
+<body>
+ {% include 'common/top.html' %}
+ <div id="Wrapper">
+ <div id="Main">
+ <div id="Sidebar">
+ </div>
+ <div id="Rightbar">
+ {% include 'rightbar/user.html' %}
+ <div class="sep20"></div>
+ {% include 'rightbar/ads.html' %}
+ </div>
+ <div id="Content">
+ <div class="box">
+ <div class="cell"><span class="fade"><a href="/">{{ site.title }}</a> <span class="chevron">&nbsp;&nbsp;</span> 账户查询</span></div>
+ <div class="inner">
+ <table cellpadding="10" cellspacing="0" width="100%">
+ <tr>
+ <td width="25%">
+
+ </td>
+ <td width="25%">
+ </td>
+ <td width="25%">
+ 账户级别
+ <div class="sep10"></div>
+ BRONZE
+ </td>
+ <td width="25%">
+ 可用余额
+ <div class="sep10"></div>
+ 25.0
+ </td>
+ </tr>
+ </table>
+ <table cellpadding="5" cellspacing="0" width="100%" class="money">
+ <tr>
+ <td width="25%">
+
+ </td>
+ <td width="25%">
+ </td>
+ <td width="25%">
+ </td>
+ <td width="25%">
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+ </div>
+ <div class="c"></div>
+ </div>
+ </div>
+ {% include 'common/bottom.html' %}
+</body>
+</html>
View
@@ -59,6 +59,7 @@ class Member(db.Model):
noob = db.IntegerProperty(required=True, default=0)
show_home_top = db.IntegerProperty(required=True, default=1)
show_quick_post = db.IntegerProperty(required=True, default=0)
+ btc = db.StringProperty(required=False, default='')
def hasFavorited(self, something):
if type(something).__name__ == 'Node':

0 comments on commit ed75674

Please sign in to comment.