It's sometimes useful to present some information to all users in a semi-persistent fashion, related to the site as a whole. Create a mechanism to store and present these notifications.
The notifications should be semi-persistent, unlike the existing flash messages. The notifications should be closable; once closed, they should not show up for that user again until a new message is in effect. The notifications should also support a (per message?) configurable number of impressions per user; after the user has seen the message the specified number of times, it should no longer be shown to that user.
allura:cj/6777
The mongo index should be on (deleted, _id) for the current() query to be fastest. And since this will run on every pageview, we need it to be very fast.
Setting a cookie for each notification's impression count and also when it's been closed seems excessive. That could add up to a lot of cookies. We could have just one cookie per notification. Or probably better would be to store it on user session which is persisted as just a single cookie. And we can keep that small by popping off the old notifications' data. One problem: closing a notification is done all client-side in this implementation. We'd have to make an AJAX call if we stored it in the session. Hybrid could be a cookie for closed notification and impressions stored on the session. Or, assuming we have only one current notification, we could do it all with cookies but just one or two, using the same cookie name all the time and just updating the value to match the current notification id.
Since there's no obvious administration mechanism for this, we should add to docs/administration.rst explaining how to manually create a notification entry.
I assumed we would only have one active notification at a time and that we wouldn't be changing them all that often. I did consider putting it in the user session, but figured that they would fill up the user session faster than the multiple cookies would cause a problem for the browser.
I can switch it to use a single cookie, though, since the query logic already assumes only one active notification at a time.
I agree with your assumptions. Eventually they will accumulate though. And if it's in the session we can pop the old ones off. I guess we could do that with cookies too. Either way, a bit of cleanup I think is appropriate.
Rebased and force-pushed to:
allura:cj/6777
allura.tests.functional.test_admin:TestExport.test_access
among others fails with:Fixup pushed (please squash)