Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

每天发提醒

  • Loading branch information...
commit ac6692fc2847a24b87e3b736c7a37805b7f6b5f4 1 parent 097acea
laiwei authored
View
4 cronjob/generate_pdf.py
@@ -71,8 +71,8 @@ def generate_pdf_by_user(user_id):
if __name__ == "__main__":
- start = 161
- limit = 100
+ start = 690
+ limit = 200
while start <= 800:
for uid in User.get_ids_asc(start=start, limit=limit):
print '------begin generate pdf of user:', uid
View
3  past/model/status.py
@@ -17,6 +17,9 @@
log = logging.getLogger(__file__)
+#TODO:refactor,暴露在外面的接口为Status
+#把Data相关的都应该隐藏起来,不允许外部import
+
class Status(object):
STATUS_REDIS_KEY = "/status/text/%s"
View
2  past/templates/bind_wordpress.html
@@ -60,7 +60,7 @@
<div class="sep10"></div>
你的blog认领验证码为:<span id="feed2_0" class="fade">{{random_id}}</span>
<div class="sep10"></div>
- 为了验证blog的主人^^,请发一篇blog,内容为 {{random_id}},完成该步骤后,请点下一步完成绑定
+ 为了验证blog的主人^^,请发一篇blog,"文章内容"为 {{random_id}},完成该步骤后,请点下一步完成绑定
<div class="sep3"></div>
<input type="submit" name="confirm_bind_wordpress" value="下一步"></input>
View
6 past/templates/blocks.html
@@ -28,7 +28,11 @@
{%if unbinded%}
{%for ub in unbinded%}
<span class="from {{ub[1]}}">
+ {%if ub[0] == 'W'%}
+ <a title="绑定wordpress" href="/bind/{{ub[1]}}">{{ub[1]}}</a>
+ {%else%}
<a title="添加{{ub[2]}}授权登录" href="/connect/{{ub[1]}}">{{ub[1]}}</a>
+ {%endif%}
</span>
{%endfor%}
{%endif%}
@@ -131,3 +135,5 @@
</div>
<div class="sep10"></div>
{%- endmacro %}
+
+
View
8 past/templates/pdf.html
@@ -5,6 +5,14 @@
{% block content_block %}
<div id="sidebar"></div>
<div id="rightbar">
+ <div class="box">
+ <div class="cell"><span class="bigger">通知</span></div>
+ <div class="inner">
+ <span class="fade">由于服务器的磁盘空间有限,没有办法给大家把过往月份的PDF全部生成。默认只生成了最近一个月的PDF,如果想下载过往的PDF,请发邮件给 <strong class="bigger">help@thepast.me</strong> 告知,会尽量满足需求的。</span>
+ </div>
+ </div>
+ <div class="sep10"></div>
+
{{blocks.rightbar_intros_block(intros)}}
<div class="sep10"></div>
{{blocks.rightbar_feedback_block()}}
View
39 past/utils/sendmail.py
@@ -0,0 +1,39 @@
+#-*- coding:utf-8 -*-
+
+import smtplib
+from email.MIMEMultipart import MIMEMultipart
+from email.MIMEBase import MIMEBase
+from email.MIMEText import MIMEText
+from email.Utils import COMMASPACE, formatdate
+from email import Encoders
+import os
+
+def send_mail(to, fro, subject, text, html, files=[],server="localhost"):
+ assert type(to)==list
+ assert type(files)==list
+
+ # Create message container - the correct MIME type is multipart/alternative.
+ msg = MIMEMultipart('alternative')
+ msg['From'] = fro
+ msg['To'] = COMMASPACE.join(to)
+ msg['Date'] = formatdate(localtime=True)
+ msg['Subject'] = subject
+
+ if text:
+ msg.attach( MIMEText(text, 'plain' ))
+ if html:
+ msg.attach( MIMEText(html, 'html'))
+
+ for file in files:
+ part = MIMEBase('application', "octet-stream")
+ part.set_payload( open(file,"rb").read() )
+ Encoders.encode_base64(part)
+ part.add_header('Content-Disposition', 'attachment; filename="%s"'
+ % os.path.basename(file))
+ msg.attach(part)
+
+ smtp = smtplib.SMTP(server)
+ smtp.sendmail(fro, to, msg.as_string() )
+ smtp.close()
+
+#send_mail(['laiwei_ustc <laiwei.ustc@gmail.com>'],'thepast <help@thepast.me>','thepast.me 历史上的今天','http://thepast.me个人杂志计划',['/home/work/proj/thepast/past/static/img/avatar.png','/home/work/proj/thepast/var/down/pdf/thepast.me_4_201203.pdf'])
Please sign in to comment.
Something went wrong with that request. Please try again.