~chicharreros/magicicada-server/trunk

« back to all changes in this revision

Viewing changes to magicicada/rpcdb/backend.py

  • Committer: Magicicada Bot
  • Author(s): Facundo Batista
  • Date: 2017-01-08 23:37:32 UTC
  • mfrom: (79.1.2 publicfiles)
  • Revision ID: magicicada_bot-20170108233732-faaeoq6sc9jorgue
[r=nataliabidart] Support public files changing and listing through the normal Server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright 2008-2015 Canonical
2
 
# Copyright 2015 Chicharreros (https://launchpad.net/~chicharreros)
 
2
# Copyright 2015-2016 Chicharreros (https://launchpad.net/~chicharreros)
3
3
#
4
4
# This program is free software: you can redistribute it and/or modify
5
5
# it under the terms of the GNU Affero General Public License as
100
100
                      shares=shares, udfs=udfs)
101
101
        return result
102
102
 
 
103
    def list_public_files(self, user_id):
 
104
        """List all the public files for the user."""
 
105
        user = self._get_user(user_id)
 
106
 
 
107
        public_files = [self._process_node(n) for n in user.get_public_files()]
 
108
        result = dict(public_files=public_files)
 
109
        return result
 
110
 
 
111
    def change_public_access(self, user_id, volume_id, node_id,
 
112
                             is_public, session_id=None):
 
113
        """Change the public access for a node."""
 
114
        user = self._get_user(user_id, session_id)
 
115
        node = user.volume(volume_id).node(node_id)
 
116
        node = node.change_public_access(is_public)
 
117
        return dict(public_url=node.public_url)
 
118
 
103
119
    def move(self, user_id, volume_id, node_id,
104
120
             new_parent_id, new_name, session_id=None):
105
121
        """Move a node and/or rename it."""
308
324
                 storage_key=storage_key, is_live=is_live,
309
325
                 size=size, is_file=is_file, volume_id=node.vol_id,
310
326
                 parent_id=node.parent_id, content_hash=node.content_hash,
311
 
                 path=node.path, has_content=has_content)
 
327
                 path=node.path, has_content=has_content,
 
328
                 public_url=node.public_url)
312
329
        return d
313
330
 
314
331
    def get_delta(self, user_id, volume_id, from_generation, limit):