<li class="nav-item"> | <li class="nav-item"> | ||||
<a class="nav-link" href="{% url 'admin:index' %}">Administration</a> | <a class="nav-link" href="{% url 'admin:index' %}">Administration</a> | ||||
</li> | </li> | ||||
<li> | |||||
<a class="nav-link" href="{% url 'post_list' %}">Dashboard</a> | |||||
</li> | |||||
<li class="nav-item"> | |||||
<a class="nav-link" href="{% url 'student_page' %}">Studentenansicht</a> | |||||
</li> | |||||
{% elif user.is_staff %} | {% elif user.is_staff %} | ||||
<li class="nav-item"> | <li class="nav-item"> | ||||
<a class="nav-link" href="{% url 'logout' %}">Administration</a> | <a class="nav-link" href="{% url 'logout' %}">Administration</a> | ||||
</li> | </li> | ||||
<li class="nav-item"> | |||||
<a class="nav-link" href="{% url 'post_list' %}">Dashboard</a> | |||||
</li> | |||||
{% else %} | {% else %} | ||||
<li class="nav-item"> | <li class="nav-item"> | ||||
<a class="nav-link" href="{% url 'student_page' %}">{{user.get_username}}'s Dashboard</a> | <a class="nav-link" href="{% url 'student_page' %}">{{user.get_username}}'s Dashboard</a> | ||||
<li> | <li> | ||||
<form class="form" role="form" method="post" action="{% url 'login' %}" accept-charset="UTF-8" id="login-nav"> | <form class="form" role="form" method="post" action="{% url 'login' %}" accept-charset="UTF-8" id="login-nav"> | ||||
{% csrf_token %} {% if next %} | {% csrf_token %} {% if next %} | ||||
<input type="hidden" name="next" value="{{ next }}" /> | |||||
{% endif %} | |||||
<input type="hidden" name="next" value="{{ next }}" /> {% endif %} | |||||
<div class="form-group"> | <div class="form-group"> | ||||
<label class="sr-only" for="username">Benutzername</label> | <label class="sr-only" for="username">Benutzername</label> | ||||
<input type="text" class="form-control" id="username" name="username" placeholder="Benutzername" required> | <input type="text" class="form-control" id="username" name="username" placeholder="Benutzername" required> | ||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | ||||
<script src="{% static 'bootstrap/js/jquery-1.11.1.js' %} "></script> | <script src="{% static 'bootstrap/js/jquery-1.11.1.js' %} "></script> | ||||
<script src="{% static 'bootstrap/jsjquery.tagcanvas.min.js' %} " type="text/javascript"></script> | <script src="{% static 'bootstrap/jsjquery.tagcanvas.min.js' %} " type="text/javascript"></script> | ||||
<script src="{% static 'js/app.js' %}"></script> | |||||
<script src="{% static 'js/app.js' %}"></script> | |||||
<script src="{% static 'bootstrap/js/bootstrap.bundle.js' %}"></script> | <script src="{% static 'bootstrap/js/bootstrap.bundle.js' %}"></script> | ||||
</body> | </body> | ||||
{% extends 'base.html' %} {% block content %} | {% extends 'base.html' %} {% block content %} | ||||
{% if tag %} Posts tagged with "{{ tag.name }}" {% endif %} | {% if tag %} Posts tagged with "{{ tag.name }}" {% endif %} | ||||
{% for post in posts %} {% load taggit_templatetags2_tags %} | |||||
{% for post in posts %} | |||||
<div class="post"> | <div class="post"> | ||||
<div class="date"> | <div class="date"> | ||||
{{ post.published_date }} | {{ post.published_date }} |
{% extends "base.html" %} {% block content %} {% load taggit_templatetags2_tags %} | |||||
{% get_taglist as tags for 'application.customuser'%} | |||||
<div id=""> | |||||
Your tags: | |||||
<ul> | |||||
{% for tag in tags %} | |||||
<li> | |||||
<a href="{% url 'post_list_by_tag' tag.slug %}">{{ tag }}</a> | |||||
</li> | |||||
{% endfor %} | |||||
</ul> | |||||
</div> | |||||
<div> | |||||
{{ tags }} {{ u }} | |||||
</div> | |||||
<div> | |||||
from List: {% for tag in tags %} | |||||
{% for tag in posts %} | |||||
<p>{{ tag.name }} </p>{% endfor %}{% endfor %} | |||||
</div> | |||||
{% endblock %} |
urlpatterns = [ | urlpatterns = [ | ||||
url(r'^$', views.post_list, name='post_list'), | url(r'^$', views.post_list, name='post_list'), | ||||
url(r'^tag/(?P<slug>[-\w]+)/$', views.post_list, name='post_list_by_tag'), | url(r'^tag/(?P<slug>[-\w]+)/$', views.post_list, name='post_list_by_tag'), | ||||
url(r'^taglist/$', views.tag_list, name='tag_list'), | |||||
url(r'^taglist/(?P<slug>[-\w]+)/$', views.post_list, name='post_list_by_tag'), | |||||
url(r'^student/', views.student_page, name='student_page'), | url(r'^student/', views.student_page, name='student_page'), | ||||
url(r'^search/', views.blog_search_list_view, name='blog_search_list_view'), | url(r'^search/', views.blog_search_list_view, name='blog_search_list_view'), | ||||
url(r'^post/(?P<pk>\d+)/$', views.post_detail, name='post_detail'), | url(r'^post/(?P<pk>\d+)/$', views.post_detail, name='post_detail'), |
from django.contrib.auth import authenticate, login, logout | from django.contrib.auth import authenticate, login, logout | ||||
from django.db.models import Q | from django.db.models import Q | ||||
import sys | import sys | ||||
import collections | |||||
from taggit_templatetags2.views import TagCanvasListView | from taggit_templatetags2.views import TagCanvasListView | ||||
import logging | import logging | ||||
@login_required | @login_required | ||||
def student_page(request): | 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": | if request.method == "POST": | ||||
form = NewTagForm(request.POST, instance=user_instance) | form = NewTagForm(request.POST, instance=user_instance) | ||||
if form.is_valid(): | if form.is_valid(): | ||||
return render(request, 'student_page.html', {'form':form}) | 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): | class TagSearch(TagCanvasListView): |