Example #1
0
def albumUpload(request):
    thisUser = None
    if request.user.is_authenticated():
        thisUser = request.user

        myCircles = Circle.objects.filter(owner=thisUser)

        myAlbums = PhotoAlbum.objects.filter(owner=thisUser)

        myPhotos = Photo.objects.filter(owner=thisUser)

        users = User.objects.all().order_by('name')

        circleForm = addCircleForm(request.POST)

        albumForm = addAlbumForm(request.POST)
        albumForm.fields['photos'].queryset = Photo.objects.filter(
            owner=thisUser)

        circleQuery = Circle.objects.filter(owner=thisUser)

        photoForm = addPhotoForm(request.POST)
        photoForm.fields['permissions'].queryset = circleQuery

        batchPhotoForm = addBatchPhotoForm(request.POST)
        batchPhotoForm.fields['permissions'].queryset = circleQuery

    else:
        myCircles = None
        myAlbums = None
        myPhotos = None

        users = User.objects.all().order_by('name')
        circleForm = addCircleForm()
        albumForm = addAlbumForm()
        photoForm = addPhotoForm()
        batchPhotoForm = addBatchPhotoForm()

    context = {
        'myCircles': myCircles,
        'myAlbums': myAlbums,
        'myPhotos': myPhotos,
        'users': users,
        'circleForm': circleForm,
        'albumForm': albumForm,
        'photoForm': photoForm,
        'requestPost': request.POST,
        'batchPhotoForm': batchPhotoForm,
    }

    return render(request, 'familypix/albumUpload.html', context)
Example #2
0
def albumUpload(request):
    thisUser = None
    if request.user.is_authenticated():
        thisUser = request.user
    
        myCircles = Circle.objects.filter(owner=thisUser)

        myAlbums = PhotoAlbum.objects.filter(owner = thisUser)

        myPhotos = Photo.objects.filter(owner=thisUser)
    
        users = User.objects.all().order_by('name')
    
        circleForm = addCircleForm(request.POST)
    
        albumForm = addAlbumForm(request.POST)
        albumForm.fields['photos'].queryset = Photo.objects.filter(owner=thisUser)
        
        circleQuery = Circle.objects.filter(owner=thisUser)
        
        photoForm = addPhotoForm(request.POST)
        photoForm.fields['permissions'].queryset = circleQuery
        
        batchPhotoForm = addBatchPhotoForm(request.POST)
        batchPhotoForm.fields['permissions'].queryset = circleQuery
        
    else:
        myCircles = None
        myAlbums = None
        myPhotos = None
        
        
        users = User.objects.all().order_by('name')
        circleForm = addCircleForm()
        albumForm = addAlbumForm()    
        photoForm = addPhotoForm()
        batchPhotoForm = addBatchPhotoForm()
    
    context = {'myCircles' : myCircles, 'myAlbums' : myAlbums, 'myPhotos' : myPhotos, 'users': users, 'circleForm' : circleForm, 'albumForm': albumForm, 'photoForm' : photoForm, 'requestPost' : request.POST, 'batchPhotoForm' : batchPhotoForm,}
    
    return render(request, 'familypix/albumUpload.html', context)
Example #3
0
def addAlbum(request):

    if request.method == 'POST':

        form = addAlbumForm(request.POST)
        if form.is_valid():
            newAlbum = form.save(commit=False)
            newAlbum.owner = request.user
            newAlbum.save()
            form.save_m2m()

    return redirect('index')
Example #4
0
def addAlbum(request):
    
    if request.method == 'POST':
        
        form = addAlbumForm(request.POST)
        if form.is_valid():
            newAlbum = form.save(commit=False)
            newAlbum.owner = request.user
            newAlbum.save()
            form.save_m2m()
    
    
    return redirect('index')