def test_form_render(self, lshift): """ test a generic string render """ scaffold_path = ffs.Path(settings.PROJECT_PATH) / 'scaffolding' create_form_template_for(Colour, scaffold_path) lshift.assert_called_once_with( '{% load forms %}\n{% input field="Colour.name" %}')
def test_form_render(self, lshift): """ test a generic string render """ scaffold_path = ffs.Path(settings.PROJECT_PATH)/'scaffolding' create_form_template_for(Colour, scaffold_path) lshift.assert_called_once_with( '{% load forms %}\n{% input field="Colour.name" %}' )
def scaffold(args): """ Create record boilierplates: 1. Run a south auto migration 2. Create display templates 3. Create forms """ app = args.app name = find_application_name() scaffold_utils._set_settings_module(name) sys.path.append(os.path.abspath('.')) # 1. Let's run a Django migration dry_run = '' if args.dry_run: dry_run = '--dry-run' if not args.nomigrations: makemigrations_cmd = "python manage.py makemigrations {app} " \ "--traceback {dry_run}" makemigrations_cmd = makemigrations_cmd.format( app=app, dry_run=dry_run) migrate_cmd = 'python manage.py migrate {app} --traceback'.format( app=app) os.system(makemigrations_cmd) if not args.dry_run: os.system(migrate_cmd) # 2. Let's create some display templates from opal.models import Subrecord, EpisodeSubrecord, PatientSubrecord models = stringport('{0}.models'.format(app)) for i in dir(models): thing = getattr(models, i) if inspect.isclass(thing) and issubclass(thing, Subrecord): if thing in [Subrecord, EpisodeSubrecord, PatientSubrecord]: continue if not thing.get_display_template(): if args.dry_run: write('No Display template for {0}'.format(thing)) else: scaffold_utils.create_display_template_for( thing, SCAFFOLDING_BASE ) if not thing.get_modal_template(): if args.dry_run: write('No Form template for {0}'.format(thing)) else: scaffold_utils.create_form_template_for( thing, SCAFFOLDING_BASE ) return
def test_float_render(self, build_field_schema, lshift): build_field_schema.return_value = { 'lookup_list': None, 'model': 'Colour', 'name': 'number', 'title': 'Number', 'type': 'float' }, scaffold_path = ffs.Path(settings.PROJECT_PATH) / 'scaffolding' create_form_template_for(Colour, scaffold_path) lshift.assert_called_once_with( '{% load forms %}\n{% input field="Colour.number" %}')
def scaffold(args): """ Create record boilierplates: 1. Run a south auto migration 2. Create display templates 3. Create forms """ app = args.app name = find_application_name() scaffold_utils._set_settings_module(name) sys.path.append(os.path.abspath('.')) # 1. Let's run a Django migration dry_run = '' if args.dry_run: dry_run = '--dry-run' if not args.nomigrations: makemigrations_cmd = "python manage.py makemigrations {app} " \ "--traceback {dry_run}" makemigrations_cmd = makemigrations_cmd.format(app=app, dry_run=dry_run) migrate_cmd = 'python manage.py migrate {app} --traceback'.format( app=app) os.system(makemigrations_cmd) if not args.dry_run: os.system(migrate_cmd) # 2. Let's create some display templates from opal.models import Subrecord, EpisodeSubrecord, PatientSubrecord models = stringport('{0}.models'.format(app)) for i in dir(models): thing = getattr(models, i) if inspect.isclass(thing) and issubclass(thing, Subrecord): if thing in [Subrecord, EpisodeSubrecord, PatientSubrecord]: continue if not thing.get_display_template(): if args.dry_run: write('No Display template for {0}'.format(thing)) else: scaffold_utils.create_display_template_for( thing, SCAFFOLDING_BASE) if not thing.get_modal_template(): if args.dry_run: write('No Form template for {0}'.format(thing)) else: scaffold_utils.create_form_template_for( thing, SCAFFOLDING_BASE) return
def test_float_render(self, build_field_schema, lshift): build_field_schema.return_value = { 'lookup_list': None, 'model': 'Colour', 'name': 'number', 'title': 'Number', 'type': 'float' }, scaffold_path = ffs.Path(settings.PROJECT_PATH)/'scaffolding' create_form_template_for(Colour, scaffold_path) lshift.assert_called_once_with( '{% load forms %}\n{% input field="Colour.number" %}' )
def test_makes_forms_dir_if_does_not_exist(self, build_field_schema, mkdir, nonzero, booler, lshift): build_field_schema.return_value = { 'lookup_list': None, 'model': 'Colour', 'name': 'name', 'title': 'Name', 'type': 'null_boolean' }, # We need both of these to make sure this works on both Python3 and Python2 nonzero.return_value = False booler.return_value = False scaffold_path = ffs.Path(settings.PROJECT_PATH) / 'scaffolding' create_form_template_for(Colour, scaffold_path) mkdir.assert_called_once_with()
def test_makes_forms_dir_if_does_not_exist(self, build_field_schema, mkdir, nonzero, booler, lshift): build_field_schema.return_value = { 'lookup_list': None, 'model': 'Colour', 'name': 'name', 'title': 'Name', 'type': 'null_boolean' }, # We need both of these to make sure this works on both Python3 and Python2 nonzero.return_value = False booler.return_value = False scaffold_path = ffs.Path(settings.PROJECT_PATH)/'scaffolding' create_form_template_for(Colour, scaffold_path) mkdir.assert_called_once_with()