def get(self, id): current_user_id = self.current_user_id result = None if not id.isdigit(): id = id_by_url(id) if id: id = int(id) if not id or current_user_id == id: return self.finish('null') zsite = Zsite.mc_get(id) if zsite: career = career_current(id) career = filter(bool, career) current_user_id = self.current_user_id if current_user_id != id: if follow_get(current_user_id, id): word = '淡忘' else: word = '关注' result = [ zsite.name, ' , '.join(career), ico_url_with_default(id), zsite.link, zsite.id, word, motto_get(zsite.id) ] return self.finish(dumps(result))
def zsite_by_query(query): from config import SITE_DOMAIN from urlparse import urlparse from model.zsite_url import id_by_url from model.user_mail import user_id_by_mail user_id = None if '@' in query: user_id = user_id_by_mail(query) elif SITE_DOMAIN in query: key = urlparse(query).netloc.split('.', 1)[0] user_id = id_by_url(key) elif query.isdigit(): if Zsite.mc_get(query): user_id = query else: query = query.replace('http://', '').split(".", 1)[0] user_id = id_by_url(query) return user_id
def zsite_by_query(query): from config import SITE_DOMAIN from urlparse import urlparse from model.zsite_url import id_by_url from model.user_mail import user_id_by_mail user_id = None if '@' in query: user_id = user_id_by_mail(query) elif SITE_DOMAIN in query: key = urlparse(query).netloc.split('.', 1)[0] user_id = id_by_url(key) elif query.isdigit(): if Zsite.mc_get(query): user_id = query else: query = query.replace('http://', '').split(".",1)[0] user_id = id_by_url(query) return user_id
def post(self, id): event = self._event(id) if event is None: return txt = self.get_argument('txt', '') li = [] for i in txt.splitlines(): url = i.split('//')[-1].split('.%s' % SITE_DOMAIN)[0] if url.isdigit(): user_id = int(url) else: user_id = id_by_url(url) if user_id and user_id not in li: li.append(user_id) event_joiner_new(id, user_id, EVENT_JOIN_STATE_YES) self.redirect('/event/add/%s' % id)
def search(keywords, cid, offset, limit): netloc = urlparse(keywords).netloc if netloc and netloc.endswith(SITE_DOMAIN_SUFFIX): url = netloc[:-len(SITE_DOMAIN_SUFFIX)] if url: id = id_by_url(url) if id: return Zsite.mc_get_list([id]), 1 e = ENQUIRE keywords = make_query(keywords) match, count = _search(e, keywords, cid, offset, limit) r = [] for m in match: doc = m.document rss_id = doc.get_value(0) r.append(rss_id) return Zsite.mc_get_list(r), count
def get(self, id): current_user_id = self.current_user_id result = None if not id.isdigit(): id = id_by_url(id) if id: id = int(id) if not id or current_user_id == id: return self.finish('null') zsite = Zsite.mc_get(id) if zsite: career = career_current(id) career = filter(bool, career) current_user_id = self.current_user_id if current_user_id != id: if follow_get(current_user_id, id): word = '淡忘' else: word = '关注' result = [zsite.name, ' , '.join(career), ico_url_with_default(id), zsite.link, zsite.id, word, motto_get(zsite.id)] return self.finish(dumps(result))
rech[0].state = state rech[0].save() else: SiteRecHistory(user_id=user_id, zsite_id=zsite_id, state=state).save() id_list = SiteRecNew.get(user_id).split() if zsite_id in id_list: id_list.remove(zsite_id) SiteRecNew.set(user_id, ' '.join(map(str, id_list))) top_rec_unmark(user_id, TOP_REC_CID_SITE_REC) def site_rec_set(user_id, site_id): SiteRecNew.set(user_id, ' '.join([str(i) for i in site_id])) top_rec_mark(user_id, TOP_REC_CID_SITE_REC) def site_rec_dump(user_id): zsite_list = site_rec(user_id) return zsite_json(user_id, zsite_list) if __name__ == '__main__': from model.zsite_url import id_by_url jid = id_by_url('jandan') from zweb.orm import ormiter for i in ormiter(SiteRecHistory): print i.id
rech[0].state = state rech[0].save() else: SiteRecHistory( user_id=user_id, zsite_id=zsite_id, state=state ).save() id_list = SiteRecNew.get(user_id).split() if zsite_id in id_list: id_list.remove(zsite_id) SiteRecNew.set(user_id, ' '.join(map(str,id_list))) top_rec_unmark(user_id, TOP_REC_CID_SITE_REC) def site_rec_set(user_id, site_id): SiteRecNew.set(user_id, ' '.join([str(i) for i in site_id])) top_rec_mark(user_id, TOP_REC_CID_SITE_REC) def site_rec_dump(user_id): zsite_list = site_rec(user_id) return zsite_json(user_id, zsite_list) if __name__ == '__main__': from model.zsite_url import id_by_url jid = id_by_url('jandan') from zweb.orm import ormiter for i in ormiter(SiteRecHistory): print i.id