コード例 #1
0
def responder(id_msg):
    professor = request.args.get('professor','')
    aluno = request.args.get('aluno','')
    mensagem = request.json.get('texto',None)
    if aluno == '' and professor == '':
      return jsonify({'response': False, 'error': 'Insira aluno ou professor'})
    for todo in todo_forum:
      for texto in todo['textos']:
        for comment in texto:
          if comment['id_msg'] == id_msg:
            if(professor != ''):
              try:
                if acesso.leciona(professor, todo['disciplina']):
                  texto.append(monta_dic(professor, mensagem))
                  return jsonify({'response': True, 'post_id': next_post})
                if not acesso.leciona(professor, todo['disciplina']):
                  return jsonify({'response': False, 'error': 'Professor nao existente'})
              except:
                return jsonify({'response': False, 'error': 'falha interna do servidor'}), 500
            if(aluno != ''):
              if acesso.eh_aluno(aluno, todo['disciplina']):
                texto.append(monta_dic(aluno, mensagem))
                return jsonify({'response': True, 'post_id': next_post})
              if not acesso.eh_aluno(aluno, todo['disciplina']):
                return jsonify({'response': False, 'error': 'Aluno nao existente'})
コード例 #2
0
ファイル: forum.py プロジェクト: lcs-amorim/Exercicios
def get_texts(id_disciplina):
    professor = request.args.get('professor', '')
    aluno = request.args.get('aluno', '')
    resposta = {}
    if (professor == '') and (aluno == ''):
        return jsonify({'response': False, 'textos': resposta}), 404

    if leciona(professor, id_disciplina) == True:
        for scan in todo_forum:
            if scan['disciplina'] == id_disciplina:
                resposta = scan
                if participantes(professor, id_disciplina) == True:
                    part = participantes(professor, id_disciplina)
                    test = part['participantes']
                return jsonify({
                    'response': True,
                    'textos': resposta['textos'],
                    'participantes': test
                }), 200

    if eh_aluno(aluno, id_disciplina) == True:
        for scan1 in todo_forum:
            if scan1['disciplina'] == id_disciplina:
                resposta = scan
                if participantes(aluno, id_disciplina) == True:
                    part = participantes(aluno, id_disciplina)
                    test = part['participantes']
                return jsonify({
                    'response': True,
                    'textos': resposta['textos'],
                    'participantes': test
                }), 200
コード例 #3
0
def get_texts(id_disciplina):

    pessoa = request.args.get('professor','')+request.args.get('aluno','')
    if pessoa == '':
        return jsonify({'response':False,'textos':[]})
    pessoa = int(pessoa)
    if not acesso.leciona(pessoa,id_disciplina) and not acesso.eh_aluno(pessoa,id_disciplina):
        return jsonify({'response':False,'textos':[]})
    for di in todo_forum:
        if(di['disciplina'] == id_disciplina):
            return jsonify({'response':True,'textos':di['textos']})
コード例 #4
0
def get_texts(id_disciplina):
    professor = request.args.get('professor','')
    aluno = request.args.get('aluno', '')
    copia = []
    print()
    if aluno == '' and professor == '':
            return jsonify({'response': False, 'textos':[]})
    for forum in todo_forum:
            if id_disciplina == forum['disciplina']:
                    if professor != '':
                            if(acesso.leciona(professor, id_disciplina)):
                                    participa = acesso.participantes(id_disciplina)['participantes']
                                    return jsonify({'textos':forum['textos'], 'response': True, 'participantes': participa})
                            else:
                                    return jsonify({'response': False, 'textos':[]})
                    elif aluno != '':
                            if(acesso.eh_aluno(aluno, id_disciplina)):
                                    copia.append(forum['textos'])
                                    participa = acesso.participantes(id_disciplina)['participantes']
                                    return jsonify({'textos':forum['textos'], 'response': True, 'participantes': participa})
                            else:
                                    return jsonify({'response': False, 'textos':[]})
    return jsonify({'response': False, 'error': 'disciplina nao encontrada'})
コード例 #5
0
ファイル: runtests.py プロジェクト: lcs-amorim/Exercicios
 def test_005_metodo_eh_aluno(self):
     self.assertEqual(acesso.eh_aluno(10,1),True)
     self.assertEqual(acesso.eh_aluno(10,2),False)
     self.assertEqual(acesso.eh_aluno(1,200),(False,'inexistente'))