Changeset 1ced41a in indico


Ignore:
Timestamp:
08/05/11 10:53:27 (22 months ago)
Author:
Jose Benito <jose.benito.gonzalez@…>
Branches:
master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
c87441
Parents:
60171b
git-author:
Marius Damarackas <marius.damarackas@…> (04/13/11 14:40:39)
git-committer:
Jose Benito <jose.benito.gonzalez@…> (08/05/11 10:53:27)
Message:

[IMP] Changed styles admin panel to support TPL

  • refactored some code in order to change XSL to TPL, changed some variable names
  • added a missing feature so that only styles with existing TPL files would be shown to the user
Location:
indico/MaKaC
Files:
13 edited
1 moved

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/common/Configuration.py

    r137cf0 r1ced41a  
    260260    # default values - Administrators can update this list from the Indico 
    261261    # administration web interface 
    262     __stylesheets = { 
    263             "cdsagenda_olist": "CDS Agenda ordered list", 
    264             "nicecompact":"Compact style", 
    265             "ilc":"ILC style", 
    266             "standard_inline_minutes":"Indico style - inline minutes", 
    267             "lhcrrb":"LHC RRB", 
    268             "xml":"Simple xml", 
    269             "alice_meeting":"ALICE meeting", 
    270             "administrative3": "Administrative style 2", 
    271             "administrative4": "Administrative style (all material)", 
    272             "atlas":"ATLAS Meeting", 
    273             "text":"Simple text", 
    274             "totem_meeting":"TOTEM Meeting", 
    275             "administrative2":"Administrative style (with time)", 
    276             "cdsagenda":"CDS Agenda style", 
    277             "static":"Parallel", 
    278             "sa":"Staff Association", 
    279             "sa2":"Staff Association (with time)", 
    280             "it":"IT style", 
    281             "cdsagenda_inline_minutes":"CDS Agenda inline minutes", 
    282             "lcg":"LCG style", 
    283             "lhcb_meeting":"LHCb meeting", 
    284             "egee_meeting":"EGEE meeting", 
    285             "administrative":"Administrative style", 
    286             "cms":"CMS Meeting", 
    287             "standard":"Indico style", 
    288             "lecture":"Lecture", 
    289             "egee_lecture":"EGEE lecture", 
    290             "event": "Event" } 
     262    __styles = { 
     263            "cdsagenda_olist":  ("CDS Agenda ordered list", "CDSAgendaOrdered.tpl"), 
     264            "nicecompact":      ("Compact style", "Compact.tpl"), 
     265            "ilc":              ("ILC style", "ILC.tpl"), 
     266            "standard_inline_minutes": ("Indico style - inline minutes", "IndicoWithMinutes.tpl"), 
     267            "lhcrrb":           ("LHC RRB", "LHCRBB.tpl"), 
     268            "xml":              ("Simple xml", "SimpleXML.tpl"), 
     269            "alice_meeting":    ("ALICE meeting", "ALICEMeeting.tpl"), 
     270            "administrative3":  ("Administrative style 2", "Administrative3.tpl"), 
     271            "administrative4":  ("Administrative style (all material)", "Administrative4.tpl"), 
     272            "atlas":            ("ATLAS Meeting", "ATLASMeeting.tpl"), 
     273            "text":             ("Simple text", "SimpleText.tpl"), 
     274            "totem_meeting":    ("TOTEM Meeting", "TOTEMMeeting.tpl"), 
     275            "administrative2":  ("Administrative style (with time)", "Administrative2.tpl"), 
     276            "cdsagenda":        ("CDS Agenda style", "CDSAgenda.tpl"), 
     277            "static":           ("Parallel", None), 
     278            "sa":               ("Staff Association", "StaffAssociation.tpl"), 
     279            "sa2":              ("Staff Association (with time)", "StaffAssociationWithTime.tpl"), 
     280            "it":               ("IT style", "IT.tpl"), 
     281            "cdsagenda_inline_minutes": ("CDS Agenda inline minutes", "CDSAgendaWithMinutes.tpl"), 
     282            "lcg":              ("LCG style", "LCG.tpl"), 
     283            "lhcb_meeting":     ("LHCb meeting", "LHCbMeeting.tpl"), 
     284            "egee_meeting":     ("EGEE meeting", "EGEEMeeting.tpl"), 
     285            "cms":              ("CMS Meeting", "CMSMeeting.tpl"), 
     286            "standard":         ("Indico style", "Indico.tpl"), 
     287            "lecture":          ("Lecture", "Lecture.tpl"), 
     288            "egee_lecture":     ("EGEE lecture", "EGEELecture.tpl"), 
     289            "event":            ("Event", "Event.tpl"), 
     290            "jacow":            ("JACoW XML", "JACoW.tpl"), 
     291            "endotofpet":       ("EndoTOFPET", "EndoTOFPET.tpl"), 
     292            "pf":               ("Pension Fund", "PensionFund.tpl"), 
     293            "crystal_clear":    ("Crystal Clear", "CrystalClear.tpl"), 
     294            "openlab":          ("Openlab", "Openlab.tpl"), 
     295    } 
    291296 
    292297    # default values - Administrators can update this list from the Indico 
     
    294299    __eventStylesheets = { 
    295300        "conference": [ 
     301            "administrative3", 
     302            "cdsagenda", 
     303            "cdsagenda_inline_minutes", 
     304            "cdsagenda_olist", 
     305            "egee_meeting", 
    296306            "it", 
    297             "administrative3", 
    298             "administrative4", 
    299             "cdsagenda", 
     307            "jacow", 
     308            "lhcb_meeting", 
     309            "nicecompact", 
     310            "standard", 
     311            "static", 
    300312            "text", 
    301             "egee_meeting", 
    302             "administrative", 
    303             "cdsagenda_olist", 
    304             "standard", 
    305             "nicecompact", 
    306             "cdsagenda_inline_minutes", 
    307             "lhcb_meeting", 
    308             "xml", 
    309             "static" ], 
     313            "xml"], 
    310314        "simple_event": [ 
    311315            "it", 
     
    314318            "lecture", 
    315319            "egee_lecture", 
     320            "jacow", 
    316321            "xml", 
    317322            "event" ], 
    318323        "meeting": [ 
    319             "cdsagenda_olist", 
    320             "nicecompact", 
    321             "ilc", 
    322             "standard_inline_minutes", 
    323             "lhcrrb", 
    324             "xml", 
    325             "alice_meeting", 
     324            "administrative2", 
    326325            "administrative3", 
    327326            "administrative4", 
     327            "alice_meeting", 
    328328            "atlas", 
     329            "cdsagenda", 
     330            "cdsagenda_inline_minutes", 
     331            "cdsagenda_olist", 
     332            "cms", 
     333            "crystal_clear", 
     334            "egee_meeting", 
     335            "endotofpet", 
     336            "ilc", 
     337            "it", 
     338            "lcg", 
     339            "lhcb_meeting", 
     340            "lhcrrb", 
     341            "nicecompact", 
     342            "openlab" 
     343            "pf", 
     344            "sa", 
     345            "sa2", 
     346            "standard", 
     347            "standard_inline_minutes", 
     348            "static", 
    329349            "text", 
    330350            "totem_meeting", 
    331             "administrative2", 
    332             "cdsagenda", 
    333             "static", 
    334             "sa", 
    335             "sa2", 
    336             "it", 
    337             "cdsagenda_inline_minutes", 
    338             "lcg", 
    339             "lhcb_meeting", 
    340             "egee_meeting", 
    341             "administrative", 
    342             "cms", 
    343             "standard" ] 
     351            "xml"] 
    344352        } 
     353 
    345354 
    346355    # default values - Administrators can update this list from the Indico 
     
    489498            'PublicURL'                 : "%s/%s" % (self.getBaseURL(), self.getPublicFolder()), 
    490499            'SystemIcons'               : self.__systemIcons, 
    491             'Stylesheets'               : self.__stylesheets, 
     500            'Styles'                    : self.__styles, 
    492501            'EventStylesheets'          : self.__eventStylesheets, 
    493502            'TempDir'                   : self.getUploadedFilesTempDir(), 
  • indico/MaKaC/common/info.py

    r2da75d r1ced41a  
    432432 
    433433class StyleManager(Persistent): 
    434     """This class manages the stylesheets used by the server for the display 
     434    """This class manages the styles used by the server for the display 
    435435       of events timetables 
    436436    """ 
    437437 
    438438    def __init__( self ): 
    439         self._stylesheets = Config.getInstance().getStylesheets() 
     439        self._styles = Config.getInstance().getStyles() 
    440440        self._eventStylesheets = Config.getInstance().getEventStylesheets() 
    441441        self._defaultEventStylesheet = Config.getInstance().getDefaultEventStylesheet() 
    442442 
    443     def getStylesheets(self): 
    444         """gives back the entire stylesheet list. 
    445         """ 
    446         return self._stylesheets 
    447  
    448     def setStylesheets(self, sList=[]): 
    449         self._stylesheets = sList 
    450  
    451     def getEventStylesheets(self): 
    452         """gives back the entire stylesheet/event association list. 
     443    def getStyles(self): 
     444        try: 
     445            return self._styles 
     446        except AttributeError: 
     447            self._styles = Config.getInstance().getStyles() 
     448            return self._styles 
     449 
     450    def setStyles(self, newStyles): 
     451        self._styles = newStyles 
     452 
     453    def getEventStyles(self): 
     454        """gives back the entire style/event association list. 
    453455        """ 
    454456        return self._eventStylesheets 
    455457 
    456     def setEventStylesheets(self, sDict={}): 
     458    def setEventStyles(self, sDict={}): 
    457459        self._eventStylesheets = sDict 
    458460 
    459     def getDefaultEventStylesheet(self): 
    460         """gives back the default stylesheet/event association 
     461    def getDefaultEventStyles(self): 
     462        """gives back the default styles/event association 
    461463        """ 
    462464        return self._defaultEventStylesheet 
    463465 
    464     def setDefaultEventStylesheet(self, sDict={}): 
     466    def setDefaultEventStyle(self, sDict={}): 
    465467        self._defaultEventStylesheet = sDict 
    466468 
    467     def getDefaultStylesheetForEventType(self, type): 
     469    def getDefaultStyleForEventType(self, eventType): 
    468470        """gives back the default stylesheet for the given type of event 
    469471        """ 
    470         return self._defaultEventStylesheet.get(type,"") 
    471  
    472     def removeStyle( self, style, type="" ): 
     472        return self._defaultEventStylesheet.get(eventType, "") 
     473 
     474    def removeStyle(self, styleId, type=""): 
    473475        if type == "": 
    474476            # style globally removed 
    475             if style in self.getStylesheets().keys(): 
    476                 styles = self.getStylesheets() 
    477                 del styles[style] 
    478                 self.setStylesheets(styles) 
    479                 self.removeStyleFromAllTypes(style) 
     477            styles = self.getStyles() 
     478            if styleId in styles.keys(): 
     479                del styles[styleId] 
     480                self.setStyles(styles) 
     481                self.removeStyleFromAllTypes(styleId) 
    480482        else: 
    481483            # style removed only in the type list 
    482             self.removeStyleFromEventType(style, type) 
     484            self.removeStyleFromEventType(styleId, type) 
    483485 
    484486    def addStyleToEventType( self, style, type ): 
    485         dict = self.getEventStylesheets() 
     487        dict = self.getEventStyles() 
    486488        styles = dict.get(type,[]) 
    487489        if style not in styles: 
    488490            styles.append(style) 
    489491            dict[type] = styles 
    490             self.setEventStylesheets(dict) 
     492            self.setEventStyles(dict) 
    491493 
    492494    def removeStyleFromEventType( self, style, type ): 
    493495        # style removed only in the type list 
    494         dict = self.getEventStylesheets() 
     496        dict = self.getEventStyles() 
    495497        styles = dict.get(type,[]) 
    496         defaultStyle = self.getDefaultStylesheetForEventType(type) 
     498        defaultStyle = self.getDefaultStyleForEventType(type) 
    497499        if style != "" and style in styles: 
    498500            styles.remove(style) 
    499501            dict[type] = styles 
    500             self.setEventStylesheets(dict) 
     502            self.setEventStyles(dict) 
    501503            if style.strip() == defaultStyle.strip(): 
    502504                if len(styles) > 0: 
     
    508510    def setDefaultStyle( self, style, type ): 
    509511        if style != "": 
    510             dict = self.getDefaultEventStylesheet() 
     512            dict = self.getDefaultEventStyles() 
    511513            dict[type] = style 
    512             self.setDefaultEventStylesheet(dict) 
     514            self.setDefaultEventStyle(dict) 
    513515 
    514516    def removeStyleFromAllTypes( self, style ): 
     
    516518            self.removeStyleFromEventType(style, type) 
    517519 
    518     def getStylesheetListForEventType(self, type): 
    519         """gives back the stylesheet list associated to a given type of event. 
     520    def getStyleListForEventType(self, eventType): 
     521        """gives back the style list associated to a given type of event. 
    520522        If no event was specified it returns the empty list. 
    521523           Params: 
    522524                type -- unique identifier of the event type 
    523525        """ 
    524         return self._eventStylesheets.get( type, [] ) 
    525  
    526     def getStylesheetDictForEventType(self, type): 
    527         """gives back the stylesheet list associated to a given type of event. 
     526        return self._eventStylesheets.get(eventType, []) 
     527 
     528    def getExistingStylesForEventType(self, eventType): 
     529        result = [] 
     530        for style in self.getStyleListForEventType(eventType): 
     531            if self.existsTPLFile(style) or style == 'static': 
     532                result.append(style) 
     533        return result 
     534 
     535    def getStyleDictForEventType(self, type): 
     536        """gives back the style list associated to a given type of event. 
    528537        If no event was specified it returns the empty list. 
    529538           Params: 
    530539                type -- unique identifier of the event type 
    531540        """ 
    532         return dict((ssid, self._stylesheets[ssid]) for ssid in self._eventStylesheets.get( type, [] )) 
    533  
    534     def getStylesheetName( self, stylesheet ): 
    535         return self._stylesheets.get( stylesheet, "" ) 
    536  
    537     def getBaseXSLPath( self ): 
    538         return Config.getInstance().getStylesheetsDir() 
    539  
    540     def getXSLPath( self, stylesheet ): 
    541         if stylesheet.strip() != "": 
    542             basepath = Config.getInstance().getStylesheetsDir() 
    543             path = os.path.join( basepath, "%s.xsl" % stylesheet ) 
     541        styles = self.getStyles() 
     542        return dict((styleID, styles[styleID]) for styleID in self._eventStylesheets.get(type, [])) 
     543 
     544    def getStyleName(self, styleId): 
     545        styles = self.getStyles() 
     546        if styleId in styles: 
     547            return styles[styleId][0] 
     548        else: 
     549            return "" 
     550 
     551    def getBaseTPLPath(self): 
     552        tplDir = Config.getInstance().getTPLDir() 
     553        return os.path.join(tplDir, "events") 
     554 
     555    def existsTPLFile(self, styleId): 
     556        if styleId.strip() != "": 
     557            tplFile = self.getTPLFilename(styleId) 
     558            if not tplFile: 
     559                return False 
     560            path = os.path.join(self.getBaseTPLPath(), tplFile) 
    544561            if os.path.exists(path): 
    545                 return path 
    546         return "" 
    547  
    548     def getXSLFile( self, stylesheet ): 
    549         if self.getXSLPath( stylesheet ): 
    550             return "%s.xsl" % stylesheet 
    551         return "" 
     562                return True 
     563        return False 
     564 
     565    def getStyleFilenames(self): 
     566        return [fileName for styleName, fileName in self.getStyles().values()] 
     567 
     568    def getTPLFilename(self, styleId): 
     569        styles = self.getStyles() 
     570        if styleId in styles: 
     571            fileName = styles[styleId][1] 
     572            return fileName 
     573        else: 
     574            return None 
    552575 
    553576    def getBaseCSSPath( self ): 
  • indico/MaKaC/services/implementation/conference.py

    rf6e097 r1ced41a  
    182182 
    183183            dispMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target) 
    184             dispMgr.setDefaultStyle(styleMgr.getDefaultStylesheetForEventType(newType)) 
     184            dispMgr.setDefaultStyle(styleMgr.getDefaultStyleForEventType(newType)) 
    185185 
    186186    def _handleGet(self): 
  • indico/MaKaC/webinterface/pages/admins.py

    r137cf0 r1ced41a  
    852852        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    853853        vars["styleMgr"] = styleMgr 
    854         baseXSLPath = styleMgr.getBaseXSLPath() 
     854        baseTPLPath = styleMgr.getBaseTPLPath() 
    855855        baseCSSPath = styleMgr.getBaseCSSPath() 
    856         vars["contextHelpText"] = i18nformat("""- <b>_("XSL files")</b> _("are mandatory and located in"):<br/>%s<br/>- <b>_("CSS files")</b> _("are optional and located in"):<br/>%s<br/>- <b>_("Lines in red")</b> _("indicate a missing .xsl file (these styles will not be presented to the users"))<br/>- <b>_("XSL and CSS files")</b> _("should be named after the ID of the style (+extension: .xsl or .css)")""") % (baseXSLPath,baseCSSPath) 
     856        vars["contextHelpText"] = i18nformat("""- <b>_("TPL files")</b> _("are mandatory and located in"):<br/>%s<br/>- <b>_("CSS files")</b> _("are optional and located in"):<br/>%s<br/>- <b>_("Lines in red")</b> _("indicate a missing .tpl file (these styles will not be presented to the users"))<br/>- <b>_("CSS files")</b> _("should be named after the ID of the style (plus extension .css)")""") % (baseTPLPath,baseCSSPath) 
    857857        vars["deleteIconURL"] = Config.getInstance().getSystemIconURL("remove") 
    858858        return vars 
     
    870870        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    871871        vars["styleMgr"] = styleMgr 
    872         availableStylesheets = [] 
    873         XSLBasePath = styleMgr.getBaseXSLPath() 
    874         if os.path.exists(XSLBasePath): 
    875             for file in os.listdir(XSLBasePath): 
    876                 if os.path.isfile(os.path.join(XSLBasePath,file)) and ".xsl" in file: 
    877                     filename = file.replace(".xsl","") 
    878                     if filename not in styleMgr.getStylesheets().keys(): 
    879                         availableStylesheets.append(filename) 
    880         vars["availableStylesheets"] = availableStylesheets 
    881         vars["contextHelpText"] = "Lists all XSL files in %s which are not already used in a declared style" % XSLBasePath 
     872        availableStyles = [] 
     873        TPLBasePath = styleMgr.getBaseTPLPath() 
     874        if os.path.exists(TPLBasePath): 
     875            for filename in os.listdir(TPLBasePath): 
     876                if os.path.isfile(os.path.join(TPLBasePath, filename)) and filename.endswith(".tpl"): 
     877                    if filename not in styleMgr.getStyleFilenames(): 
     878                        availableStyles.append(filename) 
     879        vars["availableStyles"] = availableStyles 
     880        vars["contextHelpText"] = "Lists all TPL files in %s which are not already used in a declared style" % TPLBasePath 
    882881        return vars 
    883882 
  • indico/MaKaC/webinterface/pages/category.py

    r0e77ad r1ced41a  
    12221222        vars["supportEmail"] = vars.get("supportEmail","") 
    12231223        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    1224         stylesheets = styleMgr.getStylesheetListForEventType(self._type) 
     1224        styles = styleMgr.getExistingStylesForEventType(self._type) 
    12251225        styleoptions = "" 
    1226         for stylesheet in stylesheets: 
     1226        for styleId in styles: 
    12271227            defStyle = "" 
    12281228            if self._categ: 
    12291229                defStyle = self._categ.getDefaultStyle(self._type) 
    12301230            if defStyle == "": 
    1231                 defStyle = styleMgr.getDefaultStylesheetForEventType(self._type) 
    1232             if stylesheet == defStyle: 
     1231                defStyle = styleMgr.getDefaultStyleForEventType(self._type) 
     1232            if styleId == defStyle: 
    12331233                selected = "selected" 
    12341234            else: 
    12351235                selected = "" 
    1236             styleoptions += "<option value=\"%s\" %s>%s</option>" % (stylesheet,selected,styleMgr.getStylesheetName(stylesheet)) 
     1236            styleoptions += "<option value=\"%s\" %s>%s</option>" % (styleId,selected,styleMgr.getStyleName(styleId)) 
    12371237        vars["styleOptions"] = styleoptions 
    12381238 
     
    14791479            vars["items"] = self.__getSubCategoryItems( self._categ.getSubCategoryList(), vars["categModifyURLGen"] ) 
    14801480        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    1481         vars["defaultMeetingStyle"] = styleMgr.getStylesheetName(self._categ.getDefaultStyle("meeting")) 
    1482         vars["defaultLectureStyle"] = styleMgr.getStylesheetName(self._categ.getDefaultStyle("simple_event")) 
     1481        vars["defaultMeetingStyle"] = styleMgr.getStyleName(self._categ.getDefaultStyle("meeting")) 
     1482        vars["defaultLectureStyle"] = styleMgr.getStyleName(self._categ.getDefaultStyle("simple_event")) 
    14831483 
    14841484##        vars["defaultVisibility"] = self._categ.getVisibility() 
     
    15881588        for type in [ "simple_event", "meeting" ]: 
    15891589            styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    1590             stylesheets = styleMgr.getStylesheetListForEventType(type) 
     1590            styles = styleMgr.getExistingStylesForEventType(type) 
    15911591            styleoptions = "" 
    1592             for stylesheet in stylesheets: 
     1592            for styleId in styles: 
    15931593                defStyle = self._categ.getDefaultStyle(type) 
    15941594                if defStyle == "": 
    1595                     defStyle = styleMgr.getDefaultStylesheetForEventType(type) 
    1596                 if stylesheet == defStyle: 
     1595                    defStyle = styleMgr.getDefaultStyleForEventType(type) 
     1596                if styleId == defStyle: 
    15971597                    selected = "selected" 
    15981598                else: 
    15991599                    selected = "" 
    1600                 styleoptions += "<option value=\"%s\" %s>%s</option>" % (stylesheet,selected,styleMgr.getStylesheetName(stylesheet)) 
     1600                styleoptions += "<option value=\"%s\" %s>%s</option>" % (styleId,selected,styleMgr.getStyleName(styleId)) 
    16011601            vars["%sStyleOptions" % type] = styleoptions 
    16021602 
     
    16231623        for type in [ "simple_event", "meeting" ]: 
    16241624            styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    1625             stylesheets = styleMgr.getStylesheetListForEventType(type) 
     1625            styles = styleMgr.getExistingStylesForEventType(type) 
    16261626            styleoptions = "" 
    1627             for stylesheet in stylesheets: 
     1627            for styleId in styles: 
    16281628                defStyle = self.__target.getDefaultStyle(type) 
    16291629                if defStyle == "": 
    1630                     defStyle = styleMgr.getDefaultStylesheetForEventType(type) 
    1631                 if stylesheet == defStyle: 
     1630                    defStyle = styleMgr.getDefaultStyleForEventType(type) 
     1631                if styleId == defStyle: 
    16321632                    selected = "selected" 
    16331633                else: 
    16341634                    selected = "" 
    1635                 styleoptions += "<option value=\"%s\" %s>%s</option>" % (stylesheet,selected,styleMgr.getStylesheetName(stylesheet)) 
     1635                styleoptions += "<option value=\"%s\" %s>%s</option>" % (styleId,selected,styleMgr.getStyleName(styleId)) 
    16361636            vars["%sStyleOptions" % type] = styleoptions 
    16371637        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() 
  • indico/MaKaC/webinterface/pages/conferences.py

    r601300 r1ced41a  
    11981198        vars['hasDifferentLocation'] = self._hasDifferentLocation 
    11991199 
    1200         body = wcomponents.WTemplated("events/Meeting").getHTML(vars) 
     1200        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
     1201        if styleMgr.existsTPLFile(self._view): 
     1202            fileName = os.path.splitext(styleMgr.getTPLFilename(self._view))[0] 
     1203            body = wcomponents.WTemplated(os.path.join("events", fileName)).getHTML(vars) 
     1204        else: 
     1205            return _("Template could not be found.") 
    12011206 
    12021207        frame = all(self._params.get(key, "") != "no" for key in ("frame", "fr")) 
     
    28452850        defStyle = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getDefaultStyle() 
    28462851        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    2847         defaultStyle = styleMgr.getStylesheetName(defStyle) 
     2852        defaultStyle = styleMgr.getStyleName(defStyle) 
    28482853        vars["defaultStyle"] = defaultStyle 
    28492854        visibility = self._conf.getVisibility() 
     
    30633068        type = self._conf.getType() 
    30643069        vars["timezoneOptions"] = TimezoneRegistry.getShortSelectItemsHTML(self._conf.getTimezone()) 
    3065         stylesheets=styleMgr.getStylesheetListForEventType(type) 
     3070        styles=styleMgr.getExistingStylesForEventType(type) 
    30663071        styleoptions = "" 
    30673072        defStyle = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getDefaultStyle() 
    3068         if defStyle not in stylesheets: 
     3073        if defStyle not in styles: 
    30693074            defStyle = "" 
    3070         for stylesheet in stylesheets: 
    3071             if stylesheet == defStyle or (defStyle == "" and stylesheet == "static"): 
     3075        for styleId in styles: 
     3076            if styleId == defStyle or (defStyle == "" and styleId == "static"): 
    30723077                selected = "selected" 
    30733078            else: 
    30743079                selected = "" 
    3075             styleoptions += "<option value=\"%s\" %s>%s</option>" % (stylesheet,selected,styleMgr.getStylesheetName(stylesheet)) 
     3080            styleoptions += "<option value=\"%s\" %s>%s</option>" % (styleId,selected,styleMgr.getStyleName(styleId)) 
    30763081        vars["conference"] = self._conf 
    30773082        vars["useRoomBookingModule"] = minfo.getRoomBookingModuleActive() 
  • indico/MaKaC/webinterface/rh/admins.py

    r5f7a6d r1ced41a  
    297297        self._new = params.get("new", "") 
    298298        self._name = params.get("name", "") 
    299         self._xslfile = params.get("xslfile", "") 
     299        self._styleID = params.get("styleID", "") 
     300        self._tplfile = params.get("tplfile", "") 
    300301        self._eventType = params.get("event_type", "") 
    301302        self._action = params.get("action", "") 
     
    305306        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    306307        if self._new != "": 
    307             if self._xslfile not in styleMgr.getStylesheets().keys() and self._name != "": 
    308                 styles = styleMgr.getStylesheets() 
    309                 styles[self._xslfile] = self._name 
    310                 styleMgr.setStylesheets(styles) 
    311         if self._action == "default" and self._eventType != "" and self._xslfile != "": 
    312             styleMgr.setDefaultStyle(self._xslfile, self._eventType) 
    313         if self._action == "delete" and self._eventType != "" and self._xslfile != "": 
    314             styleMgr.removeStyle(self._xslfile, self._eventType) 
     308            if self._styleID not in styleMgr.getStyles().keys() and self._name != "" and self._styleID != "": 
     309                styles = styleMgr.getStyles() 
     310                styles[self._styleID] = (self._name, self._tplfile) 
     311                styleMgr.setStyles(styles) 
     312        if self._action == "default" and self._eventType != "" and self._tplfile != "": 
     313            styleMgr.setDefaultStyle(self._tplfile, self._eventType) 
     314        if self._action == "delete" and self._eventType != "" and self._tplfile != "": 
     315            styleMgr.removeStyle(self._tplfile, self._eventType) 
    315316        if self._action == "add" and self._eventType != "" and self._newstyle != "": 
    316317            styleMgr.addStyleToEventType(self._newstyle, self._eventType) 
     
    323324    def _checkParams( self, params ): 
    324325        RHAdminBase._checkParams( self, params ) 
    325         self._xslfile = params.get("xslfile", "") 
     326        self._tplfile = params.get("tplfile", "") 
    326327        self._eventType = params.get("event_type","") 
    327328 
    328329    def _process( self ): 
    329330        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    330         if self._xslfile != "": 
    331             styleMgr.removeStyle(self._xslfile, self._eventType) 
     331        if self._tplfile != "": 
     332            styleMgr.removeStyle(self._tplfile, self._eventType) 
    332333        self._redirect(urlHandlers.UHAdminsStyles.getURL()) 
    333334 
  • indico/MaKaC/webinterface/rh/categoryDisplay.py

    rc515e60 r1ced41a  
    512512            dispMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(c) 
    513513            styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    514             dispMgr.setDefaultStyle(styleMgr.getDefaultStylesheetForEventType(newType)) 
     514            dispMgr.setDefaultStyle(styleMgr.getDefaultStyleForEventType(newType)) 
    515515    setValues = staticmethod( setValues ) 
    516516 
  • indico/MaKaC/webinterface/rh/conferenceDisplay.py

    r601300 r1ced41a  
    403403            if view == "": 
    404404                styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    405                 view =styleMgr.getDefaultStylesheetForEventType( type ) 
     405                view =styleMgr.getDefaultStyleForEventType( type ) 
    406406                displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).setDefaultStyle( view ) 
    407407        isLibxml = True 
     
    462462            if view == "": 
    463463                styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    464                 view =styleMgr.getDefaultStylesheetForEventType( type ) 
     464                view =styleMgr.getDefaultStyleForEventType( type ) 
    465465                displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).setDefaultStyle( view ) 
    466466        # create the html factory 
  • indico/MaKaC/webinterface/tpls/AdminsAddStyle.tpl

    r988cfe r1ced41a  
    77  <td> 
    88    <br> 
    9     <table width="60%" align="center" border="0" style="border-left: 1px solid #777777"> 
     9    <table width="60%" border="0"> 
    1010    <tr> 
    1111      <td colspan="3" class="groupTitle">${ _("New Display Style")}</td> 
    1212    </tr> 
    13     % if len(availableStylesheets) == 0: 
     13    % if len(availableStyles) == 0: 
    1414    <tr> 
    15       <td colspan="3">${ _("All XSL stylesheets are already in use in a declared style. In order to add a new style, start by adding the corresponding .xsl file in") } ${ styleMgr.getBaseXSLPath()}</td> 
     15      <td colspan="3">${ _("All template files are already in use in a declared style. In order to add a new style, start by adding the corresponding .tpl file in") } ${ styleMgr.getBaseTPLPath()}</td> 
    1616    </tr> 
    1717    % else: 
     
    2121    </tr> 
    2222    <tr> 
    23       <td nowrap class="titleCellTD"><span class="titleCellFormat">${ _("XSL Stylesheet")}</span></td> 
     23      <td nowrap class="titleCellTD"><span class="titleCellFormat">${ _("ID")}</span></td> 
     24      <td align="left" width="80%"><input type="text" name="styleID" size="25"> 
     25      ${inlineContextHelp(_("Style ID is used in URLs and for naming the CSS file. It must be unique for every style."))} 
     26      </td> 
     27    </tr> 
     28    <tr> 
     29      <td nowrap class="titleCellTD"><span class="titleCellFormat">${ _("Template file")}</span></td> 
    2430      <td align="left"> 
    25         <select name="xslfile"> 
    26         % for style in availableStylesheets: 
    27           <option value="${ style }">${ style }.xsl</option> 
     31        <select name="tplfile"> 
     32        % for style in availableStyles: 
     33          <option value="${ style }">${ style }</option> 
    2834        % endfor 
    2935        </select> 
  • indico/MaKaC/webinterface/tpls/AdminsStyles.tpl

    r60171b r1ced41a  
    1212          </form> 
    1313          <table cellspacing="1" align="center"> 
    14           <tr style="border-bottom: 1px;"><th>${ _("Name (ID)")}</th><th>${ _("XSL file")}</th><th>${ _("CSS file")}</th><th>${ _("Actions")}</th></tr> 
    15           <% styles = styleMgr.getStylesheets().keys() %> 
     14          <tr style="border-bottom: 1px;"> 
     15            <th>${ _("Name")}</th> 
     16            <th>${ _("ID")}</th> 
     17            <th>${ _("TPL file")}</th> 
     18            <th>${ _("CSS file")}</th> 
     19            <th>${ _("Actions")}</th> 
     20          </tr> 
     21          <% styles = styleMgr.getStyles().keys() %> 
    1622          <% styles.sort() %> 
    1723          % for style in styles: 
    18           <tr style="background-color: ${"#faa" if styleMgr.getXSLPath(style) == "" and style != 'static' else "lightgreen"}"> 
    19             <td align="right">${ styleMgr.getStylesheetName(style) } (${style})</td> 
    20             <td align="center">${ _("found") if styleMgr.getXSLPath(style) else  _("not found")}</td> 
     24          <tr style="background-color: ${"#faa" if not styleMgr.existsTPLFile(style) and style != 'static' else "lightgreen"}"> 
     25            <td align="left">${ styleMgr.getStyleName(style) }</td> 
     26            <td align="left">${style}</td> 
     27            <td align="left"> 
     28            % if style != 'static': 
     29                ${styleMgr.getTPLFilename(style)} 
     30            % else: 
     31                - 
     32            % endif 
     33            </td> 
    2134            <td align="center">${ _("yes") if styleMgr.getCSSPath(style) else  _("no")}</td> 
    2235            <td> 
    2336            % if style == "static": 
    24             ${inlineContextHelp(_('This style cannot be deleted. this is the default style for conferences.<br/>It does not rely on an XSL file.'))} 
     37            ${inlineContextHelp(_('This style cannot be deleted. This is the default style for conferences.'))} 
    2538            % else: 
    26             <a href="${urlHandlers.UHAdminsDeleteStyle.getURL(xslfile=style)}" onClick="if (!confirm('${ _("Are you sure you want to delete this style?")}')) { return false; }"><img border="0" src="${deleteIconURL}" alt="${ _("delete this style")}"></a> 
     39            <a href="${urlHandlers.UHAdminsDeleteStyle.getURL(tplfile=style)}" onClick="if (!confirm('${ _("Are you sure you want to delete this style?")}')) { return false; }"><img border="0" src="${deleteIconURL}" alt="${ _("delete this style")}"></a> 
    2740            % endif 
    2841            </td> 
     
    4457          <form action="${ urlHandlers.UHAdminsStyles.getURL() }" method="POST"> 
    4558          <input type="hidden" name="event_type" value="${eventType}"> 
    46           <% styles = styleMgr.getStylesheetListForEventType(eventType) %> 
     59          <% styles = styleMgr.getStyleListForEventType(eventType) %> 
    4760          <% styles.sort() %> 
    48           ${ _("current list:")} <select name="xslfile"> 
     61          ${ _("current list:")} <select name="tplfile"> 
    4962          % for style in styles: 
    50           <% isDefault = style.strip()==styleMgr.getDefaultStylesheetForEventType(eventType).strip() %> 
    51           <option value="${style}"${'style="font-weight: bold;" selected' if isDefault else ""}>${styleMgr.getStylesheetName(style)}${" (default)" if isDefault else ""}</option> 
     63          <% isDefault = style.strip() == styleMgr.getDefaultStyleForEventType(eventType).strip() %> 
     64          <option value="${style}"${'style="font-weight: bold;" selected' if isDefault else ""}>${styleMgr.getStyleName(style)}${" (default)" if isDefault else ""}</option> 
    5265          % endfor 
    5366          </select> 
     
    5669          ${ _("add new style:")} 
    5770           <select name="newstyle"> 
    58              % for style in styleMgr.getStylesheets(): 
     71             % for style in styleMgr.getStyles(): 
    5972               % if style not in styles: 
    60                <option value="${ style }">${styleMgr.getStylesheetName(style)}</option> 
     73               <option value="${ style }">${styleMgr.getStyleName(style)}</option> 
    6174               % endif 
    6275             % endfor 
  • indico/MaKaC/webinterface/tpls/EventModifMainData.tpl

    rc0de5a r1ced41a  
    247247<%  from MaKaC.common import info %> 
    248248 
    249 ${ macros.genericField(macros.FIELD_SELECT, 'inPlaceEditDefaultStyle', 'event.main.changeDefaultStyle', dict(conference="%s"%conferenceId), preCache=True, rh=self_._rh, options=info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager().getStylesheetDictForEventType(confObj.getType()), orderOptionsBy = "value") } 
     249${ macros.genericField(macros.FIELD_SELECT, 'inPlaceEditDefaultStyle', 'event.main.changeDefaultStyle', dict(conference="%s"%conferenceId), preCache=True, rh=self_._rh, options=info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager().getStyleDictForEventType(confObj.getType()), orderOptionsBy = "value") } 
    250250 
    251251${ macros.genericField(macros.FIELD_SELECT, 'inPlaceEditVisibility', 'event.main.changeVisibility', dict(conference="%s"%conferenceId), preCache=True, rh=self_._rh, options=visibilityList, orderOptionsBy = "key") } 
  • indico/MaKaC/webinterface/wcomponents.py

    r39b7d0 r1ced41a  
    486486            url.addParam("redirectURL",urlHandlers.UHConferenceOtherViews.getURL(self._conf)) 
    487487            vars["confModif"] = i18nformat("""<a href=%s>_("exit manage")</a>""")%quoteattr(str(url)) 
    488         styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    489         stylesheets = styleMgr.getStylesheetListForEventType(vars["type"]) 
    490  
    491         # View Menu 
    492         viewoptions = [] 
    493         if len(stylesheets) != 0: 
    494             stylesheets.sort() 
    495             for stylesheet in stylesheets: 
    496                 viewoptions.append({"id": styleMgr.getStylesheetName(stylesheet), "name": stylesheet}) 
    497488 
    498489        # Dates Menu 
     
    604595        #    vars["confModif"] += i18nformat("""<a href=%s>_("full agenda")</a>&nbsp;|&nbsp;""")%(quoteattr(str(urlHandlers.UHConfForceEnterAccessKey.getURL(self._conf)))) 
    605596        styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() 
    606         stylesheets = styleMgr.getStylesheetListForEventType(vars["type"]) 
     597        styles = styleMgr.getExistingStylesForEventType(vars["type"]) 
    607598 
    608599        viewoptions = [] 
    609         if len(stylesheets) != 0: 
    610             stylesheets.sort(key=styleMgr.getStylesheetName) 
    611             for stylesheet in stylesheets: 
    612                 viewoptions.append({"id": stylesheet, "name": styleMgr.getStylesheetName(stylesheet) }) 
     600        if len(styles) != 0: 
     601            styles.sort(key=styleMgr.getStyleName) 
     602            for styleId in styles: 
     603                viewoptions.append({"id": styleId, "name": styleMgr.getStyleName(styleId) }) 
    613604        vars["viewoptions"] = viewoptions 
    614         vars["SelectedStyle"] = styleMgr.getStylesheetName(vars["currentView"]) 
     605        vars["SelectedStyle"] = styleMgr.getStyleName(vars["currentView"]) 
    615606        vars["displayURL"] = urlHandlers.UHConferenceDisplay.getURL(self._rh._conf) 
    616607 
Note: See TracChangeset for help on using the changeset viewer.