Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyconbalkan/news/admin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from django.contrib import admin
from markdownx.admin import MarkdownxModelAdmin

from pyconbalkan.conference.abstractions import ConferenceAbstractAdmin
from pyconbalkan.news.models import Post


class PostAdmin(MarkdownxModelAdmin):
class PostAdmin(ConferenceAbstractAdmin, MarkdownxModelAdmin):
class Meta:
model = Post

Expand Down
21 changes: 21 additions & 0 deletions pyconbalkan/news/migrations/0008_post_conference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 2.1.7 on 2019-03-03 16:55

from django.db import migrations, models
import django.db.models.deletion
import pyconbalkan.conference.abstractions


class Migration(migrations.Migration):

dependencies = [
('conference', '0007_auto_20190227_0738'),
('news', '0007_auto_20180801_2233'),
]

operations = [
migrations.AddField(
model_name='post',
name='conference',
field=models.ForeignKey(default=pyconbalkan.conference.abstractions._get_default_conference, on_delete=django.db.models.deletion.CASCADE, to='conference.Conference'),
),
]
3 changes: 2 additions & 1 deletion pyconbalkan/news/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from markdownx.models import MarkdownxField
from taggit.managers import TaggableManager

from pyconbalkan.conference.abstractions import AbstractConference
from pyconbalkan.core.models import ActiveModel


class Post(ActiveModel):
class Post(ActiveModel, AbstractConference):
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
title = models.CharField(max_length=200)
text = MarkdownxField()
Expand Down
21 changes: 9 additions & 12 deletions pyconbalkan/news/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class PostViewSet(viewsets.ModelViewSet):


def news_view(request):
posts = Post.objects.filter(active=True, published_date__lte=timezone.now())
context = {
'news': posts,
}
return render(request, 'news.html', context)
posts = Post.objects.filter(
active=True, published_date__lte=timezone.now(), conference=request.conference
)
context = {"news": posts}
return render(request, "news.html", context)


def post_detail(request, slug):
Expand All @@ -29,12 +29,9 @@ def post_detail(request, slug):
keywords=post.keywords.names(),
image=post.image.url,
extra_props={
'viewport': 'width=device-width, initial-scale=1.0, minimum-scale=1.0'
}
"viewport": "width=device-width, initial-scale=1.0, minimum-scale=1.0"
},
)

context = {
'post': post,
'meta': meta,
}
return render(request, 'post.html', context)
context = {"post": post, "meta": meta}
return render(request, "post.html", context)