Users fixes

- Fixes issue #1295.

- Adds PermissionTestCase.

- Resolves Github issue #1156:

Adds a new teacherreg deadline to control open class (a.k.a. walk-in
activity) registration separately from normal class registration.

Sometimes directors want to leave open class registration open longer
than normal class registration. This was previously impossible, because
they used the same deadline.

This commit adds two new deadlines, Teacher/Classes/Create/Class and
Teacher/Classes/Create/OpenClass. The latter is for open classes only,
and the former is for normal classes (and associated functionalities,
such as class copying). The original deadline, Teacher/Classes/Create,
continues to exist, and implies both of the new deadlines. In this way,
the code is backwards-compatible with old settings, and no data
migration is necessary. And when directors want both types of
registration open at the same time, they can make use of this
implication so they only have to set one permission. The program
creation form should also continue to use this permission.