Esempio n. 1
0
    def post(self):
        errtip, link_cid, link_kv, name, motto, url, txt, pic_id = self._site_save()
        current_user_id = self.current_user_id
        zsite_id = self.zsite_id
        zsite = self.zsite

        success = False

        if not errtip:
            success = True
            if not url_by_id(zsite_id) and url:
                url_new(zsite_id, url)
            zsite.name = name
            zsite.save()

            link_list_save(zsite_id, link_cid, link_kv)
            txt_new(zsite_id, txt)
            motto_set(zsite_id, motto)
            site_ico_bind(current_user_id, pic_id, zsite_id)
            search_new(zsite_id)

        self.render(
            success=success,
            errtip=errtip,
            link_cid=link_cid,
            link_list=link_kv,
            name=name,
            motto=motto,
            txt=txt,
            pic_id=pic_id,
            url=url
        )
Esempio n. 2
0
    def post(self):

        sitetype = int(self.get_argument('sitetype'))
        errtip, link_cid, link_kv, name, motto, url, txt, pic_id = self._site_save()
        current_user = self.current_user
        current_user_id = current_user.id

        if not errtip:
            site = site_new(name, current_user_id, sitetype)
            site_id = site.id
            link_list_save(site_id, link_cid, link_kv)
            site_ico_bind(current_user_id, pic_id, site_id)
            motto_set(site_id, motto)
            txt_new(site_id, txt)
            if url:
                url_new(site_id, url)
            self.redirect(site.link)
            return


        return self.render(
            errtip=errtip,
            link_cid=link_cid,
            link_list=link_kv,
            name=name,
            motto=motto,
            url=url,
            sitetype=sitetype,
            txt=txt,
            pic_id=pic_id
        )
Esempio n. 3
0
    def post(self):
        errtip, link_cid, link_kv, name, motto, url, txt, pic_id = self._site_save(
        )
        current_user_id = self.current_user_id
        zsite_id = self.zsite_id
        zsite = self.zsite

        success = False

        if not errtip:
            success = True
            if not url_by_id(zsite_id) and url:
                url_new(zsite_id, url)
            zsite.name = name
            zsite.save()

            link_list_save(zsite_id, link_cid, link_kv)
            txt_new(zsite_id, txt)
            motto_set(zsite_id, motto)
            site_ico_bind(current_user_id, pic_id, zsite_id)
            search_new(zsite_id)

        self.render(success=success,
                    errtip=errtip,
                    link_cid=link_cid,
                    link_list=link_kv,
                    name=name,
                    motto=motto,
                    txt=txt,
                    pic_id=pic_id,
                    url=url)
Esempio n. 4
0
def save_link(self):
    zsite_id = self.zsite_id

    arguments = parse_qs(self.request.body, True)
    link_cid = []
    link_kv = []
    for cid, link in zip(arguments.get("cid"), arguments.get("link")):
        cid = int(cid)
        name = OAUTH2NAME_DICT[cid]
        link_cid.append((cid, 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))

    link_list_save(zsite_id, link_cid, link_kv)
Esempio n. 5
0
def save_link(self):
    zsite_id = self.zsite_id

    arguments = parse_qs(self.request.body, True)
    link_cid = []
    link_kv = []
    for cid, link in zip(arguments.get('cid'), arguments.get('link')):
        cid = int(cid)
        name = OAUTH2NAME_DICT[cid]
        link_cid.append((cid, 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))

    link_list_save(zsite_id, link_cid, link_kv)