Ejemplo n.º 1
0
def myalbum(request, url = defaultUrl):
    ''' here use two ways to get post infomation: POST or urls.py
    it'll be change in the future...
    the photo_list is the same as the urlInfoList, the name just make it more like an album...
    '''
    if request.method == 'POST':        # when POST
        form = siteForm(request.POST)

        if form.is_valid():
            site = form.cleaned_data['site']
            photo_list = getUrl.getImgList(site)
            return render(request, u'myalbum/myalbum.html', {'form': form,
                                                     'photo_list': photo_list,
                                                     'site': site})
        else:   # when POST is invalid
            form = siteForm()
            site = defaultUrl
            photo_list = getUrl.getImgList(site)
            return render(request, u'myalbum/myalbum.html', {'form': form,
                                                     'photo_list': photo_list,
                                                     'site': site})
            
    else:       # when not POST , just by /url/(.+?)
        form = siteForm()
        site = url
        photo_list = getUrl.getImgList(site)
    return render(request, u'myalbum/myalbum.html', {'form': form,
                                             'photo_list': photo_list,
                                             'site': site})
Ejemplo n.º 2
0
def myalbum(request, url=defaultUrl):
    ''' here use two ways to get post infomation: POST or urls.py
    it'll be change in the future...
    the photo_list is the same as the urlInfoList, the name just make it more like an album...
    '''
    if request.method == 'POST':  # when POST
        form = siteForm(request.POST)

        if form.is_valid():
            site = form.cleaned_data['site']
        else:  # when POST is invalid
            site = defaultUrl

    else:  # when not POST , just get url by GET method with '/url/(.+?)'
        form = siteForm()
        site = url
    fixed_site, photo_list = getUrl.getImgList(site)
    return render(request, u'myalbum/myalbum.html', {
        'form': form,
        'photo_list': photo_list,
        'site': fixed_site
    })
Ejemplo n.º 3
0
def myalbum_simple(request):
    photo_list = getUrl.getImgList(defaultUrl)  # it's the old way, now don't use getUrl.py
    return render(request, u'myalbum/myalbum.html', {'photo_list': photo_list})