Exemplo n.º 1
0
 def fetch_all_lessons(self, page):
     sql = '''select d.id, subject_name, username, from_unixtime(createtime) as createtime,
             date(from_unixtime(start_time)) as start_time, date(from_unixtime(end_time)) as end_time,
             d.actived from md_diy_subject d left join md_member m on d.member_id = m.id
             order by createtime desc'''
     sql = Pagination.add_limit_clause(sql, page)
     return self.db.query(sql)
Exemplo n.º 2
0
 def fetch_all_lessons(self, page):
     sql = '''select d.id, subject_name, username, from_unixtime(createtime) as createtime,
             date(from_unixtime(start_time)) as start_time, date(from_unixtime(end_time)) as end_time,
             d.actived from md_diy_subject d left join md_member m on d.member_id = m.id
             order by createtime desc'''
     sql = Pagination.add_limit_clause(sql, page)
     return self.db.query(sql)
Exemplo n.º 3
0
    def get(self):
        session = self.backend.get_session()

        # 查询
        package_name = self.get_argument("package_name", "")
        if package_name:
            hairpackages = session.query(HairPackage).filter(HairPackage.package_name.like("%" + package_name + "%"))
        else:
            hairpackages = session.query(HairPackage)
        hairpackages = hairpackages.order_by(HairPackage.modifytime.desc())

        # 分页
        count = hairpackages.count()
        page_count = Pagination.page_count(count)

        params = dict(
            hairpackages=hairpackages.all(),
            config=self.config,
            page_count=page_count,
            informer=BootstrapInformer("success", "共 %s 条记录" % count, "查询结果:"),
            package_name=package_name,
        )
        self.render("hairpackages/index.html", **params)

        session.close()
Exemplo n.º 4
0
    def get(self):
        query_params = dict(
            member_type=self.get_argument("member_type", None),
            actived=self.get_argument("actived", None),
            province_id=self.get_argument("province_id", None),
            city_id=self.get_argument("city_id", None),
            username=self.get_argument("username", ""),
            email=self.get_argument("email", ""),
            mobile=self.get_argument("mobile", None),
            regtime_from=self.get_argument("regtime_from", ""),
            regtime_to=self.get_argument("regtime_to", str(datetime.date.today())),
            lastlogintime_from=self.get_argument("lastlogintime_from", ""),
            lastlogintime_to=self.get_argument("lastlogintime_to", str(datetime.date.today())),
            page=self.get_argument("page", 1)
        )

        try:
            regions = self.fetch_all_regions()
            entries = self.query_users(**query_params)
            count = self.query_users_size(**query_params)
            page_count = Pagination.page_count(count)
        except Exception, e:
            print e
            self.redirect("/users")
            return
Exemplo n.º 5
0
    def get(self):
        query_params = dict(
            member_type=self.get_argument("member_type", None),
            actived=self.get_argument("actived", None),
            province_id=self.get_argument("province_id", None),
            city_id=self.get_argument("city_id", None),
            username=self.get_argument("username", ""),
            email=self.get_argument("email", ""),
            mobile=self.get_argument("mobile", None),
            regtime_from=self.get_argument("regtime_from", ""),
            regtime_to=self.get_argument("regtime_to",
                                         str(datetime.date.today())),
            lastlogintime_from=self.get_argument("lastlogintime_from", ""),
            lastlogintime_to=self.get_argument("lastlogintime_to",
                                               str(datetime.date.today())),
            page=self.get_argument("page", 1))

        try:
            regions = self.fetch_all_regions()
            entries = self.query_users(**query_params)
            count = self.query_users_size(**query_params)
            page_count = Pagination.page_count(count)
        except Exception, e:
            print e
            self.redirect("/users")
            return
