绝望坡项目

juewangpo

An amazing bravo excellent web application written in Python and Flask and Bootstrap, driven in SAE PaaS.

Deployment

  • Use SVN to taken the '1'package to SAE.
  • visit host/admin/initdb to init the database.
  • visit host/admin/initusers to create random users.(optional)
  • Remember to change The AVATARURL and BACKURL to your host/upavatar and host/upback

Features

  • By detect the os.environ, juewangpo can change mysql server automatically
  • Use SQLAlchemy and Flask-SQLAlchemy to make sql models
  • Use PIL to convert img then save in SAE Storage
  • Use Qiniu Cloud Storage to process and save images
  • Customized User Profile page, various
  • Follow/Unfollow somebody, fans/followed list
  • Private Message(pm) system
  • Integrate with guests lists of Wuhan Campus Love
  • Notification system
  • visits record (besides self visit)
  • register login edit upavatar upback match follow followers message guests.

Docs

/match

  1. 匹配表,过滤用户当天的匹配次数,转为int类型

  2. 次数字典,根据用户角色提供最大次数

     times = int(MatchingRecord.query.filter_by(player=g.user.id,matching_date=date.today()).count())
     max = config.TIMES.get(g.user.role)
     if times >= max:
         flash(u'你今天已匹配%s次,明天再来吧~' % max)
         return render_template('match.html', form=form)
    

七牛python sdk修改

我在python SDK中的class PutPolicy中手动添加了 persistentPipeline。
API文档里有,python SDK里暂时没有(add by lee @14.8.14)

消息提醒功能

1.思路:创建一个notify表,三个字段:id(主键),type(提醒类型),user_id(提醒人)

"""我想直接用表做,不用ORM。懒得看文档,速度修改!!"""
class Notify(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    type = db.Column(db.String(20))
    user_id = db.Column(db.Integer)

2.用户follow某人或发私信给某人时,notify表增加记录
# follow
db.session.add(Notify(type='follow', user_id=id))
db.session.commit()
# message
db.session.add(Notify(type='message', user_id=id))
db.session.commit()
3.主页上显示消息提醒

if g.user.is_authenticated():
    fans = Notify.query.filter_by(type='follow', user_id=g.user.id).count()
    message = Notify.query.filter_by(type='message', user_id=g.user.id).count()

4.主页上点击 /followers 或 /session删除记录
# followers
Notify.query.filter_by(type='follow', user_id=g.user.id).delete()
db.session.commit()
# session
Notify.query.filter_by(type='message', user_id=g.user.id).delete()
db.session.commit()

Warning

1.运行 /admin/migrate,不能确保完全OK。所以,迁移前先备份。
2.在models中修改字段,无法迁移,增减字段没问题。所以,记得手动在线上数据库修改。
3.备份,备份,备份。
4.测试,测试,测试。

models

  1. lala
  2. gaga

修改日志

14.9.1 add by lee
1./match 匹配系统,性别和状态默认值。用了 class="active" 和 radio 的checked 判断。
2./edit 家乡省市默认值,原来只需要在添加pro 和city就行了

<script type="text/javascript">
$(document).ready(function(){
    $.initProv("#pro", "#city","{{ pro }}", "{{ city }}");
});
</script>

14.9.3 add by lee
1./match 匹配系统,输入框高度变了,背景颜色修改了,【Ta的档案】和【返回主页】的位置变了。
删除了无效的按钮报错(见1号的修改,已经有默认值了)
2.formsviews 删除了重复的form.height以及form.height.data(本来用wtforms做的,后来改为直接html)
3./edit 删除了无效的form.errors.height的报错
4./profile "发送私信、取消关注、返回主页",修改了样式

  1. /message_session 未读背景色,时间去除秒

WEBsite

演示网站:
juewangpo.sinaapp.com

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,552评论 5 6
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,991评论 19 139
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,939评论 0 23
  • 我听了整夜的歌 听不清自己心跳的频率 一路买醉到九月 在乡野和空城之间寻找 为谁写下满城的幽怨 十字路口谁的衣袂随...
    阿亮的月亮阅读 408评论 15 16
  • 1 从杭州回来我就生了一场重病。高烧一直无法退下,头痛欲裂,就连听到他人讲话的声音都会觉得聒噪不安。睡梦里,除了一...
    野新阅读 715评论 0 1