Site notifications would be more useful if they had options to control who they were shown to and on what pages. For the user, some obvious options are show to everyone, or show to project devs/admins. I can't think of others right now. For the pages, tool type(s) could be a useful selection. But all pages are a tool (plus I'd like this to be able to work with external code that can integrate with Allura) so a url regex would be a good option too. That'd cover lots of possibilities (specific neighborhood, specific project, auth pages, create project page, etc).
Closed 867, 868.
ib/8023a
I found some ways this can be better, but in general this is working just as it should.
Performance issue:
my_projects_by_role_name
returns a mongo query cursor, so calling.count()
on it (twice) and.first()
will run 3 separate queries. Better to save it to a list first (with.all()
orlist(...)
and then accesslen(...)
andprojects[0]
. Or, even better probably, would be to changemy_projects_by_role_name
to run the.all()
and return a list for you. Then nobody else using that method will risk the same problem again in the future. It looks like existing uses ofmy_projects_by_role_name
probably won't need to be modified to work with that (maybe a test though).Small style note: you don't need
is not None
most of the time. For example,if note.user_role
will work too and is simpler to read.In
test_get_site_notification_with_page_tool_type_page_regex
it'd be better to patch therequest.url
instead ofre.search
. Thenre.search
will run and you can make sure the pattern matching against urls works as expected.And instead of
request.url
I think it'd be more useful to match againstrequest.path_qs
which doesn't include the hostname parts. There's no need to match things against the url hostname, and usingpath_qs
will let us write regexes that anchor to the beginning of the path, like^/u/
to show on any pages in the /u/ neighborhood.Last edit: Dave Brondsema 2015-12-15
Closed #879.
ib/8023b
Note: one test fails due to https://forge-allura.apache.org/p/allura/git/merge-requests/63/