Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/a258001251842882_refactoring_san…
Browse files Browse the repository at this point in the history
…dbox_23'
  • Loading branch information
vmaksymiv committed Sep 12, 2017
2 parents fa7be70 + f06924f commit 94372d0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/openprocurement/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
from logging import getLogger
from openprocurement.api.auth import AuthenticationPolicy, authenticated_role, check_accreditation
from openprocurement.api.database import set_api_security
from openprocurement.api.utils import forbidden, request_params
from openprocurement.api.constants import ROUTE_PREFIX
from openprocurement.api.utils import forbidden, request_params, route_prefix
from pkg_resources import iter_entry_points
from pyramid.authorization import ACLAuthorizationPolicy as AuthorizationPolicy
from pyramid.config import Configurator
Expand All @@ -30,7 +29,7 @@ def main(global_config, **settings):
settings=settings,
authentication_policy=AuthenticationPolicy(settings['auth.file'], __name__),
authorization_policy=AuthorizationPolicy(),
route_prefix=ROUTE_PREFIX,
route_prefix=route_prefix(settings),
)
config.include('pyramid_exclog')
config.include("cornice")
Expand Down
4 changes: 2 additions & 2 deletions src/openprocurement/api/subscribers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def add_logging_context(event):
request = event.request
params = {
'API_VERSION': VERSION,
'API_VERSION': request.registry.settings.get('api_version', VERSION),
'TAGS': 'python,api',
'USER': str(request.authenticated_userid or ''),
'CURRENT_URL': request.url,
Expand Down Expand Up @@ -63,4 +63,4 @@ def set_renderer(event):
@subscriber(BeforeRender)
def beforerender(event):
if event.rendering_val and isinstance(event.rendering_val, dict) and 'data' in event.rendering_val:
fix_url(event.rendering_val['data'], event['request'].application_url)
fix_url(event.rendering_val['data'], event['request'].application_url, event['request'].registry.settings)
6 changes: 5 additions & 1 deletion src/openprocurement/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from openprocurement.api.constants import LOGGER
from openprocurement.api.constants import (
ADDITIONAL_CLASSIFICATIONS_SCHEMES, DOCUMENT_BLACKLISTED_FIELDS,
DOCUMENT_WHITELISTED_FIELDS, ROUTE_PREFIX, TZ, SESSION
DOCUMENT_WHITELISTED_FIELDS, ROUTE_PREFIX, TZ, SESSION, VERSION
)
from openprocurement.api.interfaces import IOPContent
from openprocurement.api.interfaces import IContentConfigurator
Expand All @@ -38,6 +38,10 @@ def validate_dkpp(items, *args):
raise ValidationError(u"One of additional classifications should be one of [{0}].".format(', '.join(ADDITIONAL_CLASSIFICATIONS_SCHEMES)))


def route_prefix(settings={}):
return '/api/{}'.format(settings.get('api_version', VERSION))


def get_now():
return datetime.now(TZ)

Expand Down
3 changes: 2 additions & 1 deletion src/openprocurement/api/views/spore.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
@spore.get()
def get_spore(request):
services = get_services()
return generate_spore_description(services, 'Service name', request.application_url, request.registry.settings.get('api_version', VERSION))
return generate_spore_description(services, 'Service name', request.application_url,
request.registry.settings.get('api_version', VERSION))

0 comments on commit 94372d0

Please sign in to comment.