Changeset 78af3d1 in OpenWorkouts-current for ow/models/workout.py


Ignore:
Timestamp:
Feb 9, 2019, 9:42:52 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
56caf3d
Parents:
55470f9
Message:

Fix permissions. From now on users can see (and edit, delete, etc) their own data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/models/workout.py

    r55470f9 r78af3d1  
    66import gpxpy
    77from repoze.folder import Folder
    8 from pyramid.security import Allow, Everyone
     8from pyramid.security import Allow, Deny, Everyone, ALL_PERMISSIONS
    99
    1010from ow.utilities import (
     
    2929        it (for now). If not, everybody can view it, only admins can edit it.
    3030        """
    31         # Default permissions
     31        uid = self.__parent__.uid
    3232        permissions = [
    33             (Allow, Everyone, 'view'),
    34             (Allow, 'group:admins', 'edit')
     33            (Allow, str(uid), 'view'),
     34            (Allow, str(uid), 'edit'),
     35            (Allow, str(uid), 'delete'),
     36            (Deny, Everyone, ALL_PERMISSIONS)
    3537        ]
    36 
    37         uid = getattr(self.__parent__, 'uid', None)
    38         if uid is not None:
    39             # Change permissions in case this workout has an owner
    40             permissions = [
    41                 (Allow, str(uid), 'view'),
    42                 (Allow, str(uid), 'edit'),
    43             ]
    4438        return permissions
    4539
Note: See TracChangeset for help on using the changeset viewer.