本文整理汇总了Python中models.Person.image_slug方法的典型用法代码示例。如果您正苦于以下问题:Python Person.image_slug方法的具体用法?Python Person.image_slug怎么用?Python Person.image_slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Person
的用法示例。
在下文中一共展示了Person.image_slug方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_person
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import image_slug [as 别名]
def new_person():
if not g.site.domain == g.user:
abort(403)
p = Person()
if request.method == "POST":
reqfile = request.files.get('file')
if reqfile:
f = File()
f.site = g.site.domain
f.name = reqfile.filename
f.content_type = reqfile.mimetype
f.slug, f.content_length = save_file(reqfile, current_app.config["UPLOAD_FOLDER"])
f.save()
p.site = g.site.domain
p.name = request.form.get("name")
p.title = request.form.get("title")
p.phone = request.form.get("phone")
p.email = request.form.get("email")
p.twitter = request.form.get("twitter")
p.description = request.form.get("description")
slugs = [ __p.slug for __p in Person.objects.filter(site=g.site.domain) ]
slug = slugify(p.name)
counter = 1
__slug = slug
while __slug in slugs:
counter += 1
__slug = "%s_%d" % (slug, counter)
p.slug = __slug
if reqfile:
p.image_slug = f.slug
p.save()
pl = Personnel.objects.get(site=g.site.domain)
pl.people.append(p.slug)
pl.save()
return redirect(url_for(".show_personnel"))
return render_template("edit_person.html", person=p)