예제 #1
0
def new_issue_landing():
    if 'authorized' in session and session['authorized'] is True:
        projects = DataBaseManager.get_projects()
        documents = list()
        disciplines = list()

        db_success = True

        selected_project = request.form.get('project')
        selected_document = request.form.get('document')
        selected_discipline = request.form.get('discipline')
        current_issue = request.form.get('issue')
        issues_so_far = request.form.get('issues_so_far')

        if selected_project:
            DataBaseManager.add_project(selected_project)
            documents = DataBaseManager.get_documents_for(selected_project)

        if selected_project and selected_document:
            DataBaseManager.add_document(selected_project, selected_document)
            disciplines = DataBaseManager.get_disciplines()

        if issues_so_far == 'None' or issues_so_far == '[]':
            issues_so_far = ''

        if selected_project and selected_document and selected_discipline and current_issue:
            id_builder = hashlib.sha1()
            id_builder.update(str(time.time()).encode('utf-8'))
            id_builder.hexdigest()
            identifier = id_builder.hexdigest()[:5]

            sentiment = TextAi.get_sentiment(current_issue).get('Sentiment')
            voice = Voice.synthesize(current_issue)

            db_success = DataBaseManager.add_issue(selected_project, selected_document, selected_discipline,
                                                   current_issue, datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
                                                   identifier, sentiment, voice, session['user'])

            if db_success:
                issues_so_far = selected_project + " :: " + selected_document + " :: " + selected_discipline + \
                                "\n" + current_issue.rstrip() + "\n\n" + issues_so_far

        return render_template("newissue.html", projects=projects, selected_project=selected_project,
                               documents=documents, selected_document=selected_document, disciplines=disciplines,
                               selected_discipline=selected_discipline, issues_so_far=issues_so_far,
                               db_success=db_success)

    return redirect(url_for("index"))
예제 #2
0
def render_main_issue_list():
    if 'authorized' in session and session['authorized'] is True:
        documents = list()
        status_input = parse_string(request.form.get('status'))
        project_input = parse_string(request.form.get('project'))
        discipline_input = parse_string(request.form.get('discipline'))
        sentiment_input = parse_string(request.form.get('sentiment'))
        document_input = parse_string(request.form.get('document'))
        last_key = parse_string(request.form.get('db_key'))
        first_page = parse_string(request.form.get('first_page'))
        filter = parse_string(request.form.get('filter'))
        next_b = parse_string(request.form.get('next_b'))

        if not filter and not first_page and not next_b:
            first_page = 'first_page'

        if project_input:
            documents = DataBaseManager.get_documents_for(project_input)

        if last_key:
            last_key_dict = eval(last_key)
        else:
            last_key_dict = None

        issues, last_key = Pagination.page_data(last_key_dict, project_input, document_input, discipline_input,
                                                          sentiment_input, status_input)
        projects = DataBaseManager.get_projects()
        disciplines = DataBaseManager.get_disciplines()
        lists = ['Open', 'Closed']
        lists2 = ['Closed', 'Open']

        return render_template("issue.html", issues=issues, projects=projects, documents=documents,
                               disciplines=disciplines, lists=lists, lists2=lists2, selected_status=status_input,
                               selected_project=project_input, selected_document=document_input,
                               selected_discipline=discipline_input, selected_sentiment=sentiment_input,
                               last_key=last_key, first_page=first_page)

    return redirect(url_for("index"))