本文整理汇总了Python中photologue.models.Photo.image方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.image方法的具体用法?Python Photo.image怎么用?Python Photo.image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类photologue.models.Photo
的用法示例。
在下文中一共展示了Photo.image方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_uploaded_file
# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import image [as 别名]
def handle_uploaded_file(f,title):
""" """
photo = Photo()
photo.title = u'%s %s' % (time_slug_string(), title)
photo.slug = time_slug_string()
photo.image = f
photo.save()
return photo
示例2: handle_uploaded_file
# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import image [as 别名]
def handle_uploaded_file(f, author):
photo = Photo()
extra = PhotoExtended()
photo.title = u"%s %s" % (author, time_slug_string())
photo.slug = u"%s-%s" % (author, slugify(time_slug_string()))
photo.image = f
photo.save()
extra.photo = photo
extra.author = author
extra.save()
return photo
示例3: uploadimagejson
# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import image [as 别名]
def uploadimagejson(request):
p = Photo()
if request.user.is_authenticated():
if request.method == 'POST':
pt = codegenerator()+codegenerator()
p.image = request.FILES['file']
p.title = pt
p.title_slug = slugify(pt) #+codegenerator()
p.save()
# template = loader.get_template('redactorimageupload.html')
params = { 'photo' : p }
# context = RequestContext(request, params)
return render_to_response('redactorimageupload.html',params,context_instance = RequestContext(request))
示例4: import_folder
# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import image [as 别名]
def import_folder(request=None, gallery_name=None):
count = 0
current_site = Site.objects.get(id=settings.SITE_ID)
if gallery_name:
gallery = Gallery.objects.filter(slug=gallery_name)
if not gallery:
gallery = Gallery(title=gallery_name, slug=gallery_name)
gallery.save()
else:
gallery = Gallery.objects.first()
if not gallery:
gallery = Gallery(title="MyFirstGallery", slug='MyFirstGallery')
gallery.save()
for filename in os.listdir(IMPORT_FOLDER):
if not os.path.isfile(filename):
if filename[-3:] in image_extensions:
logger.debug('Reading file "{0}").'.format(filename))
full_name = os.path.join(IMPORT_FOLDER, filename)
if Photo.objects.filter(title=filename).exists():
logger.debug('file already exist in system: "{0}").'.format(filename))
dst_name = os.path.join(IMPORT_CONFLICT_FOLDER, filename)
shutil.move(full_name, dst_name)
else:
storage_path = models.get_storage_path(None, filename)
dst_name = os.path.join(settings.MEDIA_ROOT, storage_path)
shutil.move(full_name, dst_name)
photo = Photo(title=filename,
slug=slugify(filename),
caption=filename,
is_public=True)
photo.image = storage_path
photo.save()
photo.sites.add(current_site)
gallery.photos.add(photo)
count += 1
if request:
messages.success(request,
_('{0} photos have been added to gallery "{1}".').format(
count,
gallery.title),
fail_silently=True)