Skip to content

Commit

Permalink
remove deprecated commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Feb 20, 2023
1 parent 4bbe7bf commit 15fde40
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 126 deletions.
4 changes: 2 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .projects import start
from .projects import create
from .forms import addform

__all__ = ['start', 'addform']
__all__ = ['create', 'addform']
102 changes: 0 additions & 102 deletions forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,108 +191,6 @@ def addform(xlsform, input_dir, django_dir, template_dir,
)


@wq.command()
@click.option(
"--input-dir",
default="../master_templates",
type=click.Path(exists=True),
help="Source / master templates",
)
@click.option(
"--django-dir",
default=".",
type=click.Path(exists=True),
help="Root of Django project",
)
@click.option(
"--template-dir",
default="../templates",
type=click.Path(exists=True),
help="Path to shared template directory",
)
@click.option(
'-overwrite',
'-f',
default=False,
is_flag=True,
help="Replace existing templates",
)
def maketemplates(input_dir, django_dir, template_dir, overwrite):
"""
(DEPRECATED) Make list/edit/detail templates. Automatically discovers all
registered models through ./manage.py dump_config.
\b
templates/[model_name]_detail.html
templates/[model_name]_edit.html
templates/[model_name]_list.html
The `wq maketemplates` command is deprecated, and will be removed
in wq.create 2.0, as will all support for @wq/jquery-mobile. The new
@wq/react + @wq/material renderer uses React components instead of
template strings.
"""
result = subprocess.check_output(
[os.path.join(django_dir, 'manage.py'), 'dump_config']
)
config = json.loads(result.decode('utf-8'))

has_diff = False

for page in config['pages'].values():
if not page.get('list', None):
continue

if has_diff == 'skipall':
break

def process_fields(fields):
for field in fields:
if field['type'] in ('repeat', 'group'):
field['wq:nested'] = True
if field['type'] == 'repeat':
field['wq:many'] = True
process_fields(field['children'])
elif field['type'] in QTYPES:
field['type_info'] = QTYPES[field['type']]
else:
field['type_info'] = {'bind': {'type': field['type']}}

process_fields(page['form'])
context = html_context({
'name': page['name'],
'title': page['name'],
'children': page['form'],
})
context['form']['urlpath'] = page['url']

template_types = set(page.get('modes', ['detail', 'edit', 'list']))

has_geo = False
for field in page['form']:
if 'geo' in field['type']:
if has_geo:
print("Warning: multiple geometry fields found.")
has_geo = True

if page.get('map', None):
has_geo = True

if has_geo:
context['form']['has_geo'] = True
template_types.add('popup')

for tmpl in template_types:
has_diff = create_file(
[template_dir, "%s_%s.html" % (page['name'], tmpl)],
render(context, os.path.join(input_dir, '%s.html' % tmpl)),
overwrite=overwrite,
previous_diff=has_diff,
)
if has_diff == 'skipall':
break


def create_file(path, contents, overwrite=False,
show_diff=False, previous_diff=False):
filename = os.path.join(*path)
Expand Down
22 changes: 0 additions & 22 deletions projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,3 @@ def do_create(project_name, destination, domain, title, with_gis, with_npm):
)

click.echo(f"Run {DEPLOY_SCRIPT} 0.0.0 to finish initial setup.")


@wq.command()
@click.argument("project_name", required=False)
@click.argument("destination", required=False)
@click.option(
"-d", "--domain", help='Web domain (e.g. example.wq.io)'
)
@click.option(
"--with-gis/--without-gis", default=None, help="Enable GeoDjango"
)
@click.option(
"--with-npm/--without-npm", default=None,
help="Enable NPM (& Create React App)"
)
def start(project_name, destination, domain=None,
with_gis=None, with_npm=None):
"""
(DEPRECATED) Alias for wq create.
"""
click.echo('This command is deprecated. Use "wq create" instead.')
do_create(project_name, destination, domain, '__old__', with_gis, with_npm)

0 comments on commit 15fde40

Please sign in to comment.