Skip to content

Commit 8ad62ef

Browse files
authored
Merge pull request #142 from PythonBalkan/bojan/news_old_year
Added news per conference
2 parents 64e724e + cf87834 commit 8ad62ef

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

pyconbalkan/news/admin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from django.contrib import admin
22
from markdownx.admin import MarkdownxModelAdmin
33

4+
from pyconbalkan.conference.abstractions import ConferenceAbstractAdmin
45
from pyconbalkan.news.models import Post
56

67

7-
class PostAdmin(MarkdownxModelAdmin):
8+
class PostAdmin(ConferenceAbstractAdmin, MarkdownxModelAdmin):
89
class Meta:
910
model = Post
1011

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 2.1.7 on 2019-03-03 16:55
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
import pyconbalkan.conference.abstractions
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('conference', '0007_auto_20190227_0738'),
12+
('news', '0007_auto_20180801_2233'),
13+
]
14+
15+
operations = [
16+
migrations.AddField(
17+
model_name='post',
18+
name='conference',
19+
field=models.ForeignKey(default=pyconbalkan.conference.abstractions._get_default_conference, on_delete=django.db.models.deletion.CASCADE, to='conference.Conference'),
20+
),
21+
]

pyconbalkan/news/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from markdownx.models import MarkdownxField
44
from taggit.managers import TaggableManager
55

6+
from pyconbalkan.conference.abstractions import AbstractConference
67
from pyconbalkan.core.models import ActiveModel
78

89

9-
class Post(ActiveModel):
10+
class Post(ActiveModel, AbstractConference):
1011
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
1112
title = models.CharField(max_length=200)
1213
text = MarkdownxField()

pyconbalkan/news/views.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class PostViewSet(viewsets.ModelViewSet):
1414

1515

1616
def news_view(request):
17-
posts = Post.objects.filter(active=True, published_date__lte=timezone.now())
18-
context = {
19-
'news': posts,
20-
}
21-
return render(request, 'news.html', context)
17+
posts = Post.objects.filter(
18+
active=True, published_date__lte=timezone.now(), conference=request.conference
19+
)
20+
context = {"news": posts}
21+
return render(request, "news.html", context)
2222

2323

2424
def post_detail(request, slug):
@@ -29,12 +29,9 @@ def post_detail(request, slug):
2929
keywords=post.keywords.names(),
3030
image=post.image.url,
3131
extra_props={
32-
'viewport': 'width=device-width, initial-scale=1.0, minimum-scale=1.0'
33-
}
32+
"viewport": "width=device-width, initial-scale=1.0, minimum-scale=1.0"
33+
},
3434
)
3535

36-
context = {
37-
'post': post,
38-
'meta': meta,
39-
}
40-
return render(request, 'post.html', context)
36+
context = {"post": post, "meta": meta}
37+
return render(request, "post.html", context)

0 commit comments

Comments
 (0)