mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
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:
1 parent
a912c867c8
commit
aaea6bf00e
4 files changed
+79
-7
No files matched your search
@@ -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])
|
||||
@@ -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')]
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user