Пример #1
0
# the comment above is for the Python interpreter, there are Unicode
# characters written straight into this source file

import json
import sys
import os

if sys.version_info[0] == 2 and sys.version_info[1] < 7:
    from portality.ordereddict import OrderedDict
else:
    from collections import OrderedDict

# countries
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", 'country-codes.json'), 'rb') as f:
    countries = json.loads(f.read())
countries_dict = OrderedDict(sorted(countries.items(), key=lambda x: x[1]['name']))
countries = countries_dict.items()

country_options = [('','')]
country_options_two_char_code_index = []

CURRENCY_DEFAULT = ''
currency_options = [(CURRENCY_DEFAULT, CURRENCY_DEFAULT)]
currency_options_code_index = []
currency_name_opts = []

for code, country_info in countries:        # FIXME: a bit of a mess - would be better to have an object that just gave us the answers on demand
    country_options.append((code, country_info['name']))
    country_options_two_char_code_index.append(code)
    if 'currency_alphabetic_code' in country_info and 'currency_name' in country_info:
        if country_info['currency_alphabetic_code'] not in currency_options_code_index:
Пример #2
0
# the comment above is for the Python interpreter, there are Unicode
# characters written straight into this source file

import json
import sys
import os

if sys.version_info[0] == 2 and sys.version_info[1] < 7:
    from portality.ordereddict import OrderedDict
else:
    from collections import OrderedDict

# countries
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", 'country-codes.json'), 'rb') as f:
    countries = json.loads(f.read())
countries_dict = OrderedDict(sorted(countries.items(), key=lambda x: x[1]['name']))
countries = countries_dict.items()

country_options = [('','')]
country_options_two_char_code_index = []

currency_options = [('','')]
currency_options_code_index = []

for code, country_info in countries:
    country_options.append((code, country_info['name']))
    country_options_two_char_code_index.append(code)
    if 'currency_alphabetic_code' in country_info and 'currency_name' in country_info:
        if country_info['currency_alphabetic_code'] not in currency_options_code_index:
            # prevent duplicates in the currency options by checking if
            # that currency has already been added - multiple countries
Пример #3
0
        'elife': {
            'name': 'eLife',
            'logo': 'elife.png',
            'url': 'https://elifesciences.org/'
        },
    },
    'patron': {
        #'elife': {'name': 'eLife Sciences Publications', 'logo': 'elife.jpg', 'url': 'https://elifesciences.org'},
        #'karger-oa': {'name': 'Karger Open Access', 'logo': 'karger-oa.svg', 'url': 'https://www.karger.com/OpenAccess'},
        #'enago': {'name': 'ENAGO', 'url': 'https://www.enago.com/'},
    }
}

# In each tier, create an ordered dictionary sorted alphabetically by sponsor name
SPONSORS = {
    k: OrderedDict(sorted(v.items(), key=lambda t: t[0]))
    for k, v in SPONSORS.items()
}

# Configure the Google Analytics tracker
from portality.lib import analytics
try:
    analytics.create_logfile(app.config.get('GOOGLE_ANALTYICS_LOG_DIR', None))
    analytics.create_tracker(app.config['GOOGLE_ANALYTICS_ID'],
                             app.config['BASE_DOMAIN'])
except (KeyError, analytics.GAException):
    err = "No Google Analytics credentials found. Required: 'GOOGLE_ANALYTICS_ID' and 'BASE_DOMAIN'."
    if app.config.get("DOAJENV") == 'production':
        app.logger.error(err)
    else:
        app.logger.debug(err)
Пример #4
0
        'name': 'ExLibris',
        'logo': 'exlibris.gif',
        'url': 'http://www.exlibrisgroup.com/'
    },
    'nature': {
        'name': 'Nature Publishing Group',
        'logo': 'nature.gif',
        'url': 'http://www.nature.com/npg_/index_npg.html'
    },
    'palgrave-macmillan': {
        'name': 'Palgrave Macmillan',
        'logo': 'palgrave-macmillan.gif',
        'url': 'http://www.palgrave.com/'
    },
}
SPONSORS = OrderedDict(sorted(SPONSORS.items(), key=lambda t: t[
    0]))  # create an ordered dictionary, sort by the key of the unordered one


# Redirects from previous DOAJ app.
# RJ: I have decided to put these here so that they can be managed
# alongside the DOAJ codebase.  I know they could also go into the
# nginx config, but there is a chance that they will get lost or forgotten
# some day, whereas this approach doesn't have that risk.
@app.route("/doaj")
def legacy():
    func = request.values.get("func")
    if func == "csv":
        return redirect(url_for('doaj.csv_data')), 301
    elif func == "rss":
        return redirect(url_for('atom.feed')), 301
    elif func == "browse" or func == 'byPublicationFee  ':