Skip to content

Commit

Permalink
Merge branch 'fix-keg-0.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
guruofgentoo committed Nov 8, 2019
2 parents b9b4fb4 + e8248e3 commit 3f5668d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions keg_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class CrudView(keg.web.BaseView):
@classmethod
def map_method_route(cls, method_name, route, methods):
method_route = keg.web.MethodRoute(method_name, route, {'methods': methods},
cls.calc_url(), cls.calc_endpoint())
cls.calc_url(use_blueprint=False),
cls.calc_endpoint(use_blueprint=False))
mr_options = method_route.options()
view_func = cls.as_view(method_route.view_func_name,
method_route.sanitized_method_name('_'))
Expand All @@ -51,10 +52,20 @@ def init_routes(cls):
ex. `cls.map_method_route('read', '/foo', ('GET', ))`"""
super(CrudView, cls).init_routes()

cls.map_method_route('add', '{}/add'.format(cls.calc_url()), ('GET', 'POST'))
cls.map_method_route('edit', '{}/<int:objid>/edit'.format(cls.calc_url()), ('GET', 'POST'))
cls.map_method_route('delete', '{}/<int:objid>/delete'.format(cls.calc_url()), ('GET', ))
cls.map_method_route('list', '{}'.format(cls.calc_url()), ('GET', 'POST'))
cls.map_method_route('add', '{}/add'.format(cls.calc_url(use_blueprint=False)),
('GET', 'POST'))
cls.map_method_route(
'edit',
'{}/<int:objid>/edit'.format(cls.calc_url(use_blueprint=False)),
('GET', 'POST')
)
cls.map_method_route(
'delete',
'{}/<int:objid>/delete'.format(cls.calc_url(use_blueprint=False)),
('GET', )
)
cls.map_method_route('list', '{}'.format(cls.calc_url(use_blueprint=False)),
('GET', 'POST'))

def __init__(self, *args, **kwargs):
super(CrudView, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -208,7 +219,7 @@ def on_add_edit_failure(self, entity, is_edit):

@classmethod
def endpoint_for_action(cls, action):
return '{}.{}:{}'.format(cls.blueprint.name, cls.calc_endpoint(), case_cw2dash(action))
return '{}:{}'.format(cls.calc_endpoint(), case_cw2dash(action))

def make_grid(self):
grid = self.grid_cls()
Expand Down Expand Up @@ -260,7 +271,7 @@ def __init__(self):
self.responding_method = 'responder'

@classmethod
def calc_url(cls):
def calc_url(cls, **kwargs):
authenticator_cls = cls.auth_manager.login_authenticator_cls
responder_cls = authenticator_cls.responder_cls.get(cls.responder_key)
return getattr(responder_cls, 'url', None)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'commonmark',

'Flask-Login',
'Keg>=0.8.0',
'Keg>=0.8.1',
'KegElements',
'inflect',
'passlib',
Expand Down

0 comments on commit 3f5668d

Please sign in to comment.