diff --git a/generators/all_posts.py b/generators/all_posts.py index 05aae5d..86ff91f 100644 --- a/generators/all_posts.py +++ b/generators/all_posts.py @@ -60,6 +60,8 @@ class AllPosts(Index): cur_posts.append(p) continue + cur_posts = cur_posts.reverse() + month_elem = self.createElement(dom, 'month') month_def = dom.createElement('month') month_def.appendChild(dom.createTextNode(cur_posts[0].creation_date.strftime(date_format))) @@ -80,6 +82,7 @@ class AllPosts(Index): # Last month if not month_elem is None and len(cur_posts) != 0: + cur_posts = cur_posts.reverse() month_elem = self.createElement(dom, 'month') month_def = dom.createElement('month') month_def.appendChild(dom.createTextNode(cur_posts[0].creation_date.strftime(date_format))) diff --git a/static/js/dynastie.js b/static/js/dynastie.js index f217f98..73d7064 100644 --- a/static/js/dynastie.js +++ b/static/js/dynastie.js @@ -50,3 +50,21 @@ function previewPost(blog_id) form.action = action; form.target = target; } + +function addTag() +{ + text_tags = document.getElementById('id_text_tags'); + avail_tags = document.getElementById('available_tags'); + + cur_elem = avail_tags.selectedIndex; + + cur_elem = (cur_elem >= 0) ? avail_tags.options[cur_elem].value : ""; + + if(cur_elem != "" && text_tags.value.indexOf(cur_elem) == -1) + { + if (text_tags.value.length > 0) + text_tags.value += ", " + cur_elem; + else + text_tags.value = cur_elem; + } +} \ No newline at end of file diff --git a/templates/add_post.html b/templates/add_post.html index 3ce151d..1843289 100644 --- a/templates/add_post.html +++ b/templates/add_post.html @@ -11,6 +11,12 @@ {% block content %}
{% csrf_token %} {{ form.as_p }} +Available tags: + +

diff --git a/templates/edit_post.html b/templates/edit_post.html index 983c814..bf06763 100644 --- a/templates/edit_post.html +++ b/templates/edit_post.html @@ -11,6 +11,12 @@ {% block content %}
{% csrf_token %} {{ form.as_p }} +Available tags: + +
diff --git a/views.py b/views.py index 0592e9c..f19392e 100644 --- a/views.py +++ b/views.py @@ -431,7 +431,10 @@ def add_post(request, blog_id): else: form = PostForm() - return render(request, 'add_post.html', {'form': form, 'blog_id' : blog_id}) + return render(request, 'add_post.html', { + 'form': form, 'blog_id' : blog_id, + 'all_tags' : Tag.objects.all() + }) @login_required def edit_post(request, post_id): @@ -469,10 +472,10 @@ def edit_post(request, post_id): comment_list = [] for comment in comments: comment_list.append(comment) - return render(request, 'edit_post.html', { 'form': form, 'post_id' : post_id, 'content' : content, - 'blog_id' : blog_id, 'comments' : comment_list + 'blog_id' : blog_id, 'comments' : comment_list, + 'all_tags' : Tag.objects.all() }) @login_required