Browse Source

fixed some issues with non-used tags

newsletter
Esther Kleinhenz 6 years ago
parent
commit
7ed667d043

+ 5
- 12
application/templates/student_page.html View File

@@ -12,18 +12,11 @@
</ul>
</div>
<div>
</div>
<form id="searchform" action="{% url 'blog_search_list_view' %}" method="get" accept-charset="utf-8">
<button class="searchbutton" type="submit">
<i class="fa fa-search"></i>
</button>
<input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search">
</form>
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
</table>
</div>

{% if messages %}
{% for message in messages %}
<div {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}</div>
{% endfor %}
{% endif %}
<form class="post-form" method="post">
{% csrf_token %} {{form.as_p}}
<button type="submit" class="save btn btn-outline-dark">Save</button>

+ 1
- 0
application/templates/tag_list.html View File

@@ -1,4 +1,5 @@
{% extends "base.html" %} {% block content %}
{% load taggit_templatetags2_tags %}

<div>
</div>

+ 20
- 0
application/templates/tag_remove.html View File

@@ -0,0 +1,20 @@
{% extends 'base.html' %} {% block content %}
{% if tag %} Posts tagged with "{{ tag.name }}" {% endif %}
{% for post in posts %}
<div class="post">
<div class="date">
{{ post.published_date }}
</div>
<h1>
<a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a>
</h1>
<p>{{ post.text|linebreaks }}</p>
Tags: {% for tag in post.tags.all %}
<a href="{% url 'student_page_remove' tag.slug %}">{{ tag.name }}</a>
{% if not forloop.last %}, {% endif %} {% endfor %} <p>
{{ post.author }}
</p>
</div>
{% endfor %}
</div>
{% endblock %}

+ 10
- 7
application/views.py View File

@@ -13,6 +13,8 @@ import sys
import collections
from taggit_templatetags2.views import TagCanvasListView
from django.contrib.auth.models import User
from django.contrib import messages



import logging
@@ -135,10 +137,13 @@ def student_page(request):
obj.user = request.user
obj.save()
m_tags = form.cleaned_data['m_tags']
obj.tags.add(*m_tags)
form.save_m2m()
return redirect('/student/')

tags = Tag.objects.all()
if m_tags in tags:
obj.tags.add(*m_tags)
form.save_m2m()
return redirect('/student/')
else:
messages.info(request, 'Sorry !! Den Tag den du suchst gibt es leider nicht!')
else:
form = NewTagForm()
return render(request, 'student_page.html', {'form':form})
@@ -150,11 +155,9 @@ def tag_list(request):
if u:
tags_user = Tag.objects.filter(customuser__user = u)
log.info(tags_user)
arr = []
for tag in tags_user:
arr.append(str(tag))
log.info(tag)
posts = Post.objects.filter(tags__in=[tag]).order_by('-published_date')
log.info(posts)
return render(request, 'tag_list.html', locals())

class TagSearch(TagCanvasListView):

+ 85
- 0
log.txt View File

@@ -315,3 +315,88 @@
[22/Oct/2018 18:55:43] INFO [mysite:152] <QuerySet [<Tag: bamberg>, <Tag: test>]>
[22/Oct/2018 18:55:43] INFO [mysite:156] bamberg
[22/Oct/2018 18:55:43] INFO [mysite:156] test
[24/Oct/2018 15:10:56] INFO [mysite:152] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:10:56] INFO [mysite:156] stefan
[24/Oct/2018 15:11:37] INFO [mysite:152] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:11:37] INFO [mysite:156] stefan
[24/Oct/2018 15:11:37] INFO [mysite:158] <QuerySet []>
[24/Oct/2018 15:13:48] INFO [mysite:152] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:13:48] INFO [mysite:156] stefan
[24/Oct/2018 15:13:48] INFO [mysite:158] <QuerySet []>
[24/Oct/2018 15:15:46] INFO [mysite:153] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:15:46] INFO [mysite:157] stefan
[24/Oct/2018 15:15:55] INFO [mysite:153] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:15:55] INFO [mysite:157] stefan
[24/Oct/2018 15:15:55] INFO [mysite:159] <QuerySet []>
[24/Oct/2018 15:17:17] INFO [mysite:152] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:17:17] INFO [mysite:156] stefan
[24/Oct/2018 15:17:17] INFO [mysite:158] <QuerySet []>
[24/Oct/2018 15:18:27] INFO [mysite:152] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:18:27] INFO [mysite:156] stefan
[24/Oct/2018 15:18:27] INFO [mysite:158] <QuerySet []>
[24/Oct/2018 15:21:10] INFO [mysite:150] <QuerySet [<Post: second bla>, <Post: first post>, <Post: Third one>]>
[24/Oct/2018 15:21:10] INFO [mysite:154] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:21:10] INFO [mysite:158] stefan
[24/Oct/2018 15:21:10] INFO [mysite:160] <QuerySet []>
[24/Oct/2018 15:22:12] INFO [mysite:152] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:22:12] INFO [mysite:156] ['stefan']
[24/Oct/2018 15:22:12] INFO [mysite:158] <QuerySet []>
[24/Oct/2018 15:22:29] INFO [mysite:152] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:22:29] INFO [mysite:156] ['stefan']
[24/Oct/2018 15:22:57] INFO [mysite:152] <QuerySet [<Tag: stefan>]>
[24/Oct/2018 15:22:57] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 15:23:36] INFO [mysite:152] <QuerySet [<Tag: stefan>, <Tag: test>]>
[24/Oct/2018 15:23:36] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 15:23:36] INFO [mysite:155] <QuerySet [<Post: Third one>, <Post: first post>, <Post: second bla>]>
[24/Oct/2018 15:24:29] INFO [mysite:152] <QuerySet [<Tag: bamberg>, <Tag: test>, <Tag: wieder>]>
[24/Oct/2018 15:24:29] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 15:24:29] INFO [mysite:155] <QuerySet [<Post: Third one>, <Post: first post>, <Post: second bla>]>
[24/Oct/2018 15:24:29] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 15:26:03] INFO [mysite:152] <QuerySet [<Tag: lukas>, <Tag: hi>]>
[24/Oct/2018 15:26:03] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 15:26:03] INFO [mysite:155] <QuerySet [<Post: Third one>, <Post: second bla>]>
[24/Oct/2018 15:51:54] INFO [mysite:152] <QuerySet [<Tag: bamberg>, <Tag: test>, <Tag: wieder>]>
[24/Oct/2018 15:51:55] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 15:51:55] INFO [mysite:155] <QuerySet [<Post: Third one>, <Post: first post>, <Post: second bla>]>
[24/Oct/2018 15:51:55] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 15:53:01] INFO [mysite:152] <QuerySet [<Tag: bamberg>, <Tag: test>]>
[24/Oct/2018 15:53:01] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 15:53:01] INFO [mysite:155] <QuerySet [<Post: Third one>, <Post: first post>, <Post: second bla>]>
[24/Oct/2018 15:53:28] INFO [mysite:152] <QuerySet [<Tag: bamberg>, <Tag: test>, <Tag: this is a new one>]>
[24/Oct/2018 15:53:28] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 15:53:28] INFO [mysite:155] <QuerySet [<Post: Third one>, <Post: first post>, <Post: second bla>]>
[24/Oct/2018 15:53:28] INFO [mysite:155] <QuerySet []>
[24/Oct/2018 18:41:24] INFO [mysite:186] None
[24/Oct/2018 18:41:31] INFO [mysite:186] bla
[24/Oct/2018 18:42:12] INFO [mysite:186] avoiddouble
[24/Oct/2018 18:42:20] INFO [mysite:186] hi
[24/Oct/2018 18:56:30] INFO [mysite:158] <QuerySet [<Tag: bamberg>, <Tag: test>]>
[24/Oct/2018 18:56:30] INFO [mysite:161] <QuerySet []>
[24/Oct/2018 18:56:30] INFO [mysite:161] <QuerySet [<Post: Third one>, <Post: first post>, <Post: second bla>]>
[24/Oct/2018 18:56:45] INFO [mysite:190] None
[24/Oct/2018 18:56:49] INFO [mysite:190] bamberg
[24/Oct/2018 18:57:29] INFO [mysite:189] bamberg
[24/Oct/2018 19:00:30] INFO [mysite:189] None
[24/Oct/2018 19:00:30] INFO [mysite:191] <QuerySet []>
[24/Oct/2018 19:00:33] INFO [mysite:189] hi
[24/Oct/2018 19:00:33] INFO [mysite:191] <QuerySet [<Post: second bla>, <Post: Third one>]>
[24/Oct/2018 19:00:38] INFO [mysite:189] bamberg
[24/Oct/2018 19:00:38] INFO [mysite:191] <QuerySet []>
[24/Oct/2018 19:00:54] INFO [mysite:189] bamberg
[24/Oct/2018 19:00:54] INFO [mysite:191] <QuerySet []>
[24/Oct/2018 19:01:16] INFO [mysite:189] test
[24/Oct/2018 19:01:16] INFO [mysite:191] <QuerySet [<Post: second bla>, <Post: first post>, <Post: Third one>]>
[24/Oct/2018 19:01:20] INFO [mysite:189] third
[24/Oct/2018 19:01:20] INFO [mysite:191] <QuerySet [<Post: Third one>]>
[24/Oct/2018 19:01:35] INFO [mysite:189] None
[24/Oct/2018 19:01:35] INFO [mysite:191] <QuerySet []>
[24/Oct/2018 19:01:40] INFO [mysite:189] bamberg
[24/Oct/2018 19:01:40] INFO [mysite:191] <QuerySet []>
[24/Oct/2018 19:03:03] INFO [mysite:189] None
[24/Oct/2018 19:03:03] INFO [mysite:191] <QuerySet []>
[24/Oct/2018 19:03:08] INFO [mysite:189] bamberg
[24/Oct/2018 19:03:08] INFO [mysite:191] <QuerySet []>
[24/Oct/2018 19:03:28] INFO [mysite:189] bamberg
[24/Oct/2018 19:03:28] INFO [mysite:191] <QuerySet [<Post: Third one>]>
[24/Oct/2018 19:03:45] INFO [mysite:189] bamberg
[24/Oct/2018 19:03:45] INFO [mysite:191] <QuerySet [<Post: Third one>, <Post: here i go again>]>

Loading…
Cancel
Save