Пример #1
0
    def metadata(self, req, form):
        """ Display Metadata file upload form """
        argd = wash_urlargd(
            form, {
                'filetype': (str, ""),
                'mode': (str, ""),
                'submit_date': (str, "yyyy-mm-dd"),
                'submit_time': (str, "hh:mm:ss"),
                'email_logs_to': (str, None)
            })
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        uid = getUid(req)
        if argd['email_logs_to'] is None:
            argd['email_logs_to'] = get_email(uid)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'],
                                                         ref="metadata")
        body += batchuploader_templates.tmpl_display_web_metaupload_form(
            argd['ln'], argd['filetype'], argd['mode'], argd['submit_date'],
            argd['submit_time'], argd['email_logs_to'])

        title = _("Metadata batch upload")
        return page(title=title,
                    body=body,
                    metaheaderadd=batchuploader_templates.tmpl_styles(),
                    uid=uid,
                    lastupdated=__lastupdated__,
                    req=req,
                    language=argd['ln'],
                    navmenuid="batchuploader")
Пример #2
0
    def metadata(self, req, form):
        """ Display Metadata file upload form """
        argd = wash_urlargd(
            form,
            {
                "error": (int, 0),
                "filetype": (str, ""),
                "mode": (str, ""),
                "submit_date": (str, "yyyy-mm-dd"),
                "submit_time": (str, "hh:mm:ss"),
            },
        )
        _ = gettext_set_language(argd["ln"])

        not_authorized = user_authorization(req, argd["ln"])
        if not_authorized:
            return not_authorized
        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd["ln"], ref="metadata")
        body += batchuploader_templates.tmpl_display_web_metaupload_form(
            argd["ln"], argd["error"], argd["filetype"], argd["mode"], argd["submit_date"], argd["submit_time"]
        )

        title = _("Metadata batch upload")
        return page(
            title=title,
            body=body,
            metaheaderadd=batchuploader_templates.tmpl_styles(),
            uid=uid,
            lastupdated=__lastupdated__,
            req=req,
            language=argd["ln"],
            navmenuid="batchuploader",
        )
Пример #3
0
    def daemon(self, req, form):
        """ Display content of folders where the daemon will look into """
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd["ln"])

        not_authorized = user_authorization(req, argd["ln"])
        if not_authorized:
            return not_authorized
        docs = get_daemon_doc_files()
        metadata = get_daemon_meta_files()

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd["ln"], ref="daemon")
        body += batchuploader_templates.tmpl_daemon_content(argd["ln"], docs, metadata)
        title = _("Batch Uploader: Daemon monitor")
        return page(
            title=title,
            body=body,
            metaheaderadd=batchuploader_templates.tmpl_styles(),
            uid=uid,
            lastupdated=__lastupdated__,
            req=req,
            language=argd["ln"],
            navmenuid="batchuploader",
        )
Пример #4
0
    def daemon(self, req, form):
        """ Display content of folders where the daemon will look into """
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        docs = get_daemon_doc_files()
        metadata = get_daemon_meta_files()

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'],
                                                         ref="daemon")
        body += batchuploader_templates.tmpl_daemon_content(
            argd['ln'], docs, metadata)
        title = _("Batch Uploader: Daemon monitor")
        return page(title=title,
                    body=body,
                    metaheaderadd=batchuploader_templates.tmpl_styles(),
                    uid=uid,
                    lastupdated=__lastupdated__,
                    req=req,
                    language=argd['ln'],
                    navmenuid="batchuploader")
