Ejemplo n.º 1
0
def p_name(request):
    """
    @api {post} /account/name [个人设置]修改名字
    @apiGroup account
    @apiParamExample {json} 请求示例
        {"name":"新名字"}
    @apiSuccessExample {json} 成功返回
        {"message": "", "error": "", "data": "", "response": "ok", "next": ""}
    @apiSuccessExample {json} 失败返回
        {"message": "修改失败,请重试", "error": "", "data": "", "response": "fail", "next": ""}
    """
    args = request.QUERY.casts(name=unicode)
    name = args.name
    user = request.user
    data = {'flag': "0", 'user_id': user.id}
    if not name:
        return ajax.jsonp_fail(request, message="姓名不能为空")
    if not is_chinese_word(name):
        return ajax.jsonp_fail(request, message="姓名长度为2-5个汉字")
    if user.type == 1:
        result = common.real_name_filter(name)
        if not result:
            data = {'flag': "1", 'user_id': user.id}
            return ajax.jsonp_ok(request, data)
    user.set_name(name)

    return ajax.jsonp_ok(request, data)
Ejemplo n.º 2
0
def r_stu_test_info(request):
    """
    @api {post} /huodong/terminal/yw/test/info [期末提分试卷]语文学生做题
    @apiGroup terminal
    @apiParamExample {json} 请求示例
    {"task_id": 作业id}
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": {
            "total": 10,                   # 全部试题                    
            "wrong": 2,                    # 错题数
            "title": "期末提分试卷-(二)",   # 试卷标题 
        },
        "response": "ok",
        "error": ""
    }
    """
    out = Struct()
    out.total = 0
    out.wrong = 0
    out.title = ""
    args = request.QUERY.casts(task_id=int, test_id=int)
    task_id = args.task_id
    test_id = args.test_id
    if not task_id and not test_id:
        return ajax.jsonp_fail(request, message="缺少作业id")
    if task_id:
        user_id = request.user_id
        detail = db.tbkt_yuwen.yw_test_detail_new.get(task_id=task_id,
                                                      user_id=user_id)
    else:
        test = db.tbkt_yuwen.yw_test_new.get(id=test_id)
        task_id = test.task_id
        detail = db.tbkt_yuwen.yw_test_detail_new.get(task_id=test.task_id,
                                                      user_id=test.user_id)

    if not detail or detail.status == 0:
        return ajax.jsonp_ok(request, out)
    sql = """
    select t.title, d.question_id from yw_task_new t, yw_task_detail_new d
    where t.id = d.task_id and t.id = %s
    """ % task_id
    task = db.tbkt_yuwen.fetchone_dict(sql)
    if not task or not task.question_id:
        return ajax.jsonp_ok(request, out)
    question_ids = map(int, task.question_id.split(","))
    text = map(Struct, json.loads(
        detail.text)) if detail and detail.text else []
    out.total = len(question_ids)
    out.wrong = len(set(i.qid for i in text if i.result == 0))
    out.title = task.title
    return ajax.jsonp_ok(request, out)
Ejemplo n.º 3
0
def p_join(request):
    """
    @api {post} /class/join [班级]加入班级接口
    @apiGroup class
    @apiParamExample {json} 请求示例
        {"dept_id": 部门ID, "grade_id":年级, "class_id":班级}
        或者
        {"unit_id": 班级ID}
    @apiSuccessExample {json} 成功返回
        {
            "message": "",
            "next": "",
            "data": {
                "unit_id": 580564   # 新班级ID
            },
            "response": "ok",
            "error": ""
        }
    @apiSuccessExample {json}  失败返回
        {
            "message": "您已经在当前班级",
            "next": "",
            "data": "",
            "response": "fail",
            "error": ""
        }
    """
    args = request.QUERY.casts(dept_id=int, grade_id=int, class_id=int, unit_id=int)
    dept_id = args.dept_id or 0
    grade_id = args.grade_id or 0
    class_id = args.class_id or 0
    unit_id = args.unit_id or 0

    user = request.user
    cache.user_profile.delete(user.id)
    cache.user_units.delete(user.id)
    if unit_id:
        ok, error = common.joinclass_id(user, unit_id)
        if not ok:
            return ajax.jsonp_fail(request, message=error)
        return ajax.jsonp_ok(request, {'unit_id': unit_id})

    if not dept_id:
        return ajax.jsonp_fail(request, message="缺少参数")
    if grade_id < 1 or grade_id > 9:
        return ajax.jsonp_fail(request, message="参数错误: grade_id")
    if class_id < 0 or class_id > 30:
        return ajax.jsonp_fail(request, message="参数错误: class_id")

    unit_id, error = common.joinclass(user, dept_id, grade_id, class_id)
    if not unit_id:
        return ajax.jsonp_fail(request, message=error)
    return ajax.jsonp_ok(request, {'unit_id': unit_id})