Exemplo n.º 6
0
    def get(self):
        session = self.backend.get_session()

        # 查询
        package_name = self.get_argument("package_name", "")
        if package_name:
            hairpackages = session.query(HairPackage).filter(
                HairPackage.package_name.like("%" + package_name + "%"))
        else:
            hairpackages = session.query(HairPackage)
        hairpackages = hairpackages.order_by(HairPackage.modifytime.desc())

        # 分页
        count = hairpackages.count()
        page_count = Pagination.page_count(count)

        params = dict(
            hairpackages=hairpackages.all(),
            config=self.config,
            page_count=page_count,
            informer=BootstrapInformer("success", "共 %s 条记录" % count, "查询结果:"),
            package_name=package_name,
        )
        self.render("hairpackages/index.html", **params)

        session.close()
Exemplo n.º 7
0
 def query_salons(self, salon_name, province_id, city_id, domain_id, page):
     '''查询沙龙'''
     sql = '''
         select * from md_salon
     '''
     sql, params = self.gen_query_str(sql, salon_name, province_id, city_id, domain_id)
     sql = Pagination.add_limit_clause(sql, page)
     return self.db.query(sql, *params)
Exemplo n.º 8
0
 def query_salons(self, salon_name, province_id, city_id, domain_id, page):
     '''查询沙龙'''
     sql = '''
         select * from md_salon
     '''
     sql, params = self.gen_query_str(sql, salon_name, province_id, city_id,
                                      domain_id)
     sql = Pagination.add_limit_clause(sql, page)
     return self.db.query(sql, *params)
Exemplo n.º 9
0
    def get(self):
        page = self.get_argument("page", 1)
        seasons = self.fetch_all_seasons(page)
        count = self.fetch_all_seasons_size()
        page_count = Pagination.page_count(count)

        params = dict(
            seasons=seasons,
            informer=BootstrapInformer("success", "共 %s 条记录" % len(seasons), "查询结果:"),
            page_count=page_count,
        )
        self.render("seasons/index.html", **params)
Exemplo n.º 10
0
    def get(self):
        page = self.get_argument("page", 1)
        seasons = self.fetch_all_seasons(page)
        count = self.fetch_all_seasons_size()
        page_count = Pagination.page_count(count)

        params = dict(
            seasons=seasons,
            informer=BootstrapInformer("success", "共 %s 条记录" % len(seasons),
                                       "查询结果:"),
            page_count=page_count,
        )
        self.render("seasons/index.html", **params)
Exemplo n.º 11
0
 def query_users(self, **args):
     sql = '''
         select m.id, m.username, m.email, m.member_type, m.regtime, m.recommend,
             m.province_id, m.city_id, m.recommend_talent,
             m.actived, s.works_count, s.lastlogintime, s.twitter_num, s.emotion_num,
             from_unixtime(m.regtime) as regtime_str,
             from_unixtime(s.lastlogintime) as lastlogintime_str
         from md_member m left outer join md_member_statistics s on m.id = s.member_id
     '''
     query_str, params = self.query_users_where_clause(**args)
     sql = sql + query_str
     sql = sql + " order by m.id desc "
     sql = Pagination.add_limit_clause(sql, args["page"])
     return self.db.query(sql, *params)
Exemplo n.º 12
0
 def query_users(self, **args):
     sql = '''
         select m.id, m.username, m.email, m.member_type, m.regtime, m.recommend,
             m.province_id, m.city_id, m.recommend_talent,
             m.actived, s.works_count, s.lastlogintime, s.twitter_num, s.emotion_num,
             from_unixtime(m.regtime) as regtime_str,
             from_unixtime(s.lastlogintime) as lastlogintime_str
         from md_member m left outer join md_member_statistics s on m.id = s.member_id
     '''
     query_str, params = self.query_users_where_clause(**args)
     sql = sql + query_str
     sql = sql + " order by m.id desc "
     sql = Pagination.add_limit_clause(sql, args["page"])
     return self.db.query(sql, *params)
Exemplo n.º 13
0
    def query_twitters(self, **args):
        sql = '''
            select m.id, m.share_type, m.createtime, from_unixtime(m.createtime) as createtime_str,
                m.actived, s.description, s.comment_num,
                p.id as pic_id, p.pic_url, p.img_path, p.img_type,
                u.id as uid, u.username, u.member_type
            from md_twitter m, md_twitter_show s, md_twitter_picture p, md_member u
            where m.id = s.tid and s.pic_id = p.id and m.member_id = u.id
        '''
        sql, params = self.gen_query_str(sql, **args)
        sql = sql + " order by m.createtime desc"

        page = args.get("page", [1])[0]
        sql = Pagination.add_limit_clause(sql, page)

        return self.db.query(sql, *params)
