diff options
| author | Bobby <[email protected]> | 2022-10-02 12:18:08 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-10-02 12:18:08 -0400 |
| commit | 194c248b20c4f1e4d02c7ffd05b4a348db68ef5b (patch) | |
| tree | 090cfbcf6015d7cc4b9b6009bc001fc39ca08aa8 | |
| parent | 1e624f30c11e22699e6f6933b18a7a257a2ab73b (diff) | |
| download | thatcomputerscientist-194c248b20c4f1e4d02c7ffd05b4a348db68ef5b.tar.xz thatcomputerscientist-194c248b20c4f1e4d02c7ffd05b4a348db68ef5b.zip | |
updates section
| -rw-r--r-- | announcements/migrations/0003_rename_body_announcement_content_and_more.py | 22 | ||||
| -rw-r--r-- | announcements/models.py | 5 | ||||
| -rw-r--r-- | blog/views.py | 5 | ||||
| -rw-r--r-- | static/css/main.css | 18 | ||||
| -rw-r--r-- | static/images/gifs/announcement.gif | bin | 0 -> 361 bytes | |||
| -rw-r--r-- | static/images/gifs/new_announcement.gif | bin | 0 -> 469 bytes | |||
| -rw-r--r-- | templates/blog/home.html | 19 |
7 files changed, 56 insertions, 13 deletions
diff --git a/announcements/migrations/0003_rename_body_announcement_content_and_more.py b/announcements/migrations/0003_rename_body_announcement_content_and_more.py new file mode 100644 index 00000000..78ceb002 --- /dev/null +++ b/announcements/migrations/0003_rename_body_announcement_content_and_more.py @@ -0,0 +1,22 @@ +# Generated by Django 4.0.6 on 2022-10-02 16:06 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('announcements', '0002_rename_date_announcement_created_at'), + ] + + operations = [ + migrations.RenameField( + model_name='announcement', + old_name='body', + new_name='content', + ), + migrations.RemoveField( + model_name='announcement', + name='title', + ), + ] diff --git a/announcements/models.py b/announcements/models.py index 06dea701..c836fe5d 100644 --- a/announcements/models.py +++ b/announcements/models.py @@ -3,8 +3,7 @@ from django.conf import settings # Create your models here. class Announcement(models.Model): - title = models.CharField(max_length=100) - body = models.TextField() + content = models.TextField() created_at = models.DateTimeField(auto_now_add=True) author = models.ForeignKey( settings.AUTH_USER_MODEL, @@ -14,5 +13,5 @@ class Announcement(models.Model): is_new = models.BooleanField(default=True) def __str__(self): - return self.title + return self.content diff --git a/blog/views.py b/blog/views.py index 03d0424e..ff1566de 100644 --- a/blog/views.py +++ b/blog/views.py @@ -11,11 +11,14 @@ import base64 import json from .models import Post, Comment from .context_processors import recent_posts, categories, archives +from announcements.models import Announcement # Create your views here. def home(request): - return render(request, 'blog/home.html', {'title': 'Home', 'recent_posts': recent_posts(), 'categories': categories(), 'archives': archives()}) + announcements = Announcement.objects.filter(is_public=True).order_by('-created_at') + announcements = announcements if len(announcements) > 0 else None + return render(request, 'blog/home.html', {'title': 'Home', 'recent_posts': recent_posts(), 'categories': categories(), 'archives': archives(), 'announcements': announcements}) def account(request): user = request.user diff --git a/static/css/main.css b/static/css/main.css index 1cf23d41..4b6fde36 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -422,3 +422,21 @@ pre { padding: 10px; border-radius: 5px; } + +.announcements { + list-style: none; + padding: 0; + margin: 0; +} + +.announcements > li::before { + content: '📢'; + margin-right: 5px; + height: 16px; +} + +.announcements > li.newac::before { + content: url('../images/gifs/new_announcement.gif'); + margin-right: 5px; + height: 16px; +} diff --git a/static/images/gifs/announcement.gif b/static/images/gifs/announcement.gif Binary files differnew file mode 100644 index 00000000..57ce6d60 --- /dev/null +++ b/static/images/gifs/announcement.gif diff --git a/static/images/gifs/new_announcement.gif b/static/images/gifs/new_announcement.gif Binary files differnew file mode 100644 index 00000000..bee5fb15 --- /dev/null +++ b/static/images/gifs/new_announcement.gif diff --git a/templates/blog/home.html b/templates/blog/home.html index 7fc4bcfc..c8b0fa4f 100644 --- a/templates/blog/home.html +++ b/templates/blog/home.html @@ -27,22 +27,23 @@ </p> </div> <br /> + {% if announcements is not None %} <fieldset> <legend> <img src = "{% static 'images/gifs/update.gif' %}" height="16px"> </legend> <marquee behavior="scroll" direction="up" height="250" scrollamount="2" scrolldelay="10" onmouseover="this.stop()" onmouseout="this.start()"> - <p> - <b>2021-01-01</b> - Happy New Year! I hope you all had a great holiday - season. I am excited to announce that I have started a new blog series - called <a href="/blog/series/programming-projects">Programming - Projects</a>. This series will be a collection of posts that will - document my journey as I learn new programming languages and frameworks. - I will be using these projects to learn new skills and to build my - portfolio. I hope you enjoy this new series! - </p> + <ul class="announcements"> + {% for announcement in announcements %} + <li {% if announcement.is_new %}class="newac"{% endif %}> + <b>{{ announcement.created_at | date:"M d, Y" }}</b> {{ announcement.content }} + </li> + {% endfor %} + </ul> </marquee> </fieldset> + <br /> + {% endif %} {% if recent_posts %} <h3 style="margin-bottom: 0px"><em>Recent Posts</em></h3> <hr /> |
