Added a bunch of form stuff
This commit is contained in:
parent
c8360c293d
commit
a668626654
@ -11,6 +11,7 @@ import main.views
|
|||||||
import case_law.views
|
import case_law.views
|
||||||
import charter_members.views
|
import charter_members.views
|
||||||
import expert_witnesses.views
|
import expert_witnesses.views
|
||||||
|
import forum.views
|
||||||
import newsletters.views
|
import newsletters.views
|
||||||
|
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ def protected_serve(request, path, document_root=None, show_indexes=False):
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', main.views.index, name='home'),
|
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'^admin/', admin.site.urls, name='admin'),
|
||||||
url(r'^attorney/(?P<id>\d+)', charter_members.views.index, name='attorney'),
|
url(r'^attorney/(?P<id>\d+)', charter_members.views.index, name='attorney'),
|
||||||
url(r'^caselaw/', case_law.views.browser, name='caselaw'),
|
url(r'^caselaw/', case_law.views.browser, name='caselaw'),
|
||||||
@ -31,6 +32,8 @@ urlpatterns = [
|
|||||||
url(r'^contact/', main.views.contact, name='contact'),
|
url(r'^contact/', main.views.contact, name='contact'),
|
||||||
url(r'^experts/(?P<id>\d+)', expert_witnesses.views.viewer, name='expert'),
|
url(r'^experts/(?P<id>\d+)', expert_witnesses.views.viewer, name='expert'),
|
||||||
url(r'^experts/', expert_witnesses.views.browser, name='experts'),
|
url(r'^experts/', expert_witnesses.views.browser, name='experts'),
|
||||||
|
url(r'^forum/post/(?P<post>\d*)', forum.views.post, name='post'),
|
||||||
|
url(r'^forum/(?P<thread>\d*)?', forum.views.view, name='forum'),
|
||||||
url(r'^login/', main.views.login, name='login'),
|
url(r'^login/', main.views.login, name='login'),
|
||||||
url(r'^logout/', main.views.logout, name='logout'),
|
url(r'^logout/', main.views.logout, name='logout'),
|
||||||
url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'),
|
url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'),
|
||||||
|
97
forum/templates/view.html
Normal file
97
forum/templates/view.html
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
$('#my-posts').popover({
|
||||||
|
title: 'My Posts',
|
||||||
|
placement: 'bottom',
|
||||||
|
html: true,
|
||||||
|
content: '<ul class="list-group">{% if myPosts.count == 0 %}None{% endif %}{% for post in myPosts %}<a href="{% url 'post' post.id %}" class="list-group-item list-group-item-action">{{ post.title }}</a>{% endfor %}</ul>'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="container-fluid bg-dark-primary">
|
||||||
|
<div class="container py-3">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="float-right">
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
<i id="my-posts" class="curs-pointer text-white fa fa-comments fa-2x mr-2"></i>
|
||||||
|
{% endif %}
|
||||||
|
{% if perms.forum.add_post %}
|
||||||
|
<i id="create-post" class="curs-pointer text-white fa fa-plus fa-2x" data-toggle="modal"
|
||||||
|
data-target="#create-post-modal"></i>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% if threads %}
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-12">
|
||||||
|
<h3 class="text-white">Threads</h3>
|
||||||
|
<ul class="list-group">
|
||||||
|
{% for thread in threads %}
|
||||||
|
<a href="{% url 'forum' thread.id %}"
|
||||||
|
class="list-group-item list-group-item-action">{{ thread.topic }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h3 class="text-white d-inline">Posts</h3>
|
||||||
|
<ul class="list-group">
|
||||||
|
{% for post in posts %}
|
||||||
|
<a href="{% url 'post' post.id %}"
|
||||||
|
class="list-group-item list-group-item-action">{{ post.title }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="create-post-modal" class="modal fade" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Create New Post</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="col-12">
|
||||||
|
<form>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="title">Title</label>
|
||||||
|
<input class="form-control" name="title">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="thread">Topic</label>
|
||||||
|
<select class="form-control" name="thread">
|
||||||
|
{% for thread in threads %}
|
||||||
|
<option value="{{ thread.id }}">{{ thread.topic }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="title">Body</label>
|
||||||
|
<textarea class="form-control" name="body"></textarea>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary">Create</button>
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -1,3 +1,28 @@
|
|||||||
from django.shortcuts import render
|
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
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
<a class="nav-link" href="{% url 'newsletters' %}">NEWSLETTERS</a>
|
<a class="nav-link" href="{% url 'newsletters' %}">NEWSLETTERS</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item text-dark-primary">
|
<li class="nav-item text-dark-primary">
|
||||||
<a class="nav-link" href="#">FORUM</a>
|
<a class="nav-link" href="{% url 'forum' %}">FORUM</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item text-dark-primary">
|
<li class="nav-item text-dark-primary">
|
||||||
<a class="nav-link" href="{% url 'caselaw' %}">CASE LAW</a>
|
<a class="nav-link" href="{% url 'caselaw' %}">CASE LAW</a>
|
||||||
@ -58,7 +58,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{% if request.user.is_staff %}
|
{% if request.user.is_staff %}
|
||||||
<li class="nav-item text-dark-primary">
|
<li class="nav-item text-dark-primary">
|
||||||
<a class="nav-link" href="/admin/">ADMIN PANEL</a>
|
<a class="nav-link" href="/admin">ADMIN PANEL</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if request.user.is_authenticated%}
|
{% if request.user.is_authenticated%}
|
||||||
|
Loading…
Reference in New Issue
Block a user