diff --git a/OACPL/urls.py b/OACPL/urls.py index 5880840..9d84123 100644 --- a/OACPL/urls.py +++ b/OACPL/urls.py @@ -11,6 +11,7 @@ import main.views import case_law.views import charter_members.views import expert_witnesses.views +import forum.views import newsletters.views @@ -23,7 +24,7 @@ def protected_serve(request, path, document_root=None, show_indexes=False): urlpatterns = [ url(r'^$', main.views.index, name='home'), - url(r'^admin/logout', main.views.logout), + url(r'^admin/logout', main.views.logout, name='logout'), url(r'^admin/', admin.site.urls, name='admin'), url(r'^attorney/(?P\d+)', charter_members.views.index, name='attorney'), url(r'^caselaw/', case_law.views.browser, name='caselaw'), @@ -31,6 +32,8 @@ urlpatterns = [ url(r'^contact/', main.views.contact, name='contact'), url(r'^experts/(?P\d+)', expert_witnesses.views.viewer, name='expert'), url(r'^experts/', expert_witnesses.views.browser, name='experts'), + url(r'^forum/post/(?P\d*)', forum.views.post, name='post'), + url(r'^forum/(?P\d*)?', forum.views.view, name='forum'), url(r'^login/', main.views.login, name='login'), url(r'^logout/', main.views.logout, name='logout'), url(r'^media/secure/(?P.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'), diff --git a/forum/templates/view.html b/forum/templates/view.html new file mode 100644 index 0000000..76950c8 --- /dev/null +++ b/forum/templates/view.html @@ -0,0 +1,97 @@ +{% extends 'base.html' %} + +{% block head %} + +{% endblock %} + +{% block body %} +
+
+
+
+
+ {% if request.user.is_authenticated %} + + {% endif %} + {% if perms.forum.add_post %} + + {% endif %} +
+
+
+ {% if threads %} +
+
+

Threads

+ +
+
+ {% endif %} +
+
+

Posts

+ +
+
+
+
+ + +{% endblock %} diff --git a/forum/views.py b/forum/views.py index 91ea44a..876396c 100644 --- a/forum/views.py +++ b/forum/views.py @@ -1,3 +1,28 @@ from django.shortcuts import render -# Create your views here. +from .models import Thread, Post, Comment + + +def view(request, thread=None): + myPosts = None + if request.user.is_authenticated(): + myPosts = Post.objects.filter(creator=request.user) + if not thread: + threads = Thread.objects.all() + posts = Post.objects.order_by('created')[:10] + else: + threads = None + posts = Post.objects.filter(topic=thread) + return render(request, 'view.html', {'threads': threads, 'posts': posts, 'myPosts': myPosts}) + + +def post(request): + pass + + +def create(request): + pass + + +def comment(request): + pass diff --git a/templates/base.html b/templates/base.html index 8107a57..b10838f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -48,7 +48,7 @@ NEWSLETTERS {% if request.user.is_staff %} {% endif %} {% if request.user.is_authenticated%}