Ejemplo n.º 4
0
def r_class_rank(request):
    """
    @api /huodong/sx/normal/class/ranks [数学常态活动]班级排名
    @apiGroup math_normal
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": [
            {
                "phone": "13900000000",
                "score": 280,
                "is_open": 1,
                "portrait": "https://file.m.tbkt.cn/upload_media/portrait/2015/05/26/20150526191718620086.png",
                "user_name": "赵勇铮",
                "id": 383892
            }
        ],
        "response": "ok",
        "error": ""
    }
    """
    user = request.user
    args = request.QUERY.casts(unit_id=int)
    unit_id = args.unit_id
    if not unit_id:
        unit_id = user.units[0].id
    data = common.class_stu_rank(user, unit_id, STU_ACTIVE_ID)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 5
0
def r_score_rank(request):
    """
    @api /huodong/sx/normal/score/ranks [数学常态活动]河南积分排名
    @apiGroup math_normal
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": [
            {
                "city": "411700",
                "score": 1082111,
                "user_id": 405269,
                "portrait": "portrait/2017/09/09/2017090915481764690.png",
                "school_name": "创恒中学",
                "real_name": "呃呃呃呃"
            }
        ],
        "response": "ok",
        "error": ""
    }
    
    * 显示登录身份的排名
    """
    args = request.QUERY.casts(p=int)
    page_no = args.p or 1
    user = request.user
    active_id = 1
    if user.is_teacher:
        active_id = 2
    data = common.score_rank(active_id, page_no)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 6
0
def p_feedback(request):
    """
    @api {post} /account/feedback [登录]意见反馈
    @apiGroup account
    @apiParamExample {json} 请求示例
        {"type":请求类型(1意见建议 2错误反馈 3其他), "content":"反馈内容", "app":机型(android/ios/pc)}
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "error": "",
        "data": "",
        "response": "ok",
        "next": ""
    }
    @apiSuccessExample {json} 失败返回
    {
        "message": "验证码错误,请重新获取",
        "error": "",
        "data": "",
        "response": "fail",
        "next": ""
    }
    """
    args = request.QUERY.casts(type=int, content=unicode, app=str)
    type = args.type or 1
    content = args.content or u''
    app = args.app or ''
    user_id = request.user_id

    if not content:
        return ajax.jsonp_fail(request, '请填写内容')
    common.feedback(user_id, type, content, app)

    return ajax.jsonp_ok(request)
Ejemplo n.º 7
0
def index(request):
    """
        @api {post} /huodong/yy/normal/index [英语常态活动]首页
        @apiGroup yy_normal
        @apiParamExample {json} 请求示例
           {}
        @apiSuccessExample {json} 成功返回
        {
            "message": "",
            "next": "",
            "data": {
                "score": 210,
                "rank_no": 1
            },
            "response": "ok",
            "error": ""
        }
        @apiSuccessExample {json} 失败返回
           {"message": "", "error": "", "data": "", "response": "fail", "next": ""}
        """
    """
    功能说明:                活动首页 目前是实时更新
    -----------------------------------------------
    修改人                    修改时间
    -----------------------------------------------
    张帅男                    2017-9-5
    """
    user_id = request.user_id
    data = common.get_user_rank(ACTIVE_ID, user_id)
    return jsonp_ok(request, data)
Ejemplo n.º 8
0
def get_recording(request):
    """
    @api {get} /huodong/reading/get_recording   [学生端]获取用户的录音(最多五个)
    @apiGroup yw_reading
    @apiParamExample {json} 请求示例
    {
        "tid": 6   # 文章id
    }
    @apiSuccessExample {json} 成功返回
    {
        "message":
        "next": "",
         "data": {
                "status": 0, 1/0,  等于1 已经上传过录音 等于0  则未上传过录音
                "video_detail": [
                    {
                        "recording_length": 5,
                        "user_name": "refresh",
                        "user_id": 7646093,
                        "id": 2,
                        "recording_path": "http://tbktfile.jxrrt.cn/yuwen/201709StuVideos/b99255c5-fc6f-4f60-8b98-fb90f18e6e06.mp3"
                    },{},{},{},
                ]
         },
        "response": "ok",
        "error": ""
    }
    """
    user = request.user
    args = request.QUERY.casts(tid=int)
    tid = args.tid
    if not tid:
        return jsonp_fail(request, message="缺少参数")
    data = common.get_video(user, tid)
    return jsonp_ok(request, data)
Ejemplo n.º 9
0
def view_paper(request):
    """
    @api {get} /huodong/reading/view_paper   [教师端]预览试卷
    @apiGroup yw_reading
    @apiParamExample {json} 请求示例
    {
        "tid“ : 100
    }
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": {
                "title": "aaaaa",                     # 文章标题
                "article_content": "aaa",    #文章内容
                }

        "response": "ok",
        "error": ""
    }
    """
    args = request.QUERY.casts(tid=int)
    tid = args.tid
    if not tid:
        return jsonp_fail(request, message="缺少参数")
    data = common.view_paper(tid)
    return jsonp_ok(request, data)
Ejemplo n.º 10
0
def p_counties(request):
    """
    @api {get} /class/counties [班级]县区列表
    @apiGroup class
    @apiParamExample {json} 请求示例
        {"city":"地市行政编码"}
    @apiSuccessExample {json} 成功返回
        {
            "message": "",
            "next": "",
            "data": [
                {
                    "id": "410381",
                    "name": "偃师市"
                },
                {
                    "id": "410301",
                    "name": "市辖区"
                }
            ],
            "response": "ok",
            "error": ""
        }
    """
    args = request.QUERY.casts(city=str)
    city = args.city or ''

    data = common.get_counties(city)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 11
0
def p_teachers(request):
    """
    @api {get} /class/teachers [班级]获取班级老师列表
    @apiGroup class
    @apiParamExample {json} 请求示例
        {"unit_id":班级ID}
    @apiSuccessExample {json} 成功返回
        {
            "message": "",
            "next": "",
            "data": {
                "teachers": [
                    {
                        "id": 4210824, # 老师ID
                        "name": "洛奇", # 老师姓名
                        "sid": 2, # 老师学科ID
                    }
                ],
            },
            "response": "ok",
            "error": ""
        }
    """
    args = request.QUERY.casts(unit_id=int)
    unit_id = args.unit_id or 0
    user = request.user
    data = common.get_class_teachers(user, unit_id)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 12
0
def p_byphone(request):
    """
    @api {get} /class/byphone [班级]按老师手机号查班级
    @apiGroup class
    @apiParamExample {json} 请求示例
        {"phone_number":"15981867201"}
    @apiSuccessExample {json} 成功返回
        {
            "message": "",
            "next": "",
            "data": [
                {
                    "id": 515192,
                    "name": "301班"
                },
            ],
            "response": "ok",
            "error": ""
        }
    @apiSuccessExample {json} 失败返回
        {
            "message": "未找到该教师",
            "next": "",
            "data": "",
            "response": "fail",
            "error": ""
        }
    """
    args = request.QUERY.casts(phone_number=str)
    phone = args.phone_number or ''
    user = request.user
    units, error = common.get_units_by_phone(user, phone)
    if error:
        return ajax.jsonp_fail(request, message=error)
    return ajax.jsonp_ok(request, units)
