diff --git a/application/templates/base.html b/application/templates/base.html index c6294f7..217f5a7 100644 --- a/application/templates/base.html +++ b/application/templates/base.html @@ -31,10 +31,20 @@ +
  • + Dashboard +
  • + {% elif user.is_staff %} + + {% else %}
  • {% csrf_token %} {% if next %} - - {% endif %} + {% endif %}
    @@ -92,7 +101,7 @@ - + diff --git a/application/templates/post_list.html b/application/templates/post_list.html index b363d69..c819f6b 100644 --- a/application/templates/post_list.html +++ b/application/templates/post_list.html @@ -1,6 +1,6 @@ {% extends 'base.html' %} {% block content %} {% if tag %} Posts tagged with "{{ tag.name }}" {% endif %} -{% for post in posts %} {% load taggit_templatetags2_tags %} +{% for post in posts %}
    {{ post.published_date }} diff --git a/application/templates/tag_list.html b/application/templates/tag_list.html new file mode 100644 index 0000000..a1f23f0 --- /dev/null +++ b/application/templates/tag_list.html @@ -0,0 +1,25 @@ +{% extends "base.html" %} {% block content %} {% load taggit_templatetags2_tags %} +{% get_taglist as tags for 'application.customuser'%} + + +
    + Your tags: +
      + {% for tag in tags %} +
    • + {{ tag }} +
    • + {% endfor %} +
    +
    +
    + {{ tags }} {{ u }} +
    +
    + from List: {% for tag in tags %} + + {% for tag in posts %} +

    {{ tag.name }}

    {% endfor %}{% endfor %} + +
    +{% endblock %} \ No newline at end of file diff --git a/application/urls.py b/application/urls.py index d059b6a..e7167ea 100644 --- a/application/urls.py +++ b/application/urls.py @@ -6,6 +6,8 @@ from . import views urlpatterns = [ url(r'^$', views.post_list, name='post_list'), url(r'^tag/(?P[-\w]+)/$', views.post_list, name='post_list_by_tag'), + url(r'^taglist/$', views.tag_list, name='tag_list'), + url(r'^taglist/(?P[-\w]+)/$', views.post_list, name='post_list_by_tag'), url(r'^student/', views.student_page, name='student_page'), url(r'^search/', views.blog_search_list_view, name='blog_search_list_view'), url(r'^post/(?P\d+)/$', views.post_detail, name='post_detail'), diff --git a/application/views.py b/application/views.py index 46e7780..a7574e5 100644 --- a/application/views.py +++ b/application/views.py @@ -10,6 +10,7 @@ from django.contrib.admin.views.decorators import staff_member_required from django.contrib.auth import authenticate, login, logout from django.db.models import Q import sys +import collections from taggit_templatetags2.views import TagCanvasListView import logging @@ -127,7 +128,7 @@ def tag_remove(request): @login_required def student_page(request): - user_instance = CustomUser.objects.get(user=request.user) + user_instance = get_object_or_404(CustomUser, user=request.user) if request.method == "POST": form = NewTagForm(request.POST, instance=user_instance) if form.is_valid(): @@ -144,7 +145,11 @@ def student_page(request): return render(request, 'student_page.html', {'form':form}) - +@login_required +def tag_list(request): + u= CustomUser.objects.get(user=request.user) + tags= Tag.objects.filter(name=u) + return render(request, 'tag_list.html', locals()) class TagSearch(TagCanvasListView):