diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 6367dcaef..6f58c300a 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -478,10 +478,13 @@ def set_remote_server(user_id): get_remote_reviews.delay(user.outbox) -def get_or_create_remote_server(domain): +def get_or_create_remote_server(domain, refresh=False): """get info on a remote server""" + server = FederatedServer() try: - return FederatedServer.objects.get(server_name=domain) + server = FederatedServer.objects.get(server_name=domain) + if not refresh: + return server except FederatedServer.DoesNotExist: pass @@ -496,13 +499,15 @@ def get_or_create_remote_server(domain): application_type = data.get("software", {}).get("name") application_version = data.get("software", {}).get("version") except ConnectorException: + if server.id: + return server application_type = application_version = None - server = FederatedServer.objects.create( - server_name=domain, - application_type=application_type, - application_version=application_version, - ) + server.server_name = domain + server.application_type = application_type + server.application_version = application_version + + server.save() return server diff --git a/bookwyrm/templates/settings/federation/instance.html b/bookwyrm/templates/settings/federation/instance.html index e5ea882d1..cb6b1fc37 100644 --- a/bookwyrm/templates/settings/federation/instance.html +++ b/bookwyrm/templates/settings/federation/instance.html @@ -11,6 +11,13 @@ {% endif %} {% endblock %} +{% block edit-button %} +
+ {% csrf_token %} + +
+{% endblock %} + {% block breadcrumbs %}