コード例 #1
0
ファイル: __init__.py プロジェクト: calcwb/gd
def delete_buzz(bid):
    """Delete Buzz"""
    buzz = Buzz.query.get(bid)
    if buzz is not None:
        buzz.delete()
        session.commit()
    return msg.ok('Buzz deleted successfuly')
コード例 #2
0
ファイル: __init__.py プロジェクト: clarete/gd
def new_comment():
    """Posts new comments to the blog"""
    print "/new_comment/"
    if not is_authenticated():
        resp = make_response(dumps({
            'status': 'error',
            'msg': _(u'User not authenticated'),
            'redirectTo': url_for('auth.login')
        }))
        # if request.form['content']:
        #     resp.set_cookie('live_comment_save', request.form['content'].replace('\n','<br/>') )
        return resp

    try:
        nao_exibir_nome = request.form['nao_exibir_nome']
    except:
        nao_exibir_nome = ""

    try:
        post_id = request.form['comentar_em']
    except:
        post_id = request.form['post_id']

    try:
        wordpress.newComment(
            username=session['username'],
            password=session['password'],
            post_id=post_id,
            content=request.form['content'],
            nao_exibir_nome=nao_exibir_nome
        )
        removecache("comentarios%s" % str(post_id))
        return msg.ok(_(u'Thank you. Your comment was successfuly sent'))
    except xmlrpclib.Fault, err:
        return msg.error(_(err.faultString), code='CommentError')
コード例 #3
0
def contrib_json():
    """Receives a user contribution and saves to the database

    This function will return a JSON format with the result of the
    operation. That can be successful or an error, if it finds any
    problem in data received or the lack of the authentication.
    """
    if not auth.is_authenticated():
        return msg.error(_(u'User not authenticated'))

    raise Exception('Not funny')

    form = ContribForm(csrf_enabled=False)
    if form.validate_on_submit():
        Contrib(title=form.data['title'].encode('utf-8'),
                content=form.data['content'].encode('utf-8'),
                theme=form.data['theme'],
                user=auth.authenticated_user())
        session.commit()

        # Returning the csrf
        data = {'data': _('Contribution received successful')}
        data.update({'csrf': form.csrf.data})
        return msg.ok(data)
    else:
        return format_csrf_error(form, form.errors, 'ValidationError')
コード例 #4
0
def delete_buzz(bid):
    """Delete Buzz"""
    buzz = Buzz.query.get(bid)
    if buzz is not None:
        buzz.delete()
        session.commit()
    return msg.ok('Buzz deleted successfuly')
コード例 #5
0
def new_comment():
    """Posts new comments to the blog"""
    print "/new_comment/"
    if not is_authenticated():
        resp = make_response(
            dumps({
                'status': 'error',
                'msg': _(u'User not authenticated'),
                'redirectTo': url_for('auth.login')
            }))
        # if request.form['content']:
        #     resp.set_cookie('live_comment_save', request.form['content'].replace('\n','<br/>') )
        return resp

    try:
        nao_exibir_nome = request.form['nao_exibir_nome']
    except:
        nao_exibir_nome = ""

    try:
        post_id = request.form['comentar_em']
    except:
        post_id = request.form['post_id']

    try:
        wordpress.newComment(username=session['username'],
                             password=session['password'],
                             post_id=post_id,
                             content=request.form['content'],
                             nao_exibir_nome=nao_exibir_nome)
        removecache("comentarios%s" % str(post_id))
        return msg.ok(_(u'Thank you. Your comment was successfuly sent'))
    except xmlrpclib.Fault, err:
        return msg.error(_(err.faultString), code='CommentError')
コード例 #6
0
def cadastrar_comite():
    if request.method == 'POST':
        nome = request.form['nome']
        email = request.form['email']
        telefone = request.form['telefone']
        cidade = request.form['cidade']
        cn = CadastroComite()
        cn.nome = unicode(nome)
        cn.email = unicode(email)
        cn.telefone = unicode(telefone)
        cn.cidade = unicode(cidade)
        dbsession.commit()

        # #Envia o email avisando que chegou uma nova contribuição
        # sendmail(
        #     conf.COMITE_SUBJECT, conf.COMITE_TO_EMAIL,
        #     conf.COMITE_MSG % {
        #         'titulo': titulo,
        #         'noticia': noticia,
        #     }
        # )

        return msg.ok(_(u'Thank you. Your contribution was successfuly sent.'))
    else:
        return msg.error(_(u'Method not allowed'))
