Overview
The content management system allows administrators to create and publish articles, upload newsletter PDFs, and post announcements to keep students informed and engaged.Article Management
Articles are rich-text content pieces that can be blog posts, educational content, or news items.Creating Articles
Navigate to Admin Dashboard > Manage Articles > Create Article.ArticleForm Fields
TheArticleForm (forms.py:231-260) requires:
- title - Article title (1-100 characters, required)
- author - Article author name (1-100 characters, required)
- content - Rich text content using CKEditor (required)
- type - Select “article” or “newsletter” (required)
- file - PDF file upload (for newsletters only, optional)
Article vs Newsletter
The platform supports two content types: Articles:- Text-based content with HTML formatting
- No file upload
- Rendered directly on the site
- Used for blog posts, news, tutorials
- Can have rich text content AND/OR a PDF file
- PDF stored in
uploads/newsletters/folder - Filename format:
newsletter_YYYY_MM_originalname.pdf - Used for monthly newsletters, reports, bulletins
Article Data Model
TheArticle model (models.py:175-200) stores:
Creating Articles
Seecreate_article() in routes.py:221-269:
- Form validation
- Article object created with:
- Title, content, author from form
user_idset tocurrent_user.idtypefrom form selectiondate_postedset to now
- If PDF file uploaded:
- Newsletters folder created if needed
- File saved with timestamp prefix:
newsletter_YYYY_MM_filename.pdf - Filename stored in
file_url
- Article committed to database
File Upload Handling
Newsletter PDFs are handled specially:Editing Articles
Navigate to Manage Articles and click Edit next to any article.Editable Fields
All fields can be modified:- Title
- Content
- Author name
- Type (article/newsletter)
- PDF file (for newsletters)
edit_article() in routes.py:285-343.
Replacing Newsletter PDFs
When uploading a new PDF:- Old PDF file is deleted from disk (routes.py:311-315)
- New PDF is uploaded
- New filename stored in
file_url
If the old file doesn’t exist, the deletion fails silently to prevent errors.
Pre-populating the Form
On GET requests, the form is pre-filled with existing article data (routes.py:332-336).Deleting Articles
Deleting an article:- Removes the database record
- Deletes the PDF file if it’s a newsletter
- Redirects to the article list
delete_article() in routes.py:346-379.
File Cleanup
The system attempts to delete the PDF file but logs a warning if it fails (routes.py:363-368):Managing Articles
The article management interface displays all articles ordered by date (newest first).Viewing Articles
Access via/admin/articles (routes.py:272-282).
Shows:
- Article title
- Author name
- Type (article/newsletter)
- Date posted
- Actions (Edit, Delete)
Article Listing Query
CKEditor Integration
Article content uses CKEditor for rich text editing.Rich Text Features
Supported formatting:- Headings, paragraphs
- Bold, italic, underline
- Lists (ordered and unordered)
- Links
- Images (via upload)
- Code blocks
- Tables
Image Uploads in Content
The CKEditor upload endpoint handles embedded images. Seeupload() in routes.py:677-704:
- Receives image from CKEditor
- Validates file extension (jpg, jpeg, png, gif only)
- Saves to
UPLOAD_FOLDERusingsecure_filename() - Returns URL for embedding:
/static/uploads/{filename}
Upload Validation
Announcement Management
Announcements are simpler content items for quick updates.Creating Announcements
Navigate to Admin Dashboard > Manage Announcements > Create Announcement.AnnouncementForm Fields
TheAnnouncementForm (forms.py:371-387) requires:
- title - Announcement title (required)
- content - Rich text content using CKEditor (required)
- Author field (implied to be admin)
- File uploads
- Type selection
Announcement Data Model
TheAnnouncement model (models.py:227-236):
Creating Announcements
Seecreate_announcement() in routes.py:1621-1646:
- Form validation
- Announcement created with title, content, and auto-set timestamp
- Saved to database
- Redirect to announcements list
Editing Announcements
Edit via/admin/announcements/edit/<announcement_id> (routes.py:1649-1677).
Only title and content can be modified. Date posted is not editable.
Deleting Announcements
Delete via/admin/announcements/delete/<announcement_id> (routes.py:1680-1699).
Deletion is permanent with no associated files to clean up.
Managing Announcements
View all announcements at/admin/announcements (routes.py:1606-1618).
Announcements are ordered by date posted (newest first):
Content Organization
Article Types
Articles are categorized by type:- article - Regular blog posts and content
- newsletter - Monthly newsletters with optional PDFs
Article.type field (indexed for performance).
Content Relationships
Articles track their creators:- Auditing who created content
- Crediting external authors via
named_creator - Tracking admin content creation activity
File Storage Structure
Newsletter Folder
Created automatically when first newsletter is uploaded (routes.py:246-249):File Security
All filenames are sanitized usingsecure_filename() from Werkzeug (routes.py:142):
- Directory traversal attacks
- Special character issues
- Filename injection
Content Display
Articles and announcements are displayed to students on the main site.Article URLs
- List view:
/articles - Detail view:
/articles/<id>
Announcement Display
- Announcements typically shown on homepage or dedicated announcements page
- Ordered by date (newest first)
PDF Access
Newsletter PDFs are served via:Best Practices
- Use descriptive article titles for better SEO
- Set meaningful author names (can differ from logged-in admin)
- Compress PDF files before uploading to save bandwidth
- Use announcements for urgent, short updates
- Use articles for longer, evergreen content
- Test CKEditor formatting before publishing
- Keep newsletter filenames simple and descriptive
- Archive old content periodically
Common Workflows
Publishing a Monthly Newsletter
Create Newsletter
- Navigate to Create Article
- Set type to “newsletter”
- Enter title: “March 2024 Newsletter”
- Enter author name
- Add summary in content field
- Upload PDF file
Creating an Announcement
Compose
- Enter clear, concise title
- Write announcement content (keep it brief)
- Use formatting for emphasis
Error Handling
The system includes comprehensive error handling:File Upload Errors
- Invalid file types are rejected
- IOError during save triggers rollback (routes.py:262-265)
- Missing folders are created automatically
Database Errors
- All database operations wrapped in try-except
- SQLAlchemyError triggers rollback
- Errors logged for debugging
- User-friendly error messages displayed
Related Routes
- Manage Articles:
/admin/articles(routes.py:272) - Create Article:
/admin/articles/create(routes.py:221) - Edit Article:
/admin/articles/edit/<id>(routes.py:285) - Delete Article:
/admin/articles/delete/<id>(routes.py:346) - Manage Announcements:
/admin/announcements(routes.py:1606) - Create Announcement:
/admin/announcements/create(routes.py:1621) - Edit Announcement:
/admin/announcements/edit/<id>(routes.py:1649) - Delete Announcement:
/admin/announcements/delete/<id>(routes.py:1680) - CKEditor Upload:
/admin/upload(routes.py:677)