Ejemplo n.º 1
0
def upload(request):
	mobile = request.POST.get('mobile')
	album_id = request.POST.get('album')
	userprof = get_user_profile(request)
	try:
		delete = request.POST.get('deleted').split('|')
	except:
		delete = []
	album = None
	if album_id != -1 and album_id != None:
		print album_id
		try:
			album = Album.objects.get(id=album_id)
		except:
			album = None
	new_album_name = request.POST.get('new_album_name')
	if new_album_name:
		
		couple = get_couple(userprof)
		album = Album(name=new_album_name)
		album.save()
		couple.albums.add(album)
		couple.save()
	index = 0
	for uploaded_content in request.FILES.getlist('content'):
		if str(index) not in delete:
			print uploaded_content
			new_content = Content()
			new_content.owner = userprof
			file_content = ContentFile(uploaded_content.read()) 
			new_content.image.save(uploaded_content.name, file_content)
			# ext = uploaded_content.name[uploaded_content.name.find('.')+1:]
			ext = os.path.splitext(uploaded_content.name)[1]
			if ext in ["mov","MOV","mp4"]:
				new_content.is_video = True
			new_content.metric = int(random.random() * 6) + 8
			new_content.save()
			new_content.save()
			if album:
				album.content.add(new_content)
				album.save()
			if mobile:
				userprof.queue.content.add(new_content);
				userprof.queue.save()
		else:
			print "not uploading index:%i" % index
		index += 1

	if mobile:
		return HttpResponseRedirect('/mobile_confirm/')
	return HttpResponseRedirect('/browse/')
Ejemplo n.º 2
0
def add_section(request):


	name=request.POST.get('section_name')
	title=request.POST.get('section_title')
	language=str(request.LANGUAGE_CODE)
	next_index=int(request.POST.get('section_index'))

	new_section=Section(section_name=name, section_title=title, section_lang=language, section_author=request.user, section_index=next_index)

	new_section.save()
	new_content=Content(section_id=new_section, text="No se ha definido contenido para esta sección")
	new_content.save()

	return HttpResponseRedirect("/")