コード例 #7
0
ファイル: __init__.py プロジェクト: gabinetedigital/gd
def cadastrar_comite():
    if request.method == 'POST':
        nome = request.form['nome']
        email = request.form['email']
        telefone = request.form['telefone']
        cidade = request.form['cidade']
        cn = CadastroComite()
        cn.nome = unicode(nome)
        cn.email = unicode(email)
        cn.telefone = unicode(telefone)
        cn.cidade = unicode(cidade)
        dbsession.commit()

        # #Envia o email avisando que chegou uma nova contribuição
        # sendmail(
        #     conf.COMITE_SUBJECT, conf.COMITE_TO_EMAIL,
        #     conf.COMITE_MSG % {
        #         'titulo': titulo,
        #         'noticia': noticia,
        #     }
        # )

        return msg.ok(_(u'Thank you. Your contribution was successfuly sent.'))
    else:
        return msg.error(_(u'Method not allowed'))
コード例 #8
0
ファイル: webapp.py プロジェクト: calcwb/gd
def logout_json():
    """Logs the user out and returns an ok message"""
    authapi.logout()

    resp = make_response( msg.ok(_(u'User loged out')) )
    resp.set_cookie('connect_type', '')
    return resp
コード例 #9
0
ファイル: __init__.py プロジェクト: calcwb/gd
def contrib_json():
    """Receives a user contribution and saves to the database

    This function will return a JSON format with the result of the
    operation. That can be successful or an error, if it finds any
    problem in data received or the lack of the authentication.
    """
    if not auth.is_authenticated():
        return msg.error(_(u'User not authenticated'))

    raise Exception('Not funny')

    form = ContribForm(csrf_enabled=False)
    if form.validate_on_submit():
        Contrib(
            title=form.data['title'].encode('utf-8'),
            content=form.data['content'].encode('utf-8'),
            theme=form.data['theme'],
            user=auth.authenticated_user())
        session.commit()

        # Returning the csrf
        data = { 'data': _('Contribution received successful') }
        data.update({ 'csrf': form.csrf.data })
        return msg.ok(data)
    else:
        return format_csrf_error(form, form.errors, 'ValidationError')
コード例 #10
0
def logout_json():
    """Logs the user out and returns an ok message"""
    authapi.logout()

    resp = make_response( msg.ok(_(u'User loged out')) )
    resp.set_cookie('connect_type', '')
    return resp
コード例 #11
0
ファイル: __init__.py プロジェクト: calcwb/gd
def batch():
    """Batch processing a list of buzz notices"""
    action = request.form['action']
    notices = Buzz.query.filter(Buzz.id.in_(request.form.getlist('notice')))
    { 'accept': lambda: [setattr(i, 'status', u'approved') for i in notices],
      'remove': lambda: [i.delete() for i in notices],
      'suggest': lambda: [setattr(i, 'status', u'selected') for i in notices],
      'publish': lambda: [setattr(i, 'status', u'published') for i in notices],
    }[action]()
    session.commit()
    return msg.ok('Notices processed: %s' % action)
コード例 #12
0
def batch():
    """Batch processing a list of buzz notices"""
    action = request.form['action']
    notices = Buzz.query.filter(Buzz.id.in_(request.form.getlist('notice')))
    {
        'accept': lambda: [setattr(i, 'status', u'approved') for i in notices],
        'remove': lambda: [i.delete() for i in notices],
        'suggest':
        lambda: [setattr(i, 'status', u'selected') for i in notices],
        'publish':
        lambda: [setattr(i, 'status', u'published') for i in notices],
    }[action]()
    session.commit()
    return msg.ok('Notices processed: %s' % action)
コード例 #13
0
ファイル: __init__.py プロジェクト: gabinetedigital/gd
def send_json():
    form = forms.QuestionForm(csrf_enabled=False)
    form.theme.choices = [(None, '----')] + \
        [(i['id'], i['name']) for i in wordpress.govr.getThemes()]
    if form.validate_on_submit():
        wordpress.govr.createContrib(
            form.data['title'],
            form.data['theme'],
            form.data['question'],
            auth.authenticated_user().id,
            '', 0, 0
        )
        return msg.ok(u'Contribution received successful')
    else:
        return format_csrf_error(form, form.errors, 'ValidationError')
