2019-06-27 08:09:51 +02:00
|
|
|
from django.http import HttpResponse, HttpResponseRedirect
|
|
|
|
from django.shortcuts import render
|
|
|
|
# Create your views here.
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
|
|
from .models import Bookmark
|
|
|
|
|
|
|
|
|
|
|
|
def index(request):
|
|
|
|
context = {
|
|
|
|
'bookmarks': Bookmark.objects.all()
|
|
|
|
}
|
|
|
|
return render(request, 'bookmarks/index.html', context)
|
|
|
|
|
|
|
|
|
|
|
|
def create(request):
|
|
|
|
return HttpResponse('OK')
|
|
|
|
|
|
|
|
|
2019-06-28 07:33:08 +02:00
|
|
|
def new(request):
|
|
|
|
return render(request, 'bookmarks/new.html')
|
|
|
|
|
|
|
|
|
|
|
|
def edit(request, bookmark_id):
|
2019-06-27 08:09:51 +02:00
|
|
|
context = {
|
2019-06-28 07:33:08 +02:00
|
|
|
'bookmark': Bookmark.objects.get(pk=bookmark_id)
|
2019-06-27 08:09:51 +02:00
|
|
|
}
|
2019-06-28 07:33:08 +02:00
|
|
|
return render(request, 'bookmarks/edit.html', context)
|
2019-06-27 08:09:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
def remove(request, bookmark_id: int):
|
|
|
|
bookmark = Bookmark.objects.get(pk=bookmark_id)
|
|
|
|
bookmark.delete()
|
|
|
|
return HttpResponseRedirect(reverse('bookmarks:index'))
|