Skip to content

Commit

Permalink
Upgrade radicale dep to v3 and adjust accordingly
Browse files Browse the repository at this point in the history
Fixes #129
  • Loading branch information
tasn committed Jun 2, 2020
2 parents 4fafd08 + 1789c8e commit 8c031e1
Show file tree
Hide file tree
Showing 8 changed files with 703 additions and 565 deletions.
44 changes: 22 additions & 22 deletions etesync_dav/radicale/rights.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from radicale.rights import BaseRights
from radicale import pathutils, rights

from .etesync_cache import EteSyncCache, etesync_for_user

import etesync as api


class Rights(BaseRights):
def authorized(self, user, path, permission):
if not bool(user):
return False
class Rights(rights.BaseRights):
def authorization(self, user, path):
if not user:
return ""

attributes = path.strip('/').split('/')
sane_path = pathutils.strip_path(path)
if not sane_path:
return "R"

if len(attributes) == 1:
if attributes[0] == '':
return permission == 'r'
else:
return attributes[0] == user
attributes = sane_path.split('/')
if user != attributes[0]:
return ""

if attributes[0] != user:
return False
if "/" not in sane_path:
return "RW"

if permission == 'r':
return True
if sane_path.count("/") == 1:
journal_uid = attributes[1]

journal_uid = attributes[1]
with etesync_for_user(user) as (etesync, _):
try:
journal = etesync.get(journal_uid)
except api.exceptions.DoesNotExist:
return ''

with etesync_for_user(user) as (etesync, _):
try:
journal = etesync.get(journal_uid)
except api.exceptions.DoesNotExist:
return False
return 'rw' if not journal.read_only else 'r'

return not journal.read_only
return ""
Loading

0 comments on commit 8c031e1

Please sign in to comment.