diff --git a/imagehosting/templates/imagehosting/all.html b/imagehosting/templates/imagehosting/all.html
new file mode 100644
index 0000000..b65dcf5
--- /dev/null
+++ b/imagehosting/templates/imagehosting/all.html
@@ -0,0 +1,38 @@
+{% extends 'imagehosting/base.html' %}
+{% load static %}
+
+{% block content%}
+
+{% for image in all %}
{% endfor %}
+
+
+
+
+{% endblock content %}
+
+
diff --git a/imagehosting/templates/imagehosting/base.html b/imagehosting/templates/imagehosting/base.html
new file mode 100644
index 0000000..7a36805
--- /dev/null
+++ b/imagehosting/templates/imagehosting/base.html
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% block content %}
+ {% endblock%}
+
+
+
diff --git a/imagehosting/templates/imagehosting/carousel.html b/imagehosting/templates/imagehosting/carousel.html
new file mode 100644
index 0000000..0a0dc16
--- /dev/null
+++ b/imagehosting/templates/imagehosting/carousel.html
@@ -0,0 +1,62 @@
+ {% load staticfiles %}
+
+
+ Gallery
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% for image in all %}
+
+ {% endfor %}
+
+
+
+
+
+{% for image in all %}
+
+{% endfor %}
+
+
+
+1
+
diff --git a/imagehosting/templates/imagehosting/image.html b/imagehosting/templates/imagehosting/image.html
new file mode 100644
index 0000000..6a33bc1
--- /dev/null
+++ b/imagehosting/templates/imagehosting/image.html
@@ -0,0 +1,17 @@
+{% extends 'imagehosting/base.html' %}
+
+{% block content %}
+
+
+
+
+
+
+{% endblock %}
+
+
diff --git a/imagehosting/templates/imagehosting/index.html b/imagehosting/templates/imagehosting/index.html
new file mode 100644
index 0000000..52d204a
--- /dev/null
+++ b/imagehosting/templates/imagehosting/index.html
@@ -0,0 +1,10 @@
+{% extends 'imagehosting/base.html' %}
+
+{% block content %}
+
+
+
+{% endblock %}
diff --git a/imagehosting/templates/imagehosting/login.html b/imagehosting/templates/imagehosting/login.html
new file mode 100644
index 0000000..e1223e0
--- /dev/null
+++ b/imagehosting/templates/imagehosting/login.html
@@ -0,0 +1,15 @@
+{% extends 'imagehosting/base.html' %}
+{% block content %}
+
+
+
+{% endblock %}
diff --git a/imagehosting/urls.py b/imagehosting/urls.py
index d13043a..5f64c5a 100644
--- a/imagehosting/urls.py
+++ b/imagehosting/urls.py
@@ -4,10 +4,19 @@ from django.conf.urls import url
from . import views
from django.conf import settings
from django.conf.urls.static import static
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+from django.contrib import admin
+from django.contrib.auth.views import login, logout
+
urlpatterns = [
url(r'^$', views.image_new, name='image_new'),
url(r'^post/(?P[0-9]+)/$', views.image_detail, name='image_detail'),
url(r'^all/$', views.all_posts, name='all_posts'),
url(r'^carousel/$', views.carousel, name='carousel'),
- url(r'^delete/(?P[0-9]+)/$', views.delete_post, name='delete_post')
+ url(r'^delete/(?P[0-9]+)/$', views.delete_post, name='delete_post'),
+ url(r'^admin/', admin.site.urls),
+ url(r'^login$', login, {'template_name':'imagehosting/login.html'}, name='login'),
+ url(r'^logout/$', logout)
]
+urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+urlpatterns += staticfiles_urlpatterns()
diff --git a/imagehosting/views.py b/imagehosting/views.py
index bd13986..f144172 100644
--- a/imagehosting/views.py
+++ b/imagehosting/views.py
@@ -5,7 +5,8 @@ from .models import Post
from .forms import PostForm, DeleteForm
from django.shortcuts import redirect
from ih import files, images
-from django.views.decorators.csrf import requires_csrf_token
+#from django.views.decorators.csrf import requires_csrf_token
+from django.contrib.auth.decorators import login_required
'''def create_thumbnail(request):
# Get file from
@@ -48,7 +49,7 @@ def create_thumb_from_file(filename):
return thumb_name
-
+@login_required(login_url="/login")
def image_new(request):
if request.method == "POST":
form = PostForm(request.POST, request.FILES)
@@ -79,17 +80,16 @@ def all_posts(request):
def carousel(request):
return render(request, 'imagehosting/carousel.html', {'all': Post.objects.all()})
-@requires_csrf_token
+#@requires_csrf_token
+@login_required(login_url="/login")
def delete_post(request, pk):
post_to_delete = get_object_or_404(Post, pk=pk)
- if request.method == 'POST':
+ if request.method == 'GET':
form = DeleteForm(request.POST, instance=post_to_delete)
if form.is_valid(): # checks CSRF
if not request.user.is_authenticated():
return HttpResponseRedirect('/admin')
post_to_delete.delete()
return redirect('imagehosting.views.all_posts')
- else:
- form = DeleteForm(instance=post_to_delete)
- return render(request, 'imagehosting/delete.html', {'form': form})
+ #return render(request, 'imagehosting/delete.html', {'form': form})