Esempio n. 1
0
    def add_internal_config(cls, configs, views):
        '''add an internal config based on project base type'''
        project = Project.get()
        project_type = project.get_base_type()
        # catch potential invalid xpath error
        try:
            if project_type:
                tmp_path = __file__
                dir_name = os.path.dirname(tmp_path)
                file_path = "%s/../config/%s-conf.xml" % (dir_name,
                                                          project_type)
                if os.path.exists(file_path):
                    for view in views:
                        config = WidgetConfig.get(file_path=file_path,
                                                  view=view)
                        if config.get_view_node():
                            configs.append(config)

            # finally, just look at the DEFAULT config
            tmp_path = __file__
            dir_name = os.path.dirname(tmp_path)
            file_path = "%s/../config/%s-conf.xml" % (dir_name, "DEFAULT")

            if os.path.exists(file_path):
                for view in views:
                    config = WidgetConfig.get(file_path=file_path, view=view)
                    if config.get_view_node():
                        configs.append(config)

        except XmlException as e:
            msg = "Error with view [%s]" % ' '.join(views)
            error_list = Container.get_seq(cls.ERR_MSG)
            if msg not in error_list:
                Container.append_seq(cls.ERR_MSG, msg)
                print(e.__str__())
Esempio n. 2
0
    def get_css_wdg(my):

        widget = Widget()

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()

        skin = web.get_skin()

        # first load context css
        Container.append_seq("Page:css", "%s/style/layout.css" % context_url)


        # add the color wheel css
        Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url)



        # get all of the registered css file
        css_files = Container.get_seq("Page:css")
        for css_file in css_files:
            widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file )

       
        # TEST TEST TEST
        widget.add('<link rel="stylesheet" href="/assets/_video/video-js.min.css" type="text/css" />\n')
        return widget
Esempio n. 3
0
    def add_internal_config(cls, configs, views):
        '''add an internal config based on project base type'''
        project = Project.get()
        project_type = project.get_base_type()
        # catch potential invalid xpath error
        try:
            if project_type:
                tmp_path = __file__
                dir_name = os.path.dirname(tmp_path)
                file_path="%s/../config/%s-conf.xml" % (dir_name, project_type)
                if os.path.exists(file_path):
                    for view in views:
                        config = WidgetConfig.get(file_path=file_path, view=view)
                        if config.get_view_node():
                            configs.append(config)

            # finally, just look at the DEFAULT config
            tmp_path = __file__
            dir_name = os.path.dirname(tmp_path)
            file_path="%s/../config/%s-conf.xml" % (dir_name, "DEFAULT")
                
            if os.path.exists(file_path):
                for view in views:
                    config = WidgetConfig.get(file_path=file_path, view=view)
                    if config.get_view_node():
                        configs.append(config)

        except XmlException, e:
            msg = "Error with view [%s]"% ' '.join(views)
            error_list = Container.get_seq(cls.ERR_MSG)
            if msg not in error_list:
                Container.append_seq(cls.ERR_MSG, msg)
                print e.__str__()
Esempio n. 4
0
    def get_css_wdg(my):

        widget = Widget()

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()

        skin = web.get_skin()

        # first load context css
        Container.append_seq("Page:css", "%s/style/layout.css" % context_url)


        # add the color wheel css
        Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url)

        # TEST
        Container.append_seq("Page:css", "%s/spt_js/video/video-js.css" % context_url)


        # get all of the registered css file
        css_files = Container.get_seq("Page:css")
        for css_file in css_files:
            widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file )

       
        return widget
