mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
*: Drop module level app property
module.app property usage is greatly reduced because setup() and force_upgrade() method are now part of App class instead of at the module level. Remove the remaining minor cases of usage and drop the property altogether. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
0a9514228f
commit
900c0d30b9
89 files changed
+151
-200
No files matched your search
@@ -34,8 +34,6 @@ _description = [
|
||||
'<a href="https://git-scm.com/docs/gittutorial">Git tutorial</a>.')
|
||||
]
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
class GitwebApp(app_module.App):
|
||||
"""FreedomBox app for Gitweb."""
|
||||
@@ -160,7 +158,7 @@ class GitwebBackupRestore(BackupRestore):
|
||||
def restore_post(self, packet):
|
||||
"""Update access after restoration of backups."""
|
||||
super().restore_post(packet)
|
||||
app.update_service_access()
|
||||
self.app.update_service_access()
|
||||
|
||||
|
||||
def repo_exists(name):
|
||||
|
||||
@@ -4,7 +4,7 @@ Tests for gitweb views.
|
||||
"""
|
||||
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
from django import urls
|
||||
@@ -70,7 +70,7 @@ def action_run(*args, **kwargs):
|
||||
def gitweb_patch():
|
||||
"""Patch gitweb."""
|
||||
with patch('plinth.modules.gitweb.get_repo_list') as get_repo_list, \
|
||||
patch('plinth.modules.gitweb.app') as gitweb_app, \
|
||||
patch('plinth.app.App.get') as app_get, \
|
||||
patch('plinth.actions.superuser_run', side_effect=action_run), \
|
||||
patch('plinth.actions.run', side_effect=action_run):
|
||||
get_repo_list.return_value = [{
|
||||
@@ -78,7 +78,9 @@ def gitweb_patch():
|
||||
}, {
|
||||
'name': EXISTING_REPOS[1]['name']
|
||||
}]
|
||||
gitweb_app.update_service_access.return_value = None
|
||||
app = Mock()
|
||||
app_get.return_value = app
|
||||
app.update_service_access.return_value = None
|
||||
|
||||
yield
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@ from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic import FormView
|
||||
|
||||
from plinth import actions, views
|
||||
from plinth import actions
|
||||
from plinth import app as app_module
|
||||
from plinth import views
|
||||
from plinth.errors import ActionError
|
||||
from plinth.modules import gitweb
|
||||
|
||||
@@ -69,7 +71,7 @@ class CreateRepoView(SuccessMessageMixin, FormView):
|
||||
_('An error occurred while creating the repository.'),
|
||||
error_text))
|
||||
else:
|
||||
gitweb.app.update_service_access()
|
||||
app_module.App.get('gitweb').update_service_access()
|
||||
|
||||
return super().form_valid(form)
|
||||
|
||||
@@ -115,7 +117,7 @@ class EditRepoView(SuccessMessageMixin, FormView):
|
||||
except ActionError:
|
||||
messages.error(self.request,
|
||||
_('An error occurred during configuration.'))
|
||||
gitweb.app.update_service_access()
|
||||
app_module.App.get('gitweb').update_service_access()
|
||||
|
||||
return super().form_valid(form)
|
||||
|
||||
@@ -132,6 +134,7 @@ def delete(request, name):
|
||||
else:
|
||||
raise Http404
|
||||
|
||||
app = app_module.App.get('gitweb')
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
gitweb.delete_repo(name)
|
||||
@@ -142,11 +145,11 @@ def delete(request, name):
|
||||
_('Could not delete {name}: {error}').format(
|
||||
name=name, error=error),
|
||||
)
|
||||
gitweb.app.update_service_access()
|
||||
app.update_service_access()
|
||||
|
||||
return redirect(reverse_lazy('gitweb:index'))
|
||||
|
||||
return TemplateResponse(request, 'gitweb_delete.html', {
|
||||
'title': gitweb.app.info.name,
|
||||
'title': app.info.name,
|
||||
'name': name
|
||||
})
|
||||
Reference in new issue
Block a user