Example #1
0
class ToDoListOptions(Schema):
    project = fields.CoalesceField(
        [fields.Integer(), fields.Text()], default=None, required=False)
    tag = custom_fields.StringIdentifiedField(models.Tag,
                                              default=None,
                                              required=False)
    query = fields.Text(default='')
    all_tasks = fields.Bool(default=False)
    flat = fields.Bool(default=False)
    limit = fields.Integer(default=25)
    ignore_priority = fields.Bool(default=False)
    minimum_priority = fields.CoalesceField(
        [fields.Integer(), fields.Text()], default=None, required=False)
    state = fields.Enum(models.State,
                        soft_match=True,
                        required=False,
                        default=None)
    order_by = fields.List(
        fields.MultiChoiceField(
            {
                'created_at',
                'finished_at',
                'state',
                'priority',
                'project',
            },
            soft_match=True,
        ),
        required=False,
        default=None,
    )
Example #2
0
class CreateTodoSchema(Schema):
    tags = fields.List(
        fields.CoalesceField([
            fields.Integer(),
            fields.Text(min=1, max=127, pattern=re.compile(r'\w+')),
        ]),
        default=(),
    )
    project = fields.CoalesceField(
        [
            fields.Integer(),
            fields.Text(min=1, max=127, pattern=re.compile(r'\w+')),
        ],
        required=False,
    )
    parents = fields.List(
        fields.CoalesceField([
            fields.Integer(),
            fields.Text(),
        ]),
        default=(),
    )
    priority = fields.CoalesceField(
        [
            fields.Integer(),
            fields.Text(min=1, max=127, pattern=re.compile(r'\w+')),
        ],
        required=False,
    )
Example #3
0
class StatsOptionsSchema(Schema):
    project = fields.CoalesceField(
        [fields.Integer(), fields.Text()], default=None, required=False)
    tag = custom_fields.StringIdentifiedField(models.Tag,
                                              default=None,
                                              required=False)
    top_level_only = fields.Bool(default=True)
    ignore_priority = fields.Bool(default=False)
    minimum_priority = fields.CoalesceField(
        [fields.Integer(), fields.Text()], default=None, required=False)
    last_n_days = fields.Integer(default=128)
Example #4
0
class LobbiesSchema(Schema):
    name = fields.Text()
    game_type = fields.Text()
    state = fields.Text()
    owner = fields.Text()
    users = fields.Lambda(lambda l: '{}/{}'.format(
        len(l.users),
        l.lobby_options.size,
    ))
    min_size = fields.Lambda(lambda l: l.lobby_options.minimum_size)
    requires_ready = fields.Lambda(
        lambda l: bool(l.lobby_options.require_ready),
        display_name='Req. Ready')
    auto_unready = fields.Lambda(
        lambda l: bool(l.lobby_options.unready_on_change))
Example #5
0
class PrioritySchema(Schema[models.Priority]):
    id = fields.Integer(read_only=True)
    name = fields.Text(min=1, max=127, pattern=re.compile(r'\w+'))
    created_at = fields.Datetime(read_only=True)
    level = fields.Integer()
    project = fields.Lambda(lambda p: p.project.name)
    is_default = fields.Bool(default=False)
Example #6
0
class ToDoSchema(Schema[models.ToDo]):
    id = fields.Integer(read_only=True)

    text = fields.Text()

    tags = fields.Lambda(lambda todo: [tag.name for tag in todo.tags])
    comments = fields.Lambda(
        lambda todo: [comment.text for comment in todo.comments])
    project = fields.Lambda(lambda todo: todo.project.name)

    priority = fields.Related(PrioritySchema(), read_only=True)

    created_at = fields.Datetime(read_only=True)
    finished_at = fields.Datetime(read_only=True)

    state = fields.Enum(models.State, read_only=True)

    children = fields.List(fields.SelfRelated(),
                           read_only=True,
                           source='active_children')
Example #7
0
class AlarmSchema(Schema[models.Alarm]):
    id = fields.Integer(read_only=True)

    text = fields.Text()

    started_at = fields.Datetime(read_only=True)
    end_at = fields.Datetime()
    next_reminder_time_target = fields.Datetime(required=False, read_only=True)

    requires_acknowledgment = fields.Bool(required=False)
    retry_delay = fields.Integer(required=False, min=5)
    send_email = fields.Bool(required=False)
    silent = fields.Bool(required=False)
    level = fields.Enum(models.ImportanceLevel, required=False)

    times_notified = fields.Integer(read_only=True)
    acknowledged = fields.Bool(read_only=True)

    canceled = fields.Bool(read_only=True)
    success = fields.Bool(read_only=True)
Example #8
0
class TagSchema(Schema[models.Tag]):
    id = fields.Integer(read_only=True)
    name = fields.Text(min=1, max=127, pattern=re.compile(r'\w+'))
    created_at = fields.Datetime(read_only=True)
Example #9
0
class CommentSchema(Schema):
    target = fields.CoalesceField([fields.Integer(), fields.Text()])
    project = custom_fields.StringIdentifiedField(models.Project, default=None)
    comment = fields.Text()
Example #10
0
class TaggedSchema(Schema[models.Tagged]):
    todo_target = fields.CoalesceField([fields.Integer(), fields.Text()])
    tag_target = custom_fields.StringIdentifiedField(models.Tag)
    project = custom_fields.StringIdentifiedField(models.Project, default=None)
    recursive = fields.Bool(default=False, write_only=True)
Example #11
0
class ProjectSchema(Schema[models.Project]):
    id = fields.Integer(read_only=True)
    name = fields.Text(min=1, max=127, pattern=re.compile(r'\w+'))
    created_at = fields.Datetime(read_only=True)
    is_default = fields.Bool(default=False)
    default_priority_filter = fields.Integer(default=None, required=False)
Example #12
0
class ModifyPrioritySchema(Schema[models.Tagged]):
    todo = fields.CoalesceField([fields.Integer(), fields.Text()])
    project = custom_fields.StringIdentifiedField(models.Project, default=None)
    priority = fields.CoalesceField([fields.Integer(), fields.Text()])
    recursive = fields.Bool(default=False, write_only=True)
Example #13
0
class AlarmListOptions(Schema):
    limit = fields.Integer(default=25)
    query = fields.CoalesceField(
        [fields.Integer(), fields.Text()], default=None, required=False)
Example #14
0
    try:
        SC.session.commit()
    except IntegrityError:
        SC.session.rollback()
        return 'Project already exists', status.HTTP_400_BAD_REQUEST

    return schema.serialize(project)


@todo_project_views.route('/project/', methods = ['PATCH'])
@inject_schema(
    Schema(
        {
            'project': StringIdentifiedField(models.Project),
            'default_priority_filter': fields.CoalesceField(
                [fields.Integer(), fields.Text()],
                default = None,
                required = False,
            ),
        }
    ),
    use_args = False,
)
def modify_project(project: models.Project, default_priority_filter: t.Union[int, str, None]):
    if default_priority_filter is not None:
        default_priority_filter = get_priority_level(SC.session, default_priority_filter, project)
    project.default_priority_filter = default_priority_filter
    SC.session.commit()
    return schemas.ProjectSchema().serialize(project)

Example #15
0
    return schema.serialize(alarm)


@alarm_views.route('/ding/', methods=['POST'])
def ding():
    ding_sync()
    return {'status': 'ok'}


@alarm_views.route('/notify/', methods=['POST'])
@with_errors
@inject_schema(
    Schema(
        fields={
            'title': fields.Text(max=61),
            'description': fields.Text(
                max=127,
                required=False,
                default='',
            ),
        }),
    use_args=False,
)
def notify(title: str, description: str):
    _notify(title, description)
    return {'status': 'ok'}


class BaseAlarmList(View):
    @abstractmethod
Example #16
0
class ModifyToDoSchema(Schema):
    target = fields.CoalesceField([fields.Integer(), fields.Text()])
    project = custom_fields.StringIdentifiedField(models.Project, default=None)
    description = fields.Text()
Example #17
0
from hardcandy.schema import Schema

from fml.server import models
from fml.server.ciwatch.watch import CI_WATCHER
from fml.server.session import SessionContainer as SC
from fml.server.views.utils import inject_schema, with_errors

ci_watch_views = Blueprint('ci_watch_views', __name__, url_prefix='/ci')
request: APIRequest


@ci_watch_views.route('/watch/', methods=['POST'])
@with_errors
@inject_schema(
    Schema({
        'cookie_name': fields.Text(required=False, default=None),
        'cookie_value': fields.Text(required=False, default=None),
        'run_id': fields.Text(),
        'timeout': fields.Datetime(required=False, default=None),
        'superseed': fields.Bool(default=False),
    }),
    use_args=False,
)
def watch_ci(
    cookie_name: t.Optional[str],
    cookie_value: t.Optional[str],
    run_id: str,
    timeout: t.Optional[datetime.datetime],
    superseed: bool,
):
    if cookie_name and cookie_value: