Пример #1
0
class Build(db.Model):
    """A complete build process for a instance, include 4 steps"""
    course_id = db.Column(db.Integer,
                          db.ForeignKey('course_instance.id'),
                          primary_key=True)
    number = db.Column(db.Integer, primary_key=True)
    start_time = db.Column(db.DateTime)
    end_time = db.Column(db.DateTime)
    state = db.Column(db.Enum(BuildState))
    step = db.Column(db.Enum(BuildStep))
    instance = db.relationship('CourseInstance',
                               backref=db.backref(
                                   'builds',
                                   cascade="save-update, merge, "
                                   "delete"))
Пример #2
0
class GitRepository(db.Model, CRUD):
    """Define a Git repository, for SSH key management"""
    origin = db.Column(db.String(255), primary_key=True)
    courses = db.relationship('CourseInstance',
                              backref='git_repository',
                              lazy='dynamic')
    public_key = db.Column(db.Text)
    last_validation = db.Column(db.DateTime)
    state = db.Column(db.Enum(State))

    @property
    def folder_name(self):
        return quote(self.origin)

    @property
    def private_key_path(self):
        return os.path.join(DevelopmentConfig.REPO_KEYS_PATH, self.folder_name)

    @property
    def bare_repo_path(self):
        return os.path.join(DevelopmentConfig.REPO_KEYS_PATH, self.folder_name)

    @property
    def need_validation(self, period=None):
        if period is None or not isinstance(period, timedelta):
            ret = (datetime.utcnow() - self.last_validation) > timedelta(
                days=0, hours=0, seconds=1)
        else:
            ret = (datetime.utcnow() - self.last_validation) > period
        return ret
Пример #3
0
class BuildLog(db.Model):
    """A single step in Build, i.e.: clone"""
    course_id = db.Column(db.Integer, primary_key=True)
    number = db.Column(db.Integer, primary_key=True)
    step = db.Column(db.Enum(BuildStep), primary_key=True)
    roman_step = db.Column(db.String,
                           primary_key=True,
                           default="Roman is not running")
    result = db.Column(db.Boolean)
    start_time = db.Column(db.DateTime)
    end_time = db.Column(db.DateTime)
    log_text = db.Column(db.Text)
Пример #4
0
class ManageCoursePerm(db.Model):
    course__instance_id = db.Column(db.Integer,
                                    db.ForeignKey('course_instance.id'),
                                    primary_key=True)
    group_id = db.Column(db.Integer,
                         db.ForeignKey('group.id'),
                         primary_key=True)

    course_instance = db.relationship('CourseInstance',
                                      foreign_keys=[course__instance_id],
                                      uselist=False,
                                      backref=db.backref("manage_course_perm",
                                                         cascade='all,delete'))
    group = db.relationship('Group',
                            foreign_keys=[group_id],
                            uselist=False,
                            backref=db.backref("manage_course_perm",
                                               cascade='all,delete'))

    type = db.Column(db.Enum(CourseOwnerType))
Пример #5
0
class GroupPermission(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    type = db.Column(db.Enum(PermType))

    def __repr__(self):
        return "<Permission (type={0})>".format(self.type.name)