Example #1
0
def init_app():
    from framework.flask import app
    try:
        make_url_map(app)
    except AssertionError:
        pass
    init_addons(website_settings)
    attach_handlers(app, website_settings)
    for addon in website_settings.ADDONS_AVAILABLE:
        try:
            addon.ready()
        except AssertionError:
            pass
    return app
Example #2
0
def create_app_context():
    try:
        init_addons(settings)
        do_set_backends(settings)
    except AssertionError:  # ignore AssertionErrors
        pass
Example #3
0
def create_app_context():
    try:
        init_addons(settings)
    except AssertionError:  # ignore AssertionErrors
        pass
# importing from the osf.io submodule
from utils import submodule_path
import sys
sys.path.insert(0, submodule_path('utils.py'))
from website.project.model import MetaSchema, DraftRegistration, Node
from framework.mongo.utils import get_or_http_error
from framework.auth.core import User
from framework.auth import Auth
from website.project.metadata.utils import serialize_meta_schema, serialize_draft_registration
from website.app import do_set_backends, init_addons
from website import settings as osf_settings

import utils

init_addons(osf_settings, routes=False)
do_set_backends(osf_settings)
adminUser = User.load('dsmpw')

def get_mongo_client():
    """Create MongoDB client and authenticate database.
    """
    client = pymongo.MongoClient(osf_settings.DB_HOST, osf_settings.DB_PORT)

    db = client[osf_settings.DB_NAME]

    if osf_settings.DB_USER and osf_settings.DB_PASS:
        db.authenticate(osf_settings.DB_USER, osf_settings.DB_PASS)

    return client
Example #5
0
# importing from the osf.io submodule
from utils import submodule_path
import sys
sys.path.insert(0, submodule_path('utils.py'))
from website.project.model import MetaSchema, DraftRegistration, Node, DraftRegistrationApproval
from framework.mongo.utils import get_or_http_error
from framework.auth.core import User
from framework.auth import Auth
from website.project.metadata.utils import serialize_meta_schema, serialize_draft_registration
from website.app import do_set_backends, init_addons
from website import settings as osf_settings

import utils

init_addons(osf_settings, routes=False)
do_set_backends(osf_settings)
adminUser = User.load('dsmpw')


def get_all_drafts():
    # TODO[lauren]: add query parameters to only retrieve submitted drafts, they will have an approval associated with them
    all_drafts = DraftRegistration.find()

    auth = Auth(adminUser)

    serialized_drafts = {
        'drafts':
        [utils.serialize_draft_registration(d, auth) for d in all_drafts]
    }
    return serialized_drafts