Exemplo n.º 14
0
    def get(self):
        salon_name = self.get_argument("salon_name", "")
        province_id = self.get_argument("province_id", 0)
        city_id = self.get_argument("city_id", 0)
        domain_id = self.get_argument("domain_id", 0)
        page = self.get_argument("page", 1)

        salons = self.query_salons(salon_name, province_id, city_id, domain_id,
                                   page)
        count = self.fetch_salons_count(salon_name, province_id, city_id,
                                        domain_id)
        page_count = Pagination.page_count(count)
        hairstylists = self.fetch_hairstylist_count()
        logos = self.fetch_all_logos()

        params = dict(
            config=self.config,

            # 沙龙列表
            salons=salons,
            hairstylists=hairstylists,
            logos=logos,
            default_img=self.default_image_url(),
            #path_prefix=self.get_salon_path_prefix(),

            # 查询模块
            regions=self.fetch_all_regions(),
            provinces=self.fetch_provinces(),
            cities=self.fetch_cities(),
            domains=self.fetch_domains(),
            arguments=self.request.arguments,

            # 分页
            page_count=page_count,

            # 提示信息
            informer=BootstrapInformer("success", "共 %s 条记录" % count, "查询结果:"),
        )
        self.render("salons/index.html", **params)
Exemplo n.º 15
0
    def get(self):
        entries = self.query_twitters(**self.request.arguments)
        count = self.query_twitters_count(**self.request.arguments)
        page_count = Pagination.page_count(count)
        informer = BootstrapInformer("success", "共 %s 条记录" % count, "查询结果")

        # 图片的URL地址
        for entry in entries:
            entry["real_pic_url"] = self.real_pic_url(entry)

        # 查询参数由数组变为数值
        dataset = {}
        for k, v in self.request.arguments.items():
            dataset.setdefault(k, list(v)[0])

        params = dict(
            entries=entries,
            config=self.config,
            page_count=page_count,
            informer=informer,
            args=dataset,
        )
        self.render("twitters/index.html", **params)
Exemplo n.º 16
0
    def get(self):
        salon_name = self.get_argument("salon_name", "")
        province_id = self.get_argument("province_id", 0)
        city_id = self.get_argument("city_id", 0)
        domain_id = self.get_argument("domain_id", 0)
        page = self.get_argument("page", 1)

        salons = self.query_salons(salon_name, province_id, city_id, domain_id, page)
        count = self.fetch_salons_count(salon_name, province_id, city_id, domain_id)
        page_count = Pagination.page_count(count)
        hairstylists = self.fetch_hairstylist_count()
        logos = self.fetch_all_logos()

        params = dict(
            config=self.config,

            # 沙龙列表
            salons=salons,
            hairstylists=hairstylists,
            logos=logos,
            default_img=self.default_image_url(),
            #path_prefix=self.get_salon_path_prefix(),

            # 查询模块
            regions=self.fetch_all_regions(),
            provinces=self.fetch_provinces(),
            cities=self.fetch_cities(),
            domains=self.fetch_domains(),
            arguments=self.request.arguments,

            # 分页
            page_count=page_count,

            # 提示信息
            informer=BootstrapInformer("success", "共 %s 条记录" % count, "查询结果:"),
        )
        self.render("salons/index.html", **params)
Exemplo n.º 17
0
 def fetch_all_seasons(self, page):
     sql = '''select *, date(from_unixtime(createtime)) as createtime_str
             from md_season_period order by createtime desc'''
     sql = Pagination.add_limit_clause(sql, page)
     return self.db.query(sql)
Exemplo n.º 18
0
 def fetch_all_seasons(self, page):
     sql = '''select *, date(from_unixtime(createtime)) as createtime_str
             from md_season_period order by createtime desc'''
     sql = Pagination.add_limit_clause(sql, page)
     return self.db.query(sql)