コード例 #1
0
class BasicHttpCredentials(db.Model, SBBase):
    __tablename__  = 'basic_http_credentials'
    __table_args__ = (db.UniqueConstraint('lt_login'), db.UniqueConstraint('lt_id'), TABLE_KWARGS)
    id        = db.Column(db.Integer, primary_key = True)
    lt_id        = db.Column(db.Integer, db.ForeignKey('learning_tools.id'), nullable = False)

    # Arguments for the LT to connect the LabManager
    lt_login     = db.Column(db.Unicode(50), nullable = False)
    lt_password  = db.Column(db.Unicode(50), nullable = False)

    # Arguments for the LabManager to connect the LT. Might be null
    lt_url       = db.Column(db.Unicode(300), nullable = True)
    labmanager_login    = db.Column(db.Unicode(50), nullable = True)
    labmanager_password = db.Column(db.Unicode(50), nullable = True)

    lt = relation('LearningTool', backref=backref('basic_http_authentications', order_by=id, cascade='all, delete'))

    def __init__(self, lt_login = None, lt_password = None, lt = None, lt_url = None, labmanager_login = None, labmanager_password = None):
        self.lt                  = lt
        self.lt_login            = lt_login
        self.lt_password         = lt_password
        self.lt_url              = lt_url
        self.labmanager_login    = labmanager_login
        self.labmanager_password = labmanager_password

    def __repr__(self):
        return "BasicHttpCredentials(lt_login=%(lmslogin)r, lt_password=%(lmspassword)r, lt=%(lmslms)r, lt_url=%(lmsurl)r, labmanager_login=%(labmanlogin)r, labmanager_password=%(labmanpassword)r)" % dict(lmslogin=self.lt_login, lmspassword=self.password, lmslms=self.lt, lmsurl=self.lt_url, labmanlogin=self.labmanager_login, labmanpassword=self.labmanager_password)

    def __unicode__(self):
        return gettext(u"Basic HTTP auth for %(name)s", name=self.lt.name)

    def update_password(self, old_password):
        if self.lt_password != old_password:
            self.lt_password = hashlib.new('sha', self.lt_password.encode('utf8')).hexdigest()
コード例 #2
0
class LtUser(db.Model, SBBase, UserMixin):
    __tablename__  = 'lt_users'
    __table_args__ = (db.UniqueConstraint('login','lt_id'), TABLE_KWARGS)
    id           = db.Column(db.Integer, primary_key = True)
    login        = db.Column(db.Unicode(50), nullable = False, index = True)
    full_name    = db.Column(db.Unicode(50), nullable = False)
    password     = db.Column(db.Unicode(128), nullable = False)
    access_level = db.Column(db.Unicode(50), nullable = False)
    lt_id    = db.Column(db.Integer, db.ForeignKey('learning_tools.id'), nullable = False)

    lt       = relation('LearningTool', backref = backref('users', order_by=id, cascade = 'all,delete'))

    courses = relationship("Course",
                    secondary=users2courses_relation,
                    backref="users")

    def __init__(self, login = None, full_name = None, lt = None, access_level = None):
        self.login        = login
        self.full_name    = full_name
        self.lt           = lt
        self.access_level = access_level

    def __unicode__(self):
        return u"%(lmslogin)s@%(lmsname)s" % dict(lmslogin=self.login, lmsname=self.lt.name)
    
    def get_id(self):
        return u"lt_user::%s::%s" %  (self.lt.name, self.login)

    @classmethod
    def exists(self, login, word, lt_id):
        return db.session.query(self).filter_by(login = login, password = word, lt_id = int(lt_id)).first()    