Пример #5
0
    def history(self, req, form):
        """Display upload history of the current user"""
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd["ln"])

        not_authorized = user_authorization(req, argd["ln"])
        if not_authorized:
            return not_authorized
        uploaded_meta_files = get_user_metadata_uploads(req)
        uploaded_doc_files = get_user_document_uploads(req)

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd["ln"], ref="history")
        body += batchuploader_templates.tmpl_upload_history(argd["ln"], uploaded_meta_files, uploaded_doc_files)
        title = _("Upload history")
        return page(
            title=title,
            body=body,
            metaheaderadd=batchuploader_templates.tmpl_styles(),
            uid=uid,
            lastupdated=__lastupdated__,
            req=req,
            language=argd["ln"],
            navmenuid="batchuploader",
        )
    def metadata(self, req, form):
        """ Display Metadata file upload form """
        argd = wash_urlargd(form, { 'filetype': (str, ""),
                                    'mode': (str, ""),
                                    'submit_date': (str, "yyyy-mm-dd"),
                                    'submit_time': (str, "hh:mm:ss"),
                                    'email_logs_to': (str, None)})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        uid = getUid(req)
        if argd['email_logs_to'] is None:
            argd['email_logs_to'] = get_email(uid)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'], ref="metadata")
        body += batchuploader_templates.tmpl_display_web_metaupload_form(argd['ln'],
                argd['filetype'], argd['mode'], argd['submit_date'],
                argd['submit_time'], argd['email_logs_to'])

        title = _("Metadata batch upload")
        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
Пример #7
0
    def history(self, req, form):
        """Display upload history of the current user"""
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        uploaded_meta_files = get_user_metadata_uploads(req)
        uploaded_doc_files = get_user_document_uploads(req)

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'],
                                                         ref="history")
        body += batchuploader_templates.tmpl_upload_history(
            argd['ln'], uploaded_meta_files, uploaded_doc_files)
        title = _("Upload history")
        return page(title=title,
                    body=body,
                    metaheaderadd=batchuploader_templates.tmpl_styles(),
                    uid=uid,
                    lastupdated=__lastupdated__,
                    req=req,
                    language=argd['ln'],
                    navmenuid="batchuploader")
Пример #8
0
    def metasubmit(self, req, form):
        """ Function called after submitting the metadata upload form.
            Checks if input fields are correct before uploading.
        """
        argd = wash_urlargd(
            form, {
                'metafile': (str, None),
                'filetype': (str, None),
                'mode': (str, None),
                'submit_date': (str, None),
                'submit_time': (str, None),
                'filename': (str, None),
                'priority': (str, None),
                'email_logs_to': (str, None)
            })
        _ = gettext_set_language(argd['ln'])

        # Check if the page is directly accessed
        if argd['metafile'] == None:
            redirect_to_url(
                req, "%s/batchuploader/metadata" % (CFG_SITE_SECURE_URL))

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized

        date = argd['submit_date'] not in ['yyyy-mm-dd', ''] \
                and argd['submit_date'] or ''
        time = argd['submit_time'] not in ['hh:mm:ss', ''] \
                and argd['submit_time'] or ''

        auth_code, auth_message = metadata_upload(req, argd['metafile'],
                                                  argd['filetype'],
                                                  argd['mode'].split()[0],
                                                  date, time, argd['filename'],
                                                  argd['ln'], argd['priority'],
                                                  argd['email_logs_to'])

        if auth_code == 1:  # not authorized
            referer = '/batchuploader/'
            return page_not_authorized(req=req,
                                       referer=referer,
                                       text=auth_message,
                                       navmenuid="batchuploader")
        else:
            uid = getUid(req)
            body = batchuploader_templates.tmpl_display_menu(argd['ln'])
            body += batchuploader_templates.tmpl_upload_successful(argd['ln'])
            title = _("Upload successful")
            navtrail = '''<a class="navtrail" href="%s/batchuploader/metadata">%s</a>''' % \
                            (CFG_SITE_SECURE_URL, _("Metadata batch upload"))
            return page(title=title,
                        body=body,
                        uid=uid,
                        navtrail=navtrail,
                        lastupdated=__lastupdated__,
                        req=req,
                        language=argd['ln'],
                        navmenuid="batchuploader")
Пример #9
0
    def docsubmit(self, req, form):
        """ Function called after submitting the document upload form.
            Performs the appropiate action depending on the input parameters
        """
        argd = wash_urlargd(form, {'docfolder': (str, ""),
                                   'matching': (str, ""),
                                   'mode': (str, ""),
                                   'submit_date': (str, ""),
                                   'submit_time': (str, ""),
                                   'priority': (str, "")})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        #Check if input fields are correct, if not, redirect to upload form
        correct_date = check_date(argd['submit_date'])
        correct_time = check_time(argd['submit_time'])
        if correct_time != 0:
            redirect_to_url(req,
            "%s/batchuploader/documents?error=1&mode=%s&docfolder=%s&matching=%s&submit_date=%s"
            % (CFG_SITE_SECURE_URL, argd['mode'], argd['docfolder'], argd['matching'], argd['submit_date']))
        if correct_date != 0:
            redirect_to_url(req,
            "%s/batchuploader/documents?error=%s&mode=%s&docfolder=%s&matching=%s&submit_time=%s"
            % (CFG_SITE_SECURE_URL, correct_date, argd['mode'], argd['docfolder'], argd['matching'], argd['submit_time']))

        date = argd['submit_date'] not in ['yyyy-mm-dd', ''] \
                                and argd['submit_date'] or ''
        time = argd['submit_time'] not in ['hh:mm:ss', ''] \
                                and argd['submit_time'] or ''

        if date != '' and time == '':
            redirect_to_url(req, "%s/batchuploader/documents?error=1&mode=%s&docfolder=%s&matching=%s&submit_date=%s"
                            % (CFG_SITE_SECURE_URL, argd['mode'], argd['docfolder'], argd['matching'], argd['submit_date']))
        elif date == '' and time != '':
            redirect_to_url(req, "%s/batchuploader/documents?error=4&mode=%s&docfolder=%s&matching=%s&submit_time=%s"
                            % (CFG_SITE_SECURE_URL, argd['mode'], argd['docfolder'], argd['matching'], argd['submit_time']))

        errors, info = document_upload(req, argd['docfolder'], argd['matching'],
                                       argd['mode'], date, time, argd['ln'], argd['priority'])

        body = batchuploader_templates.tmpl_display_menu(argd['ln'])
        uid = getUid(req)
        navtrail = '''<a class="navtrail" href="%s/batchuploader/documents">%s</a>''' % \
                    (CFG_SITE_SECURE_URL, _("Document batch upload"))

        body += batchuploader_templates.tmpl_display_web_docupload_result(argd['ln'], errors, info)
        title = _("Document batch upload result")

        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    navtrail = navtrail,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
    def docsubmit(self, req, form):
        """ Function called after submitting the document upload form.
            Performs the appropiate action depending on the input parameters
        """
        argd = wash_urlargd(form, {'docfolder': (str, ""),
                                   'matching': (str, ""),
                                   'mode': (str, ""),
                                   'submit_date': (str, ""),
                                   'submit_time': (str, ""),
                                   'priority': (str, "")})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        #Check if input fields are correct, if not, redirect to upload form
        correct_date = check_date(argd['submit_date'])
        correct_time = check_time(argd['submit_time'])
        if correct_time != 0:
            redirect_to_url(req,
            "%s/batchuploader/documents?error=1&mode=%s&docfolder=%s&matching=%s&submit_date=%s"
            % (CFG_SITE_SECURE_URL, argd['mode'], argd['docfolder'], argd['matching'], argd['submit_date']))
        if correct_date != 0:
            redirect_to_url(req,
            "%s/batchuploader/documents?error=%s&mode=%s&docfolder=%s&matching=%s&submit_time=%s"
            % (CFG_SITE_SECURE_URL, correct_date, argd['mode'], argd['docfolder'], argd['matching'], argd['submit_time']))

        date = argd['submit_date'] not in ['yyyy-mm-dd', ''] \
                                and argd['submit_date'] or ''
        time = argd['submit_time'] not in ['hh:mm:ss', ''] \
                                and argd['submit_time'] or ''

        if date != '' and time == '':
            redirect_to_url(req, "%s/batchuploader/documents?error=1&mode=%s&docfolder=%s&matching=%s&submit_date=%s"
                            % (CFG_SITE_SECURE_URL, argd['mode'], argd['docfolder'], argd['matching'], argd['submit_date']))
        elif date == '' and time != '':
            redirect_to_url(req, "%s/batchuploader/documents?error=4&mode=%s&docfolder=%s&matching=%s&submit_time=%s"
                            % (CFG_SITE_SECURE_URL, argd['mode'], argd['docfolder'], argd['matching'], argd['submit_time']))

        errors, info = document_upload(req, argd['docfolder'], argd['matching'],
                                       argd['mode'], date, time, argd['ln'], argd['priority'])

        body = batchuploader_templates.tmpl_display_menu(argd['ln'])
        uid = getUid(req)
        navtrail = '''<a class="navtrail" href="%s/batchuploader/documents">%s</a>''' % \
                    (CFG_SITE_SECURE_URL, _("Document batch upload"))

        body += batchuploader_templates.tmpl_display_web_docupload_result(argd['ln'], errors, info)
        title = _("Document batch upload result")

        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    navtrail = navtrail,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
    def metasubmit(self, req, form):
        """ Function called after submitting the metadata upload form.
            Checks if input fields are correct before uploading.
        """
        argd = wash_urlargd(form, {'metafile': (str, None),
                                   'filetype': (str, None),
                                   'mode': (str, None),
                                   'submit_date': (str, None),
                                   'submit_time': (str, None),
                                   'filename': (str, None),
                                   'priority': (str, None),
                                   'email_logs_to': (str, None)})
        _ = gettext_set_language(argd['ln'])

        # Check if the page is directly accessed
        if argd['metafile']  == None:
            redirect_to_url(req, "%s/batchuploader/metadata"
            % (CFG_SITE_SECURE_URL))

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized

        date = argd['submit_date'] not in ['yyyy-mm-dd', ''] \
                and argd['submit_date'] or ''
        time = argd['submit_time'] not in ['hh:mm:ss', ''] \
                and argd['submit_time'] or ''

        auth_code, auth_message = metadata_upload(req,
                                  argd['metafile'], argd['filetype'],
                                  argd['mode'].split()[0],
                                  date, time, argd['filename'], argd['ln'],
                                  argd['priority'], argd['email_logs_to'])

        if auth_code == 1: # not authorized
            referer = '/batchuploader/'
            return page_not_authorized(req=req, referer=referer,
                        text=auth_message, navmenuid="batchuploader")
        else:
            uid = getUid(req)
            body = batchuploader_templates.tmpl_display_menu(argd['ln'])
            body += batchuploader_templates.tmpl_upload_successful(argd['ln'])
            title = _("Upload successful")
            navtrail = '''<a class="navtrail" href="%s/batchuploader/metadata">%s</a>''' % \
                            (CFG_SITE_SECURE_URL, _("Metadata batch upload"))
            return page(title = title,
                        body = body,
                        uid = uid,
                        navtrail = navtrail,
                        lastupdated = __lastupdated__,
                        req = req,
                        language = argd['ln'],
                        navmenuid = "batchuploader")
Пример #12
0
    def documents(self, req, form):
        """ Display document upload form """
        argd = wash_urlargd(form, {
                                    })
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'], ref="documents")
        body += batchuploader_templates.tmpl_display_web_docupload_form(argd['ln'])

        title = _("Document batch upload")
        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
    def documents(self, req, form):
        """ Display document upload form """
        argd = wash_urlargd(form, {
                                    })
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'], ref="documents")
        body += batchuploader_templates.tmpl_display_web_docupload_form(argd['ln'])

        title = _("Document batch upload")
        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
Пример #14
0
    def metasubmit(self, req, form):
        """ Function called after submitting the metadata upload form.
            Checks if input fields are correct before uploading.
        """
        argd = wash_urlargd(
            form,
            {
                "filetype": (str, None),
                "mode": (str, None),
                "submit_date": (str, None),
                "submit_time": (str, None),
                "filename": (str, None),
                "priority": (str, None),
            },
        )
        _ = gettext_set_language(argd["ln"])

        not_authorized = user_authorization(req, argd["ln"])
        if not_authorized:
            return not_authorized
        # Check if input fields are correct, if not, redirect to upload form
        correct_date = check_date(argd["submit_date"])
        correct_time = check_time(argd["submit_time"])
        if correct_time != 0:
            redirect_to_url(
                req,
                "%s/batchuploader/metadata?error=1&filetype=%s&mode=%s&submit_date=%s"
                % (CFG_SITE_SECURE_URL, argd["filetype"], argd["mode"], argd["submit_date"]),
            )
        if not form.get("metafile", None) or not form.get("metafile", None).value:  # Empty file
            redirect_to_url(
                req,
                "%s/batchuploader/metadata?error=2&filetype=%s&mode=%s&submit_date=%s&submit_time=%s"
                % (CFG_SITE_SECURE_URL, argd["filetype"], argd["mode"], argd["submit_date"], argd["submit_time"]),
            )
        if correct_date != 0:
            redirect_to_url(
                req,
                "%s/batchuploader/metadata?error=%s&filetype=%s&mode=%s&submit_time=%s"
                % (CFG_SITE_SECURE_URL, correct_date, argd["filetype"], argd["mode"], argd["submit_time"]),
            )

        date = argd["submit_date"] not in ["yyyy-mm-dd", ""] and argd["submit_date"] or ""
        time = argd["submit_time"] not in ["hh:mm:ss", ""] and argd["submit_time"] or ""

        if date != "" and time == "":
            redirect_to_url(
                req,
                "%s/batchuploader/metadata?error=1&filetype=%s&mode=%s&submit_date=%s"
                % (CFG_SITE_SECURE_URL, argd["filetype"], argd["mode"], argd["submit_date"]),
            )
        elif date == "" and time != "":
            redirect_to_url(
                req,
                "%s/batchuploader/metadata?error=4&filetype=%s&mode=%s&submit_time=%s"
                % (CFG_SITE_SECURE_URL, argd["filetype"], argd["mode"], argd["submit_time"]),
            )

        # Function where bibupload queues the file
        auth_code, auth_message = metadata_upload(
            req,
            form.get("metafile", None),
            argd["filetype"],
            argd["mode"].split()[0],
            date,
            time,
            argd["filename"],
            argd["ln"],
            argd["priority"],
        )

        if auth_code == 1:  # not authorized
            referer = "/batchuploader/"
            return page_not_authorized(req=req, referer=referer, text=auth_message, navmenuid="batchuploader")
        else:
            uid = getUid(req)
            body = batchuploader_templates.tmpl_display_menu(argd["ln"])
            if auth_code == 2:  # invalid MARCXML
                body += batchuploader_templates.tmpl_invalid_marcxml(argd["ln"])
                title = _("Invalid MARCXML")
            else:
                body += batchuploader_templates.tmpl_upload_successful(argd["ln"])
                title = _("Upload successful")
            navtrail = """<a class="navtrail" href="%s/batchuploader/metadata">%s</a>""" % (
                CFG_SITE_SECURE_URL,
                _("Metadata batch upload"),
            )
            return page(
                title=title,
                body=body,
                uid=uid,
                navtrail=navtrail,
                lastupdated=__lastupdated__,
                req=req,
                language=argd["ln"],
                navmenuid="batchuploader",
            )
Пример #15
0
    def docsubmit(self, req, form):
        """ Function called after submitting the document upload form.
            Performs the appropiate action depending on the input parameters
        """
        argd = wash_urlargd(
            form,
            {
                "docfolder": (str, ""),
                "matching": (str, ""),
                "mode": (str, ""),
                "submit_date": (str, ""),
                "submit_time": (str, ""),
                "priority": (str, ""),
            },
        )
        _ = gettext_set_language(argd["ln"])

        not_authorized = user_authorization(req, argd["ln"])
        if not_authorized:
            return not_authorized
        # Check if input fields are correct, if not, redirect to upload form
        correct_date = check_date(argd["submit_date"])
        correct_time = check_time(argd["submit_time"])
        if correct_time != 0:
            redirect_to_url(
                req,
                "%s/batchuploader/documents?error=1&mode=%s&docfolder=%s&matching=%s&submit_date=%s"
                % (CFG_SITE_SECURE_URL, argd["mode"], argd["docfolder"], argd["matching"], argd["submit_date"]),
            )
        if correct_date != 0:
            redirect_to_url(
                req,
                "%s/batchuploader/documents?error=%s&mode=%s&docfolder=%s&matching=%s&submit_time=%s"
                % (
                    CFG_SITE_SECURE_URL,
                    correct_date,
                    argd["mode"],
                    argd["docfolder"],
                    argd["matching"],
                    argd["submit_time"],
                ),
            )

        date = argd["submit_date"] not in ["yyyy-mm-dd", ""] and argd["submit_date"] or ""
        time = argd["submit_time"] not in ["hh:mm:ss", ""] and argd["submit_time"] or ""

        if date != "" and time == "":
            redirect_to_url(
                req,
                "%s/batchuploader/documents?error=1&mode=%s&docfolder=%s&matching=%s&submit_date=%s"
                % (CFG_SITE_SECURE_URL, argd["mode"], argd["docfolder"], argd["matching"], argd["submit_date"]),
            )
        elif date == "" and time != "":
            redirect_to_url(
                req,
                "%s/batchuploader/documents?error=4&mode=%s&docfolder=%s&matching=%s&submit_time=%s"
                % (CFG_SITE_SECURE_URL, argd["mode"], argd["docfolder"], argd["matching"], argd["submit_time"]),
            )

        errors, info = document_upload(
            req, argd["docfolder"], argd["matching"], argd["mode"], date, time, argd["ln"], argd["priority"]
        )

        body = batchuploader_templates.tmpl_display_menu(argd["ln"])
        uid = getUid(req)
        navtrail = """<a class="navtrail" href="%s/batchuploader/documents">%s</a>""" % (
            CFG_SITE_SECURE_URL,
            _("Document batch upload"),
        )

        body += batchuploader_templates.tmpl_display_web_docupload_result(argd["ln"], errors, info)
        title = _("Document batch upload result")

        return page(
            title=title,
            body=body,
            metaheaderadd=batchuploader_templates.tmpl_styles(),
            uid=uid,
            navtrail=navtrail,
            lastupdated=__lastupdated__,
            req=req,
            language=argd["ln"],
            navmenuid="batchuploader",
        )
