diff --git a/docker-site/main/admin.py b/docker-site/main/admin.py index 3d1d346..3845ee2 100644 --- a/docker-site/main/admin.py +++ b/docker-site/main/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import UserProfile, Category, Post, Project, PublicationIRIS, UserProfilePublicationIRIS, IRISImportLog, MeetingRoom, RoomReservation, ShortLink, HistoryMilestone, ResearchArea, DashboardCard, ExternalRedirects, WikiPage, WikiPageVersion, WikiPageChangeRequest, WikiImage +from .models import UserProfile, Category, Post, PostAttachment, Project, PublicationIRIS, UserProfilePublicationIRIS, IRISImportLog, MeetingRoom, RoomReservation, ShortLink, HistoryMilestone, ResearchArea, DashboardCard, ExternalRedirects, WikiPage, WikiPageVersion, WikiPageChangeRequest, WikiImage admin.site.site_header = "AImageLab Admin" admin.site.site_title = "AImageLab Admin" @@ -44,7 +44,15 @@ class CategoryAdmin(admin.ModelAdmin): pass class PostAdmin(admin.ModelAdmin): - pass + search_fields = ('title', 'slug', 'description', 'content') + + +@admin.register(PostAttachment) +class PostAttachmentAdmin(admin.ModelAdmin): + list_display = ('name', 'post', 'uploaded_at') + list_filter = ('uploaded_at',) + search_fields = ('name', 'post__title') + autocomplete_fields = ['post'] class ProjectAdmin(admin.ModelAdmin): list_display = ('title', 'name', 'project_type', 'start_date', 'end_date') diff --git a/docker-site/main/migrations/0013_postattachment.py b/docker-site/main/migrations/0013_postattachment.py new file mode 100644 index 0000000..e457e36 --- /dev/null +++ b/docker-site/main/migrations/0013_postattachment.py @@ -0,0 +1,27 @@ +# Generated by Django 5.2.11 on 2026-05-02 00:00 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0012_externalredirects'), + ] + + operations = [ + migrations.CreateModel( + name='PostAttachment', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(help_text='Display name for this attachment', max_length=200)), + ('file', models.FileField(help_text='Attachment file', upload_to='news_attachments/%Y/%m/')), + ('uploaded_at', models.DateTimeField(auto_now_add=True)), + ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='main.post')), + ], + options={ + 'ordering': ['name', '-uploaded_at'], + }, + ), + ] diff --git a/docker-site/main/models.py b/docker-site/main/models.py index 986a33a..50d87ed 100644 --- a/docker-site/main/models.py +++ b/docker-site/main/models.py @@ -345,6 +345,21 @@ def __str__(self): return self.title +class PostAttachment(models.Model): + """Named file attachment for a news post.""" + + post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='attachments') + name = models.CharField(max_length=200, help_text="Display name for this attachment") + file = models.FileField(upload_to='news_attachments/%Y/%m/', help_text="Attachment file") + uploaded_at = models.DateTimeField(auto_now_add=True) + + class Meta: + ordering = ['name', '-uploaded_at'] + + def __str__(self): + return f"{self.name} ({self.post.title})" + + class ShortLink(models.Model): """Short URL redirect model (Go links)""" diff --git a/docker-site/main/templates/main/contacts.html b/docker-site/main/templates/main/contacts.html index 4524f81..bca037d 100644 --- a/docker-site/main/templates/main/contacts.html +++ b/docker-site/main/templates/main/contacts.html @@ -18,13 +18,13 @@

Connect with Us

- LinkedIn + LinkedIn - GitHub + GitHub - YouTube + YouTube
diff --git a/docker-site/main/templates/main/post_edit.html b/docker-site/main/templates/main/post_edit.html index c9f1afc..8ebe167 100644 --- a/docker-site/main/templates/main/post_edit.html +++ b/docker-site/main/templates/main/post_edit.html @@ -102,6 +102,33 @@