Esempio n. 1
0
def index(req):
    req.content_type = "text/html"
    req.write(pageheaderonly("Nation numbers", req=req))
    req.write("<h1>Nation numbers</h1>")
    req.flush()
    req.write("<table>\n")

    tr = ("<tr>"
          "<td>{0}</td>"
          "<td><a href='/search?{1}&sc=1'>{2}</a></td>"
          "<td><a href='/nations.py/articles?i={3}' "
          "target='_blank'>Articles</a> "
          "(<a href='/nations.py/articles?mode=text&amp;i={3}'>text</a>)"
          "</td><tr>\n")

    for i, nation in enumerate(_AFFILIATIONS):
        query = _build_query(nation)
        results = perform_request_search(p=query, of='intbitset')
        req.write(tr.format(escape(nation),
                            escape(urlencode([("p", query)]), True),
                            len(results),
                            i))
        req.flush()
    req.write("</table>\n")
    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 2
0
def index(req):
    req.content_type = "text/html"
    req.write(pageheaderonly("Nation numbers", req=req))
    req.write("<h1>Nation numbers</h1>")
    req.flush()
    req.write("<table>\n")

    tr = ("<tr>"
          "<td>{0}</td>"
          "<td><a href='/search?{1}&sc=1'>{2}</a></td>"
          "<td><a href='/nations.py/articles?i={3}' "
          "target='_blank'>Articles</a> "
          "(<a href='/nations.py/articles?mode=text&amp;i={3}'>text</a>)"
          "</td><tr>\n")

    for i, nation in enumerate(_AFFILIATIONS):
        query = _build_query(nation)
        results = perform_request_search(p=query, of='intbitset')
        req.write(tr.format(escape(nation),
                            escape(urlencode([("p", query)]), True),
                            len(results),
                            i))
        req.flush()
    req.write("</table>\n")
    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 3
