~sirn/fanboi2

ref: 98796226802a26b82c888365ad5b9cd331006792 fanboi2/fanboi2/models d---------
Allow rule override to be scoped.
Add robots.txt internal page.
Fix a bug where rules are not properly returned for single IP.

Since the `ip_address >> operator` only works for IP classes.
In order to compare both classes and single IP, ``>>=`` operator
should be used instead.
Allow specifying global HTML in footer via global/footer.
Allow slash in page names.
Add page model and views.

Allow creation of custom pages that may be use to store static content
such as guidelines or deletion policies. There also exists an
"internal pages" that are used for site customization.

Currently two internal pages are available:

* global_css — custom CSS that applies to every page.
* global_appendix — area that appear on top of footer on every page.

Any number of pages may be created.
Add rules system for evaluating rules based on IP address.

The rules system currently support two type of rules:

* Ban — disallow matched IP address to post in a board.
* Override — override board status for a certain IP address.

Each rule may be trigger on/off and may specify active period.
Fix versioned incorrectly save history for unchanged parent.

When the deleting object references to a parent, a history copy will be
created for the parent regardless whether foreign key exists on the
parent or not.

This change fixes this behavior and no longer create a history copy if
primary key is not local to the parent.
Allow boards to be restricted, locked and archived.

For moderation purpose. Behavior for each status is as follows:

* open — anyone may create new topic and post.
* restricted — nobody can create new topic but may post.
* locked — nobody may create new topic nor post.
* archived — same as locked, but board is no longer shown in the list.

In summary,

+------------+---------------+-----------*----------+
| Status     | Shown in list | New Topic | New Post |
+------------+---------------+-----------*----------+
| open       |      Yes      |    Yes    |    Yes   |
| restricted |      Yes      |    No     |    Yes   |
| locked     |      Yes      |    No     |    No    |
| archived   |      No       |    No     |    No    |
+------------+---------------+-----------*----------+
Use topic_meta for topic metadata retrieval instead of subquery

Since we now allow posts to be deleted and the post may be restored
later, topic metadata such as post count now need to explicitly tracked
somewhere (since we can no longer reuse post.number).
Index naming convention and schema housekeeping.

This commit breaks ability to migrate from existing application to newer
version due to a change in migration ID format. It is highly recommend
to dump the database with data only and restore it to a database, e.g.

    $ pg_dump -T alembic_version -a -Fc > fanboi2.dump
    $ psql template1 -c "DROP DATABASE fanboi2;"
    $ psql template1 -c "CREATE DATABASE fanboi2;"
    $ alembic upgrade c71cae24d111
    $ pg_restore -O -x -a -d fanboi2 fanboi2.dump
    $ alembic upgrade head
Remove column definition in BaseModel.

In order to make everything more explicit and to allow primary key for
the model to be customized, e.g. in case of one-to-one relationship.
Integrate versioned with existing models.
Add versioned implementation based on SQLAlchemy's History Meta.
Split model implementation into multiple files.