wlmac / metropolis

William Lyon Mackenzie's online hub for announcements, calendar events, clubs, and timetables
https://maclyonsden.com
GNU Affero General Public License v3.0
21 stars 6 forks source link

Move get current site into bodge_replace() #172

Closed yaxollum closed 2 years ago

yaxollum commented 2 years ago

This fixes the failing GitHub Actions check.

When Site.objects.get_current() is put into the global scope, it gets evaluated whenever python manage.py <any command> is run. This is fine when a database has already been built with information about the current site, but when there is no database (when running the tests using GitHub Actions or when doing a fresh install of metropolis), there is an error:

 django.db.utils.OperationalError: no such table: django_site

By moving the call to Site.objects.get_current() into a function, this error can be prevented.

nyiyui commented 2 years ago

sorry for poking after you have made changes, but is it ok to get rid of get_current() altogether and put a constant in config.py for the host? (this is what we did for another site: https://github.com/mcpt/ctf/blob/7c7e396907c5bd24652e128da01d0dd272a10997/gameserver/templatetags/markdown_tags.py#L38 (also this might be faster? it is clearer though)

yaxollum commented 2 years ago

@nyiyui Yeah that would also work. Could you pls make the changes?

nyiyui commented 2 years ago

@nyiyui Yeah that would also work. Could you pls make the changes?

yes! (i'll try to do this week)