fix: add stub for PersonView.make_user()
for tailbone compat, but pretty sure we'll want this too
This commit is contained in:
parent
17b8af27a7
commit
9805f808da
|
@ -93,6 +93,11 @@ class PersonView(MasterView):
|
||||||
}
|
}
|
||||||
return self.render_to_response('view_profile', context)
|
return self.render_to_response('view_profile', context)
|
||||||
|
|
||||||
|
def make_user(self):
|
||||||
|
""" """
|
||||||
|
self.request.session.flash("TODO: this feature is not yet supported", 'error')
|
||||||
|
return self.redirect(self.request.get_referrer())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def defaults(cls, config):
|
def defaults(cls, config):
|
||||||
cls._defaults(config)
|
cls._defaults(config)
|
||||||
|
@ -101,6 +106,7 @@ class PersonView(MasterView):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _people_defaults(cls, config):
|
def _people_defaults(cls, config):
|
||||||
route_prefix = cls.get_route_prefix()
|
route_prefix = cls.get_route_prefix()
|
||||||
|
url_prefix = cls.get_url_prefix()
|
||||||
instance_url_prefix = cls.get_instance_url_prefix()
|
instance_url_prefix = cls.get_instance_url_prefix()
|
||||||
permission_prefix = cls.get_permission_prefix()
|
permission_prefix = cls.get_permission_prefix()
|
||||||
|
|
||||||
|
@ -112,6 +118,14 @@ class PersonView(MasterView):
|
||||||
route_name=f'{route_prefix}.view_profile',
|
route_name=f'{route_prefix}.view_profile',
|
||||||
permission=f'{permission_prefix}.view_profile')
|
permission=f'{permission_prefix}.view_profile')
|
||||||
|
|
||||||
|
# make user for person
|
||||||
|
config.add_route(f'{route_prefix}.make_user',
|
||||||
|
f'{url_prefix}/make-user',
|
||||||
|
request_method='POST')
|
||||||
|
config.add_view(cls, attr='make_user',
|
||||||
|
route_name=f'{route_prefix}.make_user',
|
||||||
|
permission='users.create')
|
||||||
|
|
||||||
|
|
||||||
def defaults(config, **kwargs):
|
def defaults(config, **kwargs):
|
||||||
base = globals()
|
base = globals()
|
||||||
|
|
|
@ -56,3 +56,18 @@ class TestPersonView(WebTestCase):
|
||||||
self.request.matchdict = {'uuid': person.uuid}
|
self.request.matchdict = {'uuid': person.uuid}
|
||||||
response = view.view_profile(session=self.session)
|
response = view.view_profile(session=self.session)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_make_user(self):
|
||||||
|
self.pyramid_config.include('wuttaweb.views.common')
|
||||||
|
|
||||||
|
model = self.app.model
|
||||||
|
person = model.Person(full_name="Barney Rubble")
|
||||||
|
self.session.add(person)
|
||||||
|
self.session.commit()
|
||||||
|
|
||||||
|
# sanity check
|
||||||
|
view = self.make_view()
|
||||||
|
self.request.matchdict = {'uuid': person.uuid}
|
||||||
|
response = view.make_user()
|
||||||
|
# nb. this always redirects for now
|
||||||
|
self.assertEqual(response.status_code, 302)
|
||||||
|
|
Loading…
Reference in a new issue