Example #1
0
 def handle(self, options, global_options, *args):
     d = {}
     d['appname'] = get_input("Appname:", option_value=options.appname).lower()
     d['tablename'] = get_input("Table Name:", option_value=options.tablename).lower()
     d['theme'] = get_input("Creation Theme([a]ngularjs, [h]tml), [e]sayui)[a], [m]mGrid, a[v]alon:", default="m", choices='ahemv', option_value=options.theme)
     view_name = camel_to_cap(d['tablename'])+'View'
     view_file_name = 'views_%s.py' % d['tablename']
     url_prefix = '/'+d['appname']
     d['classname'] = get_input("View Class Name [%s]:" % view_name, default=view_name, option_value=options.classname)
     d['viewfile'] = get_input("Save views to [%s]:" % view_file_name, default=view_file_name, option_value=options.viewfile)
     layout_name = d['appname'].lower() + '_layout.html'
     d['layout'] = get_input("Layout template name [%s]:" % layout_name, default=layout_name, option_value=options.layout)
     d['url'] = get_input("Class View URL prefix [%s]:" % url_prefix, default=url_prefix, option_value=options.url)
     d['pagination'] = get_answer("Enable pagination", quit='q') == 'Y'
     d['query'] = get_answer("Enable query", quit='q') == 'Y'
     d['download'] = get_answer("Enable download", quit='q') == 'Y'
     if d['download']:
         d['downloadfile'] = get_input("Download filename [%s]:" % 'download.xls', default='download.xls', option_value=options.downloadfile)
     d['addview_popup'] = get_answer("Add View using popup", quit='q') == 'Y'
     d['addview_ajax'] = get_answer("Add View using ajax", quit='q') == 'Y'
     d['editview_popup'] = get_answer("Edit View using popup", quit='q') == 'Y'
     d['editview_ajax'] = get_answer("Edit View using ajax", quit='q') == 'Y'
     d['deleteview_ajax'] = get_answer("Delete View using ajax", quit='q') == 'Y'
     
     theme = {'a':'angularjs', 'h':'html', 'e':'easyui', 'm':'mmgrid', 'v':'avalon'}
     
     d['theme_name'] = theme_name = theme.get(d['theme'])
     self.process(theme_name, d, options, global_options, args)
Example #2
0
    def handle(self, options, global_options, *args):
        d = {}
        d['appname'] = get_input("Appname:",
                                 option_value=options.appname).lower()
        d['tablename'] = get_input("Table Name:",
                                   option_value=options.tablename).lower()
        d['theme'] = get_input(
            "Creation Theme([a]ngularjs, [h]tml), [e]sayui)[a], [m]mGrid, a[v]alon:",
            default="m",
            choices='ahemv',
            option_value=options.theme)
        view_name = camel_to_cap(d['tablename']) + 'View'
        view_file_name = 'views_%s.py' % d['tablename']
        url_prefix = '/' + d['appname']
        d['classname'] = get_input("View Class Name [%s]:" % view_name,
                                   default=view_name,
                                   option_value=options.classname)
        d['viewfile'] = get_input("Save views to [%s]:" % view_file_name,
                                  default=view_file_name,
                                  option_value=options.viewfile)
        layout_name = d['appname'].lower() + '_layout.html'
        d['layout'] = get_input("Layout template name [%s]:" % layout_name,
                                default=layout_name,
                                option_value=options.layout)
        d['url'] = get_input("Class View URL prefix [%s]:" % url_prefix,
                             default=url_prefix,
                             option_value=options.url)
        d['pagination'] = get_answer("Enable pagination", quit='q') == 'Y'
        d['query'] = get_answer("Enable query", quit='q') == 'Y'
        d['download'] = get_answer("Enable download", quit='q') == 'Y'
        if d['download']:
            d['downloadfile'] = get_input("Download filename [%s]:" %
                                          'download.xls',
                                          default='download.xls',
                                          option_value=options.downloadfile)
        d['addview_popup'] = get_answer("Add View using popup",
                                        quit='q') == 'Y'
        d['addview_ajax'] = get_answer("Add View using ajax", quit='q') == 'Y'
        d['editview_popup'] = get_answer("Edit View using popup",
                                         quit='q') == 'Y'
        d['editview_ajax'] = get_answer("Edit View using ajax",
                                        quit='q') == 'Y'
        d['deleteview_ajax'] = get_answer("Delete View using ajax",
                                          quit='q') == 'Y'

        theme = {
            'a': 'angularjs',
            'h': 'html',
            'e': 'easyui',
            'm': 'mmgrid',
            'v': 'avalon'
        }

        d['theme_name'] = theme_name = theme.get(d['theme'])
        self.process(theme_name, d, options, global_options, args)