Ejemplo n.º 13
0
def p_cities(request):
    """
    @api {get} /class/cities [班级]所有地市列表
    @apiGroup class
    @apiParamExample {json} 请求示例
        {'child':1返回地市+县区数据 0只返回地市数据,province_id:410000  省份id}
    @apiSuccessExample {json} 成功返回
        {
            "message": "",
            "next": "",
            "data": [
                {
                    "id": "410200",
                    "name": "开封市",
                    "child": [
                        {
                            "id": "410202",
                            "name": "龙亭区"
                        }
                    ]
                },
            ],
            "response": "ok",
            "error": ""
        }
    """
    args = request.QUERY.casts(child=int, province_id=int)
    child = args.child or 0
    province_id = args.province_id or 410000
    data = common.get_cities(province_id, child=child)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 14
0
def p_getpwd(request):
    """
    @api {get} /class/getpwd [班级]返回学生帐号和伪密码
    @apiGroup class
    @apiParamExample {json} 请求示例
        {"user_id":学生ID}
    @apiSuccessExample {json} 成功返回
        {
            "message": "",
            "next": "",
            "data": {
                "username": "******",
                "password": "******"
            },
            "response": "ok",
            "error": ""
        }
    """
    args = request.QUERY.casts(user_id=int)
    user_id = args.user_id or 0
    user = request.user
    if not common.is_mystudent(user, user_id):
        return ajax.jsonp_fail(request, message='权限错误')
    data = common.getpwd(user_id) or {}
    print '+++++', data
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 15
0
def p_update_student(request):
    """
    @api {post} /class/student/update [班级]更新学生信息
    @apiGroup class
    @apiParamExample {json} 请求示例
        {"user_id":学生ID, "name":姓名, "sex":1男2女}
    @apiSuccessExample {json} 成功返回
        {"message": "", "next": "", "data": "", "response": "ok", "error": ""}
    @apiSuccessExample {json} 失败返回
        {
            "message": "名字必须是2-5个汉字",
            "next": "",
            "data": "",
            "response": "fail",
            "error": ""
        }
    """
    args = request.QUERY.casts(user_id=int, name=unicode, sex=int)
    student_id = args.user_id or 0
    name = args.name or u''
    sex = args.sex or 0
    if name and not is_chinese_word(name):
        return ajax.jsonp_fail(request, message='姓名长度为2-5个汉字')
    user = request.user
    if not common.is_mystudent(user, student_id):
        return ajax.jsonp_fail(request, message='权限错误')
    thread_pool.call(common.update_student_info, student_id, name, sex)
    return ajax.jsonp_ok(request)
Ejemplo n.º 16
0
def index(request):
    """
    @api {get} /huodong/reading/index   [教师端]活动首页
    @apiGroup yw_reading
    @apiParamExample {json} 请求示例
    {
    }
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": {
            “coins”: 10000,
            “complete_students”: [
                                 {“unit_name”:””, “complete_num”:100},
                                 {“unit_name”:””, “complete_num”:100},
            ]
            “complete_status”: 1 / 0

        },
        "response": "ok",
        "error": ""
    }
    """
    user = request.user
    data = common.index(user)
    return jsonp_ok(request, data)
Ejemplo n.º 17
0
def get_paper(request):
    """
    @api {get} /huodong/reading/get_paper   [教师端]获取当前年级下的试卷
    @apiGroup yw_reading
    @apiParamExample {json} 请求示例
    {
        “grade”: 2
    }
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": [
                    {“title”:””, “question_num”:1, “status”: 1/0},
                    {“title”:””, “question_num”:1, “status”: 1/0},
                    {“title”:””, “question_num”:1, “status”: 1/0},
                ]
        "response": "ok",
        "error": ""
    }
    """
    args = request.QUERY.casts(grade=int)
    user = request.user
    grade = args.grade
    if not grade:
        return jsonp_fail(request, message="缺少参数")
    data = common.get_paper(grade, user)
    return jsonp_ok(request, data)
