Changes in / [4226ce0:6edc367] in OpenWorkouts-current


Ignore:
Location:
ow
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ow/models/user.py

    r4226ce0 r6edc367  
    66import bcrypt
    77from repoze.folder import Folder
    8 from pyramid.security import Allow, Deny, Everyone, ALL_PERMISSIONS
     8from pyramid.security import Allow
    99
    1010from ow.catalog import get_catalog, reindex_object
     
    1818    def __acl__(self):
    1919        permissions = [
     20            (Allow, str(self.uid), 'edit'),
    2021            (Allow, str(self.uid), 'view'),
    21             (Allow, str(self.uid), 'edit'),
    22             (Deny, Everyone, ALL_PERMISSIONS),
    2322        ]
    2423        return permissions
  • ow/models/workout.py

    r4226ce0 r6edc367  
    66import gpxpy
    77from repoze.folder import Folder
    8 from pyramid.security import Allow, Deny, Everyone, ALL_PERMISSIONS
     8from pyramid.security import Allow, Everyone
    99
    1010from ow.utilities import (
     
    2929        it (for now). If not, everybody can view it, only admins can edit it.
    3030        """
    31         uid = self.__parent__.uid
     31        # Default permissions
    3232        permissions = [
    33             (Allow, str(uid), 'view'),
    34             (Allow, str(uid), 'edit'),
    35             (Allow, str(uid), 'delete'),
    36             (Deny, Everyone, ALL_PERMISSIONS)
     33            (Allow, Everyone, 'view'),
     34            (Allow, 'group:admins', 'edit')
    3735        ]
     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            ]
    3844        return permissions
    3945
  • ow/static/js/ow.js

    r4226ce0 r6edc367  
    162162            y = d3.scaleLinear().rangeRound([height, 0]);
    163163
    164         d3.json(url, {credentials: "same-origin"}).then(function (data) {
     164        d3.json(url).then(function (data) {
    165165            x.domain(data.map(function (d) {
    166166                return d.name;
     
    324324            y = d3.scaleLinear().rangeRound([height, 0]);
    325325
    326         d3.json(urls[url], {credentials: "same-origin"}).then(function (data) {
     326        d3.json(urls[url]).then(function (data) {
    327327            x.domain(data.map(function (d) {
    328328                return get_name_for_x(d);
  • ow/tests/models/test_user.py

    r4226ce0 r6edc367  
    33
    44import pytest
    5 from pyramid.security import Allow, Everyone, Deny, ALL_PERMISSIONS
     5from pyramid.security import Allow
    66
    77from ow.models.root import OpenWorkouts
     
    3333    def test__acl__(self, root):
    3434        uid = str(root['john'].uid)
    35         permissions = [
    36             (Allow, uid, 'view'),
    37             (Allow, uid, 'edit'),
    38             (Deny, Everyone, ALL_PERMISSIONS),
    39         ]
     35        permissions = [(Allow, uid, 'edit'), (Allow, uid, 'view')]
    4036        assert root['john'].__acl__() == permissions
    4137
  • ow/tests/models/test_workout.py

    r4226ce0 r6edc367  
    66
    77import pytest
    8 from pyramid.security import Allow, Everyone, Deny, ALL_PERMISSIONS
     8from pyramid.security import Allow, Everyone
    99
    1010from ow.models.workout import Workout
     
    3333    def test__acl__(self, root):
    3434        # First check permissions for a workout without parent
    35         workout = Workout()
    36         with pytest.raises(AttributeError):
    37             workout.__acl__()
     35        permissions = [(Allow, Everyone, 'view'),
     36                       (Allow, 'group:admins', 'edit')]
     37        workout = Workout()
     38        assert workout.__acl__() == permissions
     39
    3840        # Now permissions on a workout that has been added to a user
    3941        uid = str(root['john'].uid)
    40         workout = root['john']['1']
    41         permissions = [
    42             (Allow, uid, 'view'),
    43             (Allow, uid, 'edit'),
    44             (Allow, uid, 'delete'),
    45             (Deny, Everyone, ALL_PERMISSIONS)
    46         ]
    47         assert workout.__acl__() == permissions
     42        permissions = [(Allow, uid, 'view'), (Allow, uid, 'edit')]
     43        assert root['john']['1'].__acl__() == permissions
    4844
    4945    def test_runthrough(self, root):
  • ow/views/workout.py

    r4226ce0 r6edc367  
    2323@view_config(
    2424    context=User,
    25     permission='edit',
    2625    name='add-workout-manually',
    2726    renderer='ow:templates/add_manual_workout.pt')
     
    6059@view_config(
    6160    context=User,
    62     permission='edit',
    6361    name='add-workout',
    6462    renderer='ow:templates/add_workout.pt')
     
    9593@view_config(
    9694    context=Workout,
    97     permission='edit',
    9895    name='edit',
    9996    renderer='ow:templates/edit_manual_workout.pt')
     
    142139@view_config(
    143140    context=Workout,
    144     permission='edit',
    145141    name='update-from-file',
    146142    renderer='ow:templates/update_workout_from_file.pt')
     
    171167@view_config(
    172168    context=Workout,
    173     permission='delete',
    174169    name='delete',
    175170    renderer='ow:templates/delete_workout.pt')
     
    189184@view_config(
    190185    context=Workout,
    191     permission='view',
    192186    renderer='ow:templates/workout.pt')
    193187def workout(context, request):
     
    218212    For now, simply return the gpx file if it has been attached to the
    219213    workout.
    220 
    221     This view requires no permission, as we access it from an non-authenticated
    222     request in a separate job, to generate the static map screenshot.
    223214    """
    224215    if not context.has_gpx:
     
    238229def workout_map(context, request):
    239230    """
    240     Render a page that has only a map with tracking info.
    241     This view requires no permission, as we access it from an non-authenticated
    242     request in a separate job, to generate the static map screenshot.
     231    Render a page that has only a map with tracking info
    243232    """
    244233    start_point = {}
Note: See TracChangeset for help on using the changeset viewer.