mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
sharing: Use privileged decorator for actions
Tests: - Initial setup works. - Empty Apache configuration file is created - Adding a share works all the information added is shown during editing. Configuration file is updated as expected. - List of shares is shown as expected. - When editing a share, information about share is shown correctly. Editing works are expected. - Removing a share works. - Trying to add share with a name that already exists throws a proper error message. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
6e7b31a3cf
commit
637e6b1198
5 files changed
+175
-248
No files matched your search
@@ -1,15 +1,14 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Django forms for sharing app.
|
||||
"""
|
||||
"""Django forms for sharing app."""
|
||||
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from plinth.modules import sharing
|
||||
from plinth.modules.users.components import UsersAndGroups
|
||||
|
||||
from . import privileged
|
||||
|
||||
|
||||
class AddShareForm(forms.Form):
|
||||
"""Form to add a new share."""
|
||||
@@ -47,7 +46,7 @@ class AddShareForm(forms.Form):
|
||||
if 'name' in self.initial and name == self.initial['name']:
|
||||
return name
|
||||
|
||||
if any((share for share in sharing.list_shares()
|
||||
if any((share for share in privileged.list_shares()
|
||||
if name == share['name'])):
|
||||
raise ValidationError(_('A share with this name already exists.'))
|
||||
|
||||
|
||||
Reference in new issue
Block a user