コード例 #1
0
    def __create_link(self, name, url, order):
        link = Link(name=name, url=url, order=order)

        link.save()
        print "Created link : {} | {}".format(name, url)

        return link
コード例 #2
0
def fake_links():
    twitter = Link(name='Twitter', url='#')
    facebook = Link(name='Facebook', url='#')
    linkedin = Link(name='LinkedIn', url='#')
    google = Link(name='Google+', url='#')
    db.session.add_all([twitter, facebook, linkedin, google])
    db.session.commit()
コード例 #3
0
    def __create_link(self, name, url, order):
        link = Link(name=name, url=url, order=order)

        link.save()
        print "Created link : {} | {}".format(name, url)

        return link
コード例 #4
0
    def POST(self):
        action=self.param("action")
        name=self.param("link_name")
        url=self.param("link_url")
        comment = self.param("link_comment")

        vals={'action':action,'postback':True,'current':'links'}
        if not (name and url):
            vals.update({'result':False,'msg':_('Please input name and url.')})
            self.render2('views/admin/link.html',vals)
        else:
            if action=='add':
               link= Link(linktext=name,href=url,linkcomment=comment)
               link.put()
               vals.update({'result':True,'msg':'Saved ok'})
               self.render2('views/admin/link.html',vals)
            elif action=='edit':
                try:
                    action_id=int(self.param('id'))
                    link=Link.get_by_id(action_id)
                    link.linktext=name
                    link.href=url
                    link.linkcomment = comment
                    link.put()
                    #goto link manage page
                    self.redirect('/admin/links')

                except:
                    vals.update({'result':False,'msg':_('Error:Link can''t been saved.')})
                    self.render2('views/admin/link.html',vals)
コード例 #5
0
 def POST(self):
     linkcheck= self.request.get_all('linkcheck')
     for link_id in linkcheck:
         kid=int(link_id)
         link=Link.get_by_id(kid)
         link.delete()
     self.redirect('/admin/links')
コード例 #6
0
 def GET(self,slug=None):
     self.render2('views/admin/links.html',
      {
       'current':'links',
       'links':Link.all().filter('linktype =','blogroll')#.order('-createdate')
       }
     )
コード例 #7
0
ファイル: management.py プロジェクト: Spoylerman/libaoyinblog
def init_data(**kwargs):
    link=Link(text="dengmin's blog",href="http://www.iyouf.info")
    link.save()
    
    default_cate=Category(name=u'未分类',slug='default',desc=u'未分类')
    default_cate.save()
    
    entry=Entry(title='Hello World!',content='<b>Hello World, welcome to use youflog! thank you!</a>',tags='youflog')
    entry.allow_comment=True
    entry.slug='hello-world'
    entry.category=default_cate
    entry.author_id=1
    entry.save(True)
    
    comment=Comment(author='admin',email='*****@*****.**',weburl='http://iyouf.info',content=u'测试第一条评论')
    comment.content_object=entry
    comment.save()
コード例 #8
0
ファイル: fakes.py プロジェクト: sallyyou/blog
def fake_links(count=50):
    for i in range(count):
        link = Link(title=fake.sentence(),
                    url=fake.url(),
                    category=LinkCategory.query.get(
                        random.randint(1, LinkCategory.query.count())))

        db.session.add(link)
    db.session.commit()
コード例 #9
0
ファイル: test_admin.py プロジェクト: zxbylx/blog
    def setUp(self):
        super(AdminTestCase, self).setUp()
        self.login()

        category = Category(name='Default')
        post = Post(title='Hello', category=category, body='Blah...')
        comment = Comment(body='A comment', post=post, from_admin=True)
        link = Link(name='GitHub', url='https://github.com/greyli')
        db.session.add_all([category, post, comment, link])
        db.session.commit()
コード例 #10
0
def admin_del_link(request, link_id):
    if users.is_current_user_admin():

        link = Link.get_by_id(int(link_id))
        if not link:
            raise Http404
        else:
            link.delete()
        return HttpResponseRedirect('/admin')
    else:
        return HttpResponseRedirect('/')
コード例 #11
0
ファイル: admin_views.py プロジェクト: kylewu/wwb_wwblog
def admin_del_link(request, link_id):
    if users.is_current_user_admin():
        
        link = Link.get_by_id(int(link_id))
        if not link:
            raise Http404
        else:
            link.delete()
        return HttpResponseRedirect('/admin')
    else:
        return HttpResponseRedirect('/')
コード例 #12
0
ファイル: admin.py プロジェクト: zxbylx/blog
def new_link():
    form = LinkForm()
    if form.validate_on_submit():
        name = form.name.data
        url = form.url.data
        link = Link(name=name, url=url)
        db.session.add(link)
        db.session.commit()
        flash('Link created.', 'success')
        return redirect(url_for('.manage_link'))
    return render_template('admin/new_link.html', form=form)
コード例 #13
0
ファイル: admin_views.py プロジェクト: kylewu/wwb_wwblog
def admin_list_link(request):
    if users.is_current_user_admin():
        
        return object_list(request,
                       template_object_name='obj',
                       queryset=Link.all(),
                       allow_empty=True,
                       extra_context={'type': 'link'},
                       template_name='admin/list.html',
                       paginate_by=setting.ADMIN_LIST_PER_PAGE,
                       )
    else:
        return HttpResponseRedirect('/')
コード例 #14
0
def admin_list_link(request):
    if users.is_current_user_admin():

        return object_list(
            request,
            template_object_name='obj',
            queryset=Link.all(),
            allow_empty=True,
            extra_context={'type': 'link'},
            template_name='admin/list.html',
            paginate_by=setting.ADMIN_LIST_PER_PAGE,
        )
    else:
        return HttpResponseRedirect('/')
コード例 #15
0
    def GET(self,slug=None):
        action=self.param("action")
        vals={'current':'links'}
        if action and  action=='edit':
                try:
                    action_id=int(self.param('id'))
                    link=Link.get_by_id(action_id)
                    vals.update({'link':link})
                except:
                    pass
        else:
            action='add'
        vals.update({'action':action})

        self.render2('views/admin/link.html',vals)
コード例 #16
0
 def initialize(self, request):
     m_pages=Entry.all().filter('entrytype =','page')\
         .filter('published =',True)\
         .filter('entry_parent =',0)\
         .order('menu_order')
     blogroll=Link.all().filter('linktype =','blogroll')
     archives=Archive.all().order('-year').order('-month').fetch(12)
     alltags=Tag.all()
     self.template_vals.update({
                     'menu_pages':m_pages,
                     'categories':Category.all(),
                     'blogroll':blogroll,
                     'archives':archives,
                     'alltags':alltags,
                     'recent_comments':Comment.all().order('-date').fetch(5)
     })
コード例 #17
0
ファイル: admin.py プロジェクト: zhigoo/youflog
def addLink(request):
    type= request.POST.get('type','add')
    text = request.POST.get('text','')
    href = request.POST.get('href','http://www.iyouf.info')
    if not href.startswith('http://'):
        href = 'http://'+href
    comment = request.POST.get('comment','')
    if type and type == 'add':
        link=Link(text=text,href=href,comment=comment)
        link.save()
    else:
        id=request.POST.get('id','')
        link=Link.objects.get(id=id)
        link.text=text
        link.href=href
        link.comment=comment
        link.save()
    return HttpResponseRedirect('/admin/links')
コード例 #18
0
 def initialize(self, request):
     BaseRequestHandler.initialize(self,request)
     m_pages=Entry.all().filter(entrytype = 'page') \
         .filter(published = True)\
         .filter(entry_parent = 0)\
         .order_by('menu_order')
     blogroll=Link.all().filter(linktype = 'blogroll')
     #archives=Archive.all().order_by('-year').order_by('-month').fetch(12)
     archives=Archive.all().order_by('-year', '-month')[0:12]
     alltags=Tag.all()
     self.template_vals.update({
                     'menu_pages':m_pages,
                     'categories':Category.all(),
                     'blogroll':blogroll,
                     'archives':archives,
                     'alltags':alltags,
                     'recent_comments':Comment.all().order_by('-date')[0:5]#.fetch(5)
     })
コード例 #19
0
def new_link():
    form = LinkForm()
    if form.validate_on_submit():
        name = form.name.data
        url = form.url.data
        if Link.query.filter_by(name=name).count() == 1:
            flash("链接已存在!", "err")
        link = Link(name=name, url=url)
        db.session.add(link)
        db.session.commit()
        flash('添加链接成功!', 'ok')
        oplog = Oplog(
            user='******',
            ip=request.remote_addr,
            reason="新增链接-%s" % form.name.data,
        )
        db.session.add(oplog)
        db.session.commit()
        return redirect(url_for("admin.new_link"))
    return render_template('admin/new_link.html', form=form)
コード例 #20
0
ファイル: wwb_fun.py プロジェクト: kylewu/wwb_wwblog
def wwb_list_link():   
    html = ''
    for link in Link.all():
        html += '<li><a href=\"%s">%s</a></li>'%(link.link.encode('utf-8'), link.title.encode('utf-8'))
    return html
コード例 #21
0
ファイル: wwb_fun.py プロジェクト: kylewu/wwb_wwblog
def wwb_list_link():
    html = ''
    for link in Link.all():
        html += '<li><a href=\"%s">%s</a></li>' % (link.link.encode('utf-8'),
                                                   link.title.encode('utf-8'))
    return html
コード例 #22
0
def InitBlogData():
	entry=Entry(title=_("Hello world!").decode('utf8'))
	entry.content=_('<p>Welcome to micolog. This is your first post. Edit or delete it, then start blogging!</p>').decode('utf8')
	entry.save(True)
	link=Link(href='http://xuming.net',linktext=_("Xuming's blog").decode('utf8'))
	link.put()