no functional changes:
update format
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
from django.contrib import admin
|
||||
import django.contrib.auth.admin
|
||||
import django.contrib.auth.models
|
||||
import taggit.admin
|
||||
|
||||
from django.contrib import admin, auth
|
||||
|
||||
from .models import Post, Event, News, FetMeeting
|
||||
from .forms import MyPostForm, MyEventForm, MyNewsForm, MyFetMeetingForm
|
||||
|
||||
import django.contrib.auth.admin
|
||||
import django.contrib.auth.models
|
||||
from django.contrib import auth
|
||||
|
||||
admin.site.unregister(auth.models.User)
|
||||
admin.site.unregister(auth.models.Group)
|
||||
import taggit.admin
|
||||
#import taggit.models
|
||||
|
||||
admin.site.unregister(taggit.models.Tag)
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from django import forms
|
||||
from ckeditor_uploader.widgets import CKEditorUploadingWidget
|
||||
from django import forms
|
||||
|
||||
from .models import Post, Event, News, FetMeeting
|
||||
|
||||
|
||||
class MyPostForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Post
|
||||
@@ -19,8 +20,7 @@ class MyPostForm(forms.ModelForm):
|
||||
class MyNewsForm(MyPostForm):
|
||||
class Meta:
|
||||
model = News
|
||||
fields = ['title','subtitle','tags', 'image','body',
|
||||
'slug','author']
|
||||
fields = ['title', 'subtitle', 'tags', 'image', 'body', 'slug', 'author']
|
||||
|
||||
widgets = {'body': CKEditorUploadingWidget(config_name='default')}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns=[
|
||||
path('func/tag_complete', views.tag_complete),
|
||||
path('func/slug_calc', views.slug_calc),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from collections import deque
|
||||
|
||||
from .models import Post, PostSerializer
|
||||
@@ -12,7 +12,7 @@ from django.core.cache import cache
|
||||
|
||||
from django.utils.text import slugify
|
||||
from django.utils import timezone
|
||||
from django.http import JsonResponse
|
||||
|
||||
|
||||
def get_next_dict():
|
||||
posts = Post.article_objects.order_by('-public_date').values('slug')
|
||||
@@ -43,8 +43,13 @@ def show(request,id=None):
|
||||
p = Post.objects.get(id=int(id))
|
||||
elif id != "" and not id is None:
|
||||
p = Post.objects.get(slug=(id))
|
||||
similar_posts = p.tags.similar_objects()
|
||||
return render(request, 'posts/show.html', {"post":p,"next":get_next_dict().get(p.slug,None), "related_posts": similar_posts})
|
||||
|
||||
context = {
|
||||
"post": p,
|
||||
"next": get_next_dict().get(p.slug,None),
|
||||
"related_posts": p.tags.similar_objects()
|
||||
}
|
||||
return render(request, 'posts/show.html', context)
|
||||
|
||||
# Ajax function that is called to calculate a slug from the title
|
||||
def slug_calc(request):
|
||||
@@ -89,5 +94,6 @@ class PostViewSet(viewsets.ModelViewSet):
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['legacy_id', 'slug','legacy_rubrik_id']
|
||||
lookup_field = 'slug'
|
||||
|
||||
def pre_save(self, obj):
|
||||
obj.image = self.request.FILES.get('image')
|
||||
|
||||
Reference in New Issue
Block a user