Пример #1
0
    def prepare(self):
        super(AdminBase, self).prepare()

        zsite = self.zsite
        if not zsite.cid == CID_COM or not zsite_member_can_admin(
                self.zsite_id, self.current_user_id):
            self.finish('{}')
Пример #2
0
def po_review_new(zsite_id, user_id, name):
    from model.zsite_member import zsite_member_can_admin
    if zsite_member_can_admin(zsite_id, user_id):
        state = STATE_ACTIVE
    else:
        state = STATE_PO_ZSITE_SHOW_THEN_REVIEW

    review = po_review_get(zsite_id, user_id)

    if review:
        if not name:
            po_review_rm(zsite_id, user_id)
        else:
            review.state = state
            review.name_ = name
            review.save()
    else:
        review = po_new(
            CID_REVIEW,
            user_id,
            name,
            state=state,
            zsite_id=zsite_id
        )
        if review:
            mc_po_review_id_get.set(
                '%s_%s'%(zsite_id, user_id),
                review.id
            )
            review.feed_new()

    if state == STATE_ACTIVE:
        mc_po_review_id_list_active_by_zsite_id.delete(zsite_id)
    return review
Пример #3
0
def po_review_new(zsite_id, user_id, name):
    from model.zsite_member import zsite_member_can_admin
    if zsite_member_can_admin(zsite_id, user_id):
        state = STATE_ACTIVE
    else:
        state = STATE_PO_ZSITE_SHOW_THEN_REVIEW

    review = po_review_get(zsite_id, user_id)

    if review:
        if not name:
            po_review_rm(zsite_id, user_id)
        else:
            review.state = state
            review.name_ = name
            review.save()
    else:
        review = po_new(CID_REVIEW,
                        user_id,
                        name,
                        state=state,
                        zsite_id=zsite_id)
        if review:
            mc_po_review_id_get.set('%s_%s' % (zsite_id, user_id), review.id)
            review.feed_new()

    if state == STATE_ACTIVE:
        mc_po_review_id_list_active_by_zsite_id.delete(zsite_id)
    return review
Пример #4
0
def com_apply_new(com_id, user_id):

    if zsite_member_can_admin(com_id, user_id):
        return

    ca = ComApply.get_or_create(com_id=com_id, user_id=user_id)
    ca.state = COM_APPLY_STATE_APPLY
    ca.create_time = today_seconds()
    ca.save()
    mc_flush(com_id)
Пример #5
0
def _product_save(self, product):
    current_user_id = self.current_user_id
    if not zsite_member_can_admin(self.zsite_id, current_user_id):
        return

    position = int(self.get_argument('position', 0))
    origin = self.get_argument('origin', None)
    plan = self.get_argument('plan', None)
    similar_product_name = self.get_arguments('similar_product_name', None)
    similar_product_url = self.get_arguments('similar_product_url', None)
    same = self.get_argument('same', None)
    different = self.get_argument('different', None)
    advantage = self.get_argument('advantage', None)
    _product = self.get_argument('product', None)
    market = self.get_argument('market', None)

    product_similar = zip(similar_product_name, similar_product_url)
    _pro = []
    if product_similar:
        for _name, _url in product_similar:
            if _name or _url:
                if _url:
                    if not (_url.startswith('http://')
                            or _url.startswith('https://')):
                        _url = 'http://%s' % _url
                if not _name:
                    _pro.append([urlparse(_url).netloc or _url, _url])
                else:
                    _pro.append([_name, _url])
        product_similar = _pro

    pic_id = None
    files = self.request.files
    if product:
        if 'pic' in files:
            pic = files['pic'][0]['body']
            pic = picopen(pic)
            if pic:
                pic_id = product_pic_new(self.zsite_id, product.id, pic)

        _info = JsDict(json.loads(product.txt or '{}'))
        _info.pic_id = pic_id
        _info.product_similar = product_similar
        _info.origin = origin
        _info.plan = plan
        _info.same = same
        _info.different = different
        _info.advantage = advantage
        _info.product = _product
        _info.market = market
        product.txt_set(json.dumps(dict(iter(_info))))
        product.save()
Пример #6
0
def _product_save(self, product):
    current_user_id = self.current_user_id
    if not zsite_member_can_admin(self.zsite_id, current_user_id):
        return

    position = int(self.get_argument('position', 0))
    origin = self.get_argument('origin', None)
    plan = self.get_argument('plan', None)
    similar_product_name = self.get_arguments('similar_product_name', None)
    similar_product_url = self.get_arguments('similar_product_url', None)
    same = self.get_argument('same', None)
    different = self.get_argument('different', None)
    advantage = self.get_argument('advantage', None)
    _product = self.get_argument('product', None)
    market = self.get_argument('market', None)

    product_similar = zip(similar_product_name, similar_product_url)
    _pro = []
    if product_similar:
        for _name, _url in product_similar:
            if _name or _url:
                if _url:
                    if not (_url.startswith('http://') or _url.startswith('https://')):
                        _url = 'http://%s'%_url
                if not _name:
                    _pro.append([urlparse(_url).netloc or _url, _url])
                else:
                    _pro.append([_name, _url])
        product_similar = _pro

    pic_id = None
    files = self.request.files
    if product:
        if 'pic' in files:
            pic = files['pic'][0]['body']
            pic = picopen(pic)
            if pic:
                pic_id = product_pic_new(self.zsite_id, product.id, pic)

        _info = JsDict(json.loads(product.txt or '{}'))
        _info.pic_id = pic_id
        _info.product_similar = product_similar
        _info.origin = origin
        _info.plan = plan
        _info.same = same
        _info.different = different
        _info.advantage = advantage
        _info.product = _product
        _info.market = market
        product.txt_set(json.dumps(dict(iter(_info))))
        product.save()
