Added newsletter viewing page

This commit is contained in:
Zak Timson 2017-09-03 17:02:57 -04:00
parent 18498b10bf
commit 54218c4298
4 changed files with 54 additions and 7 deletions

View File

@ -8,17 +8,20 @@ from django.views.static import serve
import main.views
import charter_members.views
import newsletters.views
@login_required
def protected_serve(request, path, document_root=None, show_indexes=False):
return serve(request, path, document_root, show_indexes)
urlpatterns = [
url(r'^$', main.views.index, name='home'),
url(r'^admin/logout', main.views.logout, name='logout'),
url(r'^admin/', admin.site.urls, name='admin'),
url(r'^attorney/(?P<id>\d+)', charter_members.views.index, name='attorney'),
url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'),
url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media')
url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'),
url(r'^newsletter/', newsletters.views.newsletters, name='newsletters')
]

View File

@ -0,0 +1,42 @@
{% extends 'base.html' %}
{% block body %}
<style>
.newsletter-header {
cursor: pointer;
}
.newsletter-header:hover {
background-color: rgba(0, 0, 0, 0.1)
}
</style>
<div class="container-fluid bg-dark-primary">
<div class="container py-3">
{% for newsletter in newsletters %}
<div class="col-12 p-0 mb-3 bg-white newsletter">
<div class="p-3 newsletter-header">
<h2>{{ newsletter.subject }}</h2>
<span class="text-muted">By: {{ newsletter.creator }}</span>
<span class="text-muted float-right">{{ newsletter.publish }}</span>
</div>
<div class="bg-light-blue p-3 newsletter-body" style="display:none;">
<span>{{ newsletter.body }}</span>
</div>
</div>
{% endfor %}
</div>
</div>
<script>
$('.newsletter').click(function() {
var content = $('.newsletter-body', this);
if(content.css('display') == 'block') {
content.slideUp()
} else {
content.slideDown()
}
})
</script>
{% endblock %}

View File

@ -1,3 +1,8 @@
from django.shortcuts import render
# Create your views here.
from .models import Newsletter
def newsletters(request):
newsletters = Newsletter.objects.all()
return render(request, 'newsletters.html', {'newsletters': newsletters})

View File

@ -38,11 +38,8 @@
<li class="nav-item text-dark-primary">
<a class="nav-link" href="{% url 'home' %}">HOME</a>
</li>
<li class="nav-item text-dark-primary">
<a class="nav-link" href="#">INFORMATION</a>
</li>
<li class="nav-item text-dark-primary">
<a class="nav-link" href="#">OUR OBJECTIVES</a>
<li class="new-item text-dark-primary">
<a class="nav-link" href="{% url 'newsletters' %}">NEWSLETTERS</a>
</li>
<li class="nav-item text-dark-primary">
<a class="nav-link" href="#">ATTORNEYS</a>