예제 #1
0
 def __init__(self, rh, calendar, categ=None):
     WPMainBase.__init__(self, rh)
     self._cal = calendar
     self._categ = categ
     self._locTZ = timezoneUtils.DisplayTZ(self._getAW(),
                                           None,
                                           useServerTZ=1).getDisplayTZ()
예제 #2
0
    def _display(self, params):
        sideMenu = self._getSideMenu()
        self._setCurrentMenuItem()

        # Check if user is administrator
        adminList = accessControl.AdminList.getInstance()
        self._isAdmin = (not adminList.getList() and
                         self._getAW().getUser() != None) or adminList.isAdmin(
                             self._getAW().getUser())
        self._isCategoryManager = self._isAdmin or \
                                  isinstance(self._rh.getTarget(), Category) and self._rh.getTarget().canModify(self._getAW()) or \
                                  isinstance(self._rh.getTarget(), Conference) and self._rh.getTarget().getOwnerList()!=[] and self._rh.getTarget().getOwner().canModify(self._getAW())
        self._showAdmin = self._isAdmin or self._isCategoryManager

        self._timezone = timezone(
            timezoneUtils.DisplayTZ(self._getAW()).getDisplayTZ())

        body = WMainBase(self._getBody(params),
                         self._timezone,
                         self._getNavigationDrawer(),
                         isFrontPage=self._isFrontPage(),
                         isRoomBooking=self._isRoomBooking(),
                         sideMenu=sideMenu).getHTML(
                             {"subArea": self._getSiteArea()})

        return self._applyDecoration(body)
예제 #3
0
    def _process(self):
        boaConfig = self._conf.getBOAConfig()
        pdfFilename = "%s - Book of abstracts.pdf" % cleanHTMLHeaderFilename(
            self._target.getTitle())
        cacheFile = self._getCacheFileName()
        if os.path.isfile(cacheFile):
            mtime = pytz.utc.localize(
                datetime.utcfromtimestamp(os.path.getmtime(cacheFile)))
        else:
            mtime = None

        if boaConfig.isCacheEnabled(
        ) and not self._noCache and mtime and mtime > boaConfig.lastChanged:
            return send_file(pdfFilename, cacheFile, 'PDF')
        else:
            tz = timezoneUtils.DisplayTZ(self._aw, self._target).getDisplayTZ()
            pdf = AbstractBook(self._target, self.getAW(), tz=tz)
            fname = pdf.generate()

            with open(fname, 'rb') as f:
                data = f.read()
            with open(cacheFile, 'wb') as f:
                f.write(data)

            return send_file(pdfFilename, cacheFile, 'PDF')
예제 #4
0
 def _process(self):
     set_best_lang()  # prevents from having a _LazyString when generating a pdf without session.lang set
     tz = timezoneUtils.DisplayTZ(self._aw, self._target).getDisplayTZ()
     filename = "%s - Programme.pdf" % self._target.getTitle()
     from MaKaC.PDFinterface.conference import ProgrammeToPDF
     pdf = ProgrammeToPDF(self._target, tz=tz)
     return send_file(filename, StringIO(pdf.getPDFBin()), 'PDF')
예제 #5
0
    def getVars(self):
        vars = wcomponents.WTemplated.getVars( self )
        vars["logo"] = ""
        if self._conf.getLogo():
            vars["logo"] = "<img src=\"%s\" alt=\"%s\" border=\"0\">"%(vars["logoURL"], self._conf.getTitle())
        vars["confTitle"] = self._conf.getTitle()
        vars["displayURL"] = urlHandlers.UHConferenceDisplay.getURL(self._conf)
        vars["imgConferenceRoom"] = Config.getInstance().getSystemIconURL( "conferenceRoom" )
        tzUtil = timezoneUtils.DisplayTZ(self._aw,self._conf)
        tz = tzUtil.getDisplayTZ()
        adjusted_sDate = self._conf.getStartDate().astimezone(timezone(tz))
        adjusted_eDate = self._conf.getEndDate().astimezone(timezone(tz))

        vars["confDateInterval"] = i18nformat("""_("from") %s _("to") %s (%s)""")%(format_date(adjusted_sDate, format='long'), format_date(adjusted_eDate, format='long'), tz)

        if self._conf.getStartDate().strftime("%d%B%Y") == \
                self._conf.getEndDate().strftime("%d%B%Y"):
            vars["confDateInterval"] = format_date(adjusted_sDate, format='long') + " (" + tz + ")"
        elif self._conf.getStartDate().month == self._conf.getEndDate().month:
            vars["confDateInterval"] = "%s-%s %s %s"%(adjusted_sDate.day, adjusted_eDate.day, format_date(adjusted_sDate, format='MMMM yyyy'), tz)
        vars["body"] = self._body
        vars["confLocation"] = ""
        if self._conf.getLocationList():
            vars["confLocation"] =  self._conf.getLocationList()[0].getName()
            vars["supportEmail"] = ""
        if self._conf.getSupportInfo().hasEmail():
            mailto = quoteattr("""mailto:%s?subject=%s"""%(self._conf.getSupportInfo().getEmail(), urllib.quote( self._conf.getTitle() ) ))
            vars["supportEmail"] =  i18nformat("""<a href=%s class="confSupportEmail"><img src="%s" border="0" alt="email">  _("support")</a>""")%(mailto, Config.getInstance().getSystemIconURL("mail") )
        format = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getFormat()
        vars["bgColorCode"] = format.getFormatOption("titleBgColor")["code"]
        vars["textColorCode"] = format.getFormatOption("titleTextColor")["code"]
        return vars
