Exemplo n.º 1
0
    def post(self):
        try:
            name = self.get_argument("name", "未命名课程名称")
            member_id = self.get_argument("member_id", 0)
            content = self.get_argument("content", "")
            start_date = self.get_argument("start_date", "2012-01-01")
            end_date = self.get_argument("end_date", "2020-01-01")
            actived = self.get_argument("actived", "N")
            createtime = time.mktime(datetime.datetime.now().timetuple())

            pics = self.get_arguments("pics")

            # 创建主题
            # md_diy_subject
            start_date = self.convert_date_to_timestamp(start_date)
            end_date = self.convert_date_to_timestamp(end_date)
            subject_id = self.db.execute(
                "insert into md_diy_subject(subject_name, member_id, content, actived, "
                "createtime, start_time, end_time) "
                "values(%s, %s, %s, %s, %s, %s, %s)", name, member_id, content,
                actived, createtime, start_date, end_date)
            for pic in pics:
                pic_id, pic_url = pic.split("|")
                self.db.execute(
                    "insert into md_diy_subject_content(subject_id, theme_pic_id, "
                    "thme_pic_url, sort, actived) values(%s, %s, %s, %s, %s)",
                    subject_id, pic_id, pic_url, 0, actived)
        except Exception, e:
            print e
            params = dict(
                stylists=self.fetch_stylists(),
                informer=BootstrapInformer("error", e),
            )
            self.render("lessons/new.html", **params)
            return
Exemplo n.º 2
0
class StarHandler(StarBaseHandler):
    @tornado.web.authenticated
    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", ""),
            regtime_from=self.get_argument("regtime_from", ""),
            regtime_to=self.get_argument("regtime_to", ""),
            lastlogintime_from=self.get_argument("lastlogintime_from", ""),
            lastlogintime_to=self.get_argument("lastlogintime_to", ""),
            page=self.get_argument("page", 1))

        try:
            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("/stars")
            return

        params = dict(
            provinces=self.fetch_provinces(),
            entries=entries,
            query_params=query_params,
            config=self.config,
            informer=BootstrapInformer("success", "共 %s 条记录" % count, "查询结果:"),
            page_count=page_count,
        )

        self.render("stars/index.html", **params)
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):
        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.º 5
0
    def post(self):
        username = self.get_argument("username", "")
        password = self.get_argument("password", "")
        next_url = self.get_argument("next_url", "/")

        user = self.db.get("select password from md_admin_member where username = %s", username)
        if user is not None and user.password == hashlib.md5(password).hexdigest():
            self.set_secure_cookie("username", username)
            self.set_secure_cookie("password", password)
        else:
            informer = BootstrapInformer("error", "错误的用户名或密码", "认证失败:")
            self.render("login/login.html", informer=informer, next_url=next_url)
            return

        self.redirect(next_url)
Exemplo n.º 6
0
    def post(self):
        try:
            period_name = self.get_argument("period_name", "未知主题名称")
            content = self.get_argument("content", "")
            package_id = self.get_argument("package_id", 0)
            start_time = self.get_argument("start_time", "2012-01-01")
            end_time = self.get_argument("end_time", "2012-01-01")
            theme_pic_id = self.get_argument("theme_pic_id", 0)
            theme_pic_url = self.get_argument("theme_pic_url", "")
            theme_spic_id = self.get_argument("theme_spic_id", 0)
            theme_spic_url = self.get_argument("theme_spic_url", "")
            actived = self.get_argument("actived", "N")
            twitter_ids = self.get_argument("twitter_ids", "")

            if isinstance(start_time, str) or isinstance(start_time, unicode):
                start_time = self.convert_date_to_timestamp(start_time)
            if isinstance(end_time, str) or isinstance(end_time, unicode):
                end_time = self.convert_date_to_timestamp(end_time)
            createtime = time.mktime(datetime.datetime.now().timetuple())

            id = self.db.execute(
                "insert into md_season_period(period_name, content, package_id, "
                "start_time, end_time, createtime, theme_pic_id, theme_pic_url, "
                "theme_spic_id, theme_spic_url, actived) "
                "values(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                period_name, content, package_id, start_time, end_time,
                createtime, theme_pic_id, theme_pic_url, theme_spic_id,
                theme_spic_url, actived)

            twitter_ids = twitter_ids.split(",")
            for twitter_id in twitter_ids:
                if twitter_id:
                    self.db.execute(
                        "insert into md_season_picture(period_id, tid, actived) "
                        "values(%s, %s, %s)", id, twitter_id, 'Y')

            self.redirect("/seasons")
        except Exception, e:
            params = dict(
                pics=[],
                packages=self.fetch_packages(),
                informer=BootstrapInformer("error", e),
                path_prefix=self.path_to_url(self.get_subject_path_prefix()),
            )
            self.render("seasons/new.html", **params)
