Compare commits

...

3 Commits

4 changed files with 41 additions and 11 deletions

9
TODO.md Normal file
View File

@ -0,0 +1,9 @@
# News
TODO: Add the header image into the news item list view.
TODO: Add the header image into the news item detail view.
TODO: Add the origin text into the news item list view.
TODO: Add the origin text into the news item detail view.
TODO: Create a RedirectView for the origin link.
TODO: On clicking the origin link, add one to the origin followed count.

View File

@ -0,0 +1,23 @@
# Generated by Django 5.2.8 on 2025-11-10 19:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("news", "0001_initial"),
]
operations = [
migrations.AddField(
model_name="newsitem",
name="origin_text",
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name="newsitem",
name="origin_times_followed",
field=models.PositiveIntegerField(default=0),
),
]

View File

@ -33,8 +33,9 @@ class NewsItem(models.Model):
Category, on_delete=models.PROTECT, related_name="news_items"
)
body = MarkdownxField()
origin_text = models.CharField(max_length=200, blank=True, null=True)
origin_link = models.URLField(blank=True, null=True)
origin_times_followed = models.PositiveIntegerField()
origin_times_followed = models.PositiveIntegerField(default=0)
header_img = models.ImageField(blank=True, null=True)
tags = TagField(
force_lowercase=True,

View File

@ -5,11 +5,6 @@
{% if object_list %}
{% if category %}
<h3>{{ category }} News</h3>
<!-- {% if category.introduction %} -->
<!-- <div> -->
<!-- <p>{{ category.introduction }}</p> -->
<!-- </div> -->
<!-- {% endif %} -->
{% elif tag %}
<h3>News for tag: {{ tag }}</h3>
{% else %}
@ -17,14 +12,16 @@
{% endif %}
<hr>
<div>
{% for news in object_list %}
{% for newsitem in object_list %}
<div>
<a href="{{ news.get_absolute_url }}">{{ news.title }}</a>
<hr >
<a href="{{ newsitem.get_absolute_url }}">{{ newsitem.title }}</a>
<hr>
{{ newsitem.body_as_markdown|safe }}
<hr>
<div>
<span>
<a href="{% url 'news:list_category' category=news.category.slug %}">{{ news.category }} </a>
&bull; {{ news.created | date:'jS \o\f F, Y' }}
<a href="{% url 'news:list_category' category=newsitem.category.slug %}">{{ newsitem.category }} </a>
&bull; {{ newsitem.created_at | date:'jS \o\f F, Y' }}
</span>
<span>{% include 'news/includes/display_tags.html' %}</span>
</div>