Beispiel #1
0
    def form_valid(self, form):
        """Add the share on valid form submission."""
        if form.initial != form.cleaned_data:
            sharing.remove_share(form.initial['name'])
            _add_share(form.cleaned_data)

        return super().form_valid(form)
Beispiel #2
0
def setup(helper, old_version=None):
    """Install and configure the module."""
    app.setup(old_version)
    helper.call('post', actions.superuser_run, 'syncthing', ['setup'])
    add_user_to_share_group(SYSTEM_USER, SyncthingApp.DAEMON)

    if not old_version:
        helper.call('post', app.enable)

    helper.call('post', actions.superuser_run, 'syncthing', ['setup-config'])

    if old_version == 1 and app.is_enabled():
        app.get_component('firewall-syncthing-ports').enable()

    if old_version and old_version <= 3:
        # rename LDAP and Django group
        old_groupname = 'syncthing'
        new_groupname = 'syncthing-access'

        actions.superuser_run(
            'users', options=['rename-group', old_groupname, new_groupname])

        from django.contrib.auth.models import Group
        Group.objects.filter(name=old_groupname).update(name=new_groupname)

        # update web shares to have new group name
        from plinth.modules import sharing
        shares = sharing.list_shares()
        for share in shares:
            if old_groupname in share['groups']:
                new_groups = share['groups']
                new_groups.remove(old_groupname)
                new_groups.append(new_groupname)

                name = share['name']
                sharing.remove_share(name)
                sharing.add_share(name, share['path'], new_groups,
                                  share['is_public'])
Beispiel #3
0
def remove(request, name):
    """View to remove a share."""
    sharing.remove_share(name)
    messages.success(request, _('Share deleted.'))
    return redirect(reverse_lazy('sharing:index'))