Exemplo n.º 1
0
def photo(request):
    template = 'view-photo.html'
    context_vars = {}
    
    if request.POST:
        photo = LocalPhoto()
        try:
            photo.tags = tags
        except:
            photo.tags = ''
        try:
            file = request.FILES['photo_file']
            title = request.POST['title']
            description = request.POST['description']
            tags = request.POST['tags']
            photo.uuid = uuid.uuid4()
            photo_file = get_full_file_path(photo,file.name)
            handle_uploaded_file(file,photo_file)
            photo.photo = get_file_path(photo,file.name)
            photo.title = title
            photo.description = description
            photo.user = request.user
            tags_list = tags.split(',')
            photo.tags = tags_list
            
            photo.save()
            api = get_trove_api_for_user(request.user)
            profile = UserProfile.objects.get(user=request.user)
            from troveclient.Objects import Photo
            trove_client_photo = Photo()
            trove_client_photo.height = photo.photo.height
            trove_client_photo.width = photo.photo.width
            trove_client_photo.owner = profile.trove_user_id
            trove_client_photo.date = photo.date_uploaded
            trove_client_photo.description = photo.description
            trove_client_photo.id = str(photo.uuid)
            trove_client_photo.tags = photo.tags
            trove_client_photo.title = photo.title
            urls={'original':photo.photo.url,'thumbnail':photo.thumbnail.url}
            trove_client_photo.urls = urls
            trove_photo_list = [trove_client_photo]
            
            trove_ids = api.push_photos(profile.trove_user_id, trove_photo_list)
            print trove_ids
            return HttpResponseRedirect('/photos/' + str(photo.uuid))
        except KeyError, e:
            print 'doh!'
            print e
            pass
Exemplo n.º 2
0
 def get_object(object):
     p = Photo()
     if object['date'] is None or object['date'] is "":
         p.date = ""
     else:
         date_str = object['date']
         p.date = datetime.datetime.strptime(date_str,'%Y-%m-%d T %H:%M:%S')            
     p.service = object['service']
     p.title = object['title']
     p.owner = object['owner']
     p.description = object['description']
     p.id = object['id']
     p.urls = object['urls']
     p.tags = object['tags']
     p.album_id = object['album_id']
     p.license = object['license']
     p.public = object['public']
     p.height = object['height']
     p.width = object['width']
     if object.has_key('latitude'):
         p.latitude = object['latitude']
     if object.has_key('longitude'):
         p.longitude = object['longitude']
     if object.has_key('trove_id'):
         p.trove_id = object['trove_id']
     return p