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
|
from django.urls import path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', viewblog, name="index"),
|
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'),
|
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.http import HttpResponse
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from blog.factories import TopicFactory
|
from blog.factories import TopicFactory
|
||||||
|
from blog.models import Topic
|
||||||
|
|
||||||
from markdownblog import settings
|
from markdownblog import settings
|
||||||
|
|
||||||
|
|
@ -12,9 +13,15 @@ def viewblog(request) -> HttpResponse:
|
||||||
return render(request, 'blog/index.html', {"debug": settings.DEBUG})
|
return render(request, 'blog/index.html', {"debug": settings.DEBUG})
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def order(request):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def addpost(request) -> HttpResponse:
|
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:
|
def createmocks(request, n) -> HttpResponse:
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,27 @@
|
||||||
<h3 contenteditable="true" class="posttitle">Titel</h3>
|
<h3 contenteditable="true" class="posttitle">Titel</h3>
|
||||||
<textarea>
|
<textarea>
|
||||||
</textarea>
|
</textarea>
|
||||||
<div class="col s6">
|
<div class="row">
|
||||||
<label>
|
<div class="col s6">
|
||||||
Tags
|
<label>
|
||||||
<input type="text">
|
Tags
|
||||||
</label>
|
<input type="text">
|
||||||
<button type="submit" class="waves-effect waves-light btn">
|
</label>
|
||||||
<i class="material-icons left">add</i>
|
</div>
|
||||||
Create Post
|
<div class="input-field col s6">
|
||||||
</button>
|
<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>
|
</div>
|
||||||
|
<button type="submit" class="waves-effect waves-light btn">
|
||||||
|
<i class="material-icons left">add</i>
|
||||||
|
Create Post
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
@ -92,4 +103,11 @@
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
var elems = document.querySelectorAll('select');
|
||||||
|
M.FormSelect.init(elems);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue