Пример #1
0
 def index():
     items = mongo.fetch_all_items()
     items.sort(key=lambda k: k.status, reverse=True)
     item_view_model = view_model.ViewModel(items)
     if current_user.is_active == True:
         if current_user.role == 'writer':
             return render_template('index_writer.html', view_model=item_view_model)
         elif current_user.role == 'reader':
             return render_template('index_reader.html', view_model=item_view_model)
         else:
             return render_template('index_writer.html', view_model=item_view_model)
     else:
         return render_template('index_writer.html', view_model=item_view_model)
class PointMoverCmd:
    '''
    The class that the user interacts with to set up the matrix dimensions,
    starting position of the pointer and the list of actions that the pointer
    will take.

    Attributes:
    -----------
    vi : object
        validate_input class object for ensuring user input is correct.

    cc : object
        constants class object to give user generic messages containing
        instructions.

    dim : list
        [x,y] defining shape of the matrix split from position

    pos : list
        [x,y] defining the starting position of the pointer split from matrix

    actions : list
        validated list of actions to be sent to sent to the data model for
        moving the pointer around.

    view_mod : object
        class object of the view_model that sets up the pointer and matrix

    results , message : list, str
        the result of the pointer's final position and corresponding message to
        be sent back to the user.


    Methods:
    --------

    None
    '''
    vi = validate_input.ValidateInput()
    cc = constants.Constants()

    cc.start_message()
    dim, pos = vi.split_input(
        vi.check_dimension_position(sys.stdin.readline().rstrip()))
    cc.action_list_message()
    actions = vi.contains_zero(vi.check_operation_list())
    view_mod = view_model.ViewModel(dim, pos)
    result, message = view_mod(actions)

    sys.stdout.write(message.format(result))
def test_items2():
    today = datetime.date.today()
    yesterday = today - datetime.timedelta(days=1)
    item_list = []
    item_list.append(it.Item(1, 'To Do', 'Test1', str(today)))
    item_list.append(it.Item(2, 'To Do', 'Test2', str(today)))
    item_list.append(it.Item(3, 'Doing', 'Test3', str(today)))
    item_list.append(it.Item(4, 'Doing', 'Test4', str(today)))
    item_list.append(it.Item(5, 'Done', 'Test5', str(today)))
    item_list.append(it.Item(10, 'Done', 'Test6', str(yesterday)))
    item_list.append(it.Item(11, 'Done', 'Test6', str(yesterday)))

    test_list = view_model.ViewModel(item_list)

    return test_list
Пример #4
0
def test_items3():
    today = datetime.datetime.utcnow()
    yesterday = today - datetime.timedelta(days=1)
    item_list = [
        Item(1, 'Doing', 'Task1', today),
        Item(2, 'Doing', 'Task2', today),
        Item(3, 'Done', 'Task3', today),
        Item(4, 'Done', 'Task4', today),
        Item(5, 'Done', 'Task5', today),
        Item(6, 'Done', 'Task6', yesterday),
        Item(7, 'Done', 'Task7', yesterday)
    ]

    test_list = view_model.ViewModel(item_list)

    return test_list
Пример #5
0
 def index():
     items = itemDb.get_all_items()
     current_user_role = get_user_role()
     item_view_model = view_model.ViewModel(items, current_user_role)
     return render_template('index.html', view_model=item_view_model)
Пример #6
0
def test_view_model():
    todo = [{"id": 1, "Status": "In Progress", "title": "wash dog"}]
    results = [{"id": 1, "Status": "In Progress", "title": "wash dog"}]
    view_model = app.ViewModel(todo)
    assert view_model.items == results