def show_update_view(): input_user_option = raw_input("\n-> Informe o ID do projeto que deseja ATUALIZAR:\n") try: int(input_user_option) id_exists = ProjectController().check_id_exists(input_user_option) if id_exists: print "-> Informe os novos dados do projeto:" MP = ModelProject() MP.name = raw_input("Nome: ") MP.duration = raw_input("Quantidade de horas: ") update = ProjectController().update(input_user_option, MP) if update: print "\nRegistro alterado com sucesso" else: print "\nNenhum registro foi alterado!" else: print "ID {} nao foi encontrado!".format(input_user_option) except ValueError: print "ID (%s) informado e invalido!" % input_user_option
def show_insert_view(): MP = ModelProject() MP.name = raw_input("Nome: ") MP.duration = raw_input("Quantidade de horas: ") ProjectController().insert(MP)
def setup_controllers(app): from controllers.project import ProjectController controllers = namedtuple( 'controllers', ['ProjectController'] ) app.controllers = controllers( ProjectController() )
def show_list_view(option): print "\n -> Como deseja realizar a listagem de %s ?" % option input_user_option = input( "1 - Listar todos\n" "2 - Buscar registro\n" ) if input_user_option in {1, 2}: if input_user_option == 1: project_dict = ProjectController().list() print project_dict else: input_user_search = raw_input("-> Informe o nome do registro ou uma parte do nome:\n") project_dict = ProjectController().list(input_user_search) print project_dict else: raise Exception('Acao %s nao existe' % input_user_option)
def show_delete_view(): input_user_option = raw_input("\n-> Digite o ID do projeto que deseja DELETAR:\n") try: int(input_user_option) delete = ProjectController().delete(input_user_option) if delete: print "Registro deletado com sucesso!" else: print "ID {} nao foi encontrado!".format(input_user_option) except ValueError: print "ID (%s) informado e invalido!" % input_user_option
def sets_the_project_in_the_template_data_as_an_object_with_a_needs_iterable( self): controller = ProjectController() controller.render = Mock() project = Mock() project.needs = [] controller.getProject = Mock(return_value=project) controller.showProject(1) assert hasattr(controller.template_data['project'], 'needs') try: iter(controller.template_data['project'].needs) except TypeError: ok_(False)
def sets_the_project_in_the_template_data_as_an_object_with_json_and_data( self): # TODO: This test expresses a necessary condition for now, but we should # be moving away from dependece on the json and data keywords. # The project's data should be on the project object itself, and # we should have a separate place to put the json, or a filter # that spits it out from the project object. controller = ProjectController() controller.render = Mock() controller.getProject = Mock(return_value=Mock()) controller.showProject(1) assert hasattr(controller.template_data['project'], 'json') assert hasattr(controller.template_data['project'], 'data')
from flask import Blueprint from controllers.project import ProjectController project = Blueprint('project', __name__) project_view = ProjectController.as_view('project_crud') project.add_url_rule('/', view_func=project_view, methods=('GET', 'POST')) project.add_url_rule('/<int:project_id>/', view_func=project_view, methods=('GET', 'PUT', 'DELETE'))
def export(option): if option == 'projeto': ctrl = ProjectController() ctrl.export()
def shutdown(): c = ProjectController() return c.shutdown()
def switch_theme(theme_name): c = ProjectController() return c.switch_theme(theme_name)
def toggle_favorite(): c = ProjectController() return c.toggle_favorite()
def drag_drop(): c = ProjectController() return c.drag_drop()
def rename_project(): c = ProjectController() return c.rename_project()
def main_page(): c = ProjectController() return c.main_page()
def has_access_to_an_active_orm_session(self): controller = ProjectController() controller.render = Mock() assert controller.orm.is_active