예제 #6
0
    def _process( self ):
        tz = timezoneUtils.DisplayTZ(self._aw,self._conf).getDisplayTZ()
        filename = "Contributions.pdf"
        if not self._contribs:
            return "No contributions to print"
        from MaKaC.PDFinterface.conference import ContribsToPDF
        pdf = ContribsToPDF(self._conf, self._contribs)

        return send_file(filename, pdf.generate(), 'PDF')
예제 #7
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     tzUtil = timezoneUtils.DisplayTZ(self._aw, self._conf)
     tz = tzUtil.getDisplayTZ()
     sdate = self._conf.getStartDate().astimezone(timezone(tz))
     edate = self._conf.getEndDate().astimezone(timezone(tz))
     fsdate, fedate = format_date(sdate,
                                  format='full'), format_date(edate,
                                                              format='full')
     fstime, fetime = sdate.strftime("%H:%M"), edate.strftime("%H:%M")
     if sdate.strftime("%Y%B%d") == edate.strftime("%Y%B%d"):
         timeInterval = fstime
         if sdate.strftime("%H%M") != edate.strftime("%H%M"):
             timeInterval = "%s - %s" % (fstime, fetime)
         vars["dateInterval"] = "<b>%s (%s) (%s)</b>" % (fsdate,
                                                         timeInterval, tz)
     else:
         vars["dateInterval"] = "from <b>%s (%s)</b> to <b>%s (%s) (%s)</b>"%(\
                             fsdate, fstime, fedate, fetime, tz)
     vars["title"] = self._conf.getTitle()
     vars["description"] = self.__getHTMLRow(_("Description"),
                                             self._conf.getDescription(), 0)
     vars["location"] = ""
     location = self._conf.getLocation()
     if location:
         vars["location"] = self.__getHTMLRow(
             _("Location"), "%s<br><small>%s</small>" %
             (location.getName(), location.getAddress()))
     vars["room"] = ""
     room = self._conf.getRoom()
     if room:
         roomLink = linking.RoomLinker().getHTMLLink(room, location)
         vars["room"] = self.__getHTMLRow(_("Room"), roomLink)
     vars["moreInfo"] = self.__getHTMLRow(_("Additional Info"),
                                          self._conf.getContactInfo(), 0)
     ml = []
     for mat in self._conf.getAllMaterialList():
         ml.append( wcomponents.WMaterialDisplayItem().getHTML(\
                                             self._aw, mat, \
                                             vars["materialURLGen"](mat) ) )
     vars["material"] = self.__getHTMLRow(_("Material"), "<br>".join(ml), 0)
     al = []
     if self._conf.getChairmanText() != "":
         al.append(self._conf.getChairmanText())
     for organiser in self._conf.getChairList():
         al.append( """<a href="mailto:%s">%s</a>"""%(organiser.getEmail(),\
                                                  organiser.getFullName() ) )
     vars["contact"] = self.__getHTMLRow("Contact", "<br>".join(al), 0)
     vars["modifyItem"] = ""
     if self._conf.canModify(self._aw):
         vars[
             "modifyItem"] = """<a href="%s"><img src="%s" border="0" alt="Jump to the modification interface"></a> """ % (
                 vars["modifyURL"], Configuration.Config.getInstance(
                 ).getSystemIconURL("popupMenu"))
     return vars
예제 #8
0
파일: main.py 프로젝트: wtakase/indico
    def _display(self, params):
        target = self._rh.getTarget()

        self._timezone = timezone(timezoneUtils.DisplayTZ(self._getAW()).getDisplayTZ())
        params = dict(params, **self._kwargs)
        body = WMainBase(self._getBody(params), self._timezone, self._getNavigationDrawer(),
                         isFrontPage=self._isFrontPage(),
                         isRoomBooking=self._isRoomBooking(),
                         sideMenu=self._getSideMenu()).getHTML({"subArea": self._getSiteArea()})

        return self._applyDecoration(body)
예제 #9
0
 def _process( self ):
     tz = timezoneUtils.DisplayTZ(self._aw,self._conf).getDisplayTZ()
     filename = "%s - Abstract.pdf"%self._target.getTitle()
     pdf = AbstractToPDF(self._conf, self._target,tz=tz)
     data = pdf.getPDFBin()
     #self._req.headers_out["Accept-Ranges"] = "bytes"
     self._req.headers_out["Content-Length"] = "%s"%len(data)
     cfg = Config.getInstance()
     mimetype = cfg.getFileTypeMimeType( "PDF" )
     self._req.content_type = """%s"""%(mimetype)
     self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%cleanHTMLHeaderFilename(filename)
     return data
예제 #10
0
 def __init__(self, rh, conf, event_type=""):
     self._rh = rh
     self._conf = conf
     self._display_tz = timezoneUtils.DisplayTZ(self._rh._aw, self._conf).getDisplayTZ()
     self.event = conf.as_event
     self._html = ""
     self._fileHandler = None
     self._mainPath = ""
     self._staticPath = ""
     self._eventType = event_type
     self._failed_paths = set()
     self._css_files = set()
     self._downloaded_files = {}
예제 #11
0
 def _process(self):
     tz = timezoneUtils.DisplayTZ(
         self._aw, self._target.getConference()).getDisplayTZ()
     filename = "%s - Contribution.pdf" % self._target.getTitle()
     pdf = ContribToPDF(self._target.getConference(), self._target, tz=tz)
     data = pdf.getPDFBin()
     self._req.headers_out["Content-Length"] = "%s" % len(data)
     cfg = Config.getInstance()
     mimetype = cfg.getFileTypeMimeType("PDF")
     self._req.content_type = """%s""" % (mimetype)
     self._req.headers_out[
         "Content-Disposition"] = """inline; filename="%s\"""" % filename
     return data
예제 #12
0
    def _process(self):
        set_best_lang(
        )  # prevents from having a _LazyString when generating a pdf without session.lang set
        tz = timezoneUtils.DisplayTZ(self._aw, self._target).getDisplayTZ()
        params = self._getRequestParams()
        ttPDFFormat = TimetablePDFFormat(params)

        # Choose action depending on the button pressed
        if params.has_key("cancel"):
            # If the export is cancelled, redirect to the display
            # page
            url = urlHandlers.UHConferenceDisplay.getURL(self._conf)
            url.addParam("view", self._view)
            self._redirect(url)
        else:
            retry = True
            while retry:
                if params.get("typeTT", "normalTT") == "normalTT":
                    filename = "timetable.pdf"
                    pdf = TimeTablePlain(
                        self._target,
                        self.getAW(),
                        showSessions=self._showSessions,
                        showDays=self._showDays,
                        sortingCrit=self._sortingCrit,
                        ttPDFFormat=ttPDFFormat,
                        pagesize=self._pagesize,
                        fontsize=self._fontsize,
                        firstPageNumber=self._firstPageNumber,
                        showSpeakerAffiliation=self._showSpeakerAffiliation)
                else:
                    filename = "SimplifiedTimetable.pdf"
                    pdf = SimplifiedTimeTablePlain(
                        self._target,
                        self.getAW(),
                        showSessions=self._showSessions,
                        showDays=self._showDays,
                        sortingCrit=self._sortingCrit,
                        ttPDFFormat=ttPDFFormat,
                        pagesize=self._pagesize,
                        fontsize=self._fontsize)
                try:
                    data = pdf.getPDFBin()
                    retry = False
                except LayoutError, e:
                    if not self._reduceFontSize():
                        raise MaKaCError(
                            "Error in PDF generation - One of the paragraphs does not fit on a page"
                        )
                except Exception:
                    raise
예제 #13
0
 def _process(self):
     tz = timezoneUtils.DisplayTZ(self._aw, self._conf).getDisplayTZ()
     filename = "Abstracts.pdf"
     if not self._abstracts:
         return _("No abstract to print")
     pdf = AbstractsToPDF(self._conf, self._abstracts, tz=tz)
     data = pdf.getPDFBin()
     self._req.set_content_length(len(data))
     cfg = Config.getInstance()
     mimetype = cfg.getFileTypeMimeType("PDF")
     self._req.content_type = """%s""" % (mimetype)
     self._req.headers_out[
         "Content-Disposition"] = """inline; filename="%s\"""" % filename
     return data
예제 #14
0
    def _processIfActive(self):
        tz = timezoneUtils.DisplayTZ(self._aw, self._conf).getDisplayTZ()
        cfaMgr = self._conf.getAbstractMgr()
        abstracts = set(cfaMgr.getAbstractListForAvatar(self._aw.getUser()))
        abstracts |= set(
            cfaMgr.getAbstractListForAuthorEmail(
                self._aw.getUser().getEmail()))
        self._abstractIds = sorted(abstract.getId() for abstract in abstracts)
        if not self._abstractIds:
            return _("No abstract to print")

        filename = 'my-abstracts.pdf'
        pdf = AbstractsToPDF(self._conf, self._abstractIds, tz=tz)
        return send_file(filename, pdf.generate(), 'PDF')