Esempio n. 5
0
    def get_css_wdg(self):

        widget = Widget()

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()

        skin = web.get_skin()

        version = Environment.get_release_version()

        # Bootstrap
        use_bootstrap = True
        if use_bootstrap:
            Container.append_seq(
                "Page:css",
                "%s/spt_js/bootstrap/css/bootstrap.min.css?ver=%s" %
                (context_url, version))

        # add the color wheel css
        Container.append_seq(
            "Page:css",
            "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url)
        Container.append_seq(
            "Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url)
        Container.append_seq(
            "Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url)

        # first load context css
        Container.append_seq("Page:css", "%s/style/layout.css" % context_url)

        # TEST
        Container.append_seq("Page:css",
                             "%s/spt_js/video/video-js.css" % context_url)

        # get all of the registered css file
        css_files = Container.get_seq("Page:css")
        for css_file in css_files:
            widget.add(
                '<link rel="stylesheet" href="%s" type="text/css" />\n' %
                css_file)

        # custom js files to include
        includes = Config.get_value("install", "include_css")
        includes = includes.split(",")
        for include in includes:
            include = include.strip()
            if include:
                print("include: ", include)
                widget.add(
                    '<link rel="stylesheet" href="%s" type="text/css" />\n' %
                    include)

        return widget
Esempio n. 6
0
    def get_css_wdg(self):

        widget = Widget()

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()

        skin = web.get_skin()

        version = Environment.get_release_version()

        # Bootstrap
        use_bootstrap = True
        if use_bootstrap:
            Container.append_seq("Page:css", "%s/spt_js/bootstrap/css/bootstrap.min.css?ver=%s" % (context_url, version))



        # add the color wheel css
        Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url)

        # first load context css
        Container.append_seq("Page:css", "%s/style/layout.css" % context_url)



        # TEST
        Container.append_seq("Page:css", "%s/spt_js/video/video-js.css" % context_url)


        # get all of the registered css file
        css_files = Container.get_seq("Page:css")
        for css_file in css_files:
            widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file )

        # custom js files to include
        includes = Config.get_value("install", "include_css")
        includes = includes.split(",")
        for include in includes:
            include = include.strip()
            if include:
                print("include: ", include)
                widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % include )

        return widget
Esempio n. 7
0
    def get_display(self):
        self.config_search_type = self.kwargs.get("config_search_type")
        if not self.config_search_type:
            self.config_search_type = "SideBarWdg"

        title = self.kwargs.get('title')
        config = self.kwargs.get('config')
        view = self.kwargs.get('view')
        width = self.kwargs.get('width')
        #sortable = self.kwargs.get('sortable')
        if not width:
            width = "175"

        self.prefix = self.kwargs.get("prefix")
        if not self.prefix:
            self.prefix = "side_bar"

        self.mode = self.kwargs.get("mode")
        if not self.mode:
            self.mode = 'view'

        self.default = self.kwargs.get('default') == 'True'

        div = DivWdg()
        div.add_class("spt_section_top")
        div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")

        # create the top widgets
        label = SpanWdg()
        label.add(title)
        label.add_style("font-size: 1.1em")
        section_div = LabeledHidableWdg(label=label)
        div.add(section_div)

        section_div.set_attr('spt_class_name',
                             Common.get_full_class_name(self))
        for name, value in self.kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        bgcolor = label.get_color("background3")
        project_div = RoundedCornerDivWdg(hex_color_code=bgcolor,
                                          corner_size="10")
        project_div.set_dimensions(width_str='%spx' % width,
                                   content_height_str='100px')
        content_div = project_div.get_content_wdg()

        #project_div = DivWdg()
        #content_div = project_div

        section_div.add(project_div)

        content_div.add_class("spt_side_bar_content")
        content_div.add_attr("spt_view", view)

        if type(view) in types.StringTypes:
            view = [view]

        view_margin_top = '4px'

        web = WebContainer.get_web()
        for viewx in view:
            config = self.get_config(self.config_search_type,
                                     viewx,
                                     default=self.default)
            if not config:
                continue

            # make up a title
            title = DivWdg()
            title.add_gradient("background",
                               "side_bar_title",
                               0,
                               -15,
                               default="background")
            title.add_color("color", "side_bar_title_color", default="color")
            title.add_styles(
                "margin-top: %s; margin-bottom: 3px; vertical-align: middle" %
                view_margin_top)
            if not web.is_IE():
                title.add_styles("margin-left: -5px; margin-right: -5px;")
            title.add_looks("navmenu_header")
            title.add_style("height: 18px")
            title.add_style("padding-top: 2px")
            """
            title = DivWdg()
            title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
            if not web.is_IE():
                title.add_styles( "margin-left: -10px; margin-right: -10px;")
            title.add_looks( "navmenu_header" )
            """

            # FIXME: not sure if this logic should be here. It basically
            # makes special titles for certain view names
            view_attrs = config.get_view_attributes()
            title_str = view_attrs.get("title")
            if not title_str:
                if viewx.startswith("self_view_"):
                    title_str = "My Views"
                else:
                    title_str = viewx

            title_str = Common.get_display_title(title_str)

            title_label = SpanWdg()
            title_label.add_styles("margin-left: 6px; padding-bottom: 2px;")
            title_label.add_looks("fnt_title_5 fnt_bold")
            title_label.add(title_str)
            title.add(title_label)

            content_div.add(title)

            info = {'counter': 10, 'view': viewx}
            self.generate_section(config, content_div, info)
            error_list = Container.get_seq(self.ERR_MSG)
            if error_list:
                span = SpanWdg()
                span.add_style('background', 'red')
                span.add('<br/>'.join(error_list))
                content_div.add(span)
                Container.clear_seq(self.ERR_MSG)
            self.add_dummy(config, content_div)

        return div