0
def index(req):
    user_info = collect_user_info(req)
    if not acc_is_user_in_role(user_info, acc_get_role_id("SCOAP3")):
        return page_not_authorized(req=req)

    req.content_type = "text/html"
    req.write(pageheaderonly("Repository tools", req=req))
    req.write("<h1>Repository tools</h1>")

    req.write("<h2>Compliance</h2>")
    req.write("<a href='/compliance.py'>Content compliance</a> - articles compliance with agreements<br />")
    req.write("<a href='/compliance.py/csv'>Content compliance to CSV</a> - articles compliance with agreements<br />")
    req.write("<a href='/nations.py/late'>24h deadline</a> - checks the 24h delivery deadline<br />")

    req.write("<h2>National statistics</h2>")
    req.write("<a href='/nations.py'>Countries impact</a> - number of pulications per country<br />")
    req.write("<a href='/nations.py/us_affiliations'>US affiliations</a> - all US affiliations<br />")
    req.write("<a href='/nations.py/us_affiliations_csv'>Selected US aff count CSV</a> - affiliation count for selected US universities<br />")
    req.write("<a href='/nations.py/usa_papers'>Selected US articles list</a><br />")
    req.write("<a href='/nations.py/usa_papers_csv'>Selected US articles list CSV</a><br />")

    req.write("<h2>Export to INSPIRE</h2>")
    req.write("<a href='/ffts_for_inspire.py'>Data export</a><br />")
    req.write("<a href='/ffts_for_inspire.py/csv'>Data export to CSV</a><br />")
    req.flush()

    req.write(pagefooteronly(req=req))
    return ""
    def display(self, req, form):
        """
        Display approved latest added linkbacks of the invenio instance
        """
        argd = wash_urlargd(
            form, {'rg': (int, CFG_WEBLINKBACK_LATEST_COUNT_DEFAULT)})
        # count must be positive
        if argd['rg'] < 0:
            argd['rg'] = -argd['rg']

        _ = gettext_set_language(argd['ln'])

        body = perform_request_display_approved_latest_added_linkbacks(
            argd['rg'],
            argd['ln'],
            weblinkback_templates=weblinkback_templates)

        navtrail = 'Recent Linkbacks'

        mathjaxheader, jqueryheader = weblinkback_templates.tmpl_get_mathjaxheader_jqueryheader(
        )

        return pageheaderonly(title=navtrail,
                              navtrail=navtrail,
                              verbose=1,
                              metaheaderadd = mathjaxheader + jqueryheader,
                              req=req,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
               body + \
               websearch_templates.tmpl_search_pageend(argd['ln']) + \
               pagefooteronly(language=argd['ln'], req=req)
Esempio n. 5
0
def us_affiliations(req):
    from invenio.search_engine_utils import get_fieldvalues

    req.content_type = "text/html"
    print >> req, pageheaderonly("USA affiliations", req=req)

    affiliations = []
    tmp = []
    tmp.extend(get_fieldvalues(perform_request_search(p="*"), '100__u', False))
    tmp.extend(get_fieldvalues(perform_request_search(p="*"), '100__v', False))
    tmp.extend(get_fieldvalues(perform_request_search(p="*"), '700__u', False))
    tmp.extend(get_fieldvalues(perform_request_search(p="*"), '700__v', False))

    def _find_usa(x):
        return ("United States of America" in x or "United States" in x
                or "USA" in x or "U.S.A" in x)

    affiliations.extend(filter(_find_usa, tmp))
    affiliations = set(affiliations)

    replaces = [('United States of America', ''), ("United States", ''),
                ("USA", ''), ("U.S.A", ''), ("University", ''), ("State", ''),
                ('Department of Physics and Astronomy', ""),
                ('Department of Physics', ""), ('Department', ''), (",", '')]

    affs = map(lambda x: multi_replace(x, replaces).strip(), affiliations)
    affiliations2 = zip(affiliations, affs)

    for a in sorted(affiliations2, key=lambda aff: aff[1]):
        req.write(a[0] + '<br />')
    req.write(pagefooteronly(req=req))
    return ""
    def display(self, req, form):
        """
        Display approved latest added linkbacks of the invenio instance
        """
        argd = wash_urlargd(form, {'rg': (int, CFG_WEBLINKBACK_LATEST_COUNT_DEFAULT)})
        # count must be positive
        if argd['rg'] < 0:
            argd['rg'] = -argd['rg']

        _ = gettext_set_language(argd['ln'])

        body = perform_request_display_approved_latest_added_linkbacks(argd['rg'], argd['ln'], weblinkback_templates=weblinkback_templates)

        navtrail = 'Recent Linkbacks'

        mathjaxheader, jqueryheader = weblinkback_templates.tmpl_get_mathjaxheader_jqueryheader()

        return pageheaderonly(title=navtrail,
                              navtrail=navtrail,
                              verbose=1,
                              metaheaderadd = mathjaxheader + jqueryheader,
                              req=req,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
               body + \
               websearch_templates.tmpl_search_pageend(argd['ln']) + \
               pagefooteronly(language=argd['ln'], req=req)
Esempio n. 7
0
def index(req):
    req.content_type = "text/html"
    req.write(pageheaderonly("Nation numbers", req=req))
    req.write("<h1>Nation numbers</h1>")
    req.flush()
    req.write("<table>\n")
    for i, nation_tuple in enumerate(_CFG_NATION_MAP):
        query = _build_query(nation_tuple)
        results = perform_request_search(p=query, of='intbitset')
        req.write("""<tr><td>%s</td><td><a href="/search?%s&sc=1">%s</a></td><td><a href="/nations.py/articles?i=%s" target="_blank">Articles</a> (<a href="/nations.py/articles?mode=text&amp;i=%s">text</a>)</td><tr>\n""" % (
                escape(nation_tuple[0]), escape(urlencode([("p", query)]), True), len(results), i, i
            ))
        req.flush()
    req.write("</table>\n")
    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 8
0
def show_restricted_records(req):
    user_info = collect_user_info(req)
    if not acc_is_user_in_role(user_info, acc_get_role_id("SCOAP3")):
        return page_not_authorized(req=req)

    all_ids = [id[0] for id in run_sql("Select id from bibrec")]
    visible_ids = perform_request_search()

    deleted_and_older_and_restricted = set(all_ids) - set(visible_ids)
    restricted_ids = []
    # restricted_ids_older = []
    for id in deleted_and_older_and_restricted:
        rec = get_record(id)
        collections = record_get_field_values(rec, "980","%","%","%")
        if "DELETED" not in collections:
            year = record_get_field_values(rec, "773","%","%","y")
            title = record_get_field_values(rec, "245","%","%","a")
            if title:
                title = title[0]
            else:
                title = "No title"
            if year:
                if int(year[0]) >= 2015:
                    restricted_ids.append((id, title))
                # else:
                #    restricted_ids_older.append(id)
            else:
                restricted_ids.append((id,title))

    print "Restricted ids"
    print restricted_ids

    req.content_type = "text/html"
    req.write(pageheaderonly("Repository tools", req=req))
    req.write("<h1>Restricted records</h1>")
    req.write("<strong>Total number of possibli restricted records: {0}</strong>".format(len(restricted_ids)))
    req.write("<ol>")
    for id, title in restricted_ids:
        req.write("<li><a href='http://repo.scoap3.org/record/{1}'>{0}</a> <a href='http://repo.scoap3.org/record/edit/?ln=en#state=edit&recid={1}'>edit</a></li>".format(title, id))
    req.write("</ol>")
    # for id, title in restricted_ids:
    #    req.write("{0},".format(id))

    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 9
0
def index(req):
    user_info = collect_user_info(req)
    if not acc_is_user_in_role(user_info, acc_get_role_id("SCOAP3")):
        return page_not_authorized(req=req)

    req.content_type = "text/html"
    req.write(pageheaderonly("Repository tools & extra resources", req=req))
    req.write("<h1>Repository tools</h1>")

    req.write("<h2>Compliance</h2>")
    req.write("<a href='/compliance.py'>Content compliance</a> - articles compliance with agreements<br />")
    req.write("<a href='/compliance.py/csv'>Content compliance to CSV</a> - articles compliance with agreements<br />")
    req.write("<a href='/nations.py/late'>24h deadline</a> - checks the 24h delivery deadline (OBSOLETE)<br />")

    req.write("<h2>National statistics</h2>")
    req.write("<a href='/nations.py'>Countries impact</a> - number of pulications per country<br />")
    req.write("<a href='/nations.py/us_affiliations'>US affiliations</a> - all US affiliations<br />")
    req.write("<a href='/nations.py/us_affiliations_csv'>Selected US aff count CSV</a> - affiliation count for selected US universities<br />")
    req.write("<a href='/nations.py/usa_papers'>Selected US articles list</a><br />")
    req.write("<a href='/nations.py/usa_papers_csv'>Selected US articles list CSV</a><br />")
    req.write("<a href='/nations.py/papers_by_country_csv?country=xxx'>CSV list of articles by country</a> - you need to change argument 'country=xxx' to a country from the list bellow<br />")
    req.write("<textarea>Algeria, Argentina, Armenia, Australia, Austria, Azerbaijan, Belarus, Belgium, Bangladesh, Brazil, Bulgaria, Canada, CERN, Chile, China, Colombia, Costa Rica, Cuba, Croatia, Cyprus, Czech Republic, Denmark, Egypt, Estonia, Finland, France, Georgia, Germany, Greece, Hong Kong, Hungary, Iceland, India, Indonesia, Iran, Ireland, Israel, Italy, Japan, South Korea, Lebanon, Lithuania, Luxembourg, Mexico, Montenegro, Morocco, Niger, Netherlands, New Zealand, Norway, Pakistan, Poland, Portugal, Romania, Republic of San Marino, Russia, Saudi Arabia, Serbia, Singapore, Slovakia, South Africa, Spain, Sweden, Switzerland, Taiwan, Thailand, Tunisia, Turkey, Ukraine, UK, USA, Uruguay, Uzbekistan, Venezuela, Vietnam, Yemen, Peru, Kuwait, Sri Lanka, Kazakhstan, Mongolia, United Arab Emirates, United Arab Emirates, Malaysia, Qatar, Kyrgyz Republic, Jordan</textarea>")
    req.write("<a href='https://repo.scoap3.org/nations.py/countries_by_publishers'>Countries per journals</a>")

    req.write("<h2>Articles for impact calculations</h2>")
    req.write("<a href='/nations.py/impact_articles?year=2014'>Countries impact for 2014</a><br />")
    req.write("<a href='https://gist.github.com/Dziolas/7924d2feb2b3e5b0618a'>Code to run on Inspire server to get articles for impact calculation</a><br />")

    req.write("<h2>Export to INSPIRE</h2>")
    req.write("<a href='/ffts_for_inspire.py'>Data export</a><br />")
    req.write("<a href='/ffts_for_inspire.py/csv'>Data export to CSV</a><br />")

    req.write("<h1>Hidden collections</h1>")
    req.write("<a href='/collection/Erratum'>Erratas</a><br />")
    req.write("<a href='/collection/Addendum'>Addendums</a><br />")
    req.write("<a href='/collection/Corrigendum'>Corrigendums</a><br />")
    req.write("<a href='/collection/Editorial'>Editorials</a><br />")
    req.write("<a href='/collection/older_than_2014'>Articles older than 2014</a><br />")
    req.flush()

    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 10
0
def index(req):
    req.content_type = "text/html"
    req.write(pageheaderonly("Papers with arXiv number", req=req))
    req.write("<h1>Papers with arXiv numbers:</h1>")
    req.flush()
    req.write("<table>\n")

    papers = get_list()
    for i, paper_tuple in enumerate(papers):
        req.write("""<tr><td>%i</td><td>%i</td><td>%s</td><td>%s</td><td>%s</td>""" % (i, paper_tuple[0], paper_tuple[1], paper_tuple[2], paper_tuple[3]))
        if paper_tuple[3]:
            req.write("""<td><a href='%s'>link</a></td>""" % (paper_tuple[4], ))
        else:
            req.write("""<td>no pdf</td>""")
        req.write("""<td>%s</td>""" % (paper_tuple[5], ))
        req.write("""<td>%s</td></tr>\n""" % (paper_tuple[6], ))
        req.flush()
    req.write("</table>\n")
    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 11
0
def usa_papers(req):
    req.content_type = "text/html"
    print >> req, pageheaderonly("USA papers for selected affiliations", req=req)

    ## print the list of linkt to the articles
    for university in CFG_SELECTED_AFF:
        print >> req, "<h2>%s</h2>" % (str(university),)
        search = create_search_from_affiliation(university)
        for collection in CFG_JOURNALS:
            res = perform_request_search(p='/%s/' % (search,), c=collection)
            if len(res):
                print >> req, "<h3>%s (%i)</h3>" % (str(collection), len(res))
                print >> req, "<ul>"
                for rec_id in res:
                    rec = get_record(rec_id)
                    line = "<li><a href='https://repo.scoap3.org/record/%s'>%s</a></li>" % (str(rec_id), str(rec['245'][0][0][0][1]))
                    print >> req, line
                print >> req, "</ul>"

    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 12
0
def package_arrival(req, doi=None, package_name=None):
    req.content_type = "text/html"
    req.write(pageheaderonly("Repository tools - packages arrival", req=req))
    req.write("<h1>Packages Arrivals</h1>")
    req.write("""<form action='/tools.py/package_arrival' method='get'>
                       <label for='doi'>DOI: </label>
                       <input type='text' name='doi' value='{0}'>
                       <label for='package_name'>Package Name: </label>
                       <input type='text' name='package_name' value='{1}'>
                       <input type='submit'>
                     </form>""".format(doi, package_name))
    if doi:
        req.write("<h1>Results for doi: {0}</h1>".format(doi))
        req.write("""<table>
                       <thead>
                         <th>#</th>
                         <th>Package name</th>
                         <th>Date</th>
                       </thead>""")
        packages = run_sql("select package.name as name, package.delivery_date as date from doi_package join package on doi_package.package_id = package.id WHERE doi_package.doi=%s", (doi,))
        #req.write(str(packages))

    if package_name:
        req.write("<h1>Results for package: {0}</h1>".format(package_name))
        req.write("""<table>
                       <thead>
                         <th>#</th>
                         <th>Package name</th>
                         <th>Date</th>
                       </thead>""")
        packages = run_sql("select package.name as name, package.delivery_date as date from package WHERE package.name like '%{0}%'".format(package_name))
        #req.write(str(packages))

    if packages:
        for i, package in enumerate(packages):
           req.write("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>".format(i+1, package[0], package[1]))
        req.write("</table>")

    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 13
0
def us_affiliations(req):
    from invenio.search_engine_utils import get_fieldvalues

    req.content_type = "text/html"
    print >> req, pageheaderonly("USA affiliations", req=req)

    affiliations = []
    tmp = []
    tmp.extend(get_fieldvalues(perform_request_search(p="*"), '100__u', False))
    tmp.extend(get_fieldvalues(perform_request_search(p="*"), '100__v', False))
    tmp.extend(get_fieldvalues(perform_request_search(p="*"), '700__u', False))
    tmp.extend(get_fieldvalues(perform_request_search(p="*"), '700__v', False))

    def _find_usa(x):
        return ("United States of America" in x
                or "United States" in x
                or "USA" in x
                or "U.S.A" in x)
    affiliations.extend(filter(_find_usa, tmp))
    affiliations = set(affiliations)

    replaces = [('United States of America', ''),
                ("United States", ''),
                ("USA", ''),
                ("U.S.A", ''),
                ("University", ''),
                ("State", ''),
                ('Department of Physics and Astronomy', ""),
                ('Department of Physics', ""),
                ('Department', ''),
                (",", '')]

    affs = map(lambda x: multi_replace(x, replaces).strip(), affiliations)
    affiliations2 = zip(affiliations, affs)

    for a in sorted(affiliations2, key=lambda aff: aff[1]):
        req.write(a[0]+'<br />')
    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 14
0
def usa_papers(req):
    req.content_type = "text/html"
    print >> req, pageheaderonly("USA papers for selected affiliations",
                                 req=req)

    li = "<li><a href='https://repo.scoap3.org/record/{0}'>{1}</a></li>"

    ## print the list of linkt to the articles
    for university in CFG_SELECTED_AFF:
        print >> req, "<h2>%s</h2>" % (str(university),)
        search = create_search_from_affiliation(university)
        for collection in CFG_JOURNALS:
            res = perform_request_search(p='/%s/' % (search,), c=collection)
            if len(res):
                print >> req, "<h3>%s (%i)</h3>" % (str(collection), len(res))
                print >> req, "<ul>"
                for rec_id in res:
                    rec = get_record(rec_id)
                    line = li.format(str(rec_id), str(rec['245'][0][0][0][1]))
                    print >> req, line
                print >> req, "</ul>"

    req.write(pagefooteronly(req=req))
    return ""
    def display(self, req, form):
        """
        Display the linkbacks of a record and admin approve/reject features
        """
        argd = wash_urlargd(form, {})

        _ = gettext_set_language(argd['ln'])

        # Check authorization
        uid = getUid(req)
        user_info = collect_user_info(req)

        (auth_code,
         auth_msg) = check_user_can_view_linkbacks(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest':
            # Ask to login
            target = '/youraccount/login' + \
                     make_canonical_urlargd({'ln': argd['ln'],
                                             'referer': CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target)
        elif auth_code:
            return page_not_authorized(req,
                                       referer="../",
                                       uid=uid,
                                       text=auth_msg,
                                       ln=argd['ln'])

        show_admin = False
        (auth_code, auth_msg) = acc_authorize_action(
            req,
            'moderatelinkbacks',
            collection=guess_primary_collection_of_a_record(self.recid))
        if not auth_code:
            show_admin = True

        body = perform_request_display_record_linbacks(
            req,
            self.recid,
            show_admin,
            weblinkback_templates=weblinkback_templates,
            ln=argd['ln'])

        title = websearch_templates.tmpl_record_page_header_content(
            req, self.recid, argd['ln'])[0]

        # navigation, tabs, top and bottom part
        navtrail = create_navtrail_links(
            cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
        if navtrail:
            navtrail += ' &gt; '
        navtrail += '<a class="navtrail" href="%s/%s/%s?ln=%s">' % (
            CFG_SITE_URL, CFG_SITE_RECORD, self.recid, argd['ln'])
        navtrail += title
        navtrail += '</a>'
        navtrail += ' &gt; <a class="navtrail">Linkbacks</a>'

        mathjaxheader, jqueryheader = weblinkback_templates.tmpl_get_mathjaxheader_jqueryheader(
        )

        unordered_tabs = get_detailed_page_tabs(get_colID(
            guess_primary_collection_of_a_record(self.recid)),
                                                self.recid,
                                                ln=argd['ln'])
        ordered_tabs_id = [(tab_id, values['order'])
                           for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % argd['ln']
        tabs = [(unordered_tabs[tab_id]['label'], \
                     '%s/%s/%s/%s%s' % (CFG_SITE_URL, CFG_SITE_RECORD, self.recid, tab_id, link_ln), \
                     tab_id in ['linkbacks'],
                     unordered_tabs[tab_id]['enabled']) \
                     for (tab_id, values) in ordered_tabs_id
                     if unordered_tabs[tab_id]['visible'] == True]
        top = webstyle_templates.detailed_record_container_top(
            self.recid, tabs, argd['ln'])
        bottom = webstyle_templates.detailed_record_container_bottom(
            self.recid, tabs, argd['ln'])

        return pageheaderonly(title=title,
                              navtrail=navtrail,
                              uid=uid,
                              verbose=1,
                              metaheaderadd = mathjaxheader + jqueryheader,
                              req=req,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
               top + body + bottom + \
               websearch_templates.tmpl_search_pageend(argd['ln']) + \
               pagefooteronly(language=argd['ln'], req=req)
Esempio n. 16
0
    def ill_register_request_with_recid(self, req, form):
        """
        Register ILL request.
        """

        argd = wash_urlargd(
            form, {
                'ln': (str, ""),
                'period_of_interest_from': (str, ""),
                'period_of_interest_to': (str, ""),
                'additional_comments': (str, ""),
                'conditions': (str, ""),
                'only_edition': (str, ""),
            })

        _ = gettext_set_language(argd['ln'])
        uid = getUid(req)

        body = ill_register_request_with_recid(
            recid=self.recid,
            uid=uid,
            period_of_interest_from=argd['period_of_interest_from'],
            period_of_interest_to=argd['period_of_interest_to'],
            additional_comments=argd['additional_comments'],
            conditions=argd['conditions'],
            only_edition=argd['only_edition'],
            ln=argd['ln'])

        uid = getUid(req)
        if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
            return page_not_authorized(req,
                                       "../holdings/ill_request_with_recid",
                                       navmenuid='yourbaskets')

        if isGuestUser(uid):
            if not CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS:
                return redirect_to_url(
                    req, "%s/youraccount/login%s" %
                    (CFG_SITE_SECURE_URL,
                     make_canonical_urlargd(
                         {
                             'referer':
                             "%s/record/%s/holdings/ill_request_with_recid%s" %
                             (CFG_SITE_URL, self.recid,
                              make_canonical_urlargd(argd, {})),
                             "ln":
                             argd['ln']
                         }, {})))

        user_info = collect_user_info(req)
        (auth_code,
         auth_msg) = check_user_can_view_record(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest':
            cookie = mail_cookie_create_authorize_action(
                VIEWRESTRCOLL, {
                    'collection': guess_primary_collection_of_a_record(
                        self.recid)
                })
            target = '/youraccount/login' + \
                     make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)

        unordered_tabs = get_detailed_page_tabs(get_colID(
            guess_primary_collection_of_a_record(self.recid)),
                                                self.recid,
                                                ln=argd['ln'])
        ordered_tabs_id = [(tab_id, values['order'])
                           for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % argd['ln']
        tabs = [(unordered_tabs[tab_id]['label'], \
                 '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \
                 tab_id in ['holdings'],
                 unordered_tabs[tab_id]['enabled']) \
                for (tab_id, _order) in ordered_tabs_id
                if unordered_tabs[tab_id]['visible'] == True]
        top = webstyle_templates.detailed_record_container_top(
            self.recid, tabs, argd['ln'])
        bottom = webstyle_templates.detailed_record_container_bottom(
            self.recid, tabs, argd['ln'])

        title = websearch_templates.tmpl_record_page_header_content(
            req, self.recid, argd['ln'])[0]
        navtrail = create_navtrail_links(
            cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
        navtrail += ' &gt; <a class="navtrail" href="%s/record/%s?ln=%s">' % (
            CFG_SITE_URL, self.recid, argd['ln'])
        navtrail += title
        navtrail += '</a>'

        return pageheaderonly(title=title,
                              navtrail=navtrail,
                              uid=uid,
                              verbose=1,
                              req=req,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
                              top + body + bottom + \
                              websearch_templates.tmpl_search_pageend(argd['ln']) + \
                              pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req)
Esempio n. 17
0
    def send(self, req, form):
        """
        Create a new hold request.
        """
        argd = wash_urlargd(form, {
            'period_from': (str, ""),
            'period_to': (str, ""),
            'barcode': (str, "")
        })

        uid = getUid(req)

        body = perform_new_request_send(recid=self.recid,
                                        uid=uid,
                                        period_from=argd['period_from'],
                                        period_to=argd['period_to'],
                                        barcode=argd['barcode'])

        ln = CFG_SITE_LANG
        _ = gettext_set_language(ln)

        user_info = collect_user_info(req)
        (auth_code,
         auth_msg) = check_user_can_view_record(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest':
            cookie = mail_cookie_create_authorize_action(
                VIEWRESTRCOLL, {
                    'collection': guess_primary_collection_of_a_record(
                        self.recid)
                })
            target = '/youraccount/login' + \
                     make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)

        unordered_tabs = get_detailed_page_tabs(get_colID(
            guess_primary_collection_of_a_record(self.recid)),
                                                self.recid,
                                                ln=ln)
        ordered_tabs_id = [(tab_id, values['order'])
                           for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % ln
        tabs = [(unordered_tabs[tab_id]['label'], \
                 '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \
                 tab_id in ['holdings'],
                 unordered_tabs[tab_id]['enabled']) \
                for (tab_id, _order) in ordered_tabs_id
                if unordered_tabs[tab_id]['visible'] == True]
        top = webstyle_templates.detailed_record_container_top(
            self.recid, tabs, argd['ln'])
        bottom = webstyle_templates.detailed_record_container_bottom(
            self.recid, tabs, argd['ln'])

        title = websearch_templates.tmpl_record_page_header_content(
            req, self.recid, argd['ln'])[0]
        navtrail = create_navtrail_links(
            cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
        navtrail += ' &gt; <a class="navtrail" href="%s/record/%s?ln=%s">' % (
            CFG_SITE_URL, self.recid, argd['ln'])
        navtrail += title
        navtrail += '</a>'

        return pageheaderonly(title=title,
                              navtrail=navtrail,
                              uid=uid,
                              verbose=1,
                              req=req,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
                              top + body + bottom + \
                              websearch_templates.tmpl_search_pageend(argd['ln']) + \
                              pagefooteronly(lastupdated=__lastupdated__,
                                             language=argd['ln'], req=req)
Esempio n. 18
0
    def display(self, req, form):
        """
        Show the tab 'holdings'.
        """

        argd = wash_urlargd(
            form, {
                'do': (str, "od"),
                'ds': (str, "all"),
                'nb': (int, 100),
                'p': (int, 1),
                'voted': (int, -1),
                'reported': (int, -1),
            })
        _ = gettext_set_language(argd['ln'])

        record_exists_p = record_exists(self.recid)
        if record_exists_p != 1:
            if record_exists_p == -1:
                msg = _("The record has been deleted.")
            else:
                msg = _("Requested record does not seem to exist.")
            msg = '<span class="quicknote">' + msg + '</span>'
            title, description, keywords = \
                   websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])
            return page(title=title,
                        show_title_p=False,
                        body=msg,
                        description=description,
                        keywords=keywords,
                        uid=getUid(req),
                        language=argd['ln'],
                        req=req,
                        navmenuid='search')

        body = perform_get_holdings_information(self.recid, req, argd['ln'])

        uid = getUid(req)

        user_info = collect_user_info(req)
        (auth_code,
         auth_msg) = check_user_can_view_record(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest':
            cookie = mail_cookie_create_authorize_action(
                VIEWRESTRCOLL, {
                    'collection': guess_primary_collection_of_a_record(
                        self.recid)
                })
            target = '/youraccount/login' + \
                make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target, norobot=True)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)

        unordered_tabs = get_detailed_page_tabs(get_colID(
            guess_primary_collection_of_a_record(self.recid)),
                                                self.recid,
                                                ln=argd['ln'])
        ordered_tabs_id = [(tab_id, values['order'])
                           for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % argd['ln']
        tabs = [(unordered_tabs[tab_id]['label'], \
                 '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \
                 tab_id in ['holdings'],
                 unordered_tabs[tab_id]['enabled']) \
                for (tab_id, _order) in ordered_tabs_id
                if unordered_tabs[tab_id]['visible'] == True]
        top = webstyle_templates.detailed_record_container_top(
            self.recid, tabs, argd['ln'])
        bottom = webstyle_templates.detailed_record_container_bottom(
            self.recid, tabs, argd['ln'])

        title = websearch_templates.tmpl_record_page_header_content(
            req, self.recid, argd['ln'])[0]
        navtrail = create_navtrail_links(
            cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
        navtrail += ' &gt; <a class="navtrail" href="%s/record/%s?ln=%s">' % (
            CFG_SITE_URL, self.recid, argd['ln'])
        navtrail += title
        navtrail += '</a>'

        return pageheaderonly(title=title,
                              navtrail=navtrail,
                              uid=uid,
                              verbose=1,
                              req=req,
                              metaheaderadd = "<link rel=\"stylesheet\" href=\"%s/img/jquery-ui.css\" type=\"text/css\" />" % CFG_SITE_URL,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
                              top + body + bottom + \
                              websearch_templates.tmpl_search_pageend(argd['ln']) + \
                              pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req)
Esempio n. 19
0
    def display(self, req, form):
        """
        Display comments (reviews if enabled) associated with record having id recid where recid>0.
        This function can also be used to display remarks associated with basket having id recid where recid<-99.
        @param ln: language
        @param recid: record id, integer
        @param do: display order    hh = highest helpful score, review only
                                    lh = lowest helpful score, review only
                                    hs = highest star score, review only
                                    ls = lowest star score, review only
                                    od = oldest date
                                    nd = newest date
        @param ds: display since    all= no filtering by date
                                    nd = n days ago
                                    nw = n weeks ago
                                    nm = n months ago
                                    ny = n years ago
                                    where n is a single digit integer between 0 and 9
        @param nb: number of results per page
        @param p: results page
        @param voted: boolean, active if user voted for a review, see vote function
        @param reported: int, active if user reported a certain comment/review, see report function
        @param reviews: boolean, enabled for reviews, disabled for comments
        @param subscribed: int, 1 if user just subscribed to discussion, -1 if unsubscribed
        @return the full html page.
        """
        argd = wash_urlargd(
            form,
            {
                'do': (str, "od"),
                'ds': (str, "all"),
                'nb': (int, 100),
                'p': (int, 1),
                'voted': (int, -1),
                'reported': (int, -1),
                'subscribed': (int, 0),
                'cmtgrp': (list, ["latest"]
                           )  # 'latest' is now a reserved group/round name
            })

        _ = gettext_set_language(argd['ln'])
        uid = getUid(req)

        user_info = collect_user_info(req)
        (auth_code,
         auth_msg) = check_user_can_view_comments(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest':
            cookie = mail_cookie_create_authorize_action(
                VIEWRESTRCOLL, {
                    'collection': guess_primary_collection_of_a_record(
                        self.recid)
                })
            target = '/youraccount/login' + \
                make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_SECURE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target, norobot=True)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)

        can_send_comments = False
        (auth_code,
         auth_msg) = check_user_can_send_comments(user_info, self.recid)
        if not auth_code:
            can_send_comments = True

        can_attach_files = False
        (auth_code, auth_msg) = check_user_can_attach_file_to_comments(
            user_info, self.recid)
        if not auth_code and (user_info['email'] != 'guest'):
            can_attach_files = True

        subscription = get_user_subscription_to_discussion(self.recid, uid)
        if subscription == 1:
            user_is_subscribed_to_discussion = True
            user_can_unsubscribe_from_discussion = True
        elif subscription == 2:
            user_is_subscribed_to_discussion = True
            user_can_unsubscribe_from_discussion = False
        else:
            user_is_subscribed_to_discussion = False
            user_can_unsubscribe_from_discussion = False

        unordered_tabs = get_detailed_page_tabs(get_colID(
            guess_primary_collection_of_a_record(self.recid)),
                                                self.recid,
                                                ln=argd['ln'])
        ordered_tabs_id = [(tab_id, values['order'])
                           for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % argd['ln']

        tabs = [(unordered_tabs[tab_id]['label'], \
                 '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \
                 tab_id in ['comments', 'reviews'],
                 unordered_tabs[tab_id]['enabled']) \
                for (tab_id, order) in ordered_tabs_id
                if unordered_tabs[tab_id]['visible'] == True]

        tabs_counts = get_detailed_page_tabs_counts(self.recid)
        citedbynum = tabs_counts['Citations']
        references = tabs_counts['References']
        discussions = tabs_counts['Discussions']

        top = webstyle_templates.detailed_record_container_top(
            self.recid,
            tabs,
            argd['ln'],
            citationnum=citedbynum,
            referencenum=references,
            discussionnum=discussions)
        bottom = webstyle_templates.detailed_record_container_bottom(
            self.recid, tabs, argd['ln'])

        #display_comment_rounds = [cmtgrp for cmtgrp in argd['cmtgrp'] if cmtgrp.isdigit() or cmtgrp == "all" or cmtgrp == "-1"]
        display_comment_rounds = argd['cmtgrp']

        check_warnings = []

        (ok, problem) = check_recID_is_in_range(self.recid, check_warnings,
                                                argd['ln'])
        if ok:
            body = perform_request_display_comments_or_remarks(
                req=req,
                recID=self.recid,
                display_order=argd['do'],
                display_since=argd['ds'],
                nb_per_page=argd['nb'],
                page=argd['p'],
                ln=argd['ln'],
                voted=argd['voted'],
                reported=argd['reported'],
                subscribed=argd['subscribed'],
                reviews=self.discussion,
                uid=uid,
                can_send_comments=can_send_comments,
                can_attach_files=can_attach_files,
                user_is_subscribed_to_discussion=
                user_is_subscribed_to_discussion,
                user_can_unsubscribe_from_discussion=
                user_can_unsubscribe_from_discussion,
                display_comment_rounds=display_comment_rounds)

            title, description, keywords = websearch_templates.tmpl_record_page_header_content(
                req, self.recid, argd['ln'])
            navtrail = create_navtrail_links(
                cc=guess_primary_collection_of_a_record(self.recid),
                ln=argd['ln'])
            if navtrail:
                navtrail += ' &gt; '
            navtrail += '<a class="navtrail" href="%s/%s/%s?ln=%s">' % (
                CFG_SITE_URL, CFG_SITE_RECORD, self.recid, argd['ln'])
            navtrail += title
            navtrail += '</a>'
            navtrail += ' &gt; <a class="navtrail">%s</a>' % (
                self.discussion == 1 and _("Reviews") or _("Comments"))

            mathjaxheader = ''
            if CFG_WEBCOMMENT_USE_MATHJAX_IN_COMMENTS:
                mathjaxheader = get_mathjax_header(req.is_https())
            jqueryheader = '''
            <script src="%(CFG_SITE_URL)s/js/jquery.MultiFile.pack.js" type="text/javascript" language="javascript"></script>
            ''' % {
                'CFG_SITE_URL': CFG_SITE_URL
            }


            return pageheaderonly(title=title,
                        navtrail=navtrail,
                        uid=uid,
                        verbose=1,
                        metaheaderadd = mathjaxheader + jqueryheader,
                        req=req,
                        language=argd['ln'],
                        navmenuid='search',
                        navtrail_append_title_p=0) + \
                    websearch_templates.tmpl_search_pagestart(argd['ln']) + \
                    top + body + bottom + \
                    websearch_templates.tmpl_search_pageend(argd['ln']) + \
                    pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req)
        else:
            return page(title=_("Record Not Found"),
                        body=problem,
                        uid=uid,
                        verbose=1,
                        req=req,
                        language=argd['ln'],
                        navmenuid='search')
    def send(self, req, form):
        """
        Create a new hold request.
        """
        argd = wash_urlargd(form, {'period_from': (str, ""),
                                   'period_to': (str, ""),
                                   'barcode': (str, "")
                                   })

        uid = getUid(req)

        body = perform_new_request_send(recid=self.recid,
                                        uid=uid,
                                        period_from=argd['period_from'],
                                        period_to=argd['period_to'],
                                        barcode=argd['barcode'])

        ln = CFG_SITE_LANG
        _ = gettext_set_language(ln)


        user_info = collect_user_info(req)
        (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']:
            cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)})
            target = '/youraccount/login' + \
                     make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)



        unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)),
                                                    self.recid,
                                                    ln=ln)
        ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % ln
        tabs = [(unordered_tabs[tab_id]['label'], \
                 '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \
                 tab_id in ['holdings'],
                 unordered_tabs[tab_id]['enabled']) \
                for (tab_id, _order) in ordered_tabs_id
                if unordered_tabs[tab_id]['visible'] == True]
        top = webstyle_templates.detailed_record_container_top(self.recid,
                                                               tabs,
                                                               argd['ln'])
        bottom = webstyle_templates.detailed_record_container_bottom(self.recid,
                                                                     tabs,
                                                                     argd['ln'])

        title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0]
        navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
        navtrail += ' &gt; <a class="navtrail" href="%s/record/%s?ln=%s">'% (CFG_SITE_URL, self.recid, argd['ln'])
        navtrail += title
        navtrail += '</a>'

        return pageheaderonly(title=title,
                              navtrail=navtrail,
                              uid=uid,
                              verbose=1,
                              req=req,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
                              top + body + bottom + \
                              websearch_templates.tmpl_search_pageend(argd['ln']) + \
                              pagefooteronly(lastupdated=__lastupdated__,
                                             language=argd['ln'], req=req)
    def display(self, req, form):
        """
        Display comments (reviews if enabled) associated with record having id recid where recid>0.
        This function can also be used to display remarks associated with basket having id recid where recid<-99.
        @param ln: language
        @param recid: record id, integer
        @param do: display order    hh = highest helpful score, review only
                                    lh = lowest helpful score, review only
                                    hs = highest star score, review only
                                    ls = lowest star score, review only
                                    od = oldest date
                                    nd = newest date
        @param ds: display since    all= no filtering by date
                                    nd = n days ago
                                    nw = n weeks ago
                                    nm = n months ago
                                    ny = n years ago
                                    where n is a single digit integer between 0 and 9
        @param nb: number of results per page
        @param p: results page
        @param voted: boolean, active if user voted for a review, see vote function
        @param reported: int, active if user reported a certain comment/review, see report function
        @param reviews: boolean, enabled for reviews, disabled for comments
        @param subscribed: int, 1 if user just subscribed to discussion, -1 if unsubscribed
        @return the full html page.
        """

        argd = wash_urlargd(
            form,
            {
                "do": (str, "od"),
                "ds": (str, "all"),
                "nb": (int, 100),
                "p": (int, 1),
                "voted": (int, -1),
                "reported": (int, -1),
                "subscribed": (int, 0),
                "cmtgrp": (list, ["latest"]),  # 'latest' is now a reserved group/round name
            },
        )

        _ = gettext_set_language(argd["ln"])
        uid = getUid(req)

        user_info = collect_user_info(req)
        (auth_code, auth_msg) = check_user_can_view_comments(user_info, self.recid)
        if auth_code and user_info["email"] == "guest":
            cookie = mail_cookie_create_authorize_action(
                VIEWRESTRCOLL, {"collection": guess_primary_collection_of_a_record(self.recid)}
            )
            target = "/youraccount/login" + make_canonical_urlargd(
                {"action": cookie, "ln": argd["ln"], "referer": CFG_SITE_URL + user_info["uri"]}, {}
            )
            return redirect_to_url(req, target, norobot=True)
        elif auth_code:
            return page_not_authorized(req, "../", text=auth_msg)

        can_send_comments = False
        (auth_code, auth_msg) = check_user_can_send_comments(user_info, self.recid)
        if not auth_code:
            can_send_comments = True

        can_attach_files = False
        (auth_code, auth_msg) = check_user_can_attach_file_to_comments(user_info, self.recid)
        if not auth_code and (user_info["email"] != "guest"):
            can_attach_files = True

        subscription = get_user_subscription_to_discussion(self.recid, uid)
        if subscription == 1:
            user_is_subscribed_to_discussion = True
            user_can_unsubscribe_from_discussion = True
        elif subscription == 2:
            user_is_subscribed_to_discussion = True
            user_can_unsubscribe_from_discussion = False
        else:
            user_is_subscribed_to_discussion = False
            user_can_unsubscribe_from_discussion = False

        # display_comment_rounds = [cmtgrp for cmtgrp in argd['cmtgrp'] if cmtgrp.isdigit() or cmtgrp == "all" or cmtgrp == "-1"]
        display_comment_rounds = argd["cmtgrp"]

        check_warnings = []

        (ok, problem) = check_recID_is_in_range(self.recid, check_warnings, argd["ln"])
        if ok:
            (body, errors, warnings) = perform_request_display_comments_or_remarks(
                req=req,
                recID=self.recid,
                display_order=argd["do"],
                display_since=argd["ds"],
                nb_per_page=argd["nb"],
                page=argd["p"],
                ln=argd["ln"],
                voted=argd["voted"],
                reported=argd["reported"],
                subscribed=argd["subscribed"],
                reviews=self.discussion,
                uid=uid,
                can_send_comments=can_send_comments,
                can_attach_files=can_attach_files,
                user_is_subscribed_to_discussion=user_is_subscribed_to_discussion,
                user_can_unsubscribe_from_discussion=user_can_unsubscribe_from_discussion,
                display_comment_rounds=display_comment_rounds,
            )

            unordered_tabs = get_detailed_page_tabs(
                get_colID(guess_primary_collection_of_a_record(self.recid)), self.recid, ln=argd["ln"]
            )
            ordered_tabs_id = [(tab_id, values["order"]) for (tab_id, values) in unordered_tabs.iteritems()]
            ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
            link_ln = ""
            if argd["ln"] != CFG_SITE_LANG:
                link_ln = "?ln=%s" % argd["ln"]
            tabs = [
                (
                    unordered_tabs[tab_id]["label"],
                    "%s/record/%s/%s%s" % (CFG_SITE_URL, self.recid, tab_id, link_ln),
                    tab_id in ["comments", "reviews"],
                    unordered_tabs[tab_id]["enabled"],
                )
                for (tab_id, order) in ordered_tabs_id
                if unordered_tabs[tab_id]["visible"] == True
            ]
            top = webstyle_templates.detailed_record_container_top(self.recid, tabs, argd["ln"])
            bottom = webstyle_templates.detailed_record_container_bottom(self.recid, tabs, argd["ln"])

            title, description, keywords = websearch_templates.tmpl_record_page_header_content(
                req, self.recid, argd["ln"]
            )
            navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd["ln"])
            if navtrail:
                navtrail += " &gt; "
            navtrail += '<a class="navtrail" href="%s/record/%s?ln=%s">' % (CFG_SITE_URL, self.recid, argd["ln"])
            navtrail += title
            navtrail += "</a>"
            navtrail += ' &gt; <a class="navtrail">%s</a>' % (self.discussion == 1 and _("Reviews") or _("Comments"))

            mathjaxheader = ""
            if CFG_WEBCOMMENT_USE_MATHJAX_IN_COMMENTS:
                mathjaxheader = """<script src='/MathJax/MathJax.js' type='text/javascript'></script>"""
            jqueryheader = """
            <script src="%(CFG_SITE_URL)s/js/jquery.min.js" type="text/javascript" language="javascript"></script>
            <script src="%(CFG_SITE_URL)s/js/jquery.MultiFile.pack.js" type="text/javascript" language="javascript"></script>
            """ % {
                "CFG_SITE_URL": CFG_SITE_URL
            }

            return (
                pageheaderonly(
                    title=title,
                    navtrail=navtrail,
                    uid=uid,
                    verbose=1,
                    metaheaderadd=mathjaxheader + jqueryheader,
                    req=req,
                    language=argd["ln"],
                    navmenuid="search",
                    navtrail_append_title_p=0,
                )
                + websearch_templates.tmpl_search_pagestart(argd["ln"])
                + top
                + body
                + bottom
                + websearch_templates.tmpl_search_pageend(argd["ln"])
                + pagefooteronly(lastupdated=__lastupdated__, language=argd["ln"], req=req)
            )
        else:
            return page(
                title=_("Record Not Found"),
                body=problem,
                uid=uid,
                verbose=1,
                req=req,
                language=argd["ln"],
                warnings=check_warnings,
                errors=[],
                navmenuid="search",
            )
    def display(self, req, form):
        """
        Display the linkbacks of a record and admin approve/reject features
        """
        argd = wash_urlargd(form, {})

        _ = gettext_set_language(argd['ln'])

        # Check authorization
        uid = getUid(req)
        user_info = collect_user_info(req)

        (auth_code, auth_msg) = check_user_can_view_linkbacks(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest':
            # Ask to login
            target = CFG_SITE_SECURE_URL + '/youraccount/login' + \
                     make_canonical_urlargd({'ln': argd['ln'],
                                             'referer': CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target)
        elif auth_code:
            return page_not_authorized(req,
                                       referer="../",
                                       uid=uid,
                                       text=auth_msg,
                                       ln=argd['ln'])

        show_admin = False
        (auth_code, auth_msg) = acc_authorize_action(req, 'moderatelinkbacks', collection = guess_primary_collection_of_a_record(self.recid))
        if not auth_code:
            show_admin = True

        body = perform_request_display_record_linbacks(req, self.recid, show_admin, weblinkback_templates=weblinkback_templates, ln=argd['ln'])

        title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0]

        # navigation, tabs, top and bottom part
        navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
        if navtrail:
            navtrail += ' &gt; '
        navtrail += '<a class="navtrail" href="%s/%s/%s?ln=%s">'% (CFG_SITE_URL, CFG_SITE_RECORD, self.recid, argd['ln'])
        navtrail += title
        navtrail += '</a>'
        navtrail += ' &gt; <a class="navtrail">Linkbacks</a>'

        mathjaxheader, jqueryheader = weblinkback_templates.tmpl_get_mathjaxheader_jqueryheader()

        unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)),
                                                self.recid,
                                                ln=argd['ln'])
        ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % argd['ln']
        tabs = [(unordered_tabs[tab_id]['label'], \
                     '%s/%s/%s/%s%s' % (CFG_SITE_URL, CFG_SITE_RECORD, self.recid, tab_id, link_ln), \
                     tab_id in ['linkbacks'],
                     unordered_tabs[tab_id]['enabled']) \
                     for (tab_id, values) in ordered_tabs_id
                     if unordered_tabs[tab_id]['visible'] == True]
        top = webstyle_templates.detailed_record_container_top(self.recid,
                                                              tabs,
                                                              argd['ln'])
        bottom = webstyle_templates.detailed_record_container_bottom(self.recid,
                                                                    tabs,
                                                                    argd['ln'])

        return pageheaderonly(title=title,
                              navtrail=navtrail,
                              uid=uid,
                              verbose=1,
                              metaheaderadd = mathjaxheader + jqueryheader,
                              req=req,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
               top + body + bottom + \
               websearch_templates.tmpl_search_pageend(argd['ln']) + \
               pagefooteronly(language=argd['ln'], req=req)
Esempio n. 23
0
    def display(self, req, form):
        """
        Display comments (reviews if enabled) associated with record having id recid where recid>0.
        This function can also be used to display remarks associated with basket having id recid where recid<-99.
        @param ln: language
        @param recid: record id, integer
        @param do: display order    hh = highest helpful score, review only
                                    lh = lowest helpful score, review only
                                    hs = highest star score, review only
                                    ls = lowest star score, review only
                                    od = oldest date
                                    nd = newest date
        @param ds: display since    all= no filtering by date
                                    nd = n days ago
                                    nw = n weeks ago
                                    nm = n months ago
                                    ny = n years ago
                                    where n is a single digit integer between 0 and 9
        @param nb: number of results per page
        @param p: results page
        @param voted: boolean, active if user voted for a review, see vote function
        @param reported: int, active if user reported a certain comment/review, see report function
        @param reviews: boolean, enabled for reviews, disabled for comments
        @param subscribed: int, 1 if user just subscribed to discussion, -1 if unsubscribed
        @return the full html page.
        """

        argd = wash_urlargd(form, {'do': (str, "od"),
                                   'ds': (str, "all"),
                                   'nb': (int, 100),
                                   'p': (int, 1),
                                   'voted': (int, -1),
                                   'reported': (int, -1),
                                   'subscribed': (int, 0),
                                   'cmtgrp': (list, ["latest"]) # 'latest' is now a reserved group/round name
                                   })

        _ = gettext_set_language(argd['ln'])
        uid = getUid(req)

        user_info = collect_user_info(req)
        (auth_code, auth_msg) = check_user_can_view_comments(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']:
            cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)})
            target = '/youraccount/login' + \
                make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target, norobot=True)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)

        can_send_comments = False
        (auth_code, auth_msg) = check_user_can_send_comments(user_info, self.recid)
        if not auth_code:
            can_send_comments = True

        can_attach_files = False
        (auth_code, auth_msg) = check_user_can_attach_file_to_comments(user_info, self.recid)
        if not auth_code and (user_info['email'] != 'guest' or user_info['apache_user']):
            can_attach_files = True

        subscription = get_user_subscription_to_discussion(self.recid, uid)
        if subscription == 1:
            user_is_subscribed_to_discussion = True
            user_can_unsubscribe_from_discussion = True
        elif subscription == 2:
            user_is_subscribed_to_discussion = True
            user_can_unsubscribe_from_discussion = False
        else:
            user_is_subscribed_to_discussion = False
            user_can_unsubscribe_from_discussion = False

        #display_comment_rounds = [cmtgrp for cmtgrp in argd['cmtgrp'] if cmtgrp.isdigit() or cmtgrp == "all" or cmtgrp == "-1"]
        display_comment_rounds = argd['cmtgrp']

        check_warnings = []

        (ok, problem) = check_recID_is_in_range(self.recid, check_warnings, argd['ln'])
        if ok:
            (body, errors, warnings) = perform_request_display_comments_or_remarks(req=req, recID=self.recid,
                display_order=argd['do'],
                display_since=argd['ds'],
                nb_per_page=argd['nb'],
                page=argd['p'],
                ln=argd['ln'],
                voted=argd['voted'],
                reported=argd['reported'],
                subscribed=argd['subscribed'],
                reviews=self.discussion,
                uid=uid,
                can_send_comments=can_send_comments,
                can_attach_files=can_attach_files,
                user_is_subscribed_to_discussion=user_is_subscribed_to_discussion,
                user_can_unsubscribe_from_discussion=user_can_unsubscribe_from_discussion,
                display_comment_rounds=display_comment_rounds
                )

            unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)),
                                                    self.recid,
                                                    ln=argd['ln'])
            ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()]
            ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
            link_ln = ''
            if argd['ln'] != CFG_SITE_LANG:
                link_ln = '?ln=%s' % argd['ln']
            tabs = [(unordered_tabs[tab_id]['label'], \
                     '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \
                     tab_id in ['comments', 'reviews'],
                     unordered_tabs[tab_id]['enabled']) \
                    for (tab_id, order) in ordered_tabs_id
                    if unordered_tabs[tab_id]['visible'] == True]
            top = webstyle_templates.detailed_record_container_top(self.recid,
                                                                    tabs,
                                                                    argd['ln'])
            bottom = webstyle_templates.detailed_record_container_bottom(self.recid,
                                                                         tabs,
                                                                         argd['ln'])

            title, description, keywords = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])
            navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
            if navtrail:
                navtrail += ' &gt; '
            navtrail += '<a class="navtrail" href="%s/record/%s?ln=%s">'% (CFG_SITE_URL, self.recid, argd['ln'])
            navtrail += title
            navtrail += '</a>'
            navtrail += ' &gt; <a class="navtrail">%s</a>' % (self.discussion==1 and _("Reviews") or _("Comments"))

            jsmathheader = ''
            if CFG_WEBCOMMENT_USE_JSMATH_IN_COMMENTS:
                jsmathheader = """ <script type='text/javascript'>
                                    jsMath = {
                                        Controls: {cookie: {printwarn: 0}}
                                    };
                                    </script>
                                    <script src='/jsMath/easy/invenio-jsmath.js' type='text/javascript'></script>
                               """
            jqueryheader = '''
            <script src="%(CFG_SITE_URL)s/js/jquery.min.js" type="text/javascript" language="javascript"></script>
            <script src="%(CFG_SITE_URL)s/js/jquery.MultiFile.pack.js" type="text/javascript" language="javascript"></script>
            ''' % {'CFG_SITE_URL': CFG_SITE_URL}


            return pageheaderonly(title=title,
                        navtrail=navtrail,
                        uid=uid,
                        verbose=1,
                        metaheaderadd = jsmathheader + jqueryheader,
                        req=req,
                        language=argd['ln'],
                        navmenuid='search',
                        navtrail_append_title_p=0) + \
                    websearch_templates.tmpl_search_pagestart(argd['ln']) + \
                    top + body + bottom + \
                    websearch_templates.tmpl_search_pageend(argd['ln']) + \
                    pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req)
        else:
            return page(title=_("Record Not Found"),
                        body=problem,
                        uid=uid,
                        verbose=1,
                        req=req,
                        language=argd['ln'],
                        warnings=check_warnings, errors=[],
                        navmenuid='search')