예제 #15
0
    def _addPdf(self, event, pdfUrlHandler, generatorClass,
                legacy=False, **generatorParams):
        """
        `legacy` specifies whether reportlab should be used instead of the
        new LaTeX generation mechanism
        """
        tz = timezoneUtils.DisplayTZ(self._rh._aw, self._conf).getDisplayTZ()
        filename = os.path.join(self._mainPath, pdfUrlHandler.getStaticURL(event))
        pdf = generatorClass(tz=tz, **generatorParams)

        if legacy:
            self._fileHandler.addNewFile(filename, pdf.getPDFBin())
        else:
            with open(pdf.generate()) as f:
                self._fileHandler.addNewFile(filename, f.read())
예제 #16
0
    def _processIfActive( self ):
        tz = timezoneUtils.DisplayTZ(self._aw,self._conf).getDisplayTZ()
        cfaMgr = self._conf.getAbstractMgr()
        abstracts = cfaMgr.getAbstractListForAvatar( self._aw.getUser() )
        abstracts += cfaMgr.getAbstractListForAuthorEmail(self._aw.getUser().getEmail())
        self._abstractIds = [abstract.getId() for abstract in abstracts]
        if not self._abstractIds:
            return _("No abstract to print")

        filename = "Abstracts.pdf"
        pdf = AbstractsToPDF(self._conf, self._abstractIds,tz=tz)
        data = pdf.getPDFBin()
        self._req.set_content_length(len(data))
        cfg = Config.getInstance()
        mimetype = cfg.getFileTypeMimeType( "PDF" )
        self._req.content_type = """%s"""%(mimetype)
        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename
        return data
예제 #17
0
파일: admins.py 프로젝트: belokop/indico
    def _getTabContent(self, params):
        tz = timezone(timezoneUtils.DisplayTZ(self._getAW()).getDisplayTZ())
        wc = WUpdateNews()
        newsModule = ModuleHolder().getById("news")

        newslist = fossilize(newsModule.getNewsItemsList(),
                             INewsItemFossil,
                             tz=tz)
        newsTypesList = newsModule.getNewsTypesAsDict()
        recentDays = newsModule.getRecentDays()

        pars = {
            "newslist": newslist,
            "newsTypesList": newsTypesList,
            "recentDays": recentDays
        }

        return wc.getHTML(pars)
예제 #18
0
    def _display(self, params):
        target = self._rh.getTarget()

        # Check if user is administrator
        self._isAdmin = session.user and session.user.is_admin
        self._isCategoryManager = (
            self._isAdmin or
            (isinstance(target, Category) and target.canModify(self._getAW()))
            or (isinstance(target, Conference) and target.getOwner()
                and target.getOwner().canModify(self._getAW())))
        self._showAdmin = self._isAdmin or self._isCategoryManager

        self._timezone = timezone(
            timezoneUtils.DisplayTZ(self._getAW()).getDisplayTZ())
        params = dict(params, **self._kwargs)
        body = WMainBase(self._getBody(params),
                         self._timezone,
                         self._getNavigationDrawer(),
                         isFrontPage=self._isFrontPage(),
                         isRoomBooking=self._isRoomBooking(),
                         sideMenu=self._getSideMenu()).getHTML(
                             {"subArea": self._getSiteArea()})

        return self._applyDecoration(body)
예제 #19
0
 def _process(self):
     tz = timezoneUtils.DisplayTZ(self._aw, self._conf).getDisplayTZ()
     filename = '%s - Abstract.pdf' % self._target.getTitle()
     pdf = AbstractToPDF(self._target, tz=tz)
     return send_file(filename, pdf.generate(), 'PDF')
예제 #20
0
 def _process(self):
     tz = timezoneUtils.DisplayTZ(self._aw, self._target).getDisplayTZ()
     filename = "%s - Programme.pdf" % self._target.getTitle()
     from MaKaC.PDFinterface.conference import ProgrammeToPDF
     pdf = ProgrammeToPDF(self._target, tz=tz)
     return send_file(filename, StringIO(pdf.getPDFBin()), 'PDF')
예제 #21
0
 def __init__(self, aw, session):
     self._aw = aw
     self._session = session
     self._tz = timezoneUtils.DisplayTZ(
         self._aw, self._session.getConference()).getDisplayTZ()
예제 #22
0
 def _getBody(self, params):
     wc = WNews(
         tz=timezone(timezoneUtils.DisplayTZ(self._getAW()).getDisplayTZ()))
     return wc.getHTML()