本文整理汇总了Python中models.Document.isover18s方法的典型用法代码示例。如果您正苦于以下问题:Python Document.isover18s方法的具体用法?Python Document.isover18s怎么用?Python Document.isover18s使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Document
的用法示例。
在下文中一共展示了Document.isover18s方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload2
# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import isover18s [as 别名]
def upload2(request):
# Handle file upload
logger = logging.getLogger(__name__)
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if form.is_valid():
newdoc = Document(docfile = request.FILES['docfile'], docfile1 = request.FILES['docfile1'], docfile2 = request.FILES['docfile2'])
newdoc.usersname = request.user.username
newdoc.price=request.POST.get('price','')
newdoc.category= request.POST.get('category','')
newdoc.isover18s =request.POST.get('isover18s','')
newdoc.name =request.POST.get('name','')
newdoc.description =request.POST.get('description','')
form.clean_content()
newdoc.save()
return HttpResponseRedirect(reverse('main.views.upload'))
else:
form = DocumentForm() # A empty, unbound form
# Load documents for the list page
documents = Document.objects.all()
# Render list page with the documents and the form
return render_to_response(
'upload2.html',
{'documents': documents, 'form': form},
context_instance=RequestContext(request)
)
示例2: upload
# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import isover18s [as 别名]
def upload(request):
# Handle Video upload
# A lot going on here especially shell commands
# 3 files get uploaded with various meta info fields
# Using FFMPEG 2 videos are converted to mp4 regardless of
# what they are when uploaded first. Then they get renamed,
# saved and the original ones are deleted
# A poster image for the first frame is also uploaded and
# resized using image Magick.
# Function execute_shell is used a lot sending lots of commands through
# pythons subprocess synchronously
# May redo this so it is done asynchronously but afraid people will think
# Nothing happened and not come back.
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if form.is_valid():
newdoc = Document(docfile = request.FILES['docfile'], docfile1 = request.FILES['docfile1'], docfile2 = request.FILES['docfile2'])
upload_file=request.FILES['docfile']
upload_file1=request.FILES['docfile1']
upload_file2=request.FILES['docfile2']
#logger.debug('*************************************New Filename is {0}************************************'.format(newdoc.docfile.name))
newdoc.usersname = request.user.username
newdoc.price=request.POST.get('price','')
newdoc.category= request.POST.get('category','')
newdoc.isover18s =request.POST.get('isover18s','')
newdoc.name =request.POST.get('name','')
newdoc.description =request.POST.get('description','')
bla=request.POST.get('document_type','')
logger.debug('bla bla bla ={0}'.format(bla))
if bla=='on':
newdoc.document_type =1
else:
newdoc.document_type =0
#Temporarily commented out. lots of error handling on front end
#form.clean_content()
newdoc.save()
logger.debug('File name = {0}'.format(newdoc.name))
new_file=get_new_file(newdoc.docfile.name)
new_file1=get_new_file(newdoc.docfile1.name)
#New folders and need to be created
today_folder =datetime.date.today().strftime("%Y/%m/%d")
str_= str(newdoc.docfile2.name)
str_file2="_thumb_" +str_.split('/')[-1]
#create destination of converted files
prefix='/home/donagh/webapps/shabingo_static/media/'
output=os.path.join('MEDIA_ROOT','documents',today_folder,new_file)
output1=os.path.join('MEDIA_ROOT','documents',today_folder,new_file1)
output2=os.path.join('MEDIA_ROOT','documents',today_folder,str_file2)
output_file=prefix+output
output_file1=prefix+output1
output_file2=prefix+output2
str_file=str(newdoc.docfile.name)
str_file=prefix+str_file
str_file1=str(newdoc.docfile1.name)
str_file1=prefix+str_file1
str_file2=str(newdoc.docfile2.name)
str_file2=prefix+str_file2
#The magic of FFMPEG ... Convert video to mp4
shell_cmd='ffmpeg -i '+str_file+' -vcodec libx264 -acodec libfaac '+ output_file
#logger.debug('shell_cmd ...{0}'.format(shell_cmd))
file_details=''
try:
file_details=execute_shell(shell_cmd)
newdoc.rename_shab(output)
except Exception as e:
logger.debug('Failed to execute shell command ...{0}'.format(e))
#The magic of FFMPEG ... Convert video to mp4
shell_cmd1='ffmpeg -i '+str_file1+' -vcodec libx264 -acodec libfaac '+ output_file1
file_details=''
try:
file_details=execute_shell(shell_cmd1)
newdoc.rename_prev(output1)
except Exception as e:
logger.debug('Failed to execute shell command ...{0}'.format(e))
#Resize Poster image uploadeed to keep it all perfect size and limit disk space
shell_cmd2 ="""convert %s -resize 300x200\! %s
"""%(str_file2,str_file2)
#logger.debug(' THUM NAIL CONVERSION COMMAND === {0}'.format(shell_cmd2))
try:
file_details=execute_shell(shell_cmd2)
#newdoc.rename_thumb(output2)
#.........这里部分代码省略.........