Esempio n. 8
0
    def execute(my):
        error_list = []
        from pyasm.biz import Project
        Project.clear_cache()

        sthpw_search = Search("sthpw/project")
        sthpw_search.add_filter('code','sthpw')
        sthpw_search.set_show_retired(True)
        sthpw_proj = sthpw_search.get_sobject()

        search = Search("sthpw/project")
        if my.project_code:
            search.add_filter("code", my.project_code)
        else:
            #search.add_enum_order_by("type", ['sthpw','prod','game','design','simple', 'unittest'])
            search.add_enum_order_by("code", ['sthpw'])
        projects = search.get_sobjects()

        project_codes = SObject.get_values(projects, 'code')
        # append sthpw project in case it's retired
        if 'sthpw' not in project_codes and sthpw_proj:
            if not my.project_code:
                projects.insert(0, sthpw_proj)
            sthpw_proj.reactivate()



        current_dir = os.getcwd()
        tmp_dir = Environment.get_tmp_dir()
        output_file = '%s/upgrade_output.txt' % tmp_dir
        if not os.path.exists(tmp_dir):
            os.makedirs(tmp_dir)
        elif os.path.exists(output_file):
            os.unlink(output_file)
        ofile = open(output_file, 'w')

        import datetime
        ofile.write('Upgrade Time: %s\n\n' %datetime.datetime.now())



        # dynamically generate
        #sql = DbContainer.get(code)
        database_type = Sql.get_default_database_type()
        #if database_type in ['Sqlite', 'MySQL']:
        if database_type != "PostgreSQL":
            # general an upgrade
            import imp

            namespaces = ['default', 'simple', 'sthpw', 'config']
            for namespace in namespaces:
                if database_type == 'Sqlite':
                    from pyasm.search.upgrade.sqlite import convert_sqlite_upgrade
                    file_path = convert_sqlite_upgrade(namespace)
                elif database_type == 'MySQL':
                    from pyasm.search.upgrade.mysql import convert_mysql_upgrade
                    file_path = convert_mysql_upgrade(namespace)
                elif database_type == 'SQLServer':
                    from pyasm.search.upgrade.sqlserver import convert_sqlserver_upgrade
                    file_path = convert_sqlserver_upgrade(namespace)
                elif database_type == 'Oracle':
                    file_path = convert_oracle_upgrade(namespace)
                else:
                    raise Exception("Database type not implemented here")

                (path, name) = os.path.split(file_path)
                (name, ext) = os.path.splitext(name)
                (file, filename, data) = imp.find_module(name, [path])
                module = imp.load_module(name, file, filename, data)

                class_name = "%s%sUpgrade" % (database_type,namespace.capitalize())
                exec("%s = module.%s" % (class_name, class_name) )



        # load all the default modules
        from pyasm.search.upgrade.project import *

        for project in projects:
            
            code = project.get_code()
            if code == "sthpw":
                type = "sthpw"
            else:
                type = project.get_type()

            if not type:
                type = 'default'


            if not my.quiet:
                print project.get_code(), type
                print "-"*30

            # if the project is admin, the just ignore for now
            if code == 'admin':
                continue
            
            if not project.database_exists():
                ofile.write("*" * 80 + '\n')
                msg =  "Project [%s] does not have a database\n"% project.get_code()
                ofile.write(msg)
                print msg
                ofile.write("*" * 80 + '\n\n')
                continue


            upgrade = None

            if database_type != 'PostgreSQL':
                upgrade_class = "%s%sUpgrade" % (database_type, type.capitalize())
                conf_upgrade = eval("%sConfigUpgrade()" % database_type)
            else:
                upgrade_class = "%sUpgrade" % type.capitalize()
                conf_upgrade = eval("ConfigUpgrade()")
            upgrade = eval("%s()" % upgrade_class)

            # upgrade config (done for every project but sthpw)
            conf_upgrade.set_project(project.get_code())
            conf_upgrade.set_to_version(my.to_version)
            conf_upgrade.set_forced(my.is_forced)
            conf_upgrade.set_quiet(my.quiet)
            conf_upgrade.set_confirmed(my.is_confirmed)
            conf_upgrade.execute()
            
            # append the errors for each upgrade
            key = '%s|%s' %(project.get_code(), conf_upgrade.__class__.__name__)
            error_list.append((conf_upgrade.__class__.__name__, project.get_code(), \
                Container.get_seq(key)))


            # perform the upgrade to the other tables
            if upgrade:
                upgrade.set_project(project.get_code() )
                upgrade.set_to_version(my.to_version)
                upgrade.set_forced(my.is_forced)
                upgrade.set_quiet(my.quiet)
                upgrade.set_confirmed(my.is_confirmed)
                #Command.execute_cmd(upgrade)
                # put each upgrade function in its own transaction
                # carried out in BaseUpgrade
                upgrade.execute()
                
                # append the errors for each upgrade
                key = '%s|%s' %(project.get_code(), upgrade.__class__.__name__)
                error_list.append((upgrade.__class__.__name__, project.get_code(), \
                    Container.get_seq(key)))

            from pyasm.search import DatabaseImpl
            project.set_value("last_db_update", DatabaseImpl.get().get_timestamp_now(), quoted=False)
            
            if project.has_value('last_version_update'):
                last_version = project.get_value('last_version_update')
                if my.to_version > last_version:
                    project.set_value("last_version_update", my.to_version)
            else: 
                # it should be getting the upgrade now, redo the search
                print "Please run upgrade_db.py again, the sthpw db has just been updated"
                return
            project.commit(triggers=False)



        # print the errors for each upgrade
        for cls_name, project_code, errors in error_list:
            if not my.quiet:
                print
                print "Errors for %s [%s]:" %(project_code, cls_name)
            ofile.write("Errors for %s [%s]:\n" %(project_code, cls_name))
            if not my.quiet:
                print "*" * 80
            ofile.write("*" * 80 + '\n')
            for func, error in errors:
                if not my.quiet:
                    print '[%s]' % func
                    print "-" * 70
                    print error
                ofile.write('[%s]\n' % func)
                ofile.write("-" * 70 + '\n')
                ofile.write('%s\n' %error)
        ofile.close()

        if my.quiet:
            print "Please refer to the upgrade_output.txt file for any upgrade messages."
            print
        # handle sthpw database separately.  This ensures that the project entry
        # gets created if none exists.
        #print "sthpw"
        #print "-"*30
        #upgrade = SthpwUpgrade()
        #upgrade.set_project("sthpw")
        #Command.execute_cmd(upgrade)

        # update the template zip files
        data_dir = Environment.get_data_dir(manual=False)
        dest_dir = '%s/templates' %data_dir
        if os.path.exists(dest_dir):
            install_dir = Environment.get_install_dir()
            src_code_template_dir = '%s/src/install/start/templates' %install_dir
            if os.path.exists(src_code_template_dir):
                zip_files = os.listdir(src_code_template_dir)
                io_errors = False
                for zip_file in zip_files:
                    if not zip_file.endswith(".zip"):
                        continue
                    try:
                        src_file = '%s/%s' %(src_code_template_dir, zip_file)
                        dest_file = '%s/%s' %(dest_dir, zip_file)
                        shutil.copyfile(src_file, dest_file)
                    except IOError, e:
                        print e
                        io_errors = True
                if not io_errors:
                    print "Default project template files have been updated."
                else:
                    print "There was a problem copying the default template files to <TACTIC_DATA_DIR>/templates."
Esempio n. 9
0
    def execute(my):
        error_list = []
        from pyasm.biz import Project
        Project.clear_cache()

        sthpw_search = Search("sthpw/project")
        sthpw_search.add_filter('code', 'sthpw')
        sthpw_search.set_show_retired(True)
        sthpw_proj = sthpw_search.get_sobject()

        search = Search("sthpw/project")
        if my.project_code:
            search.add_filter("code", my.project_code)
        else:
            #search.add_enum_order_by("type", ['sthpw','prod','game','design','simple', 'unittest'])
            search.add_enum_order_by("code", ['sthpw'])
        projects = search.get_sobjects()

        project_codes = SObject.get_values(projects, 'code')
        # append sthpw project in case it's retired
        if 'sthpw' not in project_codes and sthpw_proj:
            if not my.project_code:
                projects.insert(0, sthpw_proj)
            sthpw_proj.reactivate()

        current_dir = os.getcwd()
        tmp_dir = Environment.get_tmp_dir()
        output_file = '%s/upgrade_output.txt' % tmp_dir
        if not os.path.exists(tmp_dir):
            os.makedirs(tmp_dir)
        elif os.path.exists(output_file):
            os.unlink(output_file)
        ofile = open(output_file, 'w')

        import datetime
        ofile.write('Upgrade Time: %s\n\n' % datetime.datetime.now())

        # dynamically generate
        #sql = DbContainer.get(code)
        database_type = Sql.get_default_database_type()
        #if database_type in ['Sqlite', 'MySQL']:
        if database_type != "PostgreSQL":
            # general an upgrade
            import imp

            namespaces = ['default', 'simple', 'sthpw', 'config']
            for namespace in namespaces:
                if database_type == 'Sqlite':
                    from pyasm.search.upgrade.sqlite import convert_sqlite_upgrade
                    file_path = convert_sqlite_upgrade(namespace)
                elif database_type == 'MySQL':
                    from pyasm.search.upgrade.mysql import convert_mysql_upgrade
                    file_path = convert_mysql_upgrade(namespace)
                elif database_type == 'SQLServer':
                    from pyasm.search.upgrade.sqlserver import convert_sqlserver_upgrade
                    file_path = convert_sqlserver_upgrade(namespace)
                elif database_type == 'Oracle':
                    file_path = convert_oracle_upgrade(namespace)
                else:
                    raise Exception("Database type not implemented here")

                (path, name) = os.path.split(file_path)
                (name, ext) = os.path.splitext(name)
                (file, filename, data) = imp.find_module(name, [path])
                module = imp.load_module(name, file, filename, data)

                class_name = "%s%sUpgrade" % (database_type,
                                              namespace.capitalize())
                exec("%s = module.%s" % (class_name, class_name))

        # load all the default modules
        from pyasm.search.upgrade.project import *

        for project in projects:

            code = project.get_code()
            if code == "sthpw":
                type = "sthpw"
            else:
                type = project.get_type()

            if not type:
                type = 'default'

            if not my.quiet:
                print project.get_code(), type
                print "-" * 30

            # if the project is admin, the just ignore for now
            if code == 'admin':
                continue

            if not project.database_exists():
                ofile.write("*" * 80 + '\n')
                msg = "Project [%s] does not have a database\n" % project.get_code(
                )
                ofile.write(msg)
                print msg
                ofile.write("*" * 80 + '\n\n')
                continue

            upgrade = None

            if database_type != 'PostgreSQL':
                upgrade_class = "%s%sUpgrade" % (database_type,
                                                 type.capitalize())
                conf_upgrade = eval("%sConfigUpgrade()" % database_type)
            else:
                upgrade_class = "%sUpgrade" % type.capitalize()
                conf_upgrade = eval("ConfigUpgrade()")
            upgrade = eval("%s()" % upgrade_class)

            # upgrade config (done for every project but sthpw)
            conf_upgrade.set_project(project.get_code())
            conf_upgrade.set_to_version(my.to_version)
            conf_upgrade.set_forced(my.is_forced)
            conf_upgrade.set_quiet(my.quiet)
            conf_upgrade.set_confirmed(my.is_confirmed)
            conf_upgrade.execute()

            # append the errors for each upgrade
            key = '%s|%s' % (project.get_code(),
                             conf_upgrade.__class__.__name__)
            error_list.append((conf_upgrade.__class__.__name__, project.get_code(), \
                Container.get_seq(key)))

            # perform the upgrade to the other tables
            if upgrade:
                upgrade.set_project(project.get_code())
                upgrade.set_to_version(my.to_version)
                upgrade.set_forced(my.is_forced)
                upgrade.set_quiet(my.quiet)
                upgrade.set_confirmed(my.is_confirmed)
                #Command.execute_cmd(upgrade)
                # put each upgrade function in its own transaction
                # carried out in BaseUpgrade
                upgrade.execute()

                # append the errors for each upgrade
                key = '%s|%s' % (project.get_code(),
                                 upgrade.__class__.__name__)
                error_list.append((upgrade.__class__.__name__, project.get_code(), \
                    Container.get_seq(key)))

            from pyasm.search import DatabaseImpl
            project.set_value("last_db_update",
                              DatabaseImpl.get().get_timestamp_now(),
                              quoted=False)

            if project.has_value('last_version_update'):
                last_version = project.get_value('last_version_update')
                if my.to_version > last_version:
                    project.set_value("last_version_update", my.to_version)
            else:
                # it should be getting the upgrade now, redo the search
                print "Please run upgrade_db.py again, the sthpw db has just been updated"
                return
            project.commit(triggers=False)

        # print the errors for each upgrade
        for cls_name, project_code, errors in error_list:
            if not my.quiet:
                print
                print "Errors for %s [%s]:" % (project_code, cls_name)
            ofile.write("Errors for %s [%s]:\n" % (project_code, cls_name))
            if not my.quiet:
                print "*" * 80
            ofile.write("*" * 80 + '\n')
            for func, error in errors:
                if not my.quiet:
                    print '[%s]' % func
                    print "-" * 70
                    print error
                ofile.write('[%s]\n' % func)
                ofile.write("-" * 70 + '\n')
                ofile.write('%s\n' % error)
        ofile.close()

        if my.quiet:
            print "Please refer to the file [%s] for any upgrade messages." % output_file
            print
        # handle sthpw database separately.  This ensures that the project entry
        # gets created if none exists.
        #print "sthpw"
        #print "-"*30
        #upgrade = SthpwUpgrade()
        #upgrade.set_project("sthpw")
        #Command.execute_cmd(upgrade)

        # update the template zip files
        data_dir = Environment.get_data_dir(manual=False)
        dest_dir = '%s/templates' % data_dir
        if os.path.exists(dest_dir):
            install_dir = Environment.get_install_dir()
            src_code_template_dir = '%s/src/install/start/templates' % install_dir
            if os.path.exists(src_code_template_dir):
                zip_files = os.listdir(src_code_template_dir)
                io_errors = False
                for zip_file in zip_files:
                    if not zip_file.endswith(".zip"):
                        continue
                    try:
                        src_file = '%s/%s' % (src_code_template_dir, zip_file)
                        dest_file = '%s/%s' % (dest_dir, zip_file)
                        shutil.copyfile(src_file, dest_file)
                    except IOError, e:
                        print e
                        io_errors = True
                if not io_errors:
                    print "Default project template files have been updated."
                else:
                    print "There was a problem copying the default template files to <TACTIC_DATA_DIR>/templates."
