当前位置: 首页>>代码示例>>Python>>正文


Python Post.title方法代码示例

本文整理汇总了Python中models.Post.title方法的典型用法代码示例。如果您正苦于以下问题:Python Post.title方法的具体用法?Python Post.title怎么用?Python Post.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Post的用法示例。


在下文中一共展示了Post.title方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_form_operator

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def post_form_operator(action, form, request, post_id = 0):
    if action == 'add':
        post = Post(user = request.user)
        post.isdraft = True
        post.text_raw = post.text_html = ''
        post.tags_raw = form.cleaned_data['tags'].lower()
        post.title = form.cleaned_data['title']
        post.save()
            
    if action == 'edit':
        post = Post.objects.get(id__exact = post_id)
        post.updated = datetime.now()
        post.tags_raw = form.cleaned_data['tags'].lower()
        post.title = form.cleaned_data['title']
    
    post.text_raw = form.cleaned_data['text']
    post.text_html = parse_text(post.text_raw, post.id)    
    
    post.tags = form.cleaned_data['tags'].lower()
    post.save()
    
    if action == 'edit':
        messages.success(request,'Changes Saved')
        return
    else:
        messages.success(request,'Saved in Drafts')
        return post
开发者ID:r-ss,项目名称:shffl,代码行数:29,代码来源:views.py

示例2: publishs

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def publishs(user_id):

    form = PublishBlogForm()

    if form.validate_on_submit():
        post_title = request.form.get("title")
        post_body = request.form.get("body")
        if not len(strip(post_body)) or not len(strip(post_title)):
            flash("不能提交空内容!")
            return redirect(url_for("publish", user_id=user_id))

        post = Post()
        post.body = post_body
        post.title = post_title
        post.timestamp = datetime.datetime.now()
        post.user_id = user_id


        try:
            db.session.add(post)
            db.session.commit()
        except:
            flash("DataBase error!")
            return redirect(url_for("publish", user_id=user_id))

        return redirect(url_for("user", user_id=user_id))

    return render_template(
        "publish.html",
        form = form)
开发者ID:wagt679,项目名称:xingblog,代码行数:32,代码来源:views.py

示例3: create_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def create_post():
    form = forms.PostForm(request.form)
    if request.method=='POST':
        post = Post()
        post.title = form.title.data
        post.content = form.content.html
        post.toc = form.content.toc
        post.time_stamp = datetime.now()
        post.user_id = current_user.id

        tags = form.tags.data.split(',')
        post.tags = form.tags.data
        ids = []
        for tag in tags:
            t = Tag.query.filter_by(name=tag).first()
            if not t:
                db.session.add(Tag(name=tag))
                db.session.commit()
                t = Tag.query.filter_by(name=tag).first()
            ids.append(t.id)

        db.session.add(post)
        db.session.commit()
        p = current_user.posts.order_by(Post.id.desc()).first()
        for id in ids:
            db.session.add(TagMap(id,p.id))
        db.session.commit()
        #flash('Your post have been accepted.')
        return redirect(url_for('post',id=p.id))
    else:
        return render_template('create_post.html',form=form)
开发者ID:qinms,项目名称:BlogApp,代码行数:33,代码来源:views.py

示例4: upload_file_combined

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def upload_file_combined():
	form = UploadForm()
	if request.method == 'POST':
		file = request.files['file']
		if file and allowed_file(file.filename):
			filename = secure_filename(file.filename)
			hash = hashlib.md5()
			hash.update(filename);
			global counter
			new_filename = str(hash.hexdigest()[14:]) + '_' + str(random.random()*100) + str(counter)
			hash.update(new_filename)
			counter = counter + 1
			filename = hash.hexdigest()[20:] + '_' + filename
			hashstring = str(hash.hexdigest()[20:])
			path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
			print path
			file.save(path)
			url = url_for('uploaded_file', filename=filename)
			post = Post()
			post.title = form.title.data
			post.slug = hashstring
			post.geoLong = form.geoLong.data
			post.geoLat = form.geoLat.data
			post.image_url = url
			post.save()
			return redirect("/all-list")
开发者ID:rzlee,项目名称:moments-backend,代码行数:28,代码来源:views.py

示例5: tweet_data

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def tweet_data(tweet):
	if "RT @" not in tweet['text']:
		try:
			print( '@%s tweeted: %s\nFavorites: %d  Retweets: %d' %\
			( tweet['user']['screen_name'], tweet['text'],tweet['favorite_count'],\
			tweet['retweet_count'] ))
			post = Post()	
			post.title = tweet['text']
			print post.title
			post.posted_by = tweet['user']['screen_name']
			print post.posted_by
			post.date_time = tweet["created_at"].replace(" +0000","")
			print post.date_time
			post.retweets = tweet['retweet_count']
			print post.retweets
			post.favorites=tweet['favorite_count']
			print post.favorites
			post.ups=None
			print post.ups
			post.from_twitter = True
			print post.from_twitter
			post.post_link = "http://www.twitter.com/"+str(tweet['user']['screen_name'])+"/status/"+str(tweet['id'])
			print post.post_link
			post.link=regex_tweet_link(tweet)
			print post.link
			post.save()
			return post
		except:
			print "saving failed!"
			import sys
			print sys.exc_info()
开发者ID:koheif2,项目名称:twitterreddit,代码行数:33,代码来源:views.py

