Esempio n. 1
0
def album_page(request, id):
    photo1 = Photo.objects.random()
    photo2 = Photo.objects.random()
    album = Album.objects.get(album_id=id)
    album_name = album.title + " - " + str(album.numphotos) + " фото"
    photos = Photo.objects.filter(album = album) 
    vars = {'weblink': 'photo_album.html', 'sel_menu': 'photo', 'photo1': photo1, 'photo2': photo2, 'album_name': album_name, 'photos': photos, 'entry': get_funn()}
    calendar = embeded_calendar()
    vars.update(calendar)        
    return render_to_response('index.html', vars, context_instance=RequestContext(request, processors=[custom_proc]))
Esempio n. 2
0
def albums_page(request):
    photo1 = Photo.objects.random()
    photo2 = Photo.objects.random()
    albums = Album.objects.all() 
    vars = {'weblink': 'photo.html', 'sel_menu': 'photo', 'photo1': photo1, 'photo2': photo2, 'albums': albums, 'entry': get_funn()}
    calendar = embeded_calendar()
    vars.update(calendar)        
    return render_to_response('index.html', vars, context_instance=RequestContext(request, processors=[custom_proc]))
Esempio n. 3
0
def add_news(request):
    if request.user.is_authenticated()==False:
        return HttpResponse("<h2>Для виконання операції, авторизуйтесь</h2>")
    a = News()
    if request.method == 'POST':
        form = NewsForm(request.POST, instance=a)
        if form.is_valid():
            title = form.cleaned_data['title']
            text = form.cleaned_data['text']
#            date = form.cleaned_data['date']
            link = form.cleaned_data['link']
            author = form.cleaned_data['author']
            category = form.cleaned_data['category']
            comm = form.cleaned_data['comments']
#            user = form.cleaned_data['user']
            n = News(title=title, text=text, date=datetime.datetime.now(), link=link, author=author, category=category, user=request.user)
            #n.comments.add(comm)
            n.save()
            return HttpResponseRedirect('/')
    else:
        form = NewsForm(instance=a, initial={'author': request.user })
    
    photo1 = Photo.objects.random()
    photo2 = Photo.objects.random()
    vars = {'weblink': 'news_add.html', 'sel_menu': 'main', 'photo1': photo1, 'photo2': photo2, 'entry': get_funn(), 'form': form}
    calendar = embeded_calendar()
    vars.update(calendar)
    return render_to_response('index.html', vars, context_instance=RequestContext(request, processors=[custom_proc]))
Esempio n. 4
0
def edit_news(request, id):
    if request.user.is_authenticated()==False:
        return HttpResponse("<h2>Для виконання операції, авторизуйтесь</h2>")
    a = News.objects.get(pk=id)
    if request.method == 'POST':
        form = NewsForm(request.POST, instance=a)
        if form.is_valid():
            title = form.cleaned_data['title']
            text = form.cleaned_data['text']
            link = form.cleaned_data['link']
            author = form.cleaned_data['author']
            category = form.cleaned_data['category']
            comm = form.cleaned_data['comments']
            a.title=title
            a.text=text
            a.date=a.date
            a.link=link
            a.author=author
            a.category=category
            a.user=request.user
            a.save()
            return HttpResponseRedirect('/')
    else:
        form = NewsForm(instance=a)
    
    photo1 = Photo.objects.random()
    photo2 = Photo.objects.random()
    vars = {'weblink': 'news_add.html', 'sel_menu': 'main', 'photo1': photo1, 'photo2': photo2, 'entry': get_funn(), 'form': form}
    calendar = embeded_calendar()
    vars.update(calendar)
    return render_to_response('index.html', vars, context_instance=RequestContext(request, processors=[custom_proc]))
Esempio n. 5
0
def main_page(request):
    #return HttpResponse("Hello world")
    photo1 = Photo.objects.random()
    photo2 = Photo.objects.random()
    news = News.objects.all().order_by('-pk')[0:5]
    vars = {'weblink': 'main.html', 'sel_menu': 'main', 'photo1': photo1, 'photo2': photo2, 'entry': get_funn(), 'news': news}
    calendar = embeded_calendar()
    vars.update(calendar)
    
    return render_to_response('index.html', vars, context_instance=RequestContext(request, processors=[custom_proc]))