Esempio n. 10
0
    def get_display(my):
        my.config_search_type = my.kwargs.get("config_search_type")
        if not my.config_search_type:
            my.config_search_type = "SideBarWdg"

        title = my.kwargs.get('title')
        config = my.kwargs.get('config')
        view = my.kwargs.get('view')
        width = my.kwargs.get('width')
        #sortable = my.kwargs.get('sortable')
        if not width:
            width = "175"

        my.prefix = my.kwargs.get("prefix")
        if not my.prefix:
            my.prefix = "side_bar"

        my.mode = my.kwargs.get("mode")
        if not my.mode:
            my.mode = 'view'


        my.default = my.kwargs.get('default') == 'True'

        div = DivWdg()
        div.add_class("spt_section_top")
        div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")


        # create the top widgets
        label = SpanWdg()
        label.add(title)
        label.add_style("font-size: 1.1em")
        section_div = LabeledHidableWdg(label=label)
        div.add(section_div)

        section_div.set_attr('spt_class_name', Common.get_full_class_name(my))
        for name, value in my.kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        bgcolor = label.get_color("background3")
        project_div = RoundedCornerDivWdg(hex_color_code=bgcolor,corner_size="10")
        project_div.set_dimensions( width_str='%spx' % width, content_height_str='100px' )
        content_div = project_div.get_content_wdg()

        #project_div = DivWdg()
        #content_div = project_div


        section_div.add( project_div )

        content_div.add_class("spt_side_bar_content")
        content_div.add_attr("spt_view", view)

        if type(view) in types.StringTypes:
            view = [view]

        view_margin_top = '4px'

        web = WebContainer.get_web()
        for viewx in view:
            config = my.get_config(my.config_search_type, viewx, default=my.default)
            if not config:
                continue

            # make up a title
            title = DivWdg()
            title.add_gradient( "background", "side_bar_title", 0, -15, default="background" )
            title.add_color( "color", "side_bar_title_color", default="color" )
            title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
            if not web.is_IE():
                title.add_styles( "margin-left: -5px; margin-right: -5px;")
            title.add_looks( "navmenu_header" )
            title.add_style( "height: 18px" )
            title.add_style( "padding-top: 2px" )
            """
            title = DivWdg()
            title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
            if not web.is_IE():
                title.add_styles( "margin-left: -10px; margin-right: -10px;")
            title.add_looks( "navmenu_header" )
            """

            # FIXME: not sure if this logic should be here. It basically
            # makes special titles for certain view names
            view_attrs = config.get_view_attributes()
            title_str = view_attrs.get("title")
            if not title_str:
                if viewx.startswith("my_view_"):
                    title_str = "My Views"
                else:
                    title_str = viewx

            title_str = Common.get_display_title(title_str)

            title_label = SpanWdg()
            title_label.add_styles( "margin-left: 6px; padding-bottom: 2px;" )
            title_label.add_looks( "fnt_title_5 fnt_bold" )
            title_label.add( title_str )
            title.add( title_label )

            content_div.add( title )

            info = { 'counter' : 10, 'view': viewx }
            my.generate_section( config, content_div, info )
            error_list = Container.get_seq(my.ERR_MSG)
            if error_list: 
                span = SpanWdg()
                span.add_style('background', 'red')
                span.add('<br/>'.join(error_list))
                content_div.add(span)
                Container.clear_seq(my.ERR_MSG)
            my.add_dummy(config, content_div) 

        return div