Ejemplo n.º 18
0
def p_delmessage(request):
    """
    @api {post} /im/delmessage [IM]取消定时作业
    @apiGroup IM
    @apiParamExample {json} 请求示例
        {"subject_id":学科ID, "task_id":作业ID,"type":作业类型}
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": {
        },
        "response": "ok",
        "error": ""
    }
    """
    args = request.QUERY.casts(subject_id=int, task_id=int, type=int)
    subject_id = int(args.subject_id)
    task_id = int(args.task_id)
    type = int(args.type)
    db.default.message.filter(object_id=task_id,
                              subject_id=subject_id,
                              type=type,
                              status=1).update(status=-1)
    return ajax.jsonp_ok(request)
Ejemplo n.º 19
0
def get_coin(request):
    """
    @api {post} /huodong/reading/get_coin   [教师端]领取金币
    @apiGroup yw_reading
    @apiParamExample {json} 请求示例
    {

       }
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": {
                "num" : 0/20/40  # 20领取的金币数量 0 领取失败
                }

        "response": "ok",
        "error": ""
    }
    """
    user = request.user
    data = common.get_coin(user)
    if data == u'金币不足':
        return jsonp_fail(request, message=data)
    return jsonp_ok(request, data)
Ejemplo n.º 20
0
def get_article_list(request):

    """
       @api {get} /huodong/yw_activity/t/article_list  [语文常态活动]教师端推荐文章列表
       @apiGroup yw_hd_t
       @apiParamExample {json} 请求示例
        {
        "p":1 #当前页数
        }
        @apiSuccessExample {json} 成功返回
{
    "message": "",
    "next": "",
    "data": {
        "data": [
            {
                "ch_Name": "善良的狐狸",
                "ch_Code": "10610101",
                "state": 1
            }
        ],
        "page_count": 33  #总页数
    },
    "response": "ok",
    "error": ""
}
    """
    user_id = request.user_id
    args = request.QUERY.casts(p=int)
    p=args.p
    data = common.article_list(user_id,p)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 21
0
def set_message(request):
    """
    @api {post} /huodong/reading/set_message   [学生端]发布留言
    @apiGroup yw_reading
    @apiParamExample {json} 请求示例
    {
        "tid": 6   # 文章id
        "content" : "荣誉,可是要付出代价的"
    }
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": [
                ]
        "response": "ok",
        "error": ""
    }
    """
    user = request.user
    args = request.QUERY.casts(tid=int, content=str)
    tid = args.tid
    content = args.content
    if not tid or not content:
        return jsonp_fail(request, message="缺少参数")
    data = common.set_message(user, tid, content)
    return jsonp_ok(request, data)
Ejemplo n.º 22
0
def user_rank(request):

    """
       @api {get} /huodong/yw_activity/t/user_rank  [语文常态活动]学生端积分 排名
       @apiGroup yw_hd_t
        @apiSuccessExample {json} 成功返回
{
    "message": "",
    "next": "",
    "data": {
        "sampling": 0,  #抽奖次数
        "score": 0,  #总分数
        "rank_no": 0  #排名
        "city_id":1 #城市id
    },
    "response": "ok",
    "error": ""
}
    """

    user_id = request.user_id
    user_rank = get_user_rank(5,user_id)
    city_id=request.user.city
    sampling = user_rank['score'] / 1000
    user_rank['sampling']=sampling
    user_rank['city_id'] = city_id
    return ajax.jsonp_ok(request, user_rank)
