예제 #1
0
    def post(self):
        errtip = Errtip()
        current_user = self.current_user
        current_user_id = current_user.id
        name = self.get_argument('name', None)
        motto = self.get_argument('motto', None)
        pid = self.get_arguments('pid', None)
        address = self.get_arguments('address', None)
        phone = self.get_argument('phone', None)
        pid_add = zip(pid, address)
        zsite = self.zsite

        if not name:
            errtip.name = '请输入名称'
        else:
            zsite.name = name
            zsite.save()

        if not motto:
            errtip.motto = '请编写签名'

        files = self.request.files
        pic_id = None

        if 'pic' in files:
            pic = files['pic'][0]['body']
            pic = picopen(pic)
            if pic:
                pic_id = site_ico_new(current_user_id, pic)
            else:
                errtip.pic = '图片格式有误'
        else:
            pic_id = self.get_argument('pic_id', None)
            if not pic_id:
                errtip.pic = '请上传图片'

        if not errtip:
            current_user_id = self.current_user_id
            com_id = self.zsite_id
            zsite_com_new(com_id, phone=phone)
            site_ico_bind(current_user_id, pic_id, com_id)
            motto_set(com_id, motto)
            if pid_add:
                for pa in pid_add:
                    zsite_com_place_new(com_id, int(pa[0]), pa[1])
            else:
                pid_add = self.get_argument('pid_add', None)
            return self.redirect('/')

        return self.render(
            errtip=errtip,
            name=name,
            motto=motto,
            #txt=txt,
            phone=phone,
            pic_id=pic_id,
            pid_add=pid_add)
예제 #2
0
def make_site(name, link, motto, img_src, site_num, current_user_id=10017321):
    f = urllib.urlopen(img_src).read()
    if  f:
        pic = picopen(f)
        if pic:
            pic_id = site_ico_new(10017321, pic)
    site = site_new(name, current_user_id, 40)
    site_id = site.id
    site_ico_bind(current_user_id, pic_id, site_id)
    zsite_link = ZsiteLink.get_or_create(zsite_id=site_id, cid=2)
    zsite_link.link = link
    zsite_link.name = '豆瓣小站'
    zsite_link.save()
    mc_flush(site_id)
    motto_set(site_id, motto)
    rss_new(site_id, 'http://rss-tidy.42qu.com/douban/site/%s'%site_num, name, link, auto=1)
    print site_id
예제 #3
0
def make_site(name, link, motto, img_src, site_num, current_user_id=10017321):
    f = urllib.urlopen(img_src).read()
    if f:
        pic = picopen(f)
        if pic:
            pic_id = site_ico_new(10017321, pic)
    site = site_new(name, current_user_id, 40)
    site_id = site.id
    site_ico_bind(current_user_id, pic_id, site_id)
    zsite_link = ZsiteLink.get_or_create(zsite_id=site_id, cid=2)
    zsite_link.link = link
    zsite_link.name = '豆瓣小站'
    zsite_link.save()
    mc_flush(site_id)
    motto_set(site_id, motto)
    rss_new(site_id,
            'http://rss-tidy.42qu.com/douban/site/%s' % site_num,
            name,
            link,
            auto=1)
    print site_id
예제 #4
0
    def post(self):
        errtip = Errtip()
        current_user = self.current_user
        current_user_id = current_user.id
        name = self.get_argument('name', None)
        motto = self.get_argument('motto', None)
        url = self.get_argument('url', None)
        pid = self.get_arguments('pid', None)
        address = self.get_arguments('address', None)
        phone = self.get_argument('phone', None)
        pid_add = zip(pid, address)

        if not name:
            errtip.name = '请输入名称'

        if not motto:
            errtip.motto = '请编写签名'


        if url:
            errtip.url = url_valid(url)

        files = self.request.files
        pic_id = None

        if 'pic' in files:
            pic = files['pic'][0]['body']
            pic = picopen(pic)
            if pic:
                pic_id = site_ico_new(current_user_id, pic)
            else:
                errtip.pic = '图片格式有误'
        else:
            pic_id = self.get_argument('pic_id', None)
            if not pic_id:
                errtip.pic = '请上传图片'

        if not errtip:
            com = com_new(name, current_user_id )
            com_id = com.id
            zsite_com_new(com_id, phone=phone)
            site_ico_bind(current_user_id, pic_id, com_id)
            motto_set(com_id, motto)
            zsite_member_new(com_id, current_user_id, state=ZSITE_MEMBER_STATE_ACTIVE)
            if pid_add:
                for pa in pid_add:
                    zsite_com_place_new(com_id, int(pa[0]), pa[1])
            else:
                pid_add = self.get_argument('pid_add', None)
            if url:
                url_new(com_id, url)
            return self.redirect('%s/product/new'%com.link)


        return self.render(
            errtip=errtip,
            name=name,
            motto=motto,
            url=url,
            #txt=txt,
            phone=phone,
            pic_id=pic_id,
            pid_add=pid_add
        )
예제 #5
0
def _site_save(self):
    arguments = self.request.arguments

    current_user = self.current_user
    current_user_id = current_user.id

    link_cid = []
    link_kv = []
    errtip = Errtip()

    name = self.get_argument('name', None)
    motto = self.get_argument('motto', None)
    url = self.get_argument('url', None)
    txt = self.get_argument('txt', None)

    for cid, link in zip(arguments.get('cid', []), arguments.get('link', [])):
        cid = int(cid)
        link_name = SITE_LINK_ZSITE_DICT[cid]
        link_cid.append(
            (cid, link_name, linkify(link, cid))
        )



    for id, key, value in zip(
        arguments.get('id', []),
        arguments.get('key', []),
        arguments.get('value', [])
    ):
        id = int(id)
        link = linkify(value)
        link_kv.append(
            (id, key.strip() or urlparse(link).netloc, link)
        )


    files = self.request.files
    pic_id = None

    if 'pic' in files:
        pic = files['pic'][0]['body']
        pic = picopen(pic)
        if pic:
            pic_id = site_ico_new(current_user_id, pic)
        else:
            errtip.pic = '图片格式有误'
    else:
        pic_id = self.get_argument('pic_id', None)
        if not pic_id:
            errtip.pic = '请上传图片'




    if not name:
        errtip.name = '请输入名称'

    if not motto:
        errtip.motto = '请编写签名'

    if url:
        errtip.url = url_valid(url)


    if errtip:
        for cid, link_name in SITE_LINK_NAME:
            if cid not in set(i[0] for i in link_cid):
                link_cid.append(
                    (
                        cid,
                        link_name,
                        ''
                    )
                )


    return errtip, link_cid, link_kv, name, motto, url, txt, pic_id
예제 #6
0
    def post(self):
        errtip = Errtip()
        current_user = self.current_user
        current_user_id = current_user.id
        name = self.get_argument('name', None)
        motto = self.get_argument('motto', None)
        pid = self.get_arguments('pid', None)
        address = self.get_arguments('address', None)
        phone = self.get_argument('phone', None)
        pid_add = zip(pid, address)
        zsite = self.zsite

        if not name:
            errtip.name = '请输入名称'
        else:
            zsite.name = name
            zsite.save()

        if not motto:
            errtip.motto = '请编写签名'



        files = self.request.files
        pic_id = None

        if 'pic' in files:
            pic = files['pic'][0]['body']
            pic = picopen(pic)
            if pic:
                pic_id = site_ico_new(current_user_id, pic)
            else:
                errtip.pic = '图片格式有误'
        else:
            pic_id = self.get_argument('pic_id', None)
            if not pic_id:
                errtip.pic = '请上传图片'


        if not errtip:
            current_user_id = self.current_user_id
            com_id = self.zsite_id
            zsite_com_new(com_id, phone=phone)
            site_ico_bind(current_user_id, pic_id, com_id)
            motto_set(com_id, motto)
            if pid_add:
                for pa in pid_add:
                    zsite_com_place_new(com_id, int(pa[0]), pa[1])
            else:
                pid_add = self.get_argument('pid_add', None)
            return self.redirect('/')


        return self.render(
            errtip=errtip,
            name=name,
            motto=motto,
            #txt=txt,
            phone=phone,
            pic_id=pic_id,
            pid_add=pid_add
        )