Exemplo n.º 7
0
    def post(self, id):
        session = self.backend.get_session()

        hairpackage = session.query(HairPackage).get(id)
        if not hairpackage:
            raise tornado.web.HTTPError(404)

        try:
            hairpackage.set(**self.params)
            session.commit()
            self.redirect("/hairpackages")
        except Exception, e:
            print e
            session.rollback()

            params = dict(
                hairpackage=hairpackage,
                stylists=session.query(Member).filter_by(member_type=2).all(),
                config=self.config,
                informer=BootstrapInformer("error", e, "更新失败:"))
            self.render("hairpackages/edit.html", **params)
Exemplo n.º 8
0
    def post(self, id):
        args = dict(
            # basic info
            username=self.get_argument("username", None),
            actived=self.get_argument("actived", None),
            email=self.get_argument("email", None),
            gender=self.get_argument("gender", None),
            province_id=self.get_argument("province_id", None),
            city_id=self.get_argument("city_id", None),
            area_id=self.get_argument("domain_id", None),
            sign_text=self.get_argument("sign_text", None),
            avatar_id=self.get_argument("avatar_id", None),

            # common users
            hair_face=self.get_argument("hair_face", None),
            hair_quality=self.get_argument("hair_quality", None),
            hair_volume=self.get_argument("hair_volume", None),

            # stylists
            recommend=self.get_argument("recommend", None),
            recommend_talent=self.get_argument("recommend_talent", None),
            salon_id=self.get_argument("salon_id", None),
            mobile=self.get_argument("mobile", None),
            price_haircut=self.get_argument("price_haircut", None),
            price_perm=self.get_argument("price_perm", None),
            price_dye=self.get_argument("price_dye", None),
            price_care=self.get_argument("price_care", None),
        )

        user = self.fetch_user(id)
        try:
            self.update_user(id, **args)
        except Exception, e:
            informer = BootstrapInformer('error', e)
            self.render("users/edit.html",
                        user=user,
                        config=self.config,
                        informer=informer)
            return
Exemplo n.º 9
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.º 10
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.º 11
0
class UserHandler(UserBaseHandler):
    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

        params = dict(
            regions=regions,
            entries=entries,
            query_params=query_params,
            config=self.config,
            informer=BootstrapInformer("success", "共 %s 条记录" % count, "查询结果:"),
            page_count=page_count,
        )
        self.render("users/index.html", **params)
Exemplo n.º 12
0
    def post(self, id):
        season = self.fetch_season(id)

        season["period_name"] = self.get_argument("period_name",
                                                  season.period_name)
        season["content"] = self.get_argument("content", season.content)
        season["package_id"] = self.get_argument("package_id",
                                                 season.package_id)
        season["start_time"] = self.get_argument("start_time",
                                                 season.start_time)
        season["end_time"] = self.get_argument("end_time", season.end_time)
        season["theme_pic_id"] = self.get_argument("theme_pic_id",
                                                   season.theme_pic_id)
        season["theme_pic_url"] = self.get_argument("theme_pic_url",
                                                    season.theme_pic_url)
        season["theme_spic_id"] = self.get_argument("theme_spic_id",
                                                    season.theme_spic_id)
        season["theme_spic_url"] = self.get_argument("theme_spic_url",
                                                     season.theme_spic_url)
        season["actived"] = self.get_argument("actived", season.actived)

        twitter_ids = self.get_argument("twitter_ids", "")

        try:
            if isinstance(season.start_time, str) or isinstance(
                    season.start_time, unicode):
                season["start_time"] = self.convert_date_to_timestamp(
                    season.start_time)
            if isinstance(season.end_time, str) or isinstance(
                    season.end_time, unicode):
                season["end_time"] = self.convert_date_to_timestamp(
                    season.end_time)

            self.db.execute(
                "update md_season_period set period_name = %s, content = %s, "
                "package_id = %s, start_time = %s, end_time = %s, "
                "theme_pic_id = %s, theme_pic_url = %s, theme_spic_id = %s, "
                "theme_spic_url = %s, actived = %s where id = %s",
                season.period_name, season.content, season.package_id,
                season.start_time, season.end_time, season.theme_pic_id,
                season.theme_pic_url, season.theme_spic_id,
                season.theme_spic_url, season.actived, season.id)

            twitter_ids = twitter_ids.split(",")
            for twitter_id in twitter_ids:
                if twitter_id:
                    self.db.execute(
                        "insert into md_season_picture(period_id, tid, actived) "
                        "values(%s, %s, %s)", id, twitter_id, 'Y')

            self.redirect("/seasons")
        except Exception, e:
            path_prefix = self.path_to_url(self.get_subject_path_prefix())
            twitter_path_prefix = self.path_to_url(
                self.get_twitter_path_prefix())
            pic_url = path_prefix + "/" + self.pic_url(season.theme_pic_id)
            params = dict(
                season=season,
                packages=self.fetch_packages(),
                informer=BootstrapInformer("error", e),
                pic_url=pic_url,
                pics=self.fetch_season_pics(id),
                path_prefix=path_prefix,
                twitter_path_prefix=twitter_path_prefix,
            )
            self.render("seasons/edit.html", **params)