Пример #16
0
    def metasubmit(self, req, form):
        """ Function called after submitting the metadata upload form.
            Checks if input fields are correct before uploading.
        """
        argd = wash_urlargd(form, {'filetype': (str, None),
                                   'mode': (str, None),
                                   'submit_date': (str, None),
                                   'submit_time': (str, None),
                                   'filename': (str, None),
                                   'priority': (str, None)})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        #Check if input fields are correct, if not, redirect to upload form
        correct_date = check_date(argd['submit_date'])
        correct_time = check_time(argd['submit_time'])
        if correct_time != 0:
            redirect_to_url(req,
            "%s/batchuploader/metadata?error=1&filetype=%s&mode=%s&submit_date=%s"
            % (CFG_SITE_SECURE_URL, argd['filetype'], argd['mode'], argd['submit_date']))
        if not form.get('metafile', None) or not form.get('metafile', None).value: # Empty file
            redirect_to_url(req,
            "%s/batchuploader/metadata?error=2&filetype=%s&mode=%s&submit_date=%s&submit_time=%s"
            % (CFG_SITE_SECURE_URL, argd['filetype'], argd['mode'], argd['submit_date'],
            argd['submit_time']))
        if correct_date != 0:
            redirect_to_url(req,
            "%s/batchuploader/metadata?error=%s&filetype=%s&mode=%s&submit_time=%s"
            % (CFG_SITE_SECURE_URL, correct_date, argd['filetype'], argd['mode'], argd['submit_time']))

        date = argd['submit_date'] not in ['yyyy-mm-dd', ''] \
                and argd['submit_date'] or ''
        time = argd['submit_time'] not in ['hh:mm:ss', ''] \
                and argd['submit_time'] or ''

        if date != '' and time == '':
            redirect_to_url(req, "%s/batchuploader/metadata?error=1&filetype=%s&mode=%s&submit_date=%s"
            % (CFG_SITE_SECURE_URL, argd['filetype'], argd['mode'], argd['submit_date']))
        elif date == '' and time != '':
            redirect_to_url(req, "%s/batchuploader/metadata?error=4&filetype=%s&mode=%s&submit_time=%s"
            % (CFG_SITE_SECURE_URL, argd['filetype'], argd['mode'], argd['submit_time']))

        #Function where bibupload queues the file
        auth_code, auth_message = metadata_upload(req,
                                  form.get('metafile', None), argd['filetype'], argd['mode'].split()[0],
                                  date, time, argd['filename'], argd['ln'],
                                  argd['priority'])

        if auth_code == 1: # not authorized
            referer = '/batchuploader/'
            return page_not_authorized(req=req, referer=referer,
                        text=auth_message, navmenuid="batchuploader")
        else:
            uid = getUid(req)
            body = batchuploader_templates.tmpl_display_menu(argd['ln'])
            if auth_code == 2: # invalid MARCXML
                body += batchuploader_templates.tmpl_invalid_marcxml(argd['ln'])
                title = _("Invalid MARCXML")
            else:
                body += batchuploader_templates.tmpl_upload_successful(argd['ln'])
                title = _("Upload successful")
            navtrail = '''<a class="navtrail" href="%s/batchuploader/metadata">%s</a>''' % \
                            (CFG_SITE_SECURE_URL, _("Metadata batch upload"))
            return page(title = title,
                        body = body,
                        uid = uid,
                        navtrail = navtrail,
                        lastupdated = __lastupdated__,
                        req = req,
                        language = argd['ln'],
                        navmenuid = "batchuploader")
    def metasubmit(self, req, form):
        """ Function called after submitting the metadata upload form.
            Checks if input fields are correct before uploading.
        """
        argd = wash_urlargd(form, {'filetype': (str, None),
                                   'mode': (str, None),
                                   'submit_date': (str, None),
                                   'submit_time': (str, None),
                                   'filename': (str, None),
                                   'priority': (str, None)})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        #Check if input fields are correct, if not, redirect to upload form
        correct_date = check_date(argd['submit_date'])
        correct_time = check_time(argd['submit_time'])
        if correct_time != 0:
            redirect_to_url(req,
            "%s/batchuploader/metadata?error=1&filetype=%s&mode=%s&submit_date=%s"
            % (CFG_SITE_SECURE_URL, argd['filetype'], argd['mode'], argd['submit_date']))
        if not form.get('metafile', None) or not form.get('metafile', None).value: # Empty file
            redirect_to_url(req,
            "%s/batchuploader/metadata?error=2&filetype=%s&mode=%s&submit_date=%s&submit_time=%s"
            % (CFG_SITE_SECURE_URL, argd['filetype'], argd['mode'], argd['submit_date'],
            argd['submit_time']))
        if correct_date != 0:
            redirect_to_url(req,
            "%s/batchuploader/metadata?error=%s&filetype=%s&mode=%s&submit_time=%s"
            % (CFG_SITE_SECURE_URL, correct_date, argd['filetype'], argd['mode'], argd['submit_time']))

        date = argd['submit_date'] not in ['yyyy-mm-dd', ''] \
                and argd['submit_date'] or ''
        time = argd['submit_time'] not in ['hh:mm:ss', ''] \
                and argd['submit_time'] or ''

        if date != '' and time == '':
            redirect_to_url(req, "%s/batchuploader/metadata?error=1&filetype=%s&mode=%s&submit_date=%s"
            % (CFG_SITE_SECURE_URL, argd['filetype'], argd['mode'], argd['submit_date']))
        elif date == '' and time != '':
            redirect_to_url(req, "%s/batchuploader/metadata?error=4&filetype=%s&mode=%s&submit_time=%s"
            % (CFG_SITE_SECURE_URL, argd['filetype'], argd['mode'], argd['submit_time']))

        #Function where bibupload queues the file
        auth_code, auth_message = metadata_upload(req,
                                  form.get('metafile', None), argd['filetype'], argd['mode'].split()[0],
                                  date, time, argd['filename'], argd['ln'],
                                  argd['priority'])

        if auth_code == 1: # not authorized
            referer = '/batchuploader/'
            return page_not_authorized(req=req, referer=referer,
                        text=auth_message, navmenuid="batchuploader")
        else:
            uid = getUid(req)
            body = batchuploader_templates.tmpl_display_menu(argd['ln'])
            if auth_code == 2: # invalid MARCXML
                body += batchuploader_templates.tmpl_invalid_marcxml(argd['ln'])
                title = _("Invalid MARCXML")
            else:
                body += batchuploader_templates.tmpl_upload_successful(argd['ln'])
                title = _("Upload successful")
            navtrail = '''<a class="navtrail" href="%s/batchuploader/metadata">%s</a>''' % \
                            (CFG_SITE_SECURE_URL, _("Metadata batch upload"))
            return page(title = title,
                        body = body,
                        uid = uid,
                        navtrail = navtrail,
                        lastupdated = __lastupdated__,
                        req = req,
                        language = argd['ln'],
                        navmenuid = "batchuploader")