class Principal(Base): """A minimal 'Principal' implementation. The attributes on this object correspond to what one ought to implement to get full support by the system. You're free to add additional attributes. - As convenience, when passing 'password' in the initializer, it is hashed using 'get_principals().hash_password' - The boolean 'active' attribute defines whether a principal may log in. This allows the deactivation of accounts without deleting them. - The 'confirm_token' attribute is set whenever a user has forgotten their password. This token is used to identify the receiver of the email. This attribute should be set to 'None' once confirmation has succeeded. """ __tablename__ = 'principals' __mapper_args__ = dict(order_by='principals.name', ) id = Column(Integer, primary_key=True) name = Column(Unicode(100), unique=True) password = Column(Unicode(100)) active = Column(Boolean) confirm_token = Column(Unicode(100)) title = Column(Unicode(100), nullable=False) email = Column(Unicode(100), unique=True) groups = Column(JsonType(), nullable=False) creation_date = Column(DateTime(), nullable=False) last_login_date = Column(DateTime()) def __init__(self, name, password=None, active=True, confirm_token=None, title=u"", email=None, groups=()): self.name = name if password is not None: password = get_principals().hash_password(password) self.password = password self.active = active self.confirm_token = confirm_token self.title = title self.email = email self.groups = groups self.creation_date = datetime.now() self.last_login_date = None def __repr__(self): # pragma: no cover return '<Principal %r>' % self.name
def upgrade(): op.execute('ALTER TABLE calendars RENAME TO old_calendars') op.create_table( 'calendars', sa.Column('id', sa.Integer(), sa.ForeignKey('documents.id'), primary_key=True), sa.Column('feeds', JsonType(), nullable=False), sa.Column('weekends', sa.Boolean())) op.execute('INSERT INTO calendars SELECT * FROM old_calendars') op.execute('INSERT INTO documents (id) SELECT id FROM old_calendars') op.drop_table('old_calendars')
class Calendar(Content): implements(IDefaultWorkflow) id = Column(Integer, ForeignKey('contents.id'), primary_key=True) feeds = Column(JsonType(), nullable=False) weekends = Column(Boolean()) type_info = Content.type_info.copy( name=u'Calendar', title=_(u'Calendar'), add_view=u'add_calendar', addable_to=[u'Document'], ) def __init__(self, feeds=(), weekends=True, **kwargs): super(Calendar, self).__init__(**kwargs) self.feeds = feeds self.weekends = weekends
def make(self): from kotti.sqla import JsonType return JsonType()