示例6: create

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def create():
    form = RegistrationForm()
    if form.validate() is False:
        return render_template('blog/new.html', form=form)
    else:
        post = Post()
        post.title = form.title.data
        post.author = form.author.data
        post.text_content = form.text_content.data
        post.text_call = form.text_call.data
        post.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        post.active = 0

        subjects_names = form.subject.data.replace(', ', ',').split(',')

        for name in subjects_names:
            subject = Subject.query.filter_by(name=name).first()
            if (not subject):
                subject = Subject()
                subject.name = name
            post.subjects.append(subject)
        db.session.add(post)

        db.session.flush()
        if len(form.thumb.data.split(',')) > 1:
            upload_folder = os.path.join(app.config['UPLOAD_FOLDER'], mod.name, str(post.id), 'images')
            post.thumb = save_b64_image(form.thumb.data.split(',')[1], upload_folder, 'thumb')

        db.session.commit()

        message = u'Muito obrigado! Seu post foi submetido com sucesso!'
        flash(message, 'success')
        return redirect(url_for('blog.admin'))
开发者ID:aromeira,项目名称:dataviva-site,代码行数:35,代码来源:views.py

示例7: create

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def create(request):
    if request.method == "POST":
        post = Post()
        post.title = request.POST.get("title")
        post.body = request.POST.get("body")
        post.save()
        return redirect("home")
    return render(request, "create.html")
开发者ID:ModSoftio,项目名称:djangoWorkshopRlug,代码行数:10,代码来源:views.py

示例8: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
 def post(self):
     p = Post()
     p.author = users.get_current_user()
     p.content = self.request.get('content')
     p.title = self.request.get('title')
     if self.request.get('is_published', None):
         p.is_published = True
     p.put()
     self.redirect('/admin/blog')
开发者ID:mdwrigh2,项目名称:cthaeh,代码行数:11,代码来源:admin_blog.py

示例9: create_or_update_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def create_or_update_post(post_id, title, text, want_publish):     
    post = Post()
    if post_id != None and post_id > 0:
        post = get_post(post_id)
    post.title = title
    post.text = text
    if want_publish and post.online is False:
        post.online = True
    post.save()
    return post
开发者ID:fabienbk,项目名称:scramcode-blog,代码行数:12,代码来源:admin_views.py

示例10: marks

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def marks(request):
	form = Post()
	if request.method == 'POST': # If the form has been submitted...
		form.title = request.POST['title']
		form.body = request.POST['body']
		form.lon = float(request.POST['lon'])
		form.lat = float(request.POST['lat'])
		form.img = request.FILES.get('file', False)
		form.user = request.user
		form.save()
	return redirect('/')
开发者ID:wendiewang,项目名称:geonote,代码行数:13,代码来源:views.py

示例11: create

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def create():
	post = Post()
	post.title = request.args.get('title', '')
	post.slug = request.args.get('slug', '')
	post.geoLong = request.args.get('geoLong', '')
	post.geoLat = request.args.get('geoLat', '')
	post.image_url = request.args.get('image_url', '')
	post.save()
	data = {
			"response" : "Success",
			}
	return jsonify(data)
开发者ID:rzlee,项目名称:moments-backend,代码行数:14,代码来源:views.py

示例12: write_process

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def write_process():
    if not session['logged_in']:
        return redirect(url_for('index'))
    u = User.query.filter_by(email=session['user_name']).first()
    p = Post()
    p.title = request.form['post_title']
    p.body = request.form['post_body']
    p.timestamp = datetime.datetime.utcnow()
    p.user_id = u.id
    db.session.add(p)
    db.session.commit()
    return redirect(url_for('index'))
开发者ID:rwdxll,项目名称:flask_blog,代码行数:14,代码来源:controllers.py

示例13: save

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def save():
    my_form = CreateForm(csrf_enabled=False)
    my_post = None
    if not my_form.post_id.data and my_form.validate_on_submit():
        my_post = Post(my_form.title.data, my_form.text.data)
        db.session.add(my_post)
    if my_form.post_id.data and my_form.validate_on_submit():
        my_post = Post.query.get(my_form.post_id.data)
        my_post.title = my_form.title.data
        my_post.text = my_form.text.data
    db.session.commit()
    return redirect(url_for('view', post_id=my_post.post_id))
开发者ID:dhamaniasad,项目名称:flask-elasticsearch-1,代码行数:14,代码来源:views.py

示例14: add_blog_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
def add_blog_post(request):
    if request.method == "POST":
        post = Post()
        post.title = request.POST.get('title')
        post.text = request.POST.get('text')
        if not post.title or not post.text:
            return HttpResponse("400 Bad Request You need to specify a title and message")
        post.date = datetime.datetime.now()
        post.save()
        return json_response(request, 'Success')
    else:
        return HttpResponse("405 Method Not Allowed")
开发者ID:PSpeiser,项目名称:patrickspeiser_at_old,代码行数:14,代码来源:blog.py

示例15: build_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import title [as 别名]
    def build_post(self,form,user):
 #       print 'after validate'
 #       print 'Logged in as %s' % user
        u = UserDT()
        u.first_name = user
        u.last_name = "b"
        u.email =  user + "@here.com"
        p = Post()
        p.title = form.title.data
        p.body = form.content.data
        p.creator = u
        print ' post - post build '
        return p
开发者ID:sheng01,项目名称:DuluthKids.Net,代码行数:15,代码来源:helper.py


注:本文中的models.Post.title方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。