コード例 #1
0
ファイル: __init__.py プロジェクト: leonsim/me
 def dig(self, req):
     req.nav = '/dig'
     basic_result = Dig.basic_result()
     gossip_result = Dig.gossip_result()
     hometowns = Dig.all_hometowns()
     hot_tags = Tag.gets(count=3)
     score_cards = Card.gets_by_score()
     return st('/dig.html', **locals())
コード例 #2
0
ファイル: __init__.py プロジェクト: leonsim/me
    def admin(self, req):
        if req.user and req.user.id in ADMINS:
            if req.get_method() == "POST":
                hide_id = req.get_form_var("hide_id", "")
                card = Card.get(hide_id)
                if card:
                    Card.hide(card.id, req.user.id)
                badage_id = req.get_form_var("badage_id", "")
                badage_name = req.get_form_var("badage_name", "")
                badage_intro = req.get_form_var("badage_intro", "")
                badage_icon = req.get_form_var("badage_icon", "")
                badage = None
                if badage_id:
                    badage = Badage.get(badage_id)
                if badage_name and badage_intro and badage_icon:
                    if badage:
                        badage.update(badage_name, badage_intro, badage_icon)
                    else:
                        Badage.new(badage_name, badage_intro, badage_icon)
                badage_name = req.get_form_var("add_badage_name", "")
                badage = Badage.get_by_name(badage_name)
                if badage:
                    badage_user_ids = req.get_form_var("badage_user_ids", "").strip().split()
                    for u in badage_user_ids:
                        card = Card.get(u)
                        if card:
                            Badage.add(card.id, badage.id, req.user.id)

                award_badage_name = req.get_form_var("award_badage_name", "")
                award_sponsor = req.get_form_var("award_sponsor", "")
                award_num = req.get_form_var("award_num", "")
                award_vote_days = req.get_form_var("award_vote_days", "")
                if award_badage_name and award_num and award_vote_days:
                    award_num = award_num.isdigit() and int(award_num) or 5
                    award_vote_days = award_vote_days.isdigit() and int(award_vote_days) or 7
                    Award.new(award_badage_name, award_sponsor, award_num, award_vote_days)
            badages = Badage.gets()
            awards = Award.gets()
            q_card = req.get_form_var("q_card", "")
            q_tag = req.get_form_var("q_tag", "")
            if q_card and q_tag:
                taggers = Tag.get_taggers(q_card, q_tag)
            return st('/misc/admin.html', **locals())
        raise AccessError("need admin")
コード例 #3
0
ファイル: card.py プロジェクト: fordream/me
 def ptags(self):
     from webapp.models.tag import Tag
     return Tag.get_user_tags(self.id)
コード例 #4
0
ファイル: card.py プロジェクト: fordream/me
 def user_tags(self, tagger_id):
     from webapp.models.tag import Tag
     return Tag.get_user_tag_names(self.id, tagger_id)
コード例 #5
0
ファイル: card.py プロジェクト: fordream/me
 def tag(self, tagger_id, tags=[]):
     from webapp.models.tag import Tag
     Tag.tag(self.id, tagger_id, tags=tags)
コード例 #6
0
ファイル: __init__.py プロジェクト: leonsim/me
 def tags(self, req):
     req.nav = '/'
     all_tags = Tag.gets(count=0)
     return st('/tags.html', **locals())
コード例 #7
0
ファイル: group.py プロジェクト: fordream/me
 def tags(self):
     return Tag.get_group_tags(self.id)
コード例 #8
0
def create_fake_data():
    tag1 = Tag('前端')
    tag1.save()
    tag2 = Tag('后端')
    tag2.save()
    tag3 = Tag('JavaScript')
    tag3.save()
    tag4 = Tag('Python')
    tag4.save()
    tag5 = Tag('面试')
    tag5.save()
    tag6 = Tag('SQL')
    tag6.save()
    tag7 = Tag('读书笔记')
    tag7.save()
    blog1 = Blog('xilixjd', 'MySQL必知必会读书笔记', blog1_content)
    blog1.time = time.time()*1000
    blog1.tags.extend([tag2, tag6, tag7])
    blog1.save()
    # time.sleep(3)
    blog2 = Blog('xilixjd', '单页web应用 JavaScript 从前端到后端', blog2_content)
    blog2.time = time.time()*1000
    blog2.tags.extend([Tag.query.filter_by(title='前端').first(), Tag.query.filter_by(title='后端').first(), Tag.query.filter_by(title='JavaScript').first(), tag7])
    blog2.save()
    # time.sleep(3)
    blog3 = Blog('xilixjd', 'JavaScript 语言精粹', blog3_content)
    blog3.time = time.time()*1000
    blog3.tags.extend([tag1, tag3, tag7])
    blog3.save()
    # time.sleep(3)
    blog4 = Blog('xilixjd', 'JavaScript高级程序设计', blog4_content)
    blog4.time = time.time()*1000
    blog4.tags.extend([tag1, tag3, tag7])
    blog4.save()
    # time.sleep(3)
    blog5 = Blog('xilixjd', '超长干货超多的前端面试汇总', blog5_content)
    blog5.time = time.time()*1000
    blog5.tags.extend([Tag.query.filter_by(title='前端').first(), Tag.query.filter_by(title='面试').first(), Tag.query.filter_by(title='JavaScript').first()])
    blog5.save()
    blog6 = Blog('xilixjd', 'clean-code-javascript', blog6_content)
    blog6.time = time.time()*1000
    blog6.tags.extend([Tag.query.filter_by(title='前端').first(), Tag.query.filter_by(title='JavaScript').first()])
    blog6.save()