Пример #7
0
    def prepare(self):
        super(AdminBase, self).prepare()

        request = self.request
        host = request.host
        zsite = zsite_by_domain(host)
        if zsite is None:
            self.zsite_id = 0
        else:
            self.zsite_id = zsite.id
        self.zsite = zsite

        zsite = self.zsite
        if not zsite.cid == CID_COM or not zsite_member_can_admin(self.zsite_id, self.current_user_id):
            self.finish("{}")
Пример #8
0
 def get(self, n):
     zsite_id = self.zsite_id
     current_user_id = self.current_user_id
     can_admin = zsite_member_can_admin(zsite_id, current_user_id)
     if can_admin:
         return self.redirect('/review/admin')
     count = po_review_count(zsite_id)
     page, limit, offset = page_limit_offset(
         '/review-%s',
         count,
         n,
         PAGE_LIMIT,
     )
     review_list = po_review_list_by_zsite_id(zsite_id, limit, offset)
     self.render(can_admin=can_admin, page=page, review_list=review_list)
Пример #9
0
 def get(self, n):
     zsite_id = self.zsite_id
     current_user_id = self.current_user_id
     can_admin = zsite_member_can_admin(zsite_id, current_user_id)
     if can_admin:
         return self.redirect('/review/admin')
     count = po_review_count(zsite_id)
     page, limit, offset = page_limit_offset(
         '/review-%s',
         count,
         n,
         PAGE_LIMIT,
     )
     review_list = po_review_list_by_zsite_id(zsite_id, limit, offset)
     self.render(can_admin=can_admin, page=page, review_list=review_list)
Пример #10
0
    def get(self, id, ck):
        user_id, cid = verifyed(id, ck, delete=False)

        if user_id and CID_VERIFY_COM_HR == cid and zsite_member_can_admin(user_id, self.current_user_id):
            job_mail_verifyed(user_id)
            link = _link(user_id)

            if _job_pid_default_by_com_id(user_id):
                path = '%s/job/admin/mail'
            else:
                path = '%s/job/new'
            path = path%link
        else:
            path = '/'

        self.redirect(path)
Пример #11
0
    def prepare(self):
        super(AdminBase, self).prepare()

        request = self.request
        host = request.host
        zsite = zsite_by_domain(host)
        if zsite is None:
            self.zsite_id = 0
        else:
            self.zsite_id = zsite.id
        self.zsite = zsite

        zsite = self.zsite
        if not zsite.cid == CID_COM or not zsite_member_can_admin(
                self.zsite_id, self.current_user_id):
            self.finish('{}')
Пример #12
0
    def get(self, id, ck):
        user_id, cid = verifyed(id, ck, delete=False)

        if user_id and CID_VERIFY_COM_HR == cid and zsite_member_can_admin(
                user_id, self.current_user_id):
            job_mail_verifyed(user_id)
            link = _link(user_id)

            if _job_pid_default_by_com_id(user_id):
                path = '%s/job/admin/mail'
            else:
                path = '%s/job/new'
            path = path % link
        else:
            path = '/'

        self.redirect(path)
Пример #13
0
 def get(self):
     zsite_id = self.zsite_id
     current_user_id = self.current_user_id
     can_admin = zsite_member_can_admin(zsite_id, current_user_id)
     review = po_review_get(zsite_id, current_user_id)
     self.render(can_admin=can_admin, review=review)
Пример #14
0
 def get(self):
     zsite_id = self.zsite_id
     current_user_id = self.current_user_id
     can_admin = zsite_member_can_admin(zsite_id, current_user_id)
     review_list = po_review_show_list_with_user(zsite_id)
     return self.render(can_admin=can_admin, review_list=review_list)
Пример #15
0
 def get(self):
     zsite_id = self.zsite_id
     current_user_id = self.current_user_id
     can_admin = zsite_member_can_admin(zsite_id, current_user_id)
     self.render(can_admin=can_admin)
Пример #16
0
 def prepare(self):
     super(AdminBase, self).prepare()
     zsite = self.zsite
     if not zsite.cid == CID_COM or not zsite_member_can_admin(self.zsite_id, self.current_user_id):
         self.redirect('/')
Пример #17
0
 def get(self):
     zsite_id = self.zsite_id
     current_user_id = self.current_user_id
     can_admin = zsite_member_can_admin(zsite_id, current_user_id)
     review = po_review_get(zsite_id, current_user_id)
     self.render(can_admin=can_admin, review=review)
Пример #18
0
 def get(self):
     zsite_id = self.zsite_id
     current_user_id = self.current_user_id
     can_admin = zsite_member_can_admin(zsite_id, current_user_id)
     review_list = po_review_show_list_with_user(zsite_id)
     return self.render(can_admin=can_admin, review_list=review_list)
Пример #19
0
 def get(self):
     zsite_id = self.zsite_id
     current_user_id = self.current_user_id
     can_admin = zsite_member_can_admin(zsite_id, current_user_id)
     self.render(can_admin=can_admin)