added topic selector to new post page
This commit is contained in:
parent
dfb3b30271
commit
81c455f014
3 changed files with 38 additions and 12 deletions
|
|
@ -1,8 +1,9 @@
|
|||
from blog.views import viewblog, addpost, createmocks
|
||||
from blog.views import viewblog, addpost, createmocks, order
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
path('', viewblog, name="index"),
|
||||
path('manage/add/', addpost, name='addpost'),
|
||||
path('manage/addpost', addpost, name='addpost'),
|
||||
path('manage/order', order, name='order'),
|
||||
path('mock/topic/<int:n>/', createmocks, name='mock'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from django.contrib.auth.decorators import login_required
|
|||
from django.http import HttpResponse
|
||||
from django.shortcuts import render, redirect
|
||||
from blog.factories import TopicFactory
|
||||
from blog.models import Topic
|
||||
|
||||
from markdownblog import settings
|
||||
|
||||
|
|
@ -12,9 +13,15 @@ def viewblog(request) -> HttpResponse:
|
|||
return render(request, 'blog/index.html', {"debug": settings.DEBUG})
|
||||
|
||||
|
||||
@login_required
|
||||
def order(request):
|
||||
return None
|
||||
|
||||
|
||||
@login_required
|
||||
def addpost(request) -> HttpResponse:
|
||||
return render(request, 'blog/addpost.html')
|
||||
context = {'alltopics': Topic.objects.all().order_by('name').values()}
|
||||
return render(request, 'blog/addpost.html', context)
|
||||
|
||||
|
||||
def createmocks(request, n) -> HttpResponse:
|
||||
|
|
|
|||
|
|
@ -14,16 +14,27 @@
|
|||
<h3 contenteditable="true" class="posttitle">Titel</h3>
|
||||
<textarea>
|
||||
</textarea>
|
||||
<div class="col s6">
|
||||
<label>
|
||||
Tags
|
||||
<input type="text">
|
||||
</label>
|
||||
<button type="submit" class="waves-effect waves-light btn">
|
||||
<i class="material-icons left">add</i>
|
||||
Create Post
|
||||
</button>
|
||||
<div class="row">
|
||||
<div class="col s6">
|
||||
<label>
|
||||
Tags
|
||||
<input type="text">
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-field col s6">
|
||||
<select>
|
||||
<option selected>No topic</option>
|
||||
{% for topic in alltopics %}
|
||||
<option value="{{ topic.id }}">{{ topic.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label>Select topic</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="waves-effect waves-light btn">
|
||||
<i class="material-icons left">add</i>
|
||||
Create Post
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -92,4 +103,11 @@
|
|||
]
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var elems = document.querySelectorAll('select');
|
||||
M.FormSelect.init(elems);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue