learningequality/ka-lite — pull request #1958 by bcipolli (2014-04-13 07:07:00+00:00)
Title: #110: Initial paywall feature (demo).

This PR is intended to further discuss the design of a paywall for central server resources. I'm implementing here as a hotfix (see https://github.com/fle-internal/ka-lite-central/issues/110) while we work on getting the `nalanda-rct1` central server code ready for production.

Main features:

* Has a `CentralLicense` table, where a single user or Organization can have access levels defined.
* Individual tiers of access (currently `Basic`, `Plus`, `Premium`, and `Elite`), with custom levels of data access (currently restricts based on # of `Zones`, `Devices`, and `FacilityUser` records)
* Listeners are implemented to prevent extra objects from being added to an accunt--this allows the paywall features to be extremely localized.
* On error, users can be linked (through a message), or redirected to a page where access options can be reviewed.

Caveats:

* Page with access options isn't built yet.
* Record creation code needs to be wrapped (a) to catch errors (rather than showing a 500 server error) and (b) to be clean about not creating orphan objects. So though most of the logic is localized, a small bit of error logic is not (exception handling)
* Access levels defined are pretty arbitrary:
* `Basic`: max: 1 device, 1 zone, 10 facility users
* `Plus`: max: 5 devices, 2 zones, 100 facility users
* `Premium`: max: 25 devices, 5 zones, 500 facility users
* `Elite`: no restrictions

Would be relatively easy to set each of these values as a JSON blob (as they are already stored as a dictionary), and allow users to pay by the device/zone/user.

Looking for feedback / ideas / :+1: / anything else out there that's helpful in pushing this forward!

![screen shot 2014-04-13 at 12 04 47 am](https://cloud.githubusercontent.com/assets/4072455/2688930/c304c73a-c2d9-11e3-8a5e-ba55a2069905.png)

![image](https://cloud.githubusercontent.com/assets/4072455/2688934/27f8ab34-c2da-11e3-9294-a80f678fcf64.png)