Compare commits
No commits in common. "main" and "fix-summaries" have entirely different histories.
main
...
fix-summar
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,5 @@
|
||||||
/data
|
/data
|
||||||
fixtures
|
fixtures
|
||||||
/static
|
/static
|
||||||
.env
|
|
||||||
.env.dev
|
.env.dev
|
||||||
z_README_Hugh.md
|
z_README_Hugh.md
|
59
README.md
59
README.md
|
@ -5,18 +5,17 @@ A django app running on Docker. Replaces _Aus GLAM Blogs_.
|
||||||
## Deploy
|
## Deploy
|
||||||
|
|
||||||
* `cp .env.example .env` and enter env values for your app
|
* `cp .env.example .env` and enter env values for your app
|
||||||
* set up web server config (see nginx example)
|
* set up web server config (nginx example coming soon)
|
||||||
* `docker compose build`
|
* `docker compose build`
|
||||||
* `./glamr-dev migrate` (you may get an error at this point - ignore)
|
* `./glamr-dev migrate`
|
||||||
* `./glamr-dev createsuperuser`
|
* `./glamr-dev createsuperuser`
|
||||||
* `./glamr-dev collectstatic`
|
|
||||||
* copy static files to where your webserver can find them, e.g.`/srv/ausglamr`
|
|
||||||
* `docker compose up -d`
|
* `docker compose up -d`
|
||||||
* set up cron jobs for management commands as outlined below
|
* set up database backups (as cron jobs): `./glamr-dev backup`:
|
||||||
|
* set up cron jobs for management commands as below
|
||||||
|
|
||||||
## Admin
|
## Admin
|
||||||
|
|
||||||
Don't forget to add some **Content Warnings** for use by the Mastodon bot, within `/admin`.
|
Don't forget to add some Content Warnings for use by the Mastodon bot, within `/admin`.
|
||||||
|
|
||||||
## CLI tool
|
## CLI tool
|
||||||
|
|
||||||
|
@ -60,9 +59,9 @@ These will not be triggered within the app - they should be called via cron jobs
|
||||||
|
|
||||||
### announce
|
### announce
|
||||||
|
|
||||||
This posts the next queued announcement on Mastodon.
|
This announces the next queued announcement on Mastodon.
|
||||||
|
|
||||||
Run about every 20 mins.
|
Run every 21 mins.
|
||||||
|
|
||||||
### check_feeds
|
### check_feeds
|
||||||
|
|
||||||
|
@ -84,46 +83,8 @@ Does what you think. Creates a weekly email of the latest stuff, and send to eve
|
||||||
|
|
||||||
Run weekly.
|
Run weekly.
|
||||||
|
|
||||||
## Backups
|
### Backups
|
||||||
|
|
||||||
### Creating backups
|
There is a `backup` command in `glamr-dev`. You can adjust the filepaths in your `.env` file.
|
||||||
|
|
||||||
There is a `backup` command in `glamr-dev`. The backup is named after the current day of the week, so in effect there will be a maximum of 7 rotating backups. The backup command relies on two environment variables: `DOCKER_PATH` and `BACKUPS_DIR` - you need to set these in your `.env` if you plan to run backups manually, but if you are running it with a cron job (recommended) you need to set environment variables within the crontab itself. See more details below.
|
Run daily
|
||||||
|
|
||||||
### Restoring backups
|
|
||||||
|
|
||||||
1. back up your VPS if possible (e.g. taking a snapshot)
|
|
||||||
2. Locate the latest backup, or run the backup program: `./glamr-dev backup`
|
|
||||||
3. copy database dump into the container: `docker cp ~/ausglamr.dump ausglamr-db-1:/tmp/`
|
|
||||||
4. restore the dump: `docker exec -d ausglamr-db-1 pg_restore -c -e -U ausglamr -d ausglamr /tmp/ausglamr.dump`
|
|
||||||
|
|
||||||
## Cron jobs
|
|
||||||
|
|
||||||
The obvious way to run the management and backup commands is via cron jobs. It's important to note that environment variables generally need to be set within the crontab - you can't rely on passing them in from Ausglamr nor from a user context. If you forget to to this they will be blank and one of the bad things that will happen is cron will try and fail to run the Unix program `exec` instead of `docker exec` when trying to run backups.
|
|
||||||
|
|
||||||
Below are suggested crontab settings and jobs for Ausglamr.
|
|
||||||
|
|
||||||
```
|
|
||||||
# Aus GLAMR
|
|
||||||
# ---------
|
|
||||||
|
|
||||||
# envs
|
|
||||||
PATH=/bin:/usr/bin:/usr/local/bin:/snap/bin
|
|
||||||
DOCKER_PATH=/usr/bin/docker
|
|
||||||
BACKUPS_DIR=/home/ausglamr/backups
|
|
||||||
|
|
||||||
# Announce thrice an hour
|
|
||||||
1,23,47 * * * * cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev announce
|
|
||||||
|
|
||||||
# Check feeds hourly on the eleventh minute
|
|
||||||
11 * * * * cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev check_feeds
|
|
||||||
|
|
||||||
# Queue event announcements daily at 4:01am
|
|
||||||
1 4 * * * cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev queue_announcements
|
|
||||||
|
|
||||||
# Run backups daily - 1:01am
|
|
||||||
1 1 * * * cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev backup
|
|
||||||
|
|
||||||
# Send email weekly at 12:05pm
|
|
||||||
5 12 * * 1 cd /home/ausglamr/ausglamr && /home/ausglamr/ausglamr/glamr-dev send_weekly_email
|
|
||||||
```
|
|
|
@ -131,7 +131,6 @@ class Blog(admin.ModelAdmin):
|
||||||
"active",
|
"active",
|
||||||
)
|
)
|
||||||
ordering = ["approved", "-suspended", "-failing"]
|
ordering = ["approved", "-suspended", "-failing"]
|
||||||
search_fields = ["title", "author_name", "url"]
|
|
||||||
actions = [approve, unapprove, suspend, unsuspend, activate, disable]
|
actions = [approve, unapprove, suspend, unsuspend, activate, disable]
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,7 +140,6 @@ class Article(admin.ModelAdmin):
|
||||||
|
|
||||||
date_hierarchy = "pubdate"
|
date_hierarchy = "pubdate"
|
||||||
list_display = ("title", "blog_title", "pubdate")
|
list_display = ("title", "blog_title", "pubdate")
|
||||||
search_fields = ["title", "author_name", "blog_title", "url"]
|
|
||||||
|
|
||||||
def blog_title(self, obj): # pylint: disable=no-self-use
|
def blog_title(self, obj): # pylint: disable=no-self-use
|
||||||
"""get the title of the parent blog"""
|
"""get the title of the parent blog"""
|
||||||
|
@ -153,7 +151,7 @@ class Tag(admin.ModelAdmin):
|
||||||
"""display settings for tags"""
|
"""display settings for tags"""
|
||||||
|
|
||||||
list_display = ("name",)
|
list_display = ("name",)
|
||||||
search_fields = ["name"]
|
|
||||||
|
|
||||||
@admin.register(models.Event)
|
@admin.register(models.Event)
|
||||||
class Event(admin.ModelAdmin):
|
class Event(admin.ModelAdmin):
|
||||||
|
@ -168,7 +166,6 @@ class Event(admin.ModelAdmin):
|
||||||
"start_date",
|
"start_date",
|
||||||
)
|
)
|
||||||
ordering = ["approved", "announcements"]
|
ordering = ["approved", "announcements"]
|
||||||
search_fields = ["name", "description", "url"]
|
|
||||||
actions = [approve, unapprove]
|
actions = [approve, unapprove]
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,7 +176,6 @@ class CallForPapers(admin.ModelAdmin):
|
||||||
list_display = ("name", "event", "approved", "closing_date")
|
list_display = ("name", "event", "approved", "closing_date")
|
||||||
list_select_related = ("event",)
|
list_select_related = ("event",)
|
||||||
ordering = ["approved", "closing_date"]
|
ordering = ["approved", "closing_date"]
|
||||||
search_fields = ["event__name", "event__url", "details"]
|
|
||||||
actions = [approve, unapprove]
|
actions = [approve, unapprove]
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,7 +185,6 @@ class Group(admin.ModelAdmin):
|
||||||
|
|
||||||
list_display = ("name", "approved", "category", "description")
|
list_display = ("name", "approved", "category", "description")
|
||||||
ordering = ["approved", "name"]
|
ordering = ["approved", "name"]
|
||||||
search_fields = ["name", "description", "url"]
|
|
||||||
actions = [approve, unapprove]
|
actions = [approve, unapprove]
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,7 +200,6 @@ class Newsletter(admin.ModelAdmin):
|
||||||
"active",
|
"active",
|
||||||
)
|
)
|
||||||
ordering = ["approved", "-failing"]
|
ordering = ["approved", "-failing"]
|
||||||
search_fields = ["name", "description", "url", "author_name"]
|
|
||||||
actions = [approve, unapprove, suspend, activate, disable]
|
actions = [approve, unapprove, suspend, activate, disable]
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,7 +209,6 @@ class Edition(admin.ModelAdmin):
|
||||||
|
|
||||||
date_hierarchy = "pubdate"
|
date_hierarchy = "pubdate"
|
||||||
list_display = ("title", "newsletter_name", "pubdate")
|
list_display = ("title", "newsletter_name", "pubdate")
|
||||||
search_fields = ["title", "description", "url", "newsletter__name", "author_name"]
|
|
||||||
|
|
||||||
def newsletter_name(self, obj): # pylint: disable=no-self-use
|
def newsletter_name(self, obj): # pylint: disable=no-self-use
|
||||||
"""get the title of the parent newsletter"""
|
"""get the title of the parent newsletter"""
|
||||||
|
|
|
@ -133,11 +133,11 @@ class Command(BaseCommand):
|
||||||
for instance in cfps:
|
for instance in cfps:
|
||||||
c_date = instance.closing_date
|
c_date = instance.closing_date
|
||||||
title_string = (
|
title_string = (
|
||||||
f"<h4><a href='{instance.event.url}'>{instance.event.name} - {instance.name}</a></h4>"
|
f"<h4><a href='{instance.event.url}'>{instance.name}</a></h4>"
|
||||||
)
|
)
|
||||||
dates_string = f"<p><strong>Closes:</strong><em>{c_date:%a} {c_date.day} {c_date:%B}</em></p>"
|
dates_string = f"<p><strong>Closes:</strong><em>{c_date:%a} {c_date.day} {c_date:%B}</em></p>"
|
||||||
description_string = (
|
description_string = (
|
||||||
f"<p>{instance.details}</p><p style='margin-bottom:24px;'>{instance.event.description}</p>"
|
f"<p style='margin-bottom:24px;'>{instance.details}</p>"
|
||||||
)
|
)
|
||||||
|
|
||||||
string_list = [title_string, dates_string, description_string]
|
string_list = [title_string, dates_string, description_string]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:13
|
image: postgres:13
|
||||||
|
|
|
@ -44,9 +44,6 @@ case "$CMD" in
|
||||||
collectstatic)
|
collectstatic)
|
||||||
runweb python manage.py collectstatic
|
runweb python manage.py collectstatic
|
||||||
;;
|
;;
|
||||||
copystatic)
|
|
||||||
cp -r static /srv/ausglamr/
|
|
||||||
;;
|
|
||||||
createsuperuser)
|
createsuperuser)
|
||||||
runweb python manage.py createsuperuser --no-input
|
runweb python manage.py createsuperuser --no-input
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
server {
|
|
||||||
server_name example.com;
|
|
||||||
|
|
||||||
location = /favicon.ico {
|
|
||||||
access_log off;
|
|
||||||
log_not_found off;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /static {
|
|
||||||
autoindex on;
|
|
||||||
alias /srv/ausglamr/static;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
root html;
|
|
||||||
index index.html index.htm;
|
|
||||||
proxy_pass http://127.0.0.1:8080;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
|
||||||
root html;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +1,10 @@
|
||||||
beautifulsoup4==4.12.2
|
beautifulsoup4==4.12.2
|
||||||
gunicorn==22.0.0
|
gunicorn==22.0.0
|
||||||
Django==4.2.14
|
Django==4.2.11
|
||||||
environs==9.5.0
|
environs==9.5.0
|
||||||
feedparser==6.0.10
|
feedparser==6.0.10
|
||||||
psycopg2==2.9.5
|
psycopg2==2.9.5
|
||||||
requests==2.32.3
|
requests==2.32.0
|
||||||
|
|
||||||
# dev
|
# dev
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue