Example #1
0
 def _process(self):
     if not self.category.has_logo:
         raise NotFound
     metadata = self.category.logo_metadata
     return send_file(
         metadata["filename"], BytesIO(self.category.logo), mimetype=metadata["content_type"], conditional=True
     )
Example #2
0
 def _process( self ):
     signals.event.material_downloaded.send(self._conf, resource=self._file)
     if isinstance(self._file, Link):
         self._redirect(self._file.getURL())
     else:
         return send_file(self._file.getFileName(), self._file.getFilePath(), self._file.getFileType(),
                          self._file.getCreationDate())
Example #3
0
    def _process(self):
        # QRCode (Version 6 with error correction L can contain up to 106 bytes)
        qr = qrcode.QRCode(
            version=6,
            error_correction=qrcode.constants.ERROR_CORRECT_M,
            box_size=4,
            border=1
        )

        checkin_app = OAuthApplication.find_one(system_app_type=SystemAppType.checkin)
        qr_data = {
            "event_id": self.event.id,
            "title": self.event.title,
            "date": self.event.start_dt.isoformat(),
            "version": 1,
            "server": {
                "base_url": config.BASE_URL,
                "consumer_key": checkin_app.client_id,
                "auth_url": url_for('oauth.oauth_authorize', _external=True),
                "token_url": url_for('oauth.oauth_token', _external=True)
            }
        }
        json_qr_data = json.dumps(qr_data)
        qr.add_data(json_qr_data)
        qr.make(fit=True)
        qr_img = qr.make_image()

        output = BytesIO()
        qr_img.save(output)
        output.seek(0)

        return send_file('config.png', output, 'image/png')
Example #4
0
    def _generate_zip_file(self, files_holder, name_prefix='material', name_suffix=None):
        """Generate a zip file containing the files passed.

        :param files_holder: An iterable (or an iterable containing) object that
                             contains the files to be added in the zip file.
        :param name_prefix: The prifix to the zip file name
        :param name_suffix: The suffix to the zip file name
        :return: The generated zip file.
        """

        from indico.util.tasks import delete_file

        temp_file = NamedTemporaryFile(suffix='indico.tmp', dir=Config.getInstance().getTempDir())
        with ZipFile(temp_file.name, 'w', allowZip64=True) as zip_handler:
            self.used_filenames = set()
            for item in self._iter_items(files_holder):
                name = self._prepare_folder_structure(item)
                self.used_filenames.add(name)
                with item.storage.get_local_path(item.storage_file_id) as filepath:
                    zip_handler.write(filepath.encode('utf-8'), name)

        # Delete the temporary file after some time.  Even for a large file we don't
        # need a higher delay since the webserver will keep it open anyway until it's
        # done sending it to the client.
        delete_file.apply_async(args=[temp_file.name], countdown=3600)
        temp_file.delete = False
        zip_file_name = '{}-{}.zip'.format(name_prefix, name_suffix) if name_suffix else '{}.zip'.format(name_prefix)
        return send_file(zip_file_name, temp_file.name, 'application/zip', inline=False)
Example #5
0
def i18n_locale(locale_name):
    """
    Retrieve a locale in a Jed-compatible format
    """
    root_path = os.path.join(current_app.root_path, 'translations')
    cache_file = os.path.join(config.CACHE_DIR, 'assets_i18n_{}_{}_{}.js'.format(
        locale_name, indico.__version__, config.hash))

    if not os.path.exists(cache_file):
        i18n_data = locale_data(root_path, locale_name, 'indico')
        if not i18n_data:
            # Dummy data, not having the indico domain would cause lots of failures
            i18n_data = {'indico': {'': {'domain': 'indico',
                                         'lang': locale_name}}}

        for pid, plugin in plugin_engine.get_active_plugins().iteritems():
            data = {}
            if plugin.translation_path:
                data = locale_data(plugin.translation_path, locale_name, pid)
            if not data:
                # Dummy entry so we can still load the domain
                data = {pid: {'': {'domain': pid,
                                   'lang': locale_name}}}
            i18n_data.update(data)

        with open(cache_file, 'wb') as f:
            f.write("window.TRANSLATIONS = {};".format(json.dumps(i18n_data)))

    return send_file('{}.js'.format(locale_name), cache_file, mimetype='application/javascript',
                     no_cache=False, conditional=True)
 def _process(self):
     filename = "%s-Categ.atom" % self._target.getName().replace("/", "")
     hook = CategoryEventHook({'from': 'today'}, 'categ', {'idlist': self._target.getId(), 'dformat': 'atom'})
     res = hook(self.getAW())
     resultFossil = {'results': res[0], 'url': str(self._uh.getURL(self._target))}
     serializer = Serializer.create('atom')
     return send_file(filename, StringIO(serializer(resultFossil)), 'ATOM')
 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')
Example #8
0
 def pdf(self):
     pdf = RegistrantsListToPDF(self._conf, list=self._list, display=self._display)
     try:
         data = pdf.getPDFBin()
     except:
         raise FormValuesError( _("""Text too large to generate a PDF with "Table Style". Please try again generating with "Book Style"."""))
     return send_file('RegistrantsList.pdf', StringIO(data), 'PDF')
Example #9
0
 def _process(self):
     filename = '{}-category.atom'.format(secure_filename(self.category.title, str(self.category.id)))
     buf = serialize_category_atom(self.category,
                                   url_for(request.endpoint, self.category, _external=True),
                                   session.user,
                                   Event.end_dt >= now_utc())
     return send_file(filename, buf, 'application/atom+xml')
Example #10
0
def i18n_locale(locale_name):
    """
    Retrieve a locale in a Jed-compatible format
    """
    config = Config.getInstance()
    root_path = os.path.join(current_app.root_path, 'translations')
    plugin_key = ','.join(sorted(plugin_engine.get_active_plugins()))
    cache_file = os.path.join(config.getXMLCacheDir(), 'assets_i18n_{}_{}.js'.format(locale_name, crc32(plugin_key)))

    if not os.path.exists(cache_file):
        i18n_data = locale_data(root_path, locale_name, 'indico')
        if not i18n_data:
            # Dummy data, not having the indico domain would cause lots of failures
            i18n_data = {'indico': {'': {'domain': 'indico',
                                         'lang': locale_name}}}

        for pid, plugin in plugin_engine.get_active_plugins().iteritems():
            data = {}
            if plugin.translation_path:
                data = locale_data(plugin.translation_path, locale_name, pid)
            if not data:
                # Dummy entry so we can still load the domain
                data = {pid: {'': {'domain': pid,
                                   'lang': locale_name}}}
            i18n_data.update(data)

        if not i18n_data:
            raise NotFound("Translation for language '{}' not found".format(locale_name))

        with open(cache_file, 'wb') as f:
            f.write("window.TRANSLATIONS = {};".format(json.dumps(i18n_data)))

    return send_file('{}.js'.format(locale_name), cache_file, mimetype='application/x-javascript',
                     no_cache=False, conditional=True)
Example #11
0
File: misc.py Project: jas01/indico
 def _process(self):
     sprite_mapping = _cache.get('rooms-sprite-mapping')
     if sprite_mapping is None:
         build_rooms_spritesheet()
     if 'version' not in request.view_args:
         return redirect(url_for('.sprite', version=_cache.get('rooms-sprite-token')))
     photo_data = _cache.get('rooms-sprite')
     return send_file('rooms-sprite.jpg', BytesIO(photo_data), 'image/jpeg', no_cache=False, cache_timeout=365*86400)
Example #12
0
 def _process(self):
     from indico.modules.events import Event
     filename = '{}-category.atom'.format(secure_filename(self._target.getName(), str(self._target.id)))
     buf = serialize_category_atom(self._target,
                                   url_for(request.endpoint, self._target, _external=True),
                                   session.user,
                                   Event.end_dt >= now_utc())
     return send_file(filename, buf, 'application/atom+xml')
Example #13
0
 def _process(self):
     manager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId())
     sw = manager.getSpeakerWrapperByUniqueId(self.spkUniqueId)
     if not sw:
         raise MaKaCError("The speaker wrapper id does not match any existing speaker.")
     self.file = sw.getLocalFile()
     return send_file(self.file.getFileName(), self.file.getFilePath(), self.file.getFileType(),
                      self.file.getCreationDate())
