Some minor changes
This commit is contained in:
parent
82313b8ec8
commit
2e2bd9df4c
@ -39,6 +39,7 @@ def main(global_config, **settings):
|
||||
config.add_route('logout', '/logout')
|
||||
|
||||
add_route(config, 'picture', '/picture')
|
||||
config.add_route('picture_raw', '/p/{id}')
|
||||
config.add_route('upload', '/upload')
|
||||
config.add_route('api_upload', '/v1/upload')
|
||||
|
||||
|
@ -118,6 +118,8 @@ class Picture(Base):
|
||||
|
||||
@classmethod
|
||||
def by_id(cls, id):
|
||||
if not isinstance(id, uuid.UUID):
|
||||
id = uuid.UUID(id)
|
||||
return DBSession.query(cls).filter(cls.id == id).first()
|
||||
|
||||
@classmethod
|
||||
|
@ -3,7 +3,7 @@
|
||||
<div class="col-sm-6 col-md-3" ng-repeat="item in info">
|
||||
<div class="thumbnail">
|
||||
|
||||
<a href="{{item.viewUrl}}"><img
|
||||
<a ng-href="{{item.viewUrl}}"><img
|
||||
src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjQyIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDI0MiAyMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxkZWZzLz48cmVjdCB3aWR0aD0iMjQyIiBoZWlnaHQ9IjIwMCIgZmlsbD0iI0VFRUVFRSIvPjxnPjx0ZXh0IHg9IjkzIiB5PSIxMDAiIHN0eWxlPSJmaWxsOiNBQUFBQUE7Zm9udC13ZWlnaHQ6Ym9sZDtmb250LWZhbWlseTpBcmlhbCwgSGVsdmV0aWNhLCBPcGVuIFNhbnMsIHNhbnMtc2VyaWYsIG1vbm9zcGFjZTtmb250LXNpemU6MTFwdDtkb21pbmFudC1iYXNlbGluZTpjZW50cmFsIj4yNDJ4MjAwPC90ZXh0PjwvZz48L3N2Zz4="</img>
|
||||
</a>
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
<p>{{item.description}}</p>
|
||||
|
||||
<p><a class="btn" href="{{item.viewUrl}}">View <i
|
||||
<p><a class="btn" ng-href="{{item.viewUrl}}">View <i
|
||||
class="glyphicon glyphicon-eye-open"></i></a><a class="btn" href="{{item.editUrl}}">Edit <i
|
||||
class="glyphicon glyphicon-edit"></i></a></p>
|
||||
</div>
|
||||
|
@ -1,6 +1,8 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3" ng-repeat="item in info.pictures">
|
||||
<div class="thumbnail"><img ng-src="{{item.url}}"/></div>
|
||||
<a ng-href="{{item.url}}">
|
||||
<div class="thumbnail"><img ng-src="{{item.imageUrl}}"/></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -32,18 +32,12 @@
|
||||
controller: 'AlbumPicturesController',
|
||||
resolve: AlbumPicturesCtrlResolve
|
||||
})
|
||||
//.when('/picture', {
|
||||
// templateUrl: '/app/picture/view.html',
|
||||
// controller: 'PictureController',
|
||||
// resolve: PictureCtrl.resolve,
|
||||
// reloadOnSearch: false
|
||||
//})
|
||||
//.when('/picture/:id', {
|
||||
// templateUrl: '/app/picture/view.html',
|
||||
// controller: 'PictureController',
|
||||
// resolve: PictureCtrl.resolve,
|
||||
// reloadOnSearch: false
|
||||
//})
|
||||
.when('/picture/:id', {
|
||||
templateUrl: '/app/picture/view.html',
|
||||
controller: 'PictureController',
|
||||
resolve: PictureCtrlResolve,
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/users', {
|
||||
templateUrl: '/app/user/list.html',
|
||||
controller: 'UserListController',
|
||||
|
@ -2,7 +2,8 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('soter')
|
||||
.controller('UploadController', ['$scope', 'Upload', UploadController]);
|
||||
.controller('UploadController', ['$scope', 'Upload', UploadController])
|
||||
.controller('PictureController', ['$scope', 'picture', PictureController]);
|
||||
|
||||
function UploadController($scope, Upload) {
|
||||
$scope.upload = function (files) {
|
||||
@ -22,6 +23,19 @@
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function PictureController($scope, picture) {
|
||||
$scope.picture = picture;
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
var UploadCtrlResolve = {};
|
||||
|
||||
var PictureCtrlResolve = {
|
||||
album: ['$route', 'Picture', function ($route, Picture) {
|
||||
var id = $route.current.params.id;
|
||||
return Picture.get({id: id}).$promise;
|
||||
}]
|
||||
};
|
||||
|
||||
|
5
soter/static/app/picture/view.html
Normal file
5
soter/static/app/picture/view.html
Normal file
@ -0,0 +1,5 @@
|
||||
<div class="carousel-inner">
|
||||
<div class="item">
|
||||
<img ng-src="{{picture.imageUrl}}">
|
||||
</div>
|
||||
</div>
|
@ -1,11 +1,10 @@
|
||||
import uuid
|
||||
import re
|
||||
|
||||
import pkg_resources
|
||||
from pyramid.response import FileResponse, Response
|
||||
from pyramid.security import authenticated_userid
|
||||
|
||||
from pyramid.view import view_config
|
||||
import re
|
||||
import transaction
|
||||
|
||||
from soter.models import DBSession
|
||||
@ -94,7 +93,8 @@ def show_pics(request):
|
||||
album = Album.by_name(id)
|
||||
info = album_info(album)
|
||||
for item in album.pictures:
|
||||
info['pictures'].append({'name': item.name, 'url': request.route_url('api_picture_id', id=item.id)})
|
||||
info['pictures'].append({'name': item.name, 'url': request.route_url('picture_id', id=item.id),
|
||||
'imageUrl': request.route_url('picture_raw', id=item.id)})
|
||||
return info
|
||||
|
||||
|
||||
@ -103,7 +103,8 @@ def album_info(id):
|
||||
return {'name': "", 'description': "", 'isPublic': False, 'pictures': []}
|
||||
if not isinstance(id, Album):
|
||||
album = Album.by_id(id)
|
||||
|
||||
else:
|
||||
album = id
|
||||
album = {'id': album.id, 'name': album.name, 'description': album.description, 'isPublic': album.is_public,
|
||||
'pictures': [], 'user': {'id': album.user_id, 'name': album.user.name},
|
||||
'isFixture': album.is_fixture}
|
||||
|
@ -4,12 +4,13 @@ import uuid
|
||||
|
||||
import pkg_resources
|
||||
from pyramid.response import FileResponse
|
||||
|
||||
from pyramid.security import authenticated_userid
|
||||
|
||||
from pyramid.view import view_config
|
||||
import transaction
|
||||
|
||||
from soter.models import DBSession
|
||||
|
||||
from soter.models.master import Picture
|
||||
|
||||
|
||||
@ -37,8 +38,25 @@ def upload(request):
|
||||
return {'location': file_path}
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='api_picture_id', permission='Albums')
|
||||
def show_id(request):
|
||||
@view_config(request_method='GET', route_name='picture_raw', permission='Albums')
|
||||
def show_raw(request):
|
||||
package, resource = ('soter:upload/' + request.matchdict['id'] + '.jpg').split(':', 1)
|
||||
file = pkg_resources.resource_filename(package, resource)
|
||||
return FileResponse(file, request=request)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='api_album_id', renderer='json', request_param='pictures',
|
||||
permission='Albums')
|
||||
def show_id(request):
|
||||
return picture_info(request.matchdict['id'], request)
|
||||
|
||||
|
||||
def picture_info(id, request):
|
||||
if not isinstance(id, Picture):
|
||||
picture = Picture.by_id(id)
|
||||
else:
|
||||
picture = id
|
||||
album = {'id': picture.id, 'name': picture.name, 'imageUrl': request.route_url('picture_raw', id=picture.id),
|
||||
|
||||
'user': {'id': picture.user_id, 'name': picture.user.name}}
|
||||
return album
|
||||
|
Loading…
Reference in New Issue
Block a user