Add a license preference field

This feature is absolutely necessary. Now a user can simply define
their default license and quickly go through a form, as opposed to
stopping to click on the select and choosing the same option over
and over again.

Also added DB migration for the field, so that's working now, too.

Rebased by Sebastian and made the default value to be unicode.

Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Mark Holmquist
2012-11-10 16:59:37 -08:00
committed by Sebastian Spaeth
parent 49745d5138
commit dc4dfbde35
6 changed files with 62 additions and 36 deletions

View File

@@ -184,3 +184,15 @@ def fix_CollectionItem_v0_constraint(db_conn):
pass
db_conn.commit()
@RegisterMigration(8, MIGRATIONS)
def add_license_preference(db):
metadata = MetaData(bind=db.bind)
user_table = Table('core__users', metadata, autoload=True,
autoload_with=db.bind)
col = Column('license_preference', Unicode, default=u'')
col.create(user_table)
db.commit()

View File

@@ -63,6 +63,7 @@ class User(Base, UserMixin):
# Intented to be nullable=False, but migrations would not work for it
# set to nullable=True implicitly.
wants_comment_notification = Column(Boolean, default=True)
license_preference = Column(Unicode)
verification_key = Column(Unicode)
is_admin = Column(Boolean, default=False, nullable=False)
url = Column(Unicode)