Exemplo n.º 1
0
def load():
    companies = []

    for company in data_manager.import_data("company/companies.csv"):
        companies.append(Company(*company))

    return companies
Exemplo n.º 2
0
def load():
    positions = []

    for position in data_manager.import_data("position/positions.csv"):
        positions.append(Position(*position))

    return positions
Exemplo n.º 3
0
def load():
    applications = []

    for application in data_manager.import_data("application/applications.csv"):
        applications.append(Application(*application))

    return applications
Exemplo n.º 4
0
def index():
    stories = None
    saved_data = data_manager.import_data()
    if saved_data:
        stories = saved_data

    return render_template('index.html', stories=stories)
Exemplo n.º 5
0
def story(id=None):
    saved_data = data_manager.import_data()
    if request.method == 'POST':
        if id:
            saved_data[id]['title'] = request.form['title']
            saved_data[id]['user_story'] = request.form['user_story']
            saved_data[id]['acceptance_criteria'] = request.form[
                'acceptance_criteria']
            saved_data[id]['business_value'] = request.form['business_value']
            saved_data[id]['estimation'] = request.form['estimation']
            saved_data[id]['status'] = request.form['status']
        else:
            new_story = {
                'title': request.form['title'],
                'user_story': request.form['user_story'],
                'acceptance_criteria': request.form['acceptance_criteria'],
                'business_value': request.form['business_value'],
                'estimation': request.form['estimation'],
                'status': 'In Progress'
            }
            saved_data[str(len(saved_data))] = new_story
        data_manager.export_data(saved_data)
        return redirect('/')
    story = None
    if id:
        story = saved_data[id]

    return render_template('story.html', Id=id, story=story)
Exemplo n.º 6
0
def load():
    students = []

    for student in data_manager.import_data("student/students.csv"):
        students.append(Student(*student))

    return students
Exemplo n.º 7
0
def delete_answers_related_to_question(question_id):
    '''
    Deletes answers retated to question from csv
    :param question_id:
    :param filename:
    :return: nothing
    '''
    filename = 'sample_data/answer.csv'
    answers = data_manager.import_data(filename)
    for answer in answers:
        if answer["question_id"] == question_id:
            answers.remove(answer)
        global answer_labels
    data_manager.update_data(filename, answer_data, answers)
Exemplo n.º 8
0
def delete_question(id_):
    '''
    1. Delete question form list of dictionaries
    2. write it to file
    3. Delete answers retated to question from csv
    :param id_: str - id of question record to be deleted
    :param filename: str
    :return: nothing
    '''
    filename = 'sample_data/question.csv'
    questions = data_manager.import_data(filename)
    for question in questions:
        if question["id"] in id_:
            questions.remove(question)
    global QUESTION_LABELS
    data_manager.update_data(filename, QUESTION_LABELS, questions)
    delete_answers_related_to_question(id_)
Exemplo n.º 9
0
def sort_questions(sort_by, order):
    '''
    Sorts list of dictionaies by given parameter in ascending or descending order.
    :param list_of_dictionaries:
    :param sort_by: key by which we want to sort by
    :param order: boolean (True or False)  True = descending
    :return: sorted list of dicts
    '''
    if order == "desc":
        order = True
    else:
        order = False

    global QUESTION_FILE
    list_of_dictionaries = data_manager.import_data(QUESTION_FILE)
    return sorted(list_of_dictionaries,
                  key=lambda i: i[str(sort_by)],
                  reverse=order)
Exemplo n.º 10
0
    '''
    if order == "desc":
        order = True
    else:
        order = False

    global QUESTION_FILE
    list_of_dictionaries = data_manager.import_data(QUESTION_FILE)
    return sorted(list_of_dictionaries,
                  key=lambda i: i[str(sort_by)],
                  reverse=order)


###  FUNCTIONS READING CSV FILES AND   ###sample

answer_data = data_manager.import_data(ANSWER_FILE)


def get_question_data():
    question_data = sort_questions("submission_time", True)
    return question_data


### Pulling from database  ###

###   WRITING TO CSV   ###


def id_generator(filename):
    exists = os.path.isfile(filename)
    if not exists:
Exemplo n.º 11
0
### SORTING  ###
def sort_list_of_dict(list_of_dictionaries, sort_by, order):
    '''
    Sorts list of dictionaies by given parameter in ascending or descending order.
    :param list_of_dictionaries:
    :param sort_by: key by which we want to sort by
    :param order: boolean (True or False)  True = descending
    :return: sorted list of dicts
    '''
    return sorted(list_of_dictionaries,
                  key=lambda i: i[str(sort_by)],
                  reverse=order)


###  FUNCTIONS READING CSV FILES AND   ###
not_sorted_question_data = data_manager.import_data(sample_data_question)
question_data = sort_list_of_dict(not_sorted_question_data, "submission_time",
                                  True)

answer_data = data_manager.import_data(sample_data_answer)

### Pulling from database  ###

###   WRITING TO CSV   ###


def id_generator(filename):
    exists = os.path.isfile(filename)
    if not exists:
        return 1
    else: