Exemple #1
0
    def perform_operation_post(self, op, repo_id):
        repo = get_repo(repo_id)
        if not repo:
            raise web.seeother('/repos/')

        if op == 'modify-relay':
            relay_id = web.webapi.input(relay_id="").relay_id
            if relay_id != repo.props.relay_id:
                seafile_rpc.set_repo_property(repo.props.id,
                                              "relay-id", relay_id)
        elif op == 'set-passwd':
            passwd = web.webapi.input(passwd="").passwd
            if passwd:
                seafile_rpc.set_repo_passwd(repo.props.id, passwd)
  
        referer = web.ctx.env.get('HTTP_REFERER', '/home/')
        raise web.seeother(referer)
Exemple #2
0
    def perform_operation_post(self, op, repo_id):
        repo = get_repo(repo_id)
        if not repo:
            raise web.seeother('/repos/')

        if op == 'modify-relay':
            relay_id = web.webapi.input(relay_id="").relay_id
            if relay_id != repo.props.relay_id:
                seafile_rpc.set_repo_property(repo.props.id, "relay-id",
                                              relay_id)
        elif op == 'set-passwd':
            passwd = web.webapi.input(passwd="").passwd
            if passwd:
                seafile_rpc.set_repo_passwd(repo.props.id, passwd)

        referer = web.ctx.env.get('HTTP_REFERER', '/home/')
        raise web.seeother(referer)
Exemple #3
0
    def perform_operation_post(self, op, repo_id):
        repo = get_repo(repo_id)
        if not repo:
            raise web.seeother("/repos/")

        if op == "modify-relay":
            relay_id = web.webapi.input(relay_id="").relay_id
            if relay_id != repo.props.relay_id:
                seafile_rpc.set_repo_property(repo.props.id, "relay-id", relay_id)
        elif op == "set-passwd":
            passwd = web.webapi.input(passwd="").passwd
            if passwd:
                seafile_rpc.set_repo_passwd(repo.props.id, passwd)

        elif op == "edit-relay":
            inputs = web.webapi.input(relay_addr="", relay_port="")
            if inputs.relay_addr and inputs.relay_port:
                seafile_rpc.update_repo_relay_info(repo_id, inputs.relay_addr, inputs.relay_port)

        referer = web.ctx.env.get("HTTP_REFERER", "/home/")
        raise web.seeother(referer)
Exemple #4
0
    def perform_operation_get(self, op, repo_id):
        repo = get_repo(repo_id)
        if not repo:
            raise web.seeother('/repos/')

        if op == 'sync':
            try:
                seafile_rpc.sync(repo.props.id, None)
            except:
                pass

        elif op == 'open' and repo.props.worktree:
            try:
                open_dir(repo.props.worktree.encode('utf-8'))
            except:
                pass
            referer = web.ctx.env.get('HTTP_REFERER', '/home/')
            raise web.seeother(referer)

        elif op == 'open_file':
            quote_file_path = web.webapi.input(quote_file_path='').file_path
            file_path = quote_file_path.encode('utf-8')
            dir_path = file_path
            if os.path.exists(file_path) and os.path.isfile(file_path):
                dir_path = os.path.dirname(file_path)

            try:
                open_dir(dir_path)
            except:
                pass
            return render.checkout_msg(repo=repo, file_path=file_path, **default_options)

        elif op == 'diff':
            inputs = web.webapi.input(old='', new='')
            new_commit = seafile_rpc.get_commit(inputs.new)
            if inputs.old != '':
                old_commit = seafile_rpc.get_commit(inputs.old)
            else:
                old_commit = None
            (new, removed, renamed, modified, newdir, deldir) = get_diff(repo_id, inputs.old, inputs.new)
            return render.repo_diff(repo=repo, 
                                    new=new, removed=removed, 
                                    renamed=renamed, modified=modified,
                                    newdir=newdir, deldir=deldir,
                                    new_commit=new_commit, old_commit=old_commit,
                                    **default_options)
        elif op == 'lsch':
            inputs = web.webapi.input(old='', new='')
            (new, removed, renamed, modified, newdir, deldir) = get_diff(repo_id, inputs.old, inputs.new)
            ch = {}
            ch['new'] = new
            ch['removed'] = removed
            ch['renamed'] = renamed
            ch['modified'] = modified
            ch['newdir'] = newdir
            ch['deldir'] = deldir
            return json.dumps(ch)

        elif op == 'dir':
            inputs = web.webapi.input(commit_id='', path='/')
            dirs = seafile_rpc.list_dir_by_path(inputs.commit_id, inputs.path.encode('utf-8'))
            navs = get_dir_nav_links(repo, inputs.commit_id, inputs.path)
            try:
                commit = seafile_rpc.get_commit(inputs.commit_id)
            except SearpcError:
                raise web.seeother('/repo/?repo=%s' % repo_id)
                
            return render.repo_dir(repo=repo, dirs=dirs, commit_id=inputs.commit_id,
                                   commit=commit,
                                   navs=navs,
                                   path=inputs.path,
                                   **default_options)

        elif op == 'remove':
            try:
                seafile_rpc.remove_repo(repo_id)
            except:
                pass
            raise web.seeother('/repos/')

        elif op == 'set-auto-sync':
            auto_sync = {}
            try:
                seafile_rpc.set_repo_property(repo_id, "auto-sync", "true")
            except:
                pass
            auto_sync['start'] = True
            return json.dumps(auto_sync)

        elif op == 'set-manual-sync':
            auto_sync = {}
            try:
                seafile_rpc.set_repo_property(repo_id, "auto-sync", "false")
            except:
                pass
            auto_sync['start'] = False
            return json.dumps(auto_sync)

        referer = web.ctx.env.get('HTTP_REFERER', '/home/')
        raise web.seeother(referer)
