mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
backups: Show error when there are no disks available to add repo
When there are no additional disks available, don't show an empty drop down for disks and throw an error when submitting. Instead make it clear that no additional disks are available and that is why repository can't be created. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
1d031c97f1
commit
d9d9c8167f
@ -247,6 +247,16 @@ class AddRepositoryView(SuccessMessageMixin, FormView):
|
||||
template_name = 'backups_add_repository.html'
|
||||
success_url = reverse_lazy('backups:index')
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
"""If there are no disks available for adding, throw error."""
|
||||
if not forms.get_disk_choices():
|
||||
messages.error(
|
||||
request,
|
||||
_('No additional disks available to add a repository.'))
|
||||
return redirect(reverse_lazy('backups:index'))
|
||||
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Return additional context for rendering the template."""
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user