Example #3
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import pkg
     from uliweb.utils.pyini import Ini
     from uliweb.core.commands import get_input
     from uliweb.core.template import template_file
     import glob
     
     _types = []
     config_files = {}
     app_dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'template_files/config') for appname in self.get_apps(global_options)]
     for path in [pkg.resource_filename('uliweb', 'template_files/config/')] + app_dirs:
         if os.path.exists(path):
             files = glob.glob(os.path.join(path, '*.conf'))
             if files:
                 for f in files:
                     _name = os.path.splitext(os.path.basename(f))[0]
                     _types.append(_name)
                     config_files[_name] = f
     
     support_type = args[0] if args else ''
     while not support_type in _types and support_type != 'quit':
         print 'Supported types:\n'
         print '    ' + '\n    '.join(sorted(_types))
         print
         support_type = raw_input('Please enter support type[quit to exit]:')
     
     if support_type != 'quit':
         conf_file = config_files[support_type]
         conf_ini = conf_file[:-5] + '.ini'
         
         if not os.path.exists(conf_file):
             log.error("%s config can't be found" % support_type)
             sys.exit(1)
             
         data = {}
         data['project_dir'] = os.path.abspath(os.getcwd())
         data['project'] = os.path.basename(data['project_dir'])
         if os.path.exists(conf_ini):
             x = Ini(conf_ini)
             for k, v in x.INPUT.items():
                 if isinstance(v, (tuple, list)):
                     if len(v) == 2:
                         prompt, default = v
                     else:
                         prompt = v[0]
                         default = ''
                 else:
                     prompt, default = v or '', ''
                 if not prompt.strip():
                     prompt = 'Please input %s[%s]:' % (k, default)
                 r = get_input(prompt, default=default)
                 data[k] = r
             data.update(x.get('DEFAULT', {}))
             
         print
         print template_file(conf_file, data)
Example #4
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import pkg
     from uliweb.utils.pyini import Ini
     from uliweb.core.commands import get_input
     from uliweb.core.template import template_file
     import glob
     
     _types = []
     config_files = {}
     app_dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'template_files/config') for appname in self.get_apps(global_options)]
     for path in [pkg.resource_filename('uliweb', 'template_files/config/')] + app_dirs:
         if os.path.exists(path):
             files = glob.glob(os.path.join(path, '*.conf'))
             if files:
                 for f in files:
                     _name = os.path.splitext(os.path.basename(f))[0]
                     _types.append(_name)
                     config_files[_name] = f
     
     support_type = args[0] if args else ''
     while not support_type in _types and support_type != 'quit':
         print 'Supported types:\n'
         print '    ' + '\n    '.join(sorted(_types))
         print
         support_type = raw_input('Please enter support type[quit to exit]:')
     
     if support_type != 'quit':
         conf_file = config_files[support_type]
         conf_ini = conf_file[:-5] + '.ini'
         
         if not os.path.exists(conf_file):
             log.error("%s config can't be found" % support_type)
             sys.exit(1)
             
         data = {}
         data['project_dir'] = os.path.abspath(os.getcwd())
         data['project'] = os.path.basename(data['project_dir'])
         if os.path.exists(conf_ini):
             x = Ini(conf_ini)
             for k, v in x.INPUT.items():
                 if isinstance(v, (tuple, list)):
                     if len(v) == 2:
                         prompt, default = v
                     else:
                         prompt = v[0]
                         default = ''
                 else:
                     prompt, default = v or '', ''
                 if not prompt.strip():
                     prompt = 'Please input %s[%s]:' % (k, default)
                 r = get_input(prompt, default=default)
                 data[k] = r
             data.update(x.get('DEFAULT', {}))
             
         print
         print template_file(conf_file, data)
Example #5
0
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import pkg
        from uliweb.utils.pyini import Ini
        from uliweb.core.commands import get_input
        from uliweb.core.template import template_file
        import glob

        _types = []
        config_files = {}
        app_dirs = [
            os.path.join(SimpleFrame.get_app_dir(appname), "template_files/config")
            for appname in self.get_apps(global_options)
        ]
        for path in [pkg.resource_filename("uliweb", "template_files/config/")] + app_dirs:
            if os.path.exists(path):
                files = glob.glob(os.path.join(path, "*.conf"))
                if files:
                    for f in files:
                        _name = os.path.splitext(os.path.basename(f))[0]
                        _types.append(_name)
                        config_files[_name] = f

        support_type = args[0] if args else ""
        while not support_type in _types and support_type != "quit":
            print "Supported types:\n"
            print "    " + "\n    ".join(sorted(_types))
            print
            support_type = raw_input("Please enter support type[quit to exit]:")

        if support_type != "quit":
            conf_file = config_files[support_type]
            conf_ini = conf_file[:-5] + ".ini"

            if not os.path.exists(conf_file):
                log.error("%s config can't be found" % support_type)
                sys.exit(1)

            data = {}
            data["project_dir"] = os.path.abspath(os.getcwd())
            data["project"] = os.path.basename(data["project_dir"])
            if os.path.exists(conf_ini):
                x = Ini(conf_ini)
                for k, v in x.INPUT.items():
                    if isinstance(v, (tuple, list)):
                        prompt, default = v
                    else:
                        prompt, default = v or "", ""
                    if not prompt.strip():
                        prompt = "Please input %s[%s]:" % (k, default)
                    r = get_input(prompt, default=default)
                    data[k] = r
                data.update(x.get("DEFAULT", {}))

            print
            print template_file(conf_file, data)