Exemple #5
0
                commit = seafile_rpc.get_commit(inputs.commit_id)
            except SearpcError,e :
                raise web.seeother('/repo/?repo=%s' % repo_id)
                
            return render.repo_dir(repo=repo, dirs=dirs, commit_id=inputs.commit_id,
                                   commit=commit,
                                   navs=navs,
                                   path=inputs.path,
                                   **default_options)

        elif op == 'remove':
            seafile_rpc.remove_repo(repo_id)
            raise web.seeother('/repos/')

        elif op == 'set-auto-sync':
            seafile_rpc.set_repo_property(repo_id, "auto-sync", "true")
            auto_sync = {}
            auto_sync['start'] = True
            return json.dumps(auto_sync)

        elif op == 'set-manual-sync':
            seafile_rpc.set_repo_property(repo_id, "auto-sync", "false")
            auto_sync = {}
            auto_sync['start'] = False
            return json.dumps(auto_sync)

        referer = web.ctx.env.get('HTTP_REFERER', '/home/')
        raise web.seeother(referer)


    def perform_operation_post(self, op, repo_id):
Exemple #6
0
    def perform_operation_get(self, op, repo_id):
        repo = get_repo(repo_id)
        if not repo:
            raise web.seeother("/repos/")

        if op == "sync":
            try:
                seafile_rpc.sync(repo.props.id, None)
            except:
                pass

        elif op == "open" and repo.props.worktree:
            try:
                open_dir(repo.props.worktree.encode("utf-8"))
            except:
                pass
            referer = web.ctx.env.get("HTTP_REFERER", "/home/")
            raise web.seeother(referer)

        elif op == "open_file":
            quote_file_path = web.webapi.input(quote_file_path="").file_path
            file_path = quote_file_path.encode("utf-8")
            dir_path = file_path
            if os.path.exists(file_path) and os.path.isfile(file_path):
                dir_path = os.path.dirname(file_path)

            try:
                open_dir(dir_path)
            except:
                pass
            return render.checkout_msg(repo=repo, file_path=file_path, **default_options)

        elif op == "diff":
            inputs = web.webapi.input(old="", new="")
            new_commit = seafile_rpc.get_commit(inputs.new)
            if inputs.old != "":
                old_commit = seafile_rpc.get_commit(inputs.old)
            else:
                old_commit = None
            (new, removed, renamed, modified, newdir, deldir) = get_diff(repo_id, inputs.old, inputs.new)
            return render.repo_diff(
                repo=repo,
                new=new,
                removed=removed,
                renamed=renamed,
                modified=modified,
                newdir=newdir,
                deldir=deldir,
                new_commit=new_commit,
                old_commit=old_commit,
                **default_options
            )
        elif op == "lsch":
            inputs = web.webapi.input(old="", new="")
            (new, removed, renamed, modified, newdir, deldir) = get_diff(repo_id, inputs.old, inputs.new)
            ch = {}
            ch["new"] = new
            ch["removed"] = removed
            ch["renamed"] = renamed
            ch["modified"] = modified
            ch["newdir"] = newdir
            ch["deldir"] = deldir
            return json.dumps(ch)

        elif op == "dir":
            inputs = web.webapi.input(commit_id="", path="/")
            dirs = seafile_rpc.list_dir_by_path(inputs.commit_id, inputs.path.encode("utf-8"))
            navs = get_dir_nav_links(repo, inputs.commit_id, inputs.path)
            try:
                commit = seafile_rpc.get_commit(inputs.commit_id)
            except SearpcError:
                raise web.seeother("/repo/?repo=%s" % repo_id)

            return render.repo_dir(
                repo=repo,
                dirs=dirs,
                commit_id=inputs.commit_id,
                commit=commit,
                navs=navs,
                path=inputs.path,
                **default_options
            )

        elif op == "remove":
            try:
                seafile_rpc.remove_repo(repo_id)
            except:
                pass
            raise web.seeother("/repos/")

        elif op == "set-auto-sync":
            auto_sync = {}
            try:
                seafile_rpc.set_repo_property(repo_id, "auto-sync", "true")
            except:
                pass
            auto_sync["start"] = True
            return json.dumps(auto_sync)

        elif op == "set-manual-sync":
            auto_sync = {}
            try:
                seafile_rpc.set_repo_property(repo_id, "auto-sync", "false")
            except:
                pass
            auto_sync["start"] = False
            return json.dumps(auto_sync)

        referer = web.ctx.env.get("HTTP_REFERER", "/home/")
        raise web.seeother(referer)
Exemple #7
0
                raise web.seeother('/repo/?repo=%s' % repo_id)

            return render.repo_dir(repo=repo,
                                   dirs=dirs,
                                   commit_id=inputs.commit_id,
                                   commit=commit,
                                   navs=navs,
                                   path=inputs.path,
                                   **default_options)

        elif op == 'remove':
            seafile_rpc.remove_repo(repo_id)
            raise web.seeother('/repos/')

        elif op == 'set-auto-sync':
            seafile_rpc.set_repo_property(repo_id, "auto-sync", "true")
            auto_sync = {}
            auto_sync['start'] = True
            return json.dumps(auto_sync)

        elif op == 'set-manual-sync':
            seafile_rpc.set_repo_property(repo_id, "auto-sync", "false")
            auto_sync = {}
            auto_sync['start'] = False
            return json.dumps(auto_sync)

        referer = web.ctx.env.get('HTTP_REFERER', '/home/')
        raise web.seeother(referer)

    def perform_operation_post(self, op, repo_id):
        repo = get_repo(repo_id)