Ejemplo n.º 23
0
def p_sources(request):
    """
    @api {get} /book/sources [教材]教材相关练习册
    @apiGroup book
    @apiParamExample {json} 请求示例
        {"book_id":教材ID}
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": {
            "books": [
                {
                    "press_name": "人教版", # 出版社
                    "name": "数学一年级上册",  # 默认书名
                    "subject_id": 21,  # 学科
                    "grade_id": 1,  # 年级
                    "volume": 1,  # 1上册 2下册 3全册
                    "version_name": "新版",  # 版本
                    "id": 276 # 教材/教辅ID
                },
            ]  # 相关练习册列表
        },
        "response": "ok",
        "error": ""
    }
    """
    args = request.QUERY.casts(book_id=int)
    book_id = args.book_id

    books = common.get_sources(book_id)
    data = {'books': books}
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 24
0
def get_article_details(request):

    """
       @api {get} /huodong/yw_activity/t/article_details  [语文常态活动]文章详情页
       @apiGroup yw_hd_t
       @apiParamExample {json} 请求示例
        {
        "ch_Name":艾尔的新毯子 #文章名称
        "state":1,#state是否已推荐: 1,已推荐,0,未推荐
        "ch_Code":1 #文章code
        }
        @apiSuccessExample {json} 成功返回
{
    "message": "",
    "next": "",
    "data": {
       "ch_Name": "艾尔的新毯子",
        "state": 1, #state是否已推荐: 1,已推荐,0,未推荐
        "ti_Contents": "从前在大森林里有一只叫森森的小狐狸,他很孤独,因为他没有朋友,小动物们都不和他玩,因为动物们都觉的狐狸是最坏的动物,再加上他的爸爸是骗走乌鸦肉的那只狐狸乌鸦们更是对他恨之入骨,但森森一点也不坏,他连一只蚂蚁都没伤害过。但动物们都不相信他。森森感到十分伤心。 ||一天,森森正在森林里闲逛 ,突然听到前面有动物喊“救命”,森森寻着声音跑过去,发现一只大灰狼正张牙舞爪地扑向一只小白兔,正在这危急关头,森森突然向前一跃,挡住了大灰狼扑向小白兔爪子,并大声向居住在附近的动物们求救。大灰狼锋利的爪子刺进了森森的肉里,森森顿时流了许多血,不一会就昏了过去。这时动物们听到求救声都纷纷拿着工具陆续赶了过来,大灰狼见势不妙,慌忙逃走了。 ||当森森醒来时,发现自己躺在一张床上,动物们都围在他的床边,看到它醒来都露出了笑容,这时兔妈妈拉住森森的手说“ 谢谢你救了我的孩子,我们以前错怪了你,你是一个勇敢而又善良的好孩子!” ||从此森森和其他动物们成了好朋友,一起快乐的生活在森林里。 "
    },
    "response": "ok",
    "error": ""
}
    """
    args = request.QUERY.casts(ch_Code=int,state=int,ch_Name='json')
    state=args.state
    ch_Code=args.ch_Code
    ch_Name=args.ch_Name

    data = common.article_details(ch_Code,state,ch_Name)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 25
0
def score(request):
    '''

    :param request:
    :return:
    {
  "message": "",
  "next": "",
  "data": [
    {
      "invite_student_score": "",
      "share_score": 100,
      "sum_score": 100,
      "send_message_score": "",
      "time": "2018-06-08",
      "studnet_finish_score": ""
    }
  ],
  "response": "ok",
  "error": ""
}
    '''
    user = request.user
    class_status = user.subject_id // 10
    teacher_id = user.id
    data = common.see_score(teacher_id, class_status)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 26
0
def p_cancel(request):
    """
    @api {post} /account/cancelsms [短信]取消定时短信
    @apiGroup account
    @apiParamExample {json} 请求示例
        {"id":短信ID, "schedule_time":定时时间}
    @apiSuccessExample {json} 成功返回
        {
            "message": "",
            "next": "",
            "data": {
                "success": true
            },
            "response": "ok",
            "error": ""
        }
    """
    args = request.QUERY.casts(id=int, schedule_time=str)
    object_id = args.id
    schedule_time = args.schedule_time
    if not object_id:
        return ajax.jsonp_fail(request, message='缺少参数: id')
    if not schedule_time:
        return ajax.jsonp_fail(request, message='缺少参数: schedule_time')
    hub = tbktapi.Hub(request)
    url = '/sms/cancel'
    d = dict(id=object_id,
             schedule_time=schedule_time,
             platform_id=request.user.platform_id)
    r = hub.sms.post(url, d)
    if not r:
        return ajax.jsonp_fail(request, message='服务器开小差')
    return ajax.jsonp_ok(request, r)
Ejemplo n.º 27
0
def r_award_winner(request):
    """
    @api /huodong/sx/normal/award/winner [数学常态活动] 河南抽奖排名
    @apiGroup math_normal
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": [
            {
                "award_name": "ipad",
                "user_id": 591113,
                "city": "410400",
                "portrait": "portrait/2017/09/09/2017090918151214417.png",
                "school_name": "平顶山市卫东区矿工路小学",
                "real_name": "啊啊啊"
            }
        ],
        "response": "ok",
        "error": ""
    }

    * 显示登录身份的排名
    """
    args = request.QUERY.casts(p=int)
    page_no = args.p or 1

    user = request.user
    active_id = 1
    if user.is_teacher:
        active_id = 2

    data = common.award_winner(active_id, page_no)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 28
0
def set_recording(request):
    """
    @api {post} /huodong/reading/set_recording   [学生端]上传录音
    @apiGroup yw_reading
    @apiParamExample {json} 请求示例
    {
        "video_url": "http://tbktfile.jxrrt.cn/yuwen/201709StuVideos/b99255c5.mp3"   # 音频地址
        "tid": 1      #文章id
    }
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": {

        },
        "response": "ok",
        "error": ""
    }
    """
    user = request.user
    args = request.QUERY.casts(video_url=str, tid=int)
    video_url = args.video_url
    tid = args.tid
    if not (video_url.startswith('http') and video_url.endswith('.mp3')):
        return jsonp_fail(request, message="参数错误")
    if not video_url or not tid:
        return jsonp_fail(request, message="缺少参数")
    data = common.set_video(user, video_url, tid)
    if not data:
        return jsonp_fail(request, message="添加失败")
    return jsonp_ok(request, data)
Ejemplo n.º 29
0
def r_award_info(request):
    """
    @api /huodong/sx/normal/com/award/display [数学常态活动]奖品信息
    @apiGroup math_normal
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": [
            {
                "num": 3,  # 奖品数量
                "sequence": 1,  # 几等奖
                "end_num": 0,     
                "active_type": 1, # 奖品类型 1抽奖奖品 2排名奖品
                "start_num": 0,   
                "active_id": 1,  # 活动id
                "img_url": "http://file.tbkt.cn/upload_media/knowledge/img/2015/09/21/20150921113843806676.png",
                "active_name": "ipad"   # 奖品名字
            }
        ],
        "response": "ok",
        "error": ""
    }
    """
    user, active_id = base(request)
    data = com_award.show_award(active_id)
    return ajax.jsonp_ok(request, data)
Ejemplo n.º 30
0
def get_message(request):
    """
    @api {get} /huodong/reading/get_message   [学生端]获取留言
    @apiGroup yw_reading
    @apiParamExample {json} 请求示例
    {
        "tid": 6   # 文章id
        "page" : 1   #页数 每页20条  ! 不能不传 从1开始
    }
    @apiSuccessExample {json} 成功返回
    {
        "message": "",
        "next": "",
        "data": [
                 {“user_name”:””, “add_time”:””, “content”:””, "user_border":"", "user_portrait":"'},
                  {“user_name”:””, “add_time”:””, “content”:””, "user_border":"", "user_portrait":"'},
                  {“user_name”:””, “add_time”:””, “content”:””, "user_border":"", "user_portrait":"'},
                  {“user_name”:””, “add_time”:””, “content”:””, "user_border":"", "user_portrait":"'},
                ]
        "response": "ok",
        "error": ""
    }
    """
    user = request.user
    args = request.QUERY.casts(tid=int, page=int)
    tid = args.tid
    page = args.page
    if not tid or not page:
        return jsonp_fail(request, message="缺少参数")
    data = common.get_message(user, tid, page)
    return jsonp_ok(request, data)