This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrytonServerWrapper(object): | |
def __init__(self, user_id, session_id, context, target): | |
self.user_id = user_id | |
self.session_id = session_id | |
self.context = context | |
self.target = target | |
def __call__(self, *args): | |
new_args = [self.user_id, self.session_id] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ndb.transactional(xg=True) | |
def remove(self, new_rep_id=None): | |
# Un-assign this rep from all their stores. | |
stores = Store.query_stores(rep_id = self.key, active=None) | |
for store in stores: | |
store.rep_id = new_rep_id | |
store.put() | |
self.active = False | |
self.put() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyramid.config import Configurator | |
def main(global_config, **settings): | |
""" This function returns a Pyramid WSGI application. | |
""" | |
config = Configurator(settings=settings) | |
config.add_static_view('static', 'static', cache_max_age=3600) | |
config.add_route('home', '{url:.*}') | |
config.scan() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.config(function($routeProvider, $locationProvider, $httpProvider) { | |
// ... | |
$httpProvider.responseInterceptors.push(function ($q, $rootScope) { | |
return function (promise) { | |
$rootScope.$broadcast('startLoading'); | |
return promise.then(function (response) { | |
$rootScope.$broadcast('stopLoading'); | |
return response; | |
}, function (response) { | |
$rootScope.$broadcast('stopLoading'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$httpProvider.responseInterceptors.push(function ($q, LoadingManager) { | |
return function (promise) { | |
LoadingManager.startLoading(); | |
return promise.then(function (response) { | |
LoadingManager.stopLoading(); | |
return response; | |
}, function (response) { | |
LoadingManager.stopLoading(); | |
return $q.reject(response); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([], function() { | |
'use strict'; | |
return function ($scope, $http, $routeParams, $q, $location) { | |
var warehouseId = $routeParams.warehouseId, | |
warehouseDeferred = $q.defer(), | |
locationsDeferred = $q.defer(); | |
// @TODO: Resolve these. | |
$scope.crumbs = []; | |
$scope.warehouse = warehouseDeferred.promise; | |
$scope.locations = locationsDeferred.promise; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
// ... | |
app.config(function($routeProvider, $locationProvider) { | |
$locationProvider.html5Mode(true); | |
// ... | |
$routeProvider.otherwise({ | |
redirectTo: function (params, path, search) { | |
search = jquery.param(search); | |
if (search) { | |
window.location = path + '?' + search; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def redirect_if_not_logged_in(request): | |
if request.user is None: | |
request.session['original_url'] = request.url | |
return HTTPFound(location=request.route_url( | |
request.registry.settings['auth.login_route_name'])) | |
return Forbidden() | |
def main(global_config, **settings): | |
#... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy.ext.declarative import declarative_base | |
import sqlalchemy as db | |
from sqlalchemy.orm import relationship | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
from datetime import datetime | |
Base = declarative_base() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_request_url_info(request, settings): | |
# Need this to get port included when not 80,443. | |
request.host = None | |
request.scheme = settings['scripts.server_scheme'] | |
request.server_name = settings['scripts.server_name'] | |
request.server_port = settings['scripts.server_port'] |