Example #14
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 ConfManagerContribsToPDF
     pdf = ConfManagerContribsToPDF(self._conf, self._contribs, tz=tz)
     return send_file(filename, StringIO(pdf.getPDFBin()), 'PDF')
Example #15
0
    def _process(self):
        if not self.survey.submissions:
            flash(_('There are no submissions in this survey'))
            return redirect(url_for('.manage_survey', self.survey))

        submission_ids = set(map(int, request.form.getlist('submission_ids')))
        csv_file = generate_csv_from_survey(self.survey, submission_ids)
        return send_file('submissions-{}.csv'.format(self.survey.id), csv_file, 'text/csv')
Example #16
0
    def _process(self):
        self.commit = False
        config_params = poster_cache.get(request.view_args['uuid'])
        if not config_params:
            raise NotFound

        pdf = PosterPDF(self.template, config_params, self.event)
        return send_file('Poster-{}.pdf'.format(self.event.id), pdf.get_pdf(), 'application/pdf')
Example #17
0
 def _process(self):
     im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getImagesManager()
     if im.getPic(self._picId):
         pic = im.getPic(self._picId).getLocalFile()
         return send_file(pic.getFileName(), pic.getFilePath(), pic.getFileType())
     else:
         self._responseUtil.status = 404
         return WPError404(self, urlHandlers.UHConferenceDisplay.getURL(self._conf)).display()
Example #18
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)
            data = pdf.getPDFBin()
            with open(cacheFile, 'wb') as f:
                f.write(data)
            return send_file(pdfFilename, cacheFile, 'PDF')
    def _process(self):
        filename = "%s-Categ.ics" % self._target.getName().replace("/", "")

        hook = CategoryEventHook({}, 'categ', {'idlist': self._target.getId(), 'dformat': 'ics'})
        res = hook(self.getAW())
        resultFossil = {'results': res[0]}

        serializer = Serializer.create('ics')
        return send_file(filename, StringIO(serializer(resultFossil)), 'ICAL')
Example #20
0
    def _process( self ):
        filename = "%s-Session.ics"%self._session.getTitle()

        hook = SessionHook({}, 'session', {'event': self._conf.getId(), 'idlist':self._session.getId(), 'dformat': 'ics'})
        res = hook(self.getAW())
        resultFossil = {'results': res[0]}

        serializer = Serializer.create('ics')
        return send_file(filename, StringIO(serializer(resultFossil)), 'ICAL')
Example #21
0
 def _process(self):
     f = self._offlineEvent.file
     return send_file(
         "event-%s.zip" % self._conf.getId(),
         f.getFilePath(),
         f.getFileType(),
         last_modified=self._offlineEvent.creationTime,
         inline=False,
     )
Example #22
0
    def _process(self):
        filename = "%s - contribution.xml"%self._target.getTitle()
        x = XMLGen()
        x.openTag("contribution")
        x.writeTag("Id", self._target.getId())
        x.writeTag("Title", self._target.getTitle())
        x.writeTag("Description", self._target.getDescription())
        afm = self._target.getConference().getAbstractMgr().getAbstractFieldsMgr()
        for f in afm.getFields():
            id = f.getId()
            if f.isActive() and str(self._target.getField(id)).strip() != "":
                x.writeTag(f.getCaption().replace(" ", "_"), self._target.getField(id))
        x.writeTag("Conference", self._target.getConference().getTitle())
        session = self._target.getSession()
        if session!=None:
            x.writeTag("Session", self._target.getSession().getTitle())
        l = []
        for au in self._target.getAuthorList():
            if self._target.isPrimaryAuthor(au):
                x.openTag("PrimaryAuthor")
                x.writeTag("FirstName", au.getFirstName())
                x.writeTag("FamilyName", au.getFamilyName())
                x.writeTag("Email", au.getEmail())
                x.writeTag("Affiliation", au.getAffiliation())
                x.closeTag("PrimaryAuthor")
            else:
                l.append(au)

        for au in l:
            x.openTag("Co-Author")
            x.writeTag("FirstName", au.getFirstName())
            x.writeTag("FamilyName", au.getFamilyName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Co-Author")

        for au in self._target.getSpeakerList():
            x.openTag("Speaker")
            x.writeTag("FirstName", au.getFirstName ())
            x.writeTag("FamilyName", au.getFamilyName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Speaker")

        #To change for the new contribution type system to:
        typeName = ""
        if self._target.getType():
            typeName = self._target.getType().getName()
        x.writeTag("ContributionType", typeName)

        t = self._target.getTrack()
        if t!=None:
            x.writeTag("Track", t.getTitle())

        x.closeTag("contribution")

        return send_file(filename, StringIO(x.getXml()), 'XML')
    def _process(self):
        filename = "%s-Event.ics" % self._target.getTitle()

        hook = CategoryEventHook({'detail': self._detailLevel}, 'event',
                                 {'idlist': self._conf.getId(), 'dformat': 'ics'})
        res = hook(self.getAW())
        resultFossil = {'results': res[0]}

        serializer = Serializer.create('ics')
        return send_file(filename, StringIO(serializer(resultFossil)), 'ICAL')
Example #24
0
 def _process( self ):
     signals.event.material_downloaded.send(self._conf, resource=self._file)
     if isinstance(self._file, Link):
         self._redirect(self._file.getURL())
     elif self._file.getId() == "minutes":
         p = files.WPMinutesDisplay(self, self._file )
         return p.display()
     else:
         return send_file(self._file.getFileName(), self._file.getFilePath(), self._file.getFileType(),
                          self._file.getCreationDate())
Example #25
0
 def _process( self ):
     self._notify('materialDownloaded', self._file)
     if isinstance(self._file, Link):
         self._redirect(self._file.getURL())
     elif self._file.getId() == "minutes":
         p = files.WPMinutesDisplay(self, self._file )
         return p.display()
     else:
         return send_file(self._file.getFileName(), self._file.getFilePath(), self._file.getFileType(),
                          self._file.getCreationDate())
Example #26
0
def send_csv(filename, headers, rows):
    """Sends a CSV file to the client

    :param filename: The name of the CSV file
    :param headers: a list of cell captions
    :param rows: a list of dicts mapping captions to values
    :return: a flask response containing the CSV data
    """
    buf = generate_csv(headers, rows)
    return send_file(filename, buf, 'text/csv', inline=False)
Example #27
0
def send_xlsx(filename, headers, rows):
    """Sends an XLSX file to the client

    :param filename: The name of the CSV file
    :param headers: a list of cell captions
    :param rows: a list of dicts mapping captions to values
    :return: a flask response containing the XLSX data
    """
    buf = generate_xlsx(headers, rows)
    return send_file(filename, buf, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', inline=False)
 def _process(self):
     filename = "%s - Event.xml" % self._target.getTitle()
     from MaKaC.common.xmlGen import XMLGen
     from MaKaC.common.output import outputGenerator
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("event")
     outgen.confToXML(self._target.getConference(),0,0,1)
     xmlgen.closeTag("event")
     return send_file(filename, StringIO(xmlgen.getXml()), 'XML')
 def _process( self ):
     filename = "%s - Event.xml"%cleanHTMLHeaderFilename(self._target.getTitle())
     from MaKaC.common.xmlGen import XMLGen
     from MaKaC.common.output import outputGenerator
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("marc:record", [["xmlns:marc","http://www.loc.gov/MARC21/slim"],["xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"],["xsi:schemaLocation", "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"]])
     outgen.confToXMLMarc21(self._target.getConference())
     xmlgen.closeTag("marc:record")
     return send_file(filename, StringIO(xmlgen.getXml()), 'XML')
Example #30
0
 def _process(self):
     pdf = RegistrantsListToPDF(self.event, reglist=self.registrations, display=self.regform_items,
                                special_items=self.special_item_ids)
     try:
         data = pdf.getPDFBin()
     except Exception:
         if Config.getInstance().getDebug():
             raise
         raise FormValuesError(_("Text too large to generate a PDF with table style. "
                                 "Please try again generating with book style."))
     return send_file('RegistrantsList.pdf', BytesIO(data), 'PDF')
Example #31
0
 def _process(self):
     if not config.LATEX_ENABLED:
         raise NotFound
     pdf = AbstractsToPDF(self.event,
                          get_user_abstracts(self.event, session.user))
     return send_file('my-abstracts.pdf', pdf.generate(), 'application/pdf')
Example #32
0
 def _process(self):
     pdf = get_timetable_offline_pdf_generator(self.event_new)
     return send_file('timetable.pdf', BytesIO(pdf.getPDFBin()),
                      'application/pdf')
Example #33
0
 def _process(self):
     if not self.category.has_logo:
         raise NotFound
     metadata = self.category.logo_metadata
     return send_file(metadata['filename'], BytesIO(self.category.logo), mimetype=metadata['content_type'],
                      conditional=True)
Example #34
0
 def _process(self):
     template = self._target.getConfPaperReview().getTemplates()[
         self._templateId].getFile()
     return send_file(template.getFileName(), template.getFilePath(),
                      template.getFileType())
Example #35
0
 def _process(self):
     pdf = ProgrammeToPDF(self.event)
     return send_file('program.pdf', BytesIO(pdf.getPDFBin()),
                      'application/pdf')
Example #36
0
 def _process(self):
     sm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager()
     css = sm.getLocalCSS()
     if css:
         return send_file(css.getFileName(), css.getFilePath(), mimetype='text/css', no_cache=False, conditional=True)
     return ""
Example #37
0
 def _process(self):
     icon = self._target.getIcon()
     return send_file(icon.getFileName(), icon.getFilePath(), icon.getFileType())
Example #38
0
 def _process(self):
     return send_file('session.ics', get_session_ical_file(self.session),
                      'text/calendar')
Example #39
0
 def _process(self):
     if not self.room.has_photo:
         raise NotFound
     return send_file('room.jpg', BytesIO(self.room.photo.data),
                      'image/jpeg')
Example #40
0
 def _process(self):
     tex = ContribsToPDF(self.event, self.contribs)
     archive = tex.generate_source_archive()
     return send_file('contributions-tex.zip', archive, 'application/zip', inline=False)
Example #41
0
 def _process(self):
     if not config.LATEX_ENABLED:
         raise NotFound
     pdf = ContribsToPDF(self.event, self.contribs)
     return send_file('contributions.pdf', pdf.generate(), 'application/pdf')
Example #42
0
 def _process(self):
     if self.static_site.state != StaticSiteState.success:
         raise NotFound()
     return send_file(
         'static_site_{0.event_id}.zip'.format(self.static_site),
         self.static_site.path, 'application/zip')
Example #43
0
 def _process(self):
     io = BytesIO(self.agreement.attachment)
     file_ext = os.path.splitext(self.agreement.attachment_filename)[1]
     return send_file(self.agreement.attachment_filename, io, file_ext)
Example #44
0
 def _process(self):
     contribs = self.list_generator.get_list_kwargs()['contribs']
     pdf = ContribsToPDF(self.event, contribs)
     return send_file('contributions.pdf', pdf.generate(),
                      'application/pdf')
Example #45
0
 def _process(self):
     pdf = AbstractToPDF(self.abstract)
     filename = 'abstract-{}.pdf'.format(self.abstract.friendly_id)
     return send_file(filename, pdf.generate(), 'application/pdf')
Example #46
0
 def _process(self):
     pdf = get_session_timetable_pdf(self.session)
     return send_file('session-timetable.pdf', BytesIO(pdf.getPDFBin()),
                      'application/pdf')
Example #47
0
class RHTimeTablePDF(RHConferenceTimeTable):

    fontsizes = ['xxx-small', 'xx-small', 'x-small', 'smaller', 'small', 'normal', 'large', 'larger']

    def _checkParams(self,params):
        RHConferenceTimeTable._checkParams(self,params)
        self._showSessions=self._normaliseListParam(params.get("showSessions",[]))
        if "all" in self._showSessions:
            self._showSessions.remove("all")
        self._showDays=self._normaliseListParam(params.get("showDays",[]))
        if "all" in self._showDays:
            self._showDays.remove("all")
        self._sortingCrit=None
        if params.has_key("sortBy") and params["sortBy"].strip()!="":
            self._sortingCrit=contribFilters.SortingCriteria([params.get( "sortBy", "number").strip()])
        self._pagesize = params.get('pagesize','A4')
        self._fontsize = params.get('fontsize','normal')
        try:
            self._firstPageNumber = int(params.get('firstPageNumber','1'))
        except ValueError:
            self._firstPageNumber = 1
        self._showSpeakerAffiliation = False
        if params.has_key("showSpeakerAffiliation"):
            self._showSpeakerAffiliation = True
        # Keep track of the used layout for getting back after cancelling
        # the export.
        self._view = params.get("view", displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle())

    def _reduceFontSize( self ):
        index = self.fontsizes.index(self._fontsize)
        if index > 0:
            self._fontsize = self.fontsizes[index-1]
            return True
        return False

    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

    ##        tries = 5
    ##        while tries:
    ##            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, tz=tz)
    ##            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, tz=tz)
    ##            try:
    ##                data=pdf.getPDFBin()
    ##                tries = 0
    ##            except LayoutError, e:
    ##                if self._reduceFontSize():
    ##                    tries -= 1
    ##                else:
    ##                    tries = 0
    ##                    raise MaKaCError(str(e))

            return send_file(filename, StringIO(data), 'PDF')
Example #48
0
 def _process(self):
     filename = secure_filename('{}-Ticket.pdf'.format(self.event.title), 'ticket.pdf')
     return send_file(filename, generate_ticket(self.registration), 'application/pdf')
Example #49
0
 def _process(self):
     logo = self._target.getLogo()
     if not logo:
         raise MaKaCError(_("This event does not have a logo"))
     return send_file(logo.getFileName(), logo.getFilePath(), logo.getFileType(), no_cache=False, conditional=True)
Example #50
0
 def _process(self):
     pdf = ContributionBook(self.event, session.user, self.contribs, tz=self.event.timezone,
                            sort_by='board_number')
     return send_file('book-of-abstracts.pdf', pdf.generate(), 'application/pdf')
Example #51
0
 def _process(self):
     assert isinstance(self._file, LocalFile)
     return send_file(self._file.getFileName(), self._file.getFilePath(),
                      self._file.getFileType(),
                      self._file.getCreationDate())
Example #52
0
 def _process(self):
     pdf = ContribsToPDF(self.event, self.contribs)
     return send_file('contributions.pdf', pdf.generate(), 'application/pdf')
Example #53
0
 def _process(self):
     filename = "{0} - Contribution.pdf".format(self._target.getTitle())
     contrib_pdf = ContribToPDF(self._target)
     fpath = contrib_pdf.generate()
     return send_file(filename, fpath, 'PDF')
Example #54
0
 def _process(self):
     sorted_abstracts = sorted(self.abstracts,
                               key=attrgetter('friendly_id'))
     cls = ConfManagerAbstractsToPDF if self.management else AbstractsToPDF
     pdf = cls(self.event, sorted_abstracts)
     return send_file('abstracts.pdf', pdf.generate(), 'application/pdf')
Example #55
0
 def _process(self):
     filename = '{}-category.ics'.format(secure_filename(self.category.title, str(self.category.id)))
     buf = serialize_categories_ical([self.category.id], session.user,
                                     Event.end_dt >= (now_utc() - timedelta(weeks=4)))
     return send_file(filename, buf, 'text/calendar')
Example #56
0
 def _process(self):
     static_item_ids, item_ids = self.list_generator.get_item_ids()
     pdf = RegistrantsListToBookPDF(self.event, self.regform, self.registrations, item_ids, static_item_ids)
     return send_file('RegistrantsBook.pdf', BytesIO(pdf.getPDFBin()), 'application/pdf')
Example #57
0
 def _process(self):
     if not self.contrib.is_scheduled:
         raise NotFound('This contribution is not scheduled')
     return send_file('contribution.ics',
                      BytesIO(contribution_to_ical(self.contrib)),
                      'text/calendar')
Example #58
0
 def _process(self):
     io = BytesIO(self.agreement.attachment)
     mimetype = mimetypes.guess_type(self.agreement.attachment_filename
                                     )[0] or 'application/octet-stream'
     return send_file(self.agreement.attachment_filename, io, mimetype)
Example #59
0
 def _process_GET(self):
     if not self.room.has_photo:
         raise NotFound
     return send_file('room.jpg',
                      BytesIO(get_resized_room_photo(self.room)),
                      'image/jpeg')
Example #60
0
 def _process(self):
     pdf = AbstractsToPDF(self.event, get_user_abstracts(self.event, session.user))
     return send_file('my-abstracts.pdf', pdf.generate(), 'application/pdf')