from scoreboard import attachments from scoreboard import auth from scoreboard import cache from scoreboard import controllers from scoreboard import context from scoreboard import csrfutil from scoreboard import errors from scoreboard import main from scoreboard import models from scoreboard import utils from scoreboard import validators app = main.get_app() api = flask_restful.Api(app) context.ensure_setup() # Custom fields class ISO8601DateTime(fields.Raw): """Show datetimes as ISO8601.""" def format(self, value): if value is None: return None if isinstance(value, (int, float)): value = datetime.fromtimestamp(value) if isinstance(value, (datetime.datetime, datetime.date)): if getattr(value, 'tzinfo', True) is None: value = value.replace(tzinfo=pytz.UTC) return value.isoformat()
from flask.ext.restful import fields import hashlib import json import os import pytz from scoreboard.app import app from scoreboard import controllers from scoreboard import context from scoreboard import csrfutil from scoreboard import errors from scoreboard import models from scoreboard import utils api = restful.Api(app) context.ensure_setup() # Custom fields class HintField(fields.Raw): """Custom to show hint only if unlocked or admin.""" def format(self, value): if getattr(value, '__iter__', None): return [self.format(v) for v in value] res = { 'hid': value.hid, 'challenge_cid': value.challenge_cid, 'cost': value.cost, }