import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary all_template_token = token_dictionary()["templates"]["base_app_templates"]["base_app_all"] all_template_path_token = token_dictionary()["templates"]["base_app_templates"]["base_app_all"]["path"] all_template_directory = "" def define_all_template(class_object): global all_template_directory all_template_directory = constants.OUT_DIRECTORY + "/templates/{}_templates".format(class_object.name) + all_template_path_token define_title(class_object) define_link_to_create_item(class_object) define_table_field_header(class_object) define_table_field_value(class_object) def define_title(class_object): # Modify template all title replace_data_in_file( all_template_directory, all_template_token["template_title"], create_title(class_object) ) print("Define template all title: {}".format(all_template_directory)) print("") def define_link_to_create_item(class_object):
import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary views_methods_token = token_dictionary()["base_app"]["views"]["methods"] views_path_token = token_dictionary()["base_app"]["views"]["path"] def define_edit_method(class_object): views_directory = constants.OUT_DIRECTORY + "/" + class_object.name + views_path_token # Add views edit replace_data_in_file(views_directory, views_methods_token, create_edit_method(class_object)) print("Define edit method in: {}".format(views_directory)) print("") def create_edit_method(class_object): return """ def edit(request, id): app_object = {}.objects.get(id=id) {} """.format(class_object.name, create_call_list_items(class_object)) + """ return render(request, '{}_templates/base_app_edit.html', {}) {}""".format(class_object.name, create_parameters_to_send_view(class_object), views_methods_token) def create_call_list_items(class_object): response = "" for attribute in class_object.attributes:
import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary urls_token = token_dictionary()["application"]["urls"] def define_urls(class_object): urls_directory = constants.OUT_DIRECTORY + constants.BASE_APPLICATION_DIRECTORY + urls_token[ "path"] # Add urls import replace_data_in_file(urls_directory, urls_token["import"], create_urls_import(class_object)) print("Define import to get all view in: {}".format(urls_directory)) print("") # Add urls get all pattern replace_data_in_file( urls_directory, urls_token["url_patterns_path"], create_urls_get_all_patterns_path(class_object, "get_all")) print("Define url pattern to get all view in: {}".format(urls_directory)) print("") # Add urls create pattern replace_data_in_file( urls_directory, urls_token["url_patterns_path"], create_urls_create_patterns_path(class_object, "create")) print("Define url pattern to create view in: {}".format(urls_directory)) print("") # Add urls store pattern
import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary models_token = token_dictionary()["base_app"]["models"] models_directory = "" def define_models(class_object): global models_directory models_directory = constants.OUT_DIRECTORY + "/" + class_object.name + models_token["path"] # Create model # Define model class replace_data_in_file( models_directory, models_token["class"], create_model_class_definition(class_object.name) ) print("Define new model in: {}".format(models_directory)) print("") # Define model attributes replace_data_in_file( models_directory, models_token["attributes"], create_model_attributes_definition(class_object.attributes) ) print("Define new attributes in: {}".format(models_directory)) print("")
import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary create_template_token = token_dictionary( )["templates"]["base_app_templates"]["base_app_create"] create_template_path_token = token_dictionary( )["templates"]["base_app_templates"]["base_app_create"]["path"] create_template_directory = "" def define_create_template(class_object): global create_template_directory create_template_directory = constants.OUT_DIRECTORY + "/templates/{}_templates".format( class_object.name) + create_template_path_token define_title(class_object) define_form_fields(class_object) define_back_button(class_object) def define_title(class_object): # Modify template create title replace_data_in_file(create_template_directory, create_template_token["template_title"], create_title(class_object)) print("Define template create title: {}".format(create_template_directory)) print("") def define_form_fields(class_object):
import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary from generator.codeReplaces.views.methods.getAll import define_get_all_method from generator.codeReplaces.views.methods.getOne import define_get_one_method from generator.codeReplaces.views.methods.create import define_create_method from generator.codeReplaces.views.methods.store import define_store_method from generator.codeReplaces.views.methods.edit import define_edit_method from generator.codeReplaces.views.methods.update import define_update_method from generator.codeReplaces.views.methods.delete import define_delete_method views_token = token_dictionary()["base_app"]["views"] views_directory = "" def define_views(class_object): global views_directory views_directory = constants.OUT_DIRECTORY + "/" + class_object.name + views_token[ "path"] define_import(class_object) define_attributes_import(class_object) define_get_all_method(class_object) define_get_one_method(class_object) define_create_method(class_object) define_store_method(class_object) define_edit_method(class_object) define_update_method(class_object) define_delete_method(class_object)
import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary edit_template_token = token_dictionary( )["templates"]["base_app_templates"]["base_app_edit"] edit_template_path_token = token_dictionary( )["templates"]["base_app_templates"]["base_app_edit"]["path"] edit_template_directory = "" def define_edit_template(class_object): global edit_template_directory edit_template_directory = constants.OUT_DIRECTORY + "/templates/{}_templates".format( class_object.name) + edit_template_path_token define_title(class_object) define_form_fields(class_object) define_back_button(class_object) def define_title(class_object): # Modify template edit title replace_data_in_file(edit_template_directory, edit_template_token["template_title"], create_title(class_object)) print("Define template edit title: {}".format(edit_template_directory)) print("") def define_form_fields(class_object):
import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary settings_token = token_dictionary()["application"]["settings"] def define_settings(class_object): settings_directory = constants.OUT_DIRECTORY + constants.BASE_APPLICATION_DIRECTORY + settings_token[ "path"] # Add installed app to settings replace_data_in_file( settings_directory, settings_token["installed_local_apps"], create_settings_installed_local_app_definition(class_object.name)) print("Define new app installed in: {}".format(settings_directory)) print("") def create_settings_installed_local_app_definition(app_name): return "'{}',\n\t{}".format(app_name, settings_token["installed_local_apps"])
import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary from generator.codeReplaces.templates.all.all import define_all_template from generator.codeReplaces.templates.one.one import define_one_template from generator.codeReplaces.templates.create.create import define_create_template from generator.codeReplaces.templates.edit.edit import define_edit_template templates_token = token_dictionary()["templates"] nav_token = token_dictionary()["templates"]["nav"] def define_templates(class_object): define_all_template(class_object) define_one_template(class_object) define_create_template(class_object) define_edit_template(class_object) define_nav_item(class_object) def define_nav_item(class_object): nav_directory = constants.OUT_DIRECTORY + "/templates" + nav_token["path"] # Add nav item replace_data_in_file( nav_directory, nav_token["nav_item"], create_nav_item(class_object) ) print("Define new nav item in: {}".format(nav_directory))
import generator.utils.constants as constants from generator.utils.fileUtils import replace_data_in_file from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary one_template_token = token_dictionary( )["templates"]["base_app_templates"]["base_app_one"] one_template_path_token = token_dictionary( )["templates"]["base_app_templates"]["base_app_one"]["path"] one_template_directory = "" def define_one_template(class_object): global one_template_directory one_template_directory = constants.OUT_DIRECTORY + "/templates/{}_templates".format( class_object.name) + one_template_path_token define_title(class_object) define_table_fields_values(class_object) define_back_button(class_object) def define_title(class_object): # Modify template one title replace_data_in_file(one_template_directory, one_template_token["template_title"], create_title(class_object)) print("Define template one title: {}".format(one_template_directory)) print("") def define_table_fields_values(class_object):
from django.http import HttpResponse from applicationGenerator.utils.tokensDictionary import get_token as token_dictionary from applicationGenerator.utils.tokens import generate_json_structure from generator.codeReplaces.models import define_models from generator.codeReplaces.settings import define_settings from generator.codeReplaces.views.views import define_views from generator.codeReplaces.urls import define_urls from generator.codeReplaces.templates.templates import define_templates from distutils.dir_util import copy_tree from applicationGenerator.utils.classTemplate import ClassTemplate, AttributeTemplate import shutil import os BASE_DIRECTORY = os.getcwd() + "/resources/base_application/application" OUT_DIRECTORY = os.getcwd() + "/resources/out_application/application" BASE_APP_DIRECTORY = token_dictionary()["base_app"]["path"] BASE_APPLICATION_DIRECTORY = token_dictionary()["application"]["path"] # Create your views here. def create_application(request): if os.path.exists(os.getcwd() + '/resources/out_application'): shutil.rmtree(os.getcwd() + '/resources/out_application') # Generate out application folder copy_tree(BASE_DIRECTORY, OUT_DIRECTORY) # Read json file = request.FILES["bpmn_file"] json = generate_json_structure(file)