コード例 #1
0
def perform_request_user(req, request_type, recid, data):
    """Handle user related requests."""
    response = {}
    if request_type == 'changeTagFormat':
        try:
            tagformat_settings = session_param_get(req, 'bibedit_tagformat')
        except KeyError:
            tagformat_settings = {}
        tagformat_settings[recid] = data['tagFormat']
        session_param_set(req, 'bibedit_tagformat', tagformat_settings)
        response['resultCode'] = 2
    return response
コード例 #2
0
    def index(self, req, form):
        """
        Main submission page installed on /deposit (hack in Invenio source) with the
        following features:

          * Two different themes/skins (for portal and for invenio)
          * Upload new file to start a publication submission.
          * Enter metadata for publication(s) related to a project

        URL parameters:
         * style: Theme/skin to use - "invenio" or "portal"
         * projectid: Work on publications for this project
         * delete: Delete file and publication
         * plus: ?
         * upload: Upload new file (without Uploadify backend)
        """
        argd = wash_urlargd(
            form,
            {
                "projectid": (int, -1),
                "delete": (str, ""),
                "publicationid": (str, ""),
                "plus": (int, -1),
                "linkproject": (int, -1),
                "unlinkproject": (int, -1),
                "style": (str, None),
                "upload": (str, ""),
                "dropbox": (str, ""),
            },
        )

        _ = gettext_set_language(argd["ln"])

        # Check if user is authorized to deposit publications
        user_info = collect_user_info(req)
        auth_code, auth_message = acc_authorize_action(user_info, "submit", doctype="OpenAIRE")
        if auth_code:
            if user_info["guest"] == "1":
                return redirect_to_url(
                    req,
                    "%s/youraccount/login%s"
                    % (
                        CFG_SITE_SECURE_URL,
                        make_canonical_urlargd(
                            {"referer": "%s%s" % (CFG_SITE_URL, req.unparsed_uri), "ln": argd["ln"]}, {}
                        ),
                    ),
                )
            else:
                return page(
                    req=req,
                    body=_("You are not authorized to use OpenAIRE deposition."),
                    title=_("Authorization failure"),
                    navmenuid="submit",
                )

        # Get parameters
        projectid = argd["projectid"]
        plus = argd["plus"]
        style = get_openaire_style(req)

        if plus == -1:
            try:
                plus = bool(session_param_get(req, "plus"))
            except KeyError:
                plus = False
                session_param_set(req, "plus", plus)
        else:
            plus = bool(plus)
            session_param_set(req, "plus", plus)

        # Check projectid
        all_project_ids = get_all_projectsids()

        if projectid not in all_project_ids:
            projectid = -1

        uid = user_info["uid"]

        ## Perform file upload (if needed)
        if argd["upload"]:
            if projectid < 0:
                projectid = 0
            try:
                upload_file(form, uid, projectid)
            except UploadError, e:
                return page(req=req, body=unicode(e), title=_("File upload error"), navmenuid="submit")
コード例 #3
0
    def index(self, req, form):
        """
        Main submission page installed on /deposit (hack in Invenio source) with the
        following features:

          * Two different themes/skins (for portal and for invenio)
          * Upload new file to start a publication submission.
          * Enter metadata for publication(s) related to a project

        URL parameters:
         * style: Theme/skin to use - "invenio" or "portal"
         * projectid: Work on publications for this project
         * delete: Delete file and publication
         * plus: ?
         * upload: Upload new file (without Uploadify backend)
        """
        argd = wash_urlargd(
            form, {
                'projectid': (int, -1),
                'delete': (str, ''),
                'publicationid': (str, ''),
                'plus': (int, -1),
                'linkproject': (int, -1),
                'unlinkproject': (int, -1),
                'style': (str, None),
                'upload': (str, ''),
                'dropbox': (str, '')
            })

        _ = gettext_set_language(argd['ln'])

        # Check if user is authorized to deposit publications
        user_info = collect_user_info(req)
        auth_code, auth_message = acc_authorize_action(user_info,
                                                       'submit',
                                                       doctype='OpenAIRE')
        if auth_code:
            if user_info['guest'] == '1':
                return redirect_to_url(
                    req, "%s/youraccount/login%s" %
                    (CFG_SITE_SECURE_URL,
                     make_canonical_urlargd(
                         {
                             'referer': "%s%s" %
                             (CFG_SITE_URL, req.unparsed_uri),
                             "ln": argd['ln']
                         }, {})))
            else:
                return page(
                    req=req,
                    body=_(
                        "You are not authorized to use OpenAIRE deposition."),
                    title=_("Authorization failure"),
                    navmenuid="submit")

        # Get parameters
        projectid = argd['projectid']
        plus = argd['plus']
        style = get_openaire_style(req)

        if plus == -1:
            try:
                plus = bool(session_param_get(req, 'plus'))
            except KeyError:
                plus = False
                session_param_set(req, 'plus', plus)
        else:
            plus = bool(plus)
            session_param_set(req, 'plus', plus)

        # Check projectid
        all_project_ids = get_all_projectsids()

        if projectid not in all_project_ids:
            projectid = -1

        uid = user_info['uid']

        ## Perform file upload (if needed)
        if argd['upload']:
            if projectid < 0:
                projectid = 0
            try:
                upload_file(form, uid, projectid)
            except UploadError, e:
                return page(req=req,
                            body=unicode(e),
                            title=_("File upload error"),
                            navmenuid="submit")