Ejemplo n.º 1
0
def load_origins_whitelist():
    global ORIGINS_WHITELIST
    from osf.models import Institution, PreprintProvider

    institution_origins = tuple(domain.lower() for domain in itertools.chain(
        *[institution.domains for institution in Institution.find()]))

    preprintprovider_origins = tuple(
        preprintprovider.domain.lower()
        for preprintprovider in PreprintProvider.objects.exclude(domain=''))

    ORIGINS_WHITELIST = institution_origins + preprintprovider_origins
Ejemplo n.º 2
0
def load_origins_whitelist():
    global ORIGINS_WHITELIST
    from osf.models import Institution, PreprintProvider

    institution_origins = tuple(domain.lower() for domain in itertools.chain(*[
        institution.domains
        for institution in Institution.find()
    ]))

    preprintprovider_origins = tuple(preprintprovider.domain.lower() for preprintprovider in PreprintProvider.objects.exclude(domain=''))

    ORIGINS_WHITELIST = institution_origins + preprintprovider_origins
Ejemplo n.º 3
0
def load_origins_whitelist():
    global ORIGINS_WHITELIST
    from osf.models import Institution, PreprintProvider

    institution_origins = tuple(domain.lower() for domain in itertools.chain(
        *[institution.domains for institution in Institution.find()]))

    preprintprovider_origins = tuple(
        preprintprovider.domain.lower()
        for preprintprovider in PreprintProvider.objects.exclude(domain=''))

    ORIGINS_WHITELIST = tuple(
        urlparse(url).geturl().lower().split('{}://'.format(
            urlparse(url).scheme))[-1]
        for url in institution_origins + preprintprovider_origins)
Ejemplo n.º 4
0
 def get_institutions(self):
     institutions = Institution.find(Q('_id', 'ne', None))
     return institutions
Ejemplo n.º 5
0
 def get_queryset(self):
     return Institution.find(self.get_query_from_request())
Ejemplo n.º 6
0
def migrate_institutions(index):
    for inst in Institution.find(Q('is_deleted', 'ne', True)):
        update_institution(inst, index)
Ejemplo n.º 7
0
 def get_queryset(self):
     return Institution.find(self.get_query_from_request())
Ejemplo n.º 8
0
 def get_institutions(self):
     institutions = Institution.find(Q('_id', 'ne', None))
     return institutions
Ejemplo n.º 9
0
def test_querying_on_domains():
    inst = InstitutionFactory(domains=['foo.test'])
    result = Institution.find(Q('domains', 'eq', 'foo.test'))
    assert inst in result
Ejemplo n.º 10
0
def migrate_institutions(index):
    for inst in Institution.find(Q('is_deleted', 'ne', True)):
        update_institution(inst, index)