Esempio n. 24
0
def index(req):
    req.content_type = "text/html"
    req.write(pageheaderonly("Compliance checks", req=req))
    req.write("<h1>Compliance checks:</h1>")

    journal_list_html = ''
    journal_list_html += "<ol id='selectable'>"
    for key in (sorted(JOURNALS_PDFA.keys())
                + sorted(JOURNALS_NO_PDFA.keys())
                + sorted(JOURNALS_NO_XML.keys())):
        journal_list_html += "<li>" + key + "</li>"
    journal_list_html += "</ol>"
    req.write(journal_list_html)

    req.write("<br/>")
    req.write("<br/>")
    req.write("<select id='date_selector'><option>created</option><option>modified</option></select>")
    req.write(" between:")
    req.write("<input type='text' id='datepicker_from'>")
    req.write(" and:")
    req.write("<input type='text' id='datepicker_to'>")
    req.write("<select id='loadall'><option>Load on scroll</option><option>Load all</option></select>")
    req.write('''
            <button onclick=\"
                cc_button = $(this);
                cc_button.prop('disabled', true);
                var shall_load_all = $('#loadall option:selected').text() == 'Load all';
                var journals = '';
                $('.ui-selected').each(
                    function(index) {
                        journals += $(this).text() + ' ';
                    }
                );

                var from_date = $('#datepicker_from').val();
                var to_date = $('#datepicker_to').val();

                var selected_date = $('#date_selector option:selected').text();

                var recid_list = new Array();

                $.get('/compliance.py/get_recid_list', {collections:journals, from_date:from_date, to_date:to_date, created_or_modified_date:selected_date}).done(function(data){
                    count = 0;
                    sublists = new Array();
                    $('#content').html('');

                    if(data == '') {
                        cc_button.prop('disabled', false);
                        $('#content').html('No data for your selection.');
                        return;
                    }

                    var tmp = data.split('\\'').join('').split(' ').join('');
                    var reclist = tmp.substring(1, tmp.length - 1).split(',');

                    batchSize = 100;
                    iterations = reclist.length / batchSize;

                    for(var i = 0; i < iterations; i++){
                        sublists.push(reclist.slice(i*batchSize, (i+1)*batchSize));
                    }

                    if(shall_load_all){
                        load_all();
                    } else {
                        fill_window();
                    }
                });

                \">Check Compliance</button>
        ''')

    req.write('''
            <button onclick=\"
                var journals = '';
                $('.ui-selected').each(
                    function(index) {
                        journals += $(this).text() + ' ';
                    }
                );

                from_date = $('#datepicker_from').val();
                to_date = $('#datepicker_to').val();

                selected_date = $('#date_selector option:selected').text();

                var iframe = document.createElement('iframe');
                iframe.src = '/compliance.py/check_compliance_csv?collections=' + journals + '&from_date=' + from_date + '&to_date=' + to_date + '&created_or_modified_date=' + selected_date;
                iframe.style.display = 'none';
                document.body.appendChild(iframe);

                \">CSV</button>
        ''')

    req.write("<script src='../js/jquery-ui.min.js'></script>")
    req.write('''
        <script>
            function load_all(){
                $('#loadingfield').html('Loading...');
                if(count >= iterations){
                    $('#loadingfield').html('');
                    cc_button.prop('disabled', false);
                    return;
                }
                recs = sublists[count].join();
                $.get('/compliance.py/get_record_checks', {recids:recs}).done(function(data){
                    $('#content').append(data);
                    count += 1;
                    load_all();
                });
            }
            function fill_window(){
                $('#loadingfield').html('Loading...');
                if($(document).height() > $(window).height() || count == sublists.length){
                    $('#loadingfield').html('');
                    cc_button.prop('disabled', false);
                    return;
                }
                recs = sublists[count].join();
                $.get('/compliance.py/get_record_checks', {recids:recs}).done(function(data){
                    $('#content').append(data);
                    count += 1;
                    fill_window();
                });
            }
            function next(){
                if(count >= iterations){
                    return;
                }
                $('#loadingfield').html('Loading...');
                recs = sublists[count].join();
                $.get('/compliance.py/get_record_checks', {recids:recs}).done(function(data){
                    $('#loadingfield').html('');
                    $('#content').append(data);
                    count += 1;
                });
            }
            sublists = new Array();
            var count = 0;
            var iterations = 0;
            var cc_button;
            $(function() {$(\"#datepicker_from\").datepicker({ dateFormat: 'yy-mm-dd', maxDate: '+0d', changeMonth: true, changeYear: true });});
            $(function() {$(\"#datepicker_to\").datepicker({ dateFormat: 'yy-mm-dd', maxDate: '+0d', changeMonth: true, changeYear: true });});
            $(function() {$(\"#selectable\").selectable();});
            $(function() {$(\"#selectable\").css("list-style-type", "none");});
            $(window).scroll(function(){
                if($(window).scrollTop() == $(document).height() - $(window).height()){
                    next();
                }
            });
        </script>''')

    req.write("<table id=\"content\" class=\"compliance\"></table>")
    req.write("<div id='loadingfield' style='text-align:center; font-weight:bold;'></div>")
    req.write(pagefooteronly(req=req))
    req.flush()
    def ill_register_request_with_recid(self, req, form):
        """
        Register ILL request.
        """

        argd = wash_urlargd(form, {'ln': (str, ""),
                                   'period_of_interest_from': (str, ""),
                                   'period_of_interest_to': (str, ""),
                                   'additional_comments': (str, ""),
                                   'conditions': (str, ""),
                                   'only_edition': (str, ""),
                                   })

        _ = gettext_set_language(argd['ln'])
        uid = getUid(req)

        body = ill_register_request_with_recid(recid=self.recid,
                                               uid=uid,
                                               period_of_interest_from =  argd['period_of_interest_from'],
                                               period_of_interest_to =  argd['period_of_interest_to'],
                                               additional_comments =  argd['additional_comments'],
                                               conditions = argd['conditions'],
                                               only_edition = argd['only_edition'],
                                               ln=argd['ln'])

        uid = getUid(req)
        if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
            return page_not_authorized(req, "../holdings/ill_request_with_recid",
                                       navmenuid = 'yourbaskets')

        if isGuestUser(uid):
            if not CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS:
                return redirect_to_url(req, "%s/youraccount/login%s" % (
                    CFG_SITE_SECURE_URL,
                        make_canonical_urlargd({
                    'referer' : "%s/record/%s/holdings/ill_request_with_recid%s" % (
                        CFG_SITE_URL,
                        self.recid,
                        make_canonical_urlargd(argd, {})),
                    "ln" : argd['ln']}, {})))


        user_info = collect_user_info(req)
        (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']:
            cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)})
            target = '/youraccount/login' + \
                     make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)



        unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)),
                                                    self.recid,
                                                    ln=argd['ln'])
        ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % argd['ln']
        tabs = [(unordered_tabs[tab_id]['label'], \
                 '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \
                 tab_id in ['holdings'],
                 unordered_tabs[tab_id]['enabled']) \
                for (tab_id, _order) in ordered_tabs_id
                if unordered_tabs[tab_id]['visible'] == True]
        top = webstyle_templates.detailed_record_container_top(self.recid,
                                                               tabs,
                                                               argd['ln'])
        bottom = webstyle_templates.detailed_record_container_bottom(self.recid,
                                                                     tabs,
                                                                     argd['ln'])

        title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0]
        navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
        navtrail += ' &gt; <a class="navtrail" href="%s/record/%s?ln=%s">'% (CFG_SITE_URL, self.recid, argd['ln'])
        navtrail += title
        navtrail += '</a>'

        return pageheaderonly(title=title,
                              navtrail=navtrail,
                              uid=uid,
                              verbose=1,
                              req=req,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
                              top + body + bottom + \
                              websearch_templates.tmpl_search_pageend(argd['ln']) + \
                              pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req)
Esempio n. 26
0
def index(req):
    req.content_type = "text/html"
    req.write(pageheaderonly("Compliance checks", req=req))
    req.write("<h1>Compliance checks:</h1>")

    journal_list_html = ''
    journal_list_html += "<ol id='selectable'>"
    for key in (sorted(JOURNALS_PDFA.keys())
                + sorted(JOURNALS_NO_PDFA.keys())
                + sorted(JOURNALS_NO_XML.keys())):
        journal_list_html += "<li>" + key + "</li>"
    journal_list_html += "</ol>"
    req.write(journal_list_html)

    req.write("<br/>")
    req.write("<br/>")
    req.write("<select id='date_selector'><option>created</option><option>modified</option></select>")
    req.write(" between:")
    req.write("<input type='text' id='datepicker_from'>")
    req.write(" and:")
    req.write("<input type='text' id='datepicker_to'>")
    req.write("<select id='loadall'><option>Load on scroll</option><option>Load all</option></select>")
    req.write('''
            <button onclick=\"
                cc_button = $(this);
                cc_button.prop('disabled', true);
                var shall_load_all = $('#loadall option:selected').text() == 'Load all';
                var journals = '';
                $('.ui-selected').each(
                    function(index) {
                        journals += $(this).text() + ' ';
                    }
                );

                var from_date = $('#datepicker_from').val();
                var to_date = $('#datepicker_to').val();

                var selected_date = $('#date_selector option:selected').text();

                var recid_list = new Array();

                $.get('/compliance.py/get_recid_list', {collections:journals, from_date:from_date, to_date:to_date, created_or_modified_date:selected_date}).done(function(data){
                    count = 0;
                    sublists = new Array();
                    $('#content').html('');

                    if(data == '') {
                        cc_button.prop('disabled', false);
                        $('#content').html('No data for your selection.');
                        return;
                    }

                    var tmp = data.split('\\'').join('').split(' ').join('');
                    var reclist = tmp.substring(1, tmp.length - 1).split(',');

                    batchSize = 100;
                    iterations = reclist.length / batchSize;

                    for(var i = 0; i < iterations; i++){
                        sublists.push(reclist.slice(i*batchSize, (i+1)*batchSize));
                    }

                    if(shall_load_all){
                        load_all();
                    } else {
                        fill_window();
                    }
                });

                \">Check Compliance</button>
        ''')

    req.write('''
            <button onclick=\"
                var journals = '';
                $('.ui-selected').each(
                    function(index) {
                        journals += $(this).text() + ' ';
                    }
                );

                from_date = $('#datepicker_from').val();
                to_date = $('#datepicker_to').val();

                selected_date = $('#date_selector option:selected').text();

                var iframe = document.createElement('iframe');
                iframe.src = '/compliance.py/check_compliance_csv?collections=' + journals + '&from_date=' + from_date + '&to_date=' + to_date + '&created_or_modified_date=' + selected_date;
                iframe.style.display = 'none';
                document.body.appendChild(iframe);

                \">CSV</button>
        ''')

    req.write("<script src='../js/jquery-ui.min.js'></script>")
    req.write('''
        <script>
            function load_all(){
                $('#loadingfield').html('Loading...');
                if(count >= iterations){
                    $('#loadingfield').html('');
                    cc_button.prop('disabled', false);
                    return;
                }
                recs = sublists[count].join();
                $.get('/compliance.py/get_record_checks', {recids:recs}).done(function(data){
                    $('#content').append(data);
                    count += 1;
                    load_all();
                });
            }
            function fill_window(){
                $('#loadingfield').html('Loading...');
                if($(document).height() > $(window).height() || count == sublists.length){
                    $('#loadingfield').html('');
                    cc_button.prop('disabled', false);
                    return;
                }
                recs = sublists[count].join();
                $.get('/compliance.py/get_record_checks', {recids:recs}).done(function(data){
                    $('#content').append(data);
                    count += 1;
                    fill_window();
                });
            }
            function next(){
                if(count >= iterations){
                    return;
                }
                $('#loadingfield').html('Loading...');
                recs = sublists[count].join();
                $.get('/compliance.py/get_record_checks', {recids:recs}).done(function(data){
                    $('#loadingfield').html('');
                    $('#content').append(data);
                    count += 1;
                });
            }
            sublists = new Array();
            var count = 0;
            var iterations = 0;
            var cc_button;
            $(function() {$(\"#datepicker_from\").datepicker({ dateFormat: 'yy-mm-dd', maxDate: '+0d', changeMonth: true, changeYear: true });});
            $(function() {$(\"#datepicker_to\").datepicker({ dateFormat: 'yy-mm-dd', maxDate: '+0d', changeMonth: true, changeYear: true });});
            $(function() {$(\"#selectable\").selectable();});
            $(function() {$(\"#selectable\").css("list-style-type", "none");});
            $(window).scroll(function(){
                if($(window).scrollTop() == $(document).height() - $(window).height()){
                    next();
                }
            });
        </script>''')

    req.write("<table id=\"content\" class=\"compliance\"></table>")
    req.write("<div id='loadingfield' style='text-align:center; font-weight:bold;'></div>")
    req.write(pagefooteronly(req=req))
    req.flush()
Esempio n. 27
0
                        navtrail=create_navtrail_links(cc=cc, aas=0, ln=ln) + \
                                        ''' &gt; <a class="navtrail" href="%s/%s/%s">%s</a>
                                        &gt; %s''' % \
                        (CFG_SITE_URL, CFG_SITE_RECORD, self.recid, title, _("Access to Fulltext")),

                        description=description,
                        keywords=keywords,
                        uid=uid,
                        language=ln,
                        req=req,
                        navmenuid='search',
                        navtrail_append_title_p=0) + \
                        websearch_templates.tmpl_search_pagestart(ln) + \
                        top + t + bottom + \
                        websearch_templates.tmpl_search_pageend(ln) + \
                        pagefooteronly(language=ln, req=req)

        return getfile, []

    def __call__(self, req, form):
        """Called in case of URLs like /CFG_SITE_RECORD/123/files without
           trailing slash.
        """
        args = wash_urlargd(form, bibdocfile_templates.files_default_urlargd)
        ln = args['ln']
        link_ln = ''
        if ln != CFG_SITE_LANG:
            link_ln = '?ln=%s' % ln

        return redirect_to_url(
            req, '%s/%s/%s/files/%s' %
Esempio n. 28
0
def countries_by_publishers(req):
    req.content_type = "text/html"
    print >> req, pageheaderonly("Countries/publishers", req=req)

    ############
    ## PART 1 ##
    # journals = []
    # for pub in CFG_JOURNALS:
    #     ids = perform_request_search(cc=pub)
    #     journals.append((pub, ids))
    # journals.append(("older_than_2014", perform_request_search(cc='older_than_2014')))

    # countries = []
    # for country in sorted(set(NATIONS_DEFAULT_MAP.itervalues())):
    #     ids = perform_request_search(p="country:%s" % (country,)) + perform_request_search(cc='older_than_2014', p="country:%s" % (country,))
    #     countries.append((country, ids))

    req.write("<h1>Number of articles per country per journal</h1>")
    req.write("<h2>Minimum one author from the country</h2>")
    req.flush()
    req.write("<table>\n")
    req.write("<tr><th rowspan=2>Country</th><th colspan=10>Journals</th><th>Other</th></tr>")
    req.write("""<tr>
<td>Acta</td>
<td>Advances in High Energy Physics</td>
<td>Chinese Physics C</td>
<td>European Physical Journal C</td>
<td>Journal of Cosmology and Astroparticle Physics</td>
<td>Journal of High Energy Physics</td>
<td>New Journal of Physics</td>
<td>Nuclear Physics B</td>
<td>Physics Letters B</td>
<td>Progress of Theoretical and Experimental Physics</td>
<td>older_than_2014</td></tr>""")

    for country in sorted(set(NATIONS_DEFAULT_MAP.itervalues())):
        req.write("<tr><td>%s</td>" % (country,))
        for pub in CFG_JOURNALS + ["older_than_2014"]:
            req.write("<td>%s</td>" % perform_request_search(p="country:%s" % (country,), cc=pub))
        req.write("</tr>")

    req.write('</table>')

    ############
    ## PART 2 ##
    # journals = []
    hitcount = {}
    for pub in CFG_JOURNALS + ["older_than_2014"]:
        ids = perform_request_search(cc=pub)
        hitcount[pub] = {}
        for country in sorted(set(NATIONS_DEFAULT_MAP.itervalues())):
            hitcount[pub][country] = 0

        for id in ids:
            record = get_record(id)
            countries = set(record_get_field_values(record, '700', '%', '%', 'w') + record_get_field_values(record, '100', '%', '%', 'w'))
            if len(countries) == 1:
                c = countries.pop()
                if c in set(NATIONS_DEFAULT_MAP.itervalues()):
                    hitcount[pub][countries[0]] += 1

    req.write("<h1>Number of articles per country per journal</h1>")
    req.write("<h2>All author from the country</h2>")
    req.flush()
    req.write("<table>\n")
    req.write("<tr><th rowspan=2>Country</th><th colspan=10>Journals</th><th>Other</th></tr>")
    req.write("""<tr>
<td>Acta</td>
<td>Advances in High Energy Physics</td>
<td>Chinese Physics C</td>
<td>European Physical Journal C</td>
<td>Journal of Cosmology and Astroparticle Physics</td>
<td>Journal of High Energy Physics</td>
<td>New Journal of Physics</td>
<td>Nuclear Physics B</td>
<td>Physics Letters B</td>
<td>Progress of Theoretical and Experimental Physics</td>
<td>older_than_2014</td></tr>""")

    for country in sorted(set(NATIONS_DEFAULT_MAP.itervalues())):
        req.write("<tr><td>%s</td>" % (country,))
        for pub in CFG_JOURNALS + ["older_than_2014"]:
            req.write("<td>%s</td>" % hitcount[pub][country])
        req.write("</tr>")

    req.write('</table>')
    req.write(pagefooteronly(req=req))
    return ""
Esempio n. 29
0
def countries_by_publishers(req):
    req.content_type = "text/html"
    print >> req, pageheaderonly("Countries/publishers", req=req)

    ############
    ## PART 1 ##
    # journals = []
    # for pub in CFG_JOURNALS:
    #     ids = perform_request_search(cc=pub)
    #     journals.append((pub, ids))
    # journals.append(("older_than_2014", perform_request_search(cc='older_than_2014')))

    # countries = []
    # for country in sorted(set(NATIONS_DEFAULT_MAP.itervalues())):
    #     ids = perform_request_search(p="country:%s" % (country,)) + perform_request_search(cc='older_than_2014', p="country:%s" % (country,))
    #     countries.append((country, ids))

    req.write("<h1>Number of articles per country per journal</h1>")
    req.write("<h2>Minimum one author from the country</h2>")
    req.flush()
    req.write("<table>\n")
    req.write("<tr><th rowspan=2>Country</th><th colspan=10>Journals</th><th>Other</th></tr>")
    req.write("""<tr>
<td>Acta</td>
<td>Advances in High Energy Physics</td>
<td>Chinese Physics C</td>
<td>European Physical Journal C</td>
<td>Journal of Cosmology and Astroparticle Physics</td>
<td>Journal of High Energy Physics</td>
<td>New Journal of Physics</td>
<td>Nuclear Physics B</td>
<td>Physics Letters B</td>
<td>Progress of Theoretical and Experimental Physics</td>
<td>older_than_2014</td></tr>""")

    for country in sorted(set(NATIONS_DEFAULT_MAP.itervalues())):
        req.write("<tr><td>%s</td>" % (country,))
        for pub in CFG_JOURNALS + ["older_than_2014"]:
            req.write("<td>%s</td>" % perform_request_search(p="country:%s" % (country,), cc=pub))
        req.write("</tr>")

    req.write('</table>')

    ############
    ## PART 2 ##
    # journals = []
    hitcount = {}
    for pub in CFG_JOURNALS + ["older_than_2014"]:
        ids = perform_request_search(cc=pub)
        hitcount[pub] = {}
        for country in sorted(set(NATIONS_DEFAULT_MAP.itervalues())):
            hitcount[pub][country] = 0

        for id in ids:
            record = get_record(id)
            countries = set(record_get_field_values(record, '700', '%', '%', 'w') + record_get_field_values(record, '100', '%', '%', 'w'))
            if len(countries) == 1:
                c = countries.pop()
                if c in set(NATIONS_DEFAULT_MAP.itervalues()):
                    hitcount[pub][countries[0]] += 1

    req.write("<h1>Number of articles per country per journal</h1>")
    req.write("<h2>All author from the country</h2>")
    req.flush()
    req.write("<table>\n")
    req.write("<tr><th rowspan=2>Country</th><th colspan=10>Journals</th><th>Other</th></tr>")
    req.write("""<tr>
<td>Acta</td>
<td>Advances in High Energy Physics</td>
<td>Chinese Physics C</td>
<td>European Physical Journal C</td>
<td>Journal of Cosmology and Astroparticle Physics</td>
<td>Journal of High Energy Physics</td>
<td>New Journal of Physics</td>
<td>Nuclear Physics B</td>
<td>Physics Letters B</td>
<td>Progress of Theoretical and Experimental Physics</td>
<td>older_than_2014</td></tr>""")

    for country in sorted(set(NATIONS_DEFAULT_MAP.itervalues())):
        req.write("<tr><td>%s</td>" % (country,))
        for pub in CFG_JOURNALS + ["older_than_2014"]:
            req.write("<td>%s</td>" % hitcount[pub][country])
        req.write("</tr>")

    req.write('</table>')
    req.write(pagefooteronly(req=req))
    return ""
                        navtrail=create_navtrail_links(cc=cc, aas=0, ln=ln) + \
                                        ''' &gt; <a class="navtrail" href="%s/%s/%s">%s</a>
                                        &gt; %s''' % \
                        (CFG_SITE_URL, CFG_SITE_RECORD, self.recid, title, _("Access to Fulltext")),

                        description=description,
                        keywords=keywords,
                        uid=uid,
                        language=ln,
                        req=req,
                        navmenuid='search',
                        navtrail_append_title_p=0) + \
                        websearch_templates.tmpl_search_pagestart(ln) + \
                        top + t + bottom + \
                        websearch_templates.tmpl_search_pageend(ln) + \
                        pagefooteronly(language=ln, req=req)
        return getfile, []

    def __call__(self, req, form):
        """Called in case of URLs like /CFG_SITE_RECORD/123/files without
           trailing slash.
        """
        args = wash_urlargd(form, bibdocfile_templates.files_default_urlargd)
        ln = args['ln']
        link_ln = ''
        if ln != CFG_SITE_LANG:
            link_ln = '?ln=%s' % ln

        return redirect_to_url(req, '%s/%s/%s/files/%s' % (CFG_SITE_URL, CFG_SITE_RECORD, self.recid, link_ln))

def bibdocfile_legacy_getfile(req, form):
    def display(self, req, form):
        """
        Show the tab 'holdings'.
        """

        argd = wash_urlargd(form, {'do': (str, "od"),
                                   'ds': (str, "all"),
                                   'nb': (int, 100),
                                   'p': (int, 1),
                                   'voted': (int, -1),
                                   'reported': (int, -1),
                                   })
        _ = gettext_set_language(argd['ln'])

        record_exists_p = record_exists(self.recid)
        if record_exists_p != 1:
            if record_exists_p == -1:
                msg = _("The record has been deleted.")
            else:
                msg = _("Requested record does not seem to exist.")
            msg = '<span class="quicknote">' + msg + '</span>'
            title, description, keywords = \
                   websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])
            return page(title = title,
                        show_title_p = False,
                        body = msg,
                        description = description,
                        keywords = keywords,
                        uid = getUid(req),
                        language = argd['ln'],
                        req = req,
                        navmenuid='search')

        body = perform_get_holdings_information(self.recid, req, argd['ln'])

        uid = getUid(req)


        user_info = collect_user_info(req)
        (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']:
            cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)})
            target = '/youraccount/login' + \
                make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target, norobot=True)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)


        unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)),
                                                    self.recid,
                                                    ln=argd['ln'])
        ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % argd['ln']
        tabs = [(unordered_tabs[tab_id]['label'], \
                 '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \
                 tab_id in ['holdings'],
                 unordered_tabs[tab_id]['enabled']) \
                for (tab_id, _order) in ordered_tabs_id
                if unordered_tabs[tab_id]['visible'] == True]
        top = webstyle_templates.detailed_record_container_top(self.recid,
                                                               tabs,
                                                               argd['ln'])
        bottom = webstyle_templates.detailed_record_container_bottom(self.recid,
                                                                     tabs,
                                                                     argd['ln'])

        title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0]
        navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
        navtrail += ' &gt; <a class="navtrail" href="%s/record/%s?ln=%s">'% (CFG_SITE_URL, self.recid, argd['ln'])
        navtrail += title
        navtrail += '</a>'

        return pageheaderonly(title=title,
                              navtrail=navtrail,
                              uid=uid,
                              verbose=1,
                              req=req,
                              metaheaderadd = "<link rel=\"stylesheet\" href=\"%s/img/jquery-ui.css\" type=\"text/css\" />" % CFG_SITE_URL,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
                              top + body + bottom + \
                              websearch_templates.tmpl_search_pageend(argd['ln']) + \
                              pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req)
Esempio n. 32
0
                                        &gt; %s"""
                    % (CFG_SITE_URL, CFG_SITE_RECORD, self.recid, title, _("Access to Fulltext")),
                    description="",
                    keywords="keywords",
                    uid=uid,
                    language=ln,
                    req=req,
                    navmenuid="search",
                    navtrail_append_title_p=0,
                )
                + websearch_templates.tmpl_search_pagestart(ln)
                + top
                + t
                + bottom
                + websearch_templates.tmpl_search_pageend(ln)
                + pagefooteronly(lastupdated=__lastupdated__, language=ln, req=req)
            )

        return getfile, []

    def __call__(self, req, form):
        """Called in case of URLs like /CFG_SITE_RECORD/123/files without
           trailing slash.
        """
        args = wash_urlargd(form, websubmit_templates.files_default_urlargd)
        ln = args["ln"]
        link_ln = ""
        if ln != CFG_SITE_LANG:
            link_ln = "?ln=%s" % ln

        return redirect_to_url(req, "%s/%s/%s/files/%s" % (CFG_SITE_URL, CFG_SITE_RECORD, self.recid, link_ln))
    def request(self, req, form):
        """
        Show new hold request form.
        """
        argd = wash_urlargd(form, {'ln': (str, ""), 'barcode': (str, "")})

        _ = gettext_set_language(argd['ln'])
        uid = getUid(req)

        body = perform_new_request(recid=self.recid,
                                   barcode=argd['barcode'],
                                   ln=argd['ln'])

        uid = getUid(req)
        if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
            return page_not_authorized(req, "../holdings/request",
                                       navmenuid = 'yourbaskets')

        if isGuestUser(uid):
            if not CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS:
                return redirect_to_url(req, "%s/youraccount/login%s" % (
                    CFG_SITE_SECURE_URL,
                        make_canonical_urlargd({
                    'referer' : "%s/%s/%s/holdings/request%s" % (
                        CFG_SITE_SECURE_URL,
                        CFG_SITE_RECORD,
                        self.recid,
                        make_canonical_urlargd(argd, {})),
                    "ln" : argd['ln']}, {})), norobot=True)


        user_info = collect_user_info(req)
        (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid)
        if auth_code and user_info['email'] == 'guest':
            cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)})
            target = '/youraccount/login' + \
                     make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_SECURE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target, norobot=True)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)



        unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)),
                                                    self.recid,
                                                    ln=argd['ln'])
        ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()]
        ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1]))
        link_ln = ''
        if argd['ln'] != CFG_SITE_LANG:
            link_ln = '?ln=%s' % argd['ln']
        tabs = [(unordered_tabs[tab_id]['label'], \
                 '%s/%s/%s/%s%s' % (CFG_SITE_SECURE_URL, CFG_SITE_RECORD, self.recid, tab_id, link_ln), \
                 tab_id in ['holdings'],
                 unordered_tabs[tab_id]['enabled']) \
                for (tab_id, _order) in ordered_tabs_id
                if unordered_tabs[tab_id]['visible'] == True]
        top = webstyle_templates.detailed_record_container_top(self.recid,
                                                               tabs,
                                                               argd['ln'])
        bottom = webstyle_templates.detailed_record_container_bottom(self.recid,
                                                                     tabs,
                                                                     argd['ln'])

        title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0]
        navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln'])
        navtrail += ' &gt; <a class="navtrail" href="%s/%s/%s?ln=%s">'% (CFG_SITE_SECURE_URL, CFG_SITE_RECORD, self.recid, argd['ln'])
        navtrail += cgi.escape(title)
        navtrail += '</a>'

        return pageheaderonly(title=title,
                              navtrail=navtrail,
                              uid=uid,
                              verbose=1,
                              req=req,
                              metaheaderadd = "<link rel=\"stylesheet\" href=\"%s/img/jquery-ui.css\" type=\"text/css\" />" % CFG_SITE_SECURE_URL,
                              language=argd['ln'],
                              navmenuid='search',
                              navtrail_append_title_p=0) + \
                              websearch_templates.tmpl_search_pagestart(argd['ln']) + \
                              top + body + bottom + \
                              websearch_templates.tmpl_search_pageend(argd['ln']) + \
                              pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req)