Exemplo n.º 1
0
def backPage():
    events = session['events']
    dates = getStartEndDates()
    session['index'] = session['index'] - 7
    return render_template('index.html',
                           start_hour=session['start_day'],
                           end_hour=session['end_day'],
                           events=events,
                           dates=dates,
                           index=session['index'],
                           assignments=assignments,
                           assignment_names=assignment_names)
Exemplo n.º 2
0
def home():
    events = populateCalendar()
    dates = getStartEndDates()
    session['events'] = events
    session['index'] = 0

    return render_template('index.html',
                           start_hour=1,
                           end_hour=24,
                           events=events,
                           dates=dates,
                           index=0,
                           assignments=assignments,
                           assignment_names=assignment_names)
Exemplo n.º 3
0
def addAssignment():
    events = session['events']
    name = request.form['name']
    deadline = datetime.strptime(request.form['deadline'], '%Y-%m-%dT%H:%M')
    start = datetime.strptime(request.form['start'], '%Y-%m-%dT%H:%M')
    priority = int(request.form['priority'])
    blocks = int(request.form['blocks'])
    hours = int(request.form['hours'])
    start_time = datetime.strptime(str(session['start_day']) + ":00",
                                   '%H:%M').time()
    end_time = datetime.strptime(str(session['end_day']) + ":00",
                                 '%H:%M').time()
    leeway = timedelta(hours=session['finish_hours'])
    breaks = timedelta(minutes=session['break'])

    busy_blocks = populateBusyBlocks()
    task = Task(name, deadline, timedelta(hours=hours), blocks, priority,
                start)

    task_blocks = schedule([task], busy_blocks, start_time, end_time, leeway,
                           breaks)
    new_events = addTaskToEvent(task_blocks, session['events'])
    dates = getStartEndDates()
    new_assign = {
        "name": name,
        "blocks": blocks,
        "priority": priority,
        "deadline": deadline,
        "hours": hours
    }
    assignments.append(new_assign)
    assignment_names.append(name)
    print(assignment_names)
    print(new_assign['name'])
    print(new_assign['name'] in assignment_names)

    session['events'] = new_events
    index = session['index']

    return render_template('index.html',
                           start_hour=session['start_day'],
                           end_hour=session['end_day'],
                           events=new_events,
                           dates=dates,
                           index=index,
                           assignments=assignments,
                           assignment_names=assignment_names)
Exemplo n.º 4
0
def main():
    print(request.form['start_day'])
    session['start_day'] = int(request.form['start_day'].split(":", 1)[0])
    session['start_day_string'] = request.form['start_day']
    session['end_day'] = int(request.form['end_day'].split(":", 1)[0])
    session['end_day_string'] = request.form['end_day']

    session['break'] = int(request.form['break'])
    session['finish_hours'] = int(request.form['finish_hours'])

    events = populateCalendar()
    dates = getStartEndDates()

    session['events'] = events
    session['index'] = 0

    return render_template('index.html',
                           start_hour=session['start_day'],
                           end_hour=session['end_day'],
                           events=events,
                           dates=dates,
                           index=0,
                           assignments=assignments,
                           assignment_names=assignment_names)