コード例 #3
0
class Laboratory(db.Model, SBBase):
    __tablename__ = 'laboratories'
    __table_args__ = (db.UniqueConstraint('laboratory_id', 'rlms_id'), TABLE_KWARGS)

    id = db.Column(db.Integer, primary_key = True)

    name                     = db.Column(db.Unicode(255), nullable = False)
    laboratory_id            = db.Column(db.Unicode(255), nullable = False)
    rlms_id                  = db.Column(db.Integer, db.ForeignKey('rlmss.id'), nullable = False)
    visibility               = db.Column(db.Unicode(50), nullable = False, index = True, default = u'private')
    available                = db.Column(db.Boolean, nullable = False, index = True, default = False)
    default_local_identifier = db.Column(db.Unicode(50), nullable = False, default = u"")
    publicly_available       = db.Column(db.Boolean, nullable = False, index = True, default = False)
    # Not unique: otherwise there wouldn't be more than one with '' as value
    public_identifier        = db.Column(db.Unicode(50), nullable = False, default = u"")
    go_lab_reservation       = db.Column(db.Boolean, nullable = False, index = True, default = False)

    rlms          = relation(RLMS.__name__, backref = backref('laboratories', order_by=id, cascade = 'all,delete'))

    def __init__(self, name = None, laboratory_id = None, rlms = None, visibility = None, available = None):
        self.name          = name
        self.laboratory_id = laboratory_id
        self.rlms          = rlms
        self.visibility    = visibility
        self.available     = available

    def __unicode__(self):
        return gettext(u"%(name)s at %(rlms)s", name=self.name, rlms=self.rlms)
コード例 #4
0
ファイル: models.py プロジェクト: rahulyhg/labmanager
class Course(db.Model, SBBase):
    __tablename__ = 'courses'
    __table_args__ = (db.UniqueConstraint('lt_id', 'context_id'), TABLE_KWARGS)
    id = db.Column(db.Integer, primary_key=True)
    lt_id = db.Column(db.Integer,
                      db.ForeignKey('learning_tools.id'),
                      nullable=False)
    name = db.Column(db.Unicode(50), nullable=False)
    context_id = db.Column(db.Unicode(50), nullable=False)

    lt = relation('LearningTool',
                  backref=backref('courses',
                                  order_by=id,
                                  cascade='all, delete'))

    def __init__(self, name=None, lt=None, context_id=None):
        self.name = name
        self.lt = lt
        self.context_id = context_id

    def __repr__(self):
        return "Course(name=%(coursename)r, lt=%(courselms)r, context_id=%(coursecontext)r)" % dict(
            coursename=self.name,
            courselms=self.lt,
            coursecontext=self.context_id)

    def __unicode__(self):
        return gettext(u"%(coursename)s on %(courselms)s",
                       coursename=self.name,
                       courselms=self.lt)
コード例 #5
0
ファイル: models.py プロジェクト: rahulyhg/labmanager
class ShindigCredentials(db.Model, SBBase):
    __tablename__ = 'shindig_credentials'
    __table_args__ = (db.UniqueConstraint('lt_id'), TABLE_KWARGS)
    id = db.Column(db.Integer, primary_key=True)
    lt_id = db.Column(db.Integer,
                      db.ForeignKey('learning_tools.id'),
                      nullable=False)

    # The URL of the Shindig server. Example: http://shindig.epfl.ch (no trailing slash)
    shindig_url = db.Column(db.Unicode(50), nullable=False)

    lt = relation('LearningTool',
                  backref=backref('shindig_credentials',
                                  order_by=id,
                                  cascade='all, delete'))

    def __init__(self, lt=None, shindig_url=None):
        self.lt = lt
        self.shindig_url = shindig_url

    def __repr__(self):
        return "ShindigCredentials(lt=%(lmslms)r, shindig_url=%(shindigurl)r)" % dict(
            lmslms=self.lt, shindigurl=self.shindig_url)

    def __unicode__(self):
        return gettext(u"ShindigCredentials for %(lmsname)s",
                       lmsname=self.lt.name)
コード例 #6
0
ファイル: models.py プロジェクト: rahulyhg/labmanager
class RequestPermissionLT(db.Model, SBBase):
    __tablename__ = 'request_permissions_lt'
    __table_args__ = (db.UniqueConstraint('laboratory_id', 'lt_id'),
                      db.UniqueConstraint('local_identifier',
                                          'lt_id'), TABLE_KWARGS)
    id = db.Column(db.Integer, primary_key=True)
    local_identifier = db.Column(db.Unicode(100), nullable=False, index=True)
    laboratory_id = db.Column(db.Integer,
                              db.ForeignKey('laboratories.id'),
                              nullable=False)
    lt_id = db.Column(db.Integer,
                      db.ForeignKey('learning_tools.id'),
                      nullable=False)
    configuration = db.Column(db.Unicode(10 * 1024))  # JSON document
    accessible = db.Column(db.Boolean,
                           nullable=False,
                           index=True,
                           default=False)

    laboratory = relation(Laboratory.__name__,
                          backref=backref('lab_requestpermissions',
                                          order_by=id,
                                          cascade='all,delete'))
    lt = relation(LearningTool.__name__,
                  backref=backref('lab_requestpermissions',
                                  order_by=id,
                                  cascade='all,delete'))

    def __init__(self,
                 lt=None,
                 laboratory=None,
                 configuration=None,
                 local_identifier=None,
                 accessible=None):
        self.lt = lt
        self.laboratory = laboratory
        self.configuration = configuration
        self.local_identifier = local_identifier
        self.accessible = accessible

    def __unicode__(self):
        return gettext(u"'%(localidentifier)s': lab %(labname)s to %(ltname)s",
                       localidentifier=self.local_identifier,
                       labname=self.laboratory.name,
                       ltname=self.lt.name)
コード例 #7
0
class LearningTool(db.Model, SBBase):
    __tablename__  = 'learning_tools'
    __table_args__ = (db.UniqueConstraint('name'), db.UniqueConstraint('full_name'), TABLE_KWARGS)
    id = db.Column(db.Integer, primary_key = True)
    name      = db.Column(db.Unicode(50), nullable = False, index = True)
    full_name = db.Column(db.Unicode(50), nullable = False, index = True)
    url       = db.Column(db.Unicode(300), nullable = False)

    def __init__(self, name = None, full_name = None, url = None):
        self.name = name
        self.full_name = full_name
        self.url = url

    def __repr__(self):
        return "LearningTool(%(lmsname)r, %(lmsfullname)r, %(lmsurl)r)" % dict(lmsname=self.name, lmsfullname=self.full_name, lmsurl=self.url)

    def __unicode__(self):
        return self.name
コード例 #8
0
class PermissionToLtUser(db.Model, SBBase):
    __tablename__  = 'permissions2ltuser'
    __table_args__ = (db.UniqueConstraint('permission_to_lt_id', 'lt_user_id'), TABLE_KWARGS)
    id = db.Column(db.Integer, primary_key = True)
    permission_to_lt_id = db.Column(db.Integer, db.ForeignKey('permissions2lt.id'), nullable = False, index = True)
    lt_user_id          = db.Column(db.Integer, db.ForeignKey('lt_users.id'), nullable = False, index = True)
    
    # LTI data
    key                  = db.Column(db.Unicode(100), nullable = False, unique = True)
    secret               = db.Column(db.Unicode(100), nullable = False)

    permission_to_lt = relation('PermissionToLt', backref=backref('lt_user_permissions', order_by=id, cascade='all, delete'))
    lt_user = relation('LtUser', backref=backref('lt_user_permissions', order_by=id, cascade='all, delete'))

    def __init__(self, permission_to_lt = None, lt_user = None, key = None, secret = None):
        self.permission_to_lt = permission_to_lt
        self.lt_user          = lt_user
        self.key               = key
        self.secret            = secret
コード例 #9
0
class PermissionToCourse(db.Model, SBBase):
    __tablename__  = 'permissions2course'
    __table_args__ = (db.UniqueConstraint('permission_to_lt_id', 'course_id'), TABLE_KWARGS)
    id = db.Column(db.Integer, primary_key = True)
    configuration = db.Column(db.Unicode(10 * 1024), nullable = True)
    permission_to_lt_id = db.Column(db.Integer, db.ForeignKey('permissions2lt.id'), nullable = False)
    course_id            = db.Column(db.Integer, db.ForeignKey('courses.id'), nullable = False)

    permission_to_lt = relation('PermissionToLt', backref=backref('course_permissions', order_by=id, cascade='all, delete'))
    course            = relation('Course', backref=backref('permissions', order_by=id, cascade='all, delete'))

    def __init__(self, course = None, permission_to_lt = None, configuration = None):
        self.course            = course
        self.configuration     = configuration
        self.permission_to_lt = permission_to_lt

    def __repr__(self):
        return "PermissionToCourse(course=%(coursecourse)r, configuration=%(courseconfiguration)r, permission_to_lt=%(coursepermission)r)" % dict(coursecourse=self.course, courseconfiguration=self.configuration, coursepermission=self.permission_to_lt)

    def __unicode__(self):
        return gettext(u"%(coursename)s from %(lmsname)s on %(permission)s", coursename=self.course.name, lmsname=self.course.lt.name, permission=self.permission_to_lt)