def setUp(self): trap = io.StringIO() with redirect_stdout(trap): init() user = User.objects.create_user(**USER_CREDENTIALS) user_data = UserData() user_data.user = user user_data.save() cruise = Cruise(leader=user) cruise.save() self.cruise = cruise
def setUp(self): """ Starts the scheduler and adds the default tasks (unless it's already running). We are doing this inside a try/except statement to catch the case where the scheduler object hasn't been defined yet, which would raise an error when trying to check jobs.scheduler.running. This handles both the case where it's defined but not running, and the case where it's not defined at all yet. """ try: if not jobs.scheduler.running: raise Exception('Scheduler not already running') except: trap = io.StringIO() with redirect_stdout(trap): init()
url(r'^invoices/overview/$', login_required(invoices.invoicer_overview), name='invoicer-overview'), url(r'^invoices/history/$', login_required(invoices.invoice_history), name='invoices-search'), url(r'^invoices/new_standalone/$', login_required( user_passes_test(lambda u: u.is_superuser)( invoices.CreateStandaloneInvoice.as_view())), name='add-standalone-invoice'), url(r'^invoices/(?P<pk>[0-9]+)/edit_standalone_invoice/$', login_required( user_passes_test(lambda u: u.is_superuser)( invoices.EditStandaloneInvoice.as_view())), name='standalone-invoice-edit'), url(r'^invoices/history/from-(?P<start_date>\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01]))-to-(?P<end_date>\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01]))$', login_required(invoices.invoice_history), name='invoices-for-period'), # url(r'^__debug__/', include(debug_toolbar.urls)), ] if server_starting(): # we don't want to run this during a migration. print("--- Initializing server ---") print( "Loading default models, invalidating cache, updating invoices, fixing database inconsistencies\n" ) init() print("\nServer initialized\n")