tt-rss: Allow selection of a domain name

Fixes: #2136

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[james: Fix comment]
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati authored and James Valleroy committed 2021-11-21 19:10:54 -05:00
1 parent a912c867c8
commit aaea6bf00e
4 files changed
+79 -7

No files matched your search

+18
View File
@@ -102,6 +102,13 @@ class TTRSSApp(app_module.App):
super().enable()
actions.superuser_run('ttrss', ['enable-api-access'])
# Try to set the domain to one of the available TLS domains
domain = get_domain()
if not domain or domain == 'localhost':
from plinth.modules import names
domain = next(names.get_available_tls_domains(), None)
set_domain(domain)
class TTRSSBackupRestore(BackupRestore):
"""Component to backup/restore TT-RSS"""
@@ -136,3 +143,14 @@ def force_upgrade(helper, packages):
helper.install(['tt-rss'], force_configuration='new')
actions.superuser_run('ttrss', ['setup'])
return True
def get_domain():
"""Read TLS domain from tt-rss config file."""
return actions.superuser_run('ttrss', ['get-domain']).strip()
def set_domain(domain):
"""Set the TLS domain in tt-rss configuration file."""
if domain:
actions.superuser_run('ttrss', ['set-domain', domain])
+2 -4
View File
@@ -5,8 +5,6 @@ URLs for the Tiny Tiny RSS module.
from django.urls import re_path
from plinth.views import AppView
from .views import TTRSSAppView
urlpatterns = [
re_path(r'^apps/ttrss/$', AppView.as_view(app_id='ttrss'), name='index')
]
urlpatterns = [re_path(r'^apps/ttrss/$', TTRSSAppView.as_view(), name='index')]
+28
View File
@@ -0,0 +1,28 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.contrib import messages
from django.utils.translation import gettext_lazy as _
from plinth.forms import TLSDomainForm
from plinth.modules import ttrss
from plinth.views import AppView
class TTRSSAppView(AppView):
app_id = 'ttrss'
form_class = TLSDomainForm
def get_initial(self):
"""Return the values to fill in the form."""
initial = super().get_initial()
initial['domain'] = ttrss.get_domain()
return initial
def form_valid(self, form):
"""Change the domain of TT-RSS app."""
data = form.cleaned_data
if ttrss.get_domain() != data['domain']:
ttrss.set_domain(data['domain'])
messages.success(self.request, _('Configuration updated'))
return super().form_valid(form)