コード例 #14
0
ファイル: __init__.py プロジェクト: calcwb/gd
def accept_buzz(bid):
    """Approve messages to appear in the main buzz area"""
    buzz = Buzz.query.get(bid)
    buzz.status = u'approved'

    if(objurlConta > 1):
        avatar = buzz.owner_avatar or "/static/img/avatar.png"
        query = json.dumps({"type": "moderated", "id": str(bid), "author": str(buzz.owner_nick), "avatar": str(avatar), "content": buzz.content.encode('utf8'), "authortype": str(buzz.type_) }, ensure_ascii=False )
        url = objurl+"/buzz/pub?id="+str(buzz.audience_id)
        f = urllib.urlopen(url, query)
        f.close()

    session.commit()

    return msg.ok('Buzz accepted')
コード例 #15
0
ファイル: __init__.py プロジェクト: clarete/gd
def send_json():
    form = forms.QuestionForm(csrf_enabled=False)
    form.theme.choices = [(None, '----')] + \
        [(i['id'], i['name']) for i in wordpress.govr.getThemes()]
    if form.validate_on_submit():
        wordpress.govr.createContrib(
            form.data['title'],
            form.data['theme'],
            form.data['question'],
            auth.authenticated_user().id,
            '', 0, 0
        )
        return msg.ok(u'Contribution received successful')
    else:
        return format_csrf_error(form, form.errors, 'ValidationError')
コード例 #16
0
ファイル: __init__.py プロジェクト: calcwb/gd
def publish_buzz(bid):
    """publish messages"""
    buzz = Buzz.query.get(bid)
    buzz.status = u'published'
    buzz.date_published = datetime.now()

    if(objurlConta > 1):
        avatar = buzz.owner_avatar or "/static/img/avatar.png"
        query = json.dumps({"type": "published", "id": str(bid), "author": str(buzz.owner_nick), "avatar": str(avatar), "content": str(buzz.content), "authortype": str(buzz.type_) }, ensure_ascii=False )
        url = objurl+"/buzz/pub?id="+str(buzz.audience_id)
        f = urllib.urlopen(url, query)
        f.close()

    session.commit()
    return msg.ok('Buzz published')
コード例 #17
0
def post():
    """When ready, this method will post contributions from users that
    choosen to use our internal message service instead of twitter,
    identica or whatever."""
    audience = request.values.get('aid')
    newbuzz = Buzz(owner_nick=auth.authenticated_user().display_name,
                   owner_avatar=u'',
                   user=auth.authenticated_user(),
                   content=request.values.get('message')[:300],
                   type_=get_or_create(BuzzType, name=u'site')[0])
    newbuzz.audience_id = audience
    session.commit()
    return msg.ok(
        _('Notice posted successfuly. Please wait a few while '
          'your message is approved.'))
コード例 #18
0
ファイル: webapp.py プロジェクト: calcwb/gd
def post():
    """When ready, this method will post contributions from users that
    choosen to use our internal message service instead of twitter,
    identica or whatever."""
    audience = request.values.get('aid')
    newbuzz = Buzz(
        owner_nick=auth.authenticated_user().display_name,
        owner_avatar=u'',
        user=auth.authenticated_user(),
        content=request.values.get('message')[:300],
        type_=get_or_create(BuzzType, name=u'site')[0])
    newbuzz.audience_id = audience
    session.commit()
    return msg.ok(_('Notice posted successfuly. Please wait a few while '
                    'your message is approved.'))
コード例 #19
0
def salvar_noticia_comite():
    if request.method == 'POST':
        titulo = request.form['titulo']
        noticia = request.form['noticia']
        cn = ComiteNews()
        cn.title = unicode(titulo)
        cn.content = unicode(noticia)
        cn.user = authenticated_user()
        dbsession.commit()

        #Envia o email avisando que chegou uma nova contribuição
        sendmail(conf.COMITE_SUBJECT, conf.COMITE_TO_EMAIL, conf.COMITE_MSG % {
            'titulo': titulo,
            'noticia': noticia,
        })
        return msg.ok(_(u'Thank you. Your contribution was successfuly sent.'))
    else:
        return msg.error(_(u'Method not allowed'))
コード例 #20
0
ファイル: __init__.py プロジェクト: gabinetedigital/gd
def salvar_noticia_comite():
    if request.method == 'POST':
        titulo = request.form['titulo']
        noticia = request.form['noticia']
        cn = ComiteNews()
        cn.title = unicode(titulo)
        cn.content = unicode(noticia)
        cn.user = authenticated_user()
        dbsession.commit()

        #Envia o email avisando que chegou uma nova contribuição
        sendmail(
            conf.COMITE_SUBJECT, conf.COMITE_TO_EMAIL,
            conf.COMITE_MSG % {
                'titulo': titulo,
                'noticia': noticia,
            }
        )
        return msg.ok(_(u'Thank you. Your contribution was successfuly sent.'))
    else:
        return msg.error(_(u'Method not allowed'))
コード例 #21
0
def new_contribution():
    """Posts new contributions on the page 'conselho-comunicacao' """

    try:
        mostrar_nome = request.form['mostrar_nome']
    except KeyError:
        mostrar_nome = 'N'

    if not is_authenticated():
        return msg.error(_(u'User not authenticated'))
    try:
        print "\n\nMOSTRAR NOME!", mostrar_nome
        cid = wordpress.newComment(
            username=session['username'],
            password=session['password'],
            post_id=request.form['post_id'],
            content=request.form['content1'] or request.form['content2'],
            categoria_sugestao=request.form['categoria_sugestao'],
            mostrar_nome=mostrar_nome)
        return msg.ok(_(u'Thank you. Your contribution was successfuly sent.'))
    except xmlrpclib.Fault, err:
        return msg.error(_(err.faultString), code='CommentError')
コード例 #22
0
ファイル: __init__.py プロジェクト: gabinetedigital/gd
def new_contribution():
    """Posts new contributions on the page 'conselho-comunicacao' """

    try:
        mostrar_nome = request.form['mostrar_nome']
    except KeyError :
        mostrar_nome = 'N'

    if not is_authenticated():
        return msg.error(_(u'User not authenticated'))
    try:
        print "\n\nMOSTRAR NOME!", mostrar_nome
        cid = wordpress.newComment(
            username=session['username'],
            password=session['password'],
            post_id=request.form['post_id'],
            content=request.form['content1'] or request.form['content2'],
            categoria_sugestao=request.form['categoria_sugestao'],
            mostrar_nome=mostrar_nome
        )
        return msg.ok(_(u'Thank you. Your contribution was successfuly sent.'))
    except xmlrpclib.Fault, err:
        return msg.error(_(err.faultString), code='CommentError')
コード例 #23
0
def accept_buzz(bid):
    """Approve messages to appear in the main buzz area"""
    buzz = Buzz.query.get(bid)
    buzz.status = u'approved'

    if (objurlConta > 1):
        avatar = buzz.owner_avatar or "/static/img/avatar.png"
        query = json.dumps(
            {
                "type": "moderated",
                "id": str(bid),
                "author": str(buzz.owner_nick),
                "avatar": str(avatar),
                "content": buzz.content.encode('utf8'),
                "authortype": str(buzz.type_)
            },
            ensure_ascii=False)
        url = objurl + "/buzz/pub?id=" + str(buzz.audience_id)
        f = urllib.urlopen(url, query)
        f.close()

    session.commit()

    return msg.ok('Buzz accepted')
コード例 #24
0
def publish_buzz(bid):
    """publish messages"""
    buzz = Buzz.query.get(bid)
    buzz.status = u'published'
    buzz.date_published = datetime.now()

    if (objurlConta > 1):
        avatar = buzz.owner_avatar or "/static/img/avatar.png"
        query = json.dumps(
            {
                "type": "published",
                "id": str(bid),
                "author": str(buzz.owner_nick),
                "avatar": str(avatar),
                "content": str(buzz.content),
                "authortype": str(buzz.type_)
            },
            ensure_ascii=False)
        url = objurl + "/buzz/pub?id=" + str(buzz.audience_id)
        f = urllib.urlopen(url, query)
        f.close()

    session.commit()
    return msg.ok('Buzz published')
コード例 #25
0
def select_buzz(bid):
    """suggest messages to publish"""
    buzz = Buzz.query.get(bid)
    buzz.status = u'selected'
    session.commit()
    return msg.ok('Buzz selected')
コード例 #26
0
ファイル: __init__.py プロジェクト: calcwb/gd
def dont_publish_buzz(bid):
    """not publish messages"""
    buzz = Buzz.query.get(bid)
    buzz.status = u'approved'
    session.commit()
    return msg.ok('Buzz unpublished')
コード例 #27
0
ファイル: __init__.py プロジェクト: calcwb/gd
def select_buzz(bid):
    """suggest messages to publish"""
    buzz = Buzz.query.get(bid)
    buzz.status = u'selected'
    session.commit()
    return msg.ok('Buzz selected')
コード例 #28
0
def dont_publish_buzz(bid):
    """not publish messages"""
    buzz = Buzz.query.get(bid)
    buzz.status = u'approved'
    session.commit()
    return msg.ok('Buzz unpublished')