Пример #1
0
    def get(self, vendor_id, category_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got category_id %r in uri", category_id)

        ops = self.get_ops_info()

        category_dao.category_dao().delete(category_id)

        self.redirect('/vendors/' + vendor_id + '/categorys')
Пример #2
0
    def get(self, _id):
        """
            @description: 读取一个分类

            @rtype: L{Resp}
            @raise 400: Invalid Input
            @raise 500: Internal Server Error
        """
        category = yield category_dao.category_dao().find(_id)
        if category:
            logging.debug("OK(200): got category=[%r] from mysql", category)
            self.set_status(200)  # OK
            self.write(
                JSON.dumps({
                    "errCode": 200,
                    "errMsg": "Success",
                    "rs": category
                }))
            self.finish()
            return
        else:
            logging.warn("Not Found[404]: got category=[%r] from mysql", _id)
            self.set_status(200)  # Not Found
            self.write(JSON.dumps({"errCode": 404, "errMsg": "Not Found"}))
            self.finish()
            return
Пример #3
0
    def get(self):
        category_id = self.get_argument("category_id", "")
        categories = yield category_dao.category_dao().find_all()

        self.render('admin/blog-list.html',
                    category_id=category_id,
                    categories=categories)
    def get(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        account_id = self.get_secure_cookie("account_id")
        categorys = category_dao.category_dao().query_by_vendor(vendor_id)
        personal_tasks = personal_task_dao.personal_task_dao().query_by_vendor_account(vendor_id,account_id)

        for personal_task in personal_tasks:
            personal_task['create_time'] = timestamp_datetime(personal_task['create_time'])

            task_id = personal_task['task_id']
            task = task_dao.task_dao().query(task_id)

            trip_router_id = task['triprouter']
            triprouter = trip_router_dao.trip_router_dao().query(trip_router_id)

            personal_task['title'] = triprouter['title']
            personal_task['bk_img_url'] = triprouter['bk_img_url']
            for category in categorys:
                if category['_id'] == task['category']:
                    personal_task['category'] = category['title']
                    break

        self.render('wx/my-tasks.html',
                vendor_id=vendor_id,
                tasks=personal_tasks)
Пример #5
0
    def get(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        _array = category_dao.category_dao().query_by_vendor(vendor_id)
        docs_list = list(_array)
        self.write(JSON.dumps(docs_list, default=json_util.default))
        self.finish()
Пример #6
0
    def get(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        ops = self.get_ops_info()

        categorys = category_dao.category_dao().query_by_vendor(vendor_id)
        tasks = task_dao.task_dao().query_by_vendor(vendor_id)

        for task in tasks:
            task['create_time'] = timestamp_datetime(task['create_time'])
            trip_router_id = task['triprouter']
            logging.info("got trip_router_id>>>>>>>>>> %r in uri",
                         trip_router_id)
            triprouter = trip_router_dao.trip_router_dao().query(
                trip_router_id)
            task['title'] = triprouter['title']
            task['bk_img_url'] = triprouter['bk_img_url']
            for category in categorys:
                if category['_id'] == task['category']:
                    task['category'] = category['title']
                    break

        counter = self.get_counter(vendor_id)
        self.render('vendor/task-list.html',
                    vendor_id=vendor_id,
                    ops=ops,
                    counter=counter,
                    tasks=tasks)
Пример #7
0
 def get(self, article_id):
     data = symbol_dao.symbol_dao().find(article_id)
     data["symbol"]["mtime"] = timestamp_to_datehourmin(data["mtime"])
     categories = yield category_dao.category_dao().find_all()
     self.render('blog-details.html',
                 article=data["symbol"],
                 categories=categories)
    def get(self, article_id):
        """
            @description: 查询一个文章的所有分类

            @rtype: L{ClientsResp}
            @raise 400: Invalid Input
            @raise 500: Internal Server Error
        """
        categories = yield article_categories_dao.article_categories_dao(
        ).find_all(article_id)
        for category in categories:
            category_info = yield category_dao.category_dao().find(
                category["category_id"])
            category["name"] = category_info["name"]

        logging.debug("OK[200]: query article=[%r] categories=[%r]",
                      article_id, len(categories))
        self.set_status(200)  # OK
        self.write(
            JSON.dumps({
                "errCode": 200,
                "errMsg": "Success",
                "rs": categories
            }))
        self.finish()
        return
Пример #9
0
    def get(self, article_id):
        data = symbol_dao.symbol_dao().find(article_id)
        categories = yield category_dao.category_dao().find_all()

        self.render('admin/blog-details.html',
                    article_id=article_id,
                    article=data["symbol"],
                    categories=categories)
Пример #10
0
    def get(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        ops = self.get_ops_info()

        categorys = category_dao.category_dao().query_by_vendor(vendor_id)
        counter = self.get_counter(vendor_id)
        self.render('vendor/trip-router-create.html',
                vendor_id=vendor_id,
                ops=ops,
                counter=counter,
                categorys=categorys)
Пример #11
0
    def get(self, vendor_id, category_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got category_id %r in uri", category_id)

        ops = self.get_ops_info()

        category = category_dao.category_dao().query(category_id)
        counter = self.get_counter(vendor_id)
        self.render('vendor/category-edit.html',
                    vendor_id=vendor_id,
                    ops=ops,
                    counter=counter,
                    category=category)
Пример #12
0
    def post(self, vendor_id, category_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got category_id %r in uri", category_id)

        ops = self.get_ops_info()

        title = self.get_argument("title", "")
        desc = self.get_argument("desc", "")
        bk_img_url = self.get_argument("bk_img_url", "")
        logging.debug("got param title %r", title)
        logging.debug("got param desc %r", desc)
        logging.debug("got param bk_img_url %r", bk_img_url)

        categroy = {
            "_id": category_id,
            "title": title,
            "desc": desc,
            "bk_img_url": bk_img_url
        }
        category_dao.category_dao().update(categroy)

        self.redirect('/vendors/' + vendor_id + '/categorys')
Пример #13
0
    def get(self, article_id):
        data = symbol_dao.symbol_dao().find(article_id)

        categories = yield category_dao.category_dao().find_all()
        for category in categories:
            category["checked"] = False
            info = yield article_categories_dao.article_categories_dao(
            ).find_one(article_id, category["_id"])
            if info:
                category["checked"] = True

        self.render('admin/blog-modify.html',
                    article_id=article_id,
                    article=data["symbol"],
                    categories=categories)
Пример #14
0
    def delete(self, _id):
        """
            @description: 删除一个分类

            @rtype: L{Resp}
            @raise 400: Invalid Input
            @raise 500: Internal Server Error
        """
        yield category_dao.category_dao().delete(_id)

        logging.debug("Success[200]: delete category=[%r]", _id)
        self.set_status(200)  # OK
        self.write(JSON.dumps({"errCode": 200, "errMsg": "Success"}))
        self.finish()
        return
Пример #15
0
    def post(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        ops = self.get_ops_info()

        title = self.get_argument("title", "")
        desc = self.get_argument("desc", "")
        bk_img_url = self.get_argument("bk_img_url", "")
        logging.debug("got param title %r", title)
        logging.debug("got param desc %r", desc)
        logging.debug("got param bk_img_url %r", bk_img_url)

        _id = str(uuid.uuid1()).replace('-', '')
        logging.info("create categroy _id %r", _id)
        categroy = {
            "_id": _id,
            "vendor_id": vendor_id,
            "title": title,
            "desc": desc,
            "bk_img_url": bk_img_url
        }
        category_dao.category_dao().create(categroy)

        self.redirect('/vendors/' + vendor_id + '/categorys')
Пример #16
0
    def get(self, vendor_id, trip_router_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got trip-router_id %r in edit step1", trip_router_id)

        ops = self.get_ops_info()

        triprouter = trip_router_dao.trip_router_dao().query(trip_router_id)
        categorys = category_dao.category_dao().query_by_vendor(vendor_id)

        counter = self.get_counter(vendor_id)

        self.render('vendor/trip-router-edit-step1.html',
                vendor_id=vendor_id,
                ops=ops,
                counter=counter,
                triprouter=triprouter, categorys=categorys)
Пример #17
0
    def get(self, vendor_id):
        logging.info("GET %r", self.request.uri)

        before = float(self.get_argument("before", ""))
        # limit = int(self.get_argument("limit", ""))
        _array = activity_dao.activity_dao().query_pagination_by_status(
                vendor_id, ACTIVITY_STATUS_COMPLETED, before, PAGE_SIZE_LIMIT)
        categorys = category_dao.category_dao().query_by_vendor(vendor_id)

        for _activity in _array:
            _activity['begin_time'] = timestamp_date(float(_activity['begin_time'])) # timestamp -> %m月%d 星期%w
            _activity['end_time'] = timestamp_date(float(_activity['end_time'])) # timestamp -> %m月%d 星期%w
            for category in categorys:
                if category['_id'] == _activity['category']:
                    _activity['category'] = category['title']
                    break
        docs_list = list(_array)
        self.write(JSON.dumps(docs_list, default=json_util.default))
        self.finish()
Пример #18
0
    def post(self):
        """
            @description: 创建一个分类

            @param body:
            @type body: C{CategoryReq}
            @in body: body
            @required body: True

            @rtype: L{Resp}
            @raise 400: Invalid Input
            @raise 500: Internal Server Error
        """
        logging.debug(self.request.body)

        category = None
        try:
            category = json_decode(self.request.body)
        except:
            logging.warn("Bad Request[400]: create category=[%r]",
                         self.request.body)

            self.set_status(200)  # Bad Request
            self.write(JSON.dumps({"errCode": 400, "errMsg": "Bad Request"}))
            self.finish()
            return

        category_id = generate_uuid_str()
        category["_id"] = category_id
        category["ctime"] = current_timestamp()
        category["mtime"] = category["ctime"]
        yield category_dao.category_dao().insert(category)
        logging.debug("Success[200]: create category=[%r]", category)

        self.set_status(200)  # Created
        self.write(
            JSON.dumps({
                "errCode": 200,
                "errMsg": "Success",
                "rs": category_id
            }))
        self.finish()
        return
Пример #19
0
    def get(self):
        """
            @description: 查询所有分类

            @rtype: L{ClientsResp}
            @raise 400: Invalid Input
            @raise 500: Internal Server Error
        """
        categories = yield category_dao.category_dao().find_all()

        logging.debug("OK[200]: query categories=[%r]", len(categories))
        self.set_status(200)  # OK
        self.write(
            JSON.dumps({
                "errCode": 200,
                "errMsg": "Success",
                "rs": categories
            }))
        self.finish()
        return
Пример #20
0
    def get(self, vendor_id, trip_router_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        ops = self.get_ops_info()

        categorys = category_dao.category_dao().query_by_vendor(vendor_id)
        activitys = activity_dao.activity_dao().query_by_triprouter(trip_router_id)
        triprouter = trip_router_dao.trip_router_dao().query(trip_router_id)
        for activity in activitys:
            activity['begin_time'] = timestamp_date(float(activity['begin_time'])) # timestamp -> %m/%d/%Y
            for category in categorys:
                if category['_id'] == activity['category']:
                    activity['category'] = category['title']
                    break

        counter = self.get_counter(vendor_id)
        self.render('vendor/trip-router-activitylist.html',
                vendor_id=vendor_id,
                ops=ops,
                counter=counter,
                triprouter=triprouter,
                activitys=activitys)
Пример #21
0
    def get(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        ops = self.get_ops_info()
        logging.info("got ops %r in uri", ops)

        categorys = category_dao.category_dao().query_by_vendor(vendor_id)
        triprouters = trip_router_dao.trip_router_dao().query_by_vendor(vendor_id)

        for triprouter in triprouters:
            for category in categorys:
                if category['_id'] == triprouter['category']:
                    triprouter['category'] = category['title']
                    break
        logging.info("got triprouter %r in uri", triprouters)

        counter = self.get_counter(vendor_id)
        self.render('vendor/trip-router-list.html',
                vendor_id=vendor_id,
                ops=ops,
                counter=counter,
                triprouters=triprouters)
    def get(self, vendor_id, account_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got account_id %r in uri", account_id)

        ops = self.get_ops_info()
        access_token = self.get_access_token()

        url = API_DOMAIN + "/api/clubs/"+vendor_id+"/users/" + account_id
        http_client = HTTPClient()
        headers = {"Authorization":"Bearer " + access_token}
        response = http_client.fetch(url, method="GET", headers=headers)
        logging.info("got response.body %r", response.body)
        data = json_decode(response.body)
        _customer_profile = data['rs']

        _contacts = contact_dao.contact_dao().query_by_account(vendor_id, account_id)

        access_token = self.get_access_token()

        params = {"filter":"account", "account_id":account_id, "page":1, "limit":20,}
        url = url_concat(API_DOMAIN + "/api/orders", params)
        http_client = HTTPClient()
        headers = {"Authorization":"Bearer " + access_token}
        response = http_client.fetch(url, method="GET", headers=headers)
        logging.info("got response.body %r", response.body)
        data = json_decode(response.body)
        rs = data['rs']
        orders = rs['data']

        for order in orders:
            # 下单时间,timestamp -> %m月%d 星期%w
            order['create_time'] = timestamp_datetime(float(order['create_time']))
            # 合计金额
            order['amount'] = float(order['amount']) / 100
            order['actual_payment'] = float(order['actual_payment']) / 100

        # 取任务
        categorys = category_dao.category_dao().query_by_vendor(vendor_id)
        personal_tasks = personal_task_dao.personal_task_dao().query_by_vendor_account(vendor_id,account_id)
        logging.info("got personal_tasks============ %r in uri", len(personal_tasks))

        for personal_task in personal_tasks:
            personal_task['create_time'] = timestamp_datetime(personal_task['create_time'])

            task_id = personal_task['task_id']
            task = task_dao.task_dao().query(task_id)

            trip_router_id = task['triprouter']
            triprouter = trip_router_dao.trip_router_dao().query(trip_router_id)

            personal_task['title'] = triprouter['title']
            personal_task['bk_img_url'] = triprouter['bk_img_url']
            for category in categorys:
                if category['_id'] == task['category']:
                    personal_task['category'] = category['title']
                    break

        counter = self.get_counter(vendor_id)
        self.render('vendor/customer-profile.html',
                access_token=access_token,
                vendor_id=vendor_id,
                ops=ops,
                account_id=account_id,
                counter=counter,
                profile=_customer_profile,
                contacts=_contacts, orders=orders, tasks =personal_tasks)
Пример #23
0
    def get(self, vendor_id, triprouter_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got triprouter_id %r in uri", triprouter_id)

        _triprouter = trip_router_dao.trip_router_dao().query(triprouter_id)

        # 详细介绍 判断是否有article_id
        try:
            _triprouter['article_id']
        except:
            _triprouter['article_id'] = ''

        if (_triprouter['article_id'] != ''):

            url = "http://" + STP + "/blogs/my-articles/" + _triprouter[
                'article_id'] + "/paragraphs"
            http_client = HTTPClient()
            response = http_client.fetch(url, method="GET")
            logging.info("got response %r", response.body)
            _paragraphs = json_decode(response.body)

            _triprouter_desc = ""
            for _paragraph in _paragraphs:
                if _paragraph["type"] == 'raw':
                    _triprouter_desc = _paragraph['content']
                    break
            _triprouter_desc = _triprouter_desc.replace('&', "").replace(
                'mdash;', "").replace('<p>', "").replace("</p>", " ").replace(
                    "<section>", "").replace("</section>",
                                             " ").replace("\n", " ")
            _triprouter['desc'] = _triprouter_desc + '...'

        else:
            _triprouter['desc'] = '...'

        # 相关活动
        categorys = category_dao.category_dao().query_by_vendor(vendor_id)
        activitys = activity_dao.activity_dao().query_by_triprouter(
            triprouter_id)
        for activity in activitys:
            activity['begin_time'] = timestamp_date(
                float(activity['begin_time']))  # timestamp -> %m/%d/%Y
            activity['end_time'] = timestamp_date(float(
                activity['end_time']))  # timestamp -> %m/%d/%Y
            for category in categorys:
                if category['_id'] == activity['category']:
                    activity['category'] = category['title']
                    break

        wx_app_info = vendor_wx_dao.vendor_wx_dao().query(vendor_id)
        wx_app_id = wx_app_info['wx_app_id']
        logging.info("got wx_app_id %r in uri", wx_app_id)
        wx_app_secret = wx_app_info['wx_app_secret']
        wx_notify_domain = wx_app_info['wx_notify_domain']

        logging.info("------------------------------------uri: " +
                     self.request.uri)
        _access_token = getAccessTokenByClientCredential(
            wx_app_id, wx_app_secret)
        _jsapi_ticket = getJsapiTicket(_access_token)
        _sign = Sign(_jsapi_ticket, wx_notify_domain + self.request.uri).sign()
        logging.info("------------------------------------nonceStr: " +
                     _sign['nonceStr'])
        logging.info("------------------------------------jsapi_ticket: " +
                     _sign['jsapi_ticket'])
        logging.info("------------------------------------timestamp: " +
                     str(_sign['timestamp']))
        logging.info("------------------------------------url: " +
                     _sign['url'])
        logging.info("------------------------------------signature: " +
                     _sign['signature'])

        # _logined = False
        # wechat_open_id = self.get_secure_cookie("wechat_open_id")
        # if wechat_open_id:
        #     _logined = True

        _account_id = self.get_secure_cookie("account_id")

        self.render('wx/triprouter-info.html',
                    vendor_id=vendor_id,
                    triprouter=_triprouter,
                    activitys=activitys,
                    wx_app_id=wx_app_secret,
                    wx_notify_domain=wx_notify_domain,
                    sign=_sign,
                    account_id=_account_id)
Пример #24
0
 def get(self):
     categories = yield category_dao.category_dao().find_all()
     self.render('admin/blog-create.html', categories=categories)