Exemple #1
0
def fetch_new_questions():
    res = ''
    channels = Channel.query().fetch(Channel.MAXIMUM_CHANNELS_NUMBER)
    for c in channels:
        c.fetch_new_questions()
        res += u'Channel: {}<br/>{}<br/>'.format(c.title, c.data)
    return res
Exemple #2
0
def send(event, message):
    from models import Channel
    for channel in Channel.query():
        channel.send({
            'event': event,
            'data': message
        })
    def post(self):
        body = self.check_body(['title', 'base64_img'])
        logging.debug('called')
        try:
            channel = Channel.query(Channel.title == body['title']).get()
            logging.info(body)

            if channel:
                channel.put()
                self.response.out.write(channel.key.id())
            else:
                channel_id = Channel.create(title=body['title'],
                                            base64_img=body['base64_img'])
                self.response.out.write(channel_id)
        except ValueError as e:
            self.abort(code=404, detail=e.message)
Exemple #4
0
def list_channels():
    """List all channels"""
    channels = Channel.query()
    form = ChannelForm()
    if form.validate_on_submit():
        channel = Channel(
            id = form.id.data,
            name = form.name.data,
            token = form.token.data,
        )
        try:
            channel.put()
            flash(u'Channel %s successfully saved.' % channel.id, 'success')
            return redirect(url_for('qq.list_channels'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('qq.list_channels'))
    return render_template('list_channels.html', channels=channels, form=form)
Exemple #5
0
def channels():
    cs = Channel.query().order(Channel.title).fetch()
    return render_template('admin/channel/index.html', channels=cs)