コード例 #1
0
def get_publication_list(context,
                         list,
                         template='publications/publications.html'):
    """
	Get a publication list.
	"""

    list = List.objects.filter(list__iexact=list)

    if not list:
        return ''

    list = list[0]
    publications = list.publication_set.all()
    publications = publications.order_by('-year', '-month', '-id')

    if not publications:
        return ''

    # load custom links and files
    populate(publications)

    return render_template(template, context['request'], {
        'list': list,
        'publications': publications
    })
コード例 #2
0
def year(request, year=None):
    years = []
    publications = Publication.objects.select_related()
    if year:
        publications = publications.filter(year=year, external=False)
    else:
        publications = publications.filter(external=False)
    publications = publications.order_by('-year', '-month', '-id')

    for publication in publications:
        if publication.type.hidden:
            continue
        if not years or (years[-1][0] != publication.year):
            years.append((publication.year, []))
        years[-1][1].append(publication)

    if 'plain' in request.GET:
        return render_to_response(
            'publications/publications.txt',
            {'publications': sum([y[1] for y in years], [])},
            context_instance=RequestContext(request),
            content_type='text/plain; charset=UTF-8')

    if 'bibtex' in request.GET:
        return render_to_response(
            'publications/publications.bib',
            {'publications': sum([y[1] for y in years], [])},
            context_instance=RequestContext(request),
            content_type='text/x-bibtex; charset=UTF-8')

    if 'mods' in request.GET:
        return render_to_response(
            'publications/publications.mods',
            {'publications': sum([y[1] for y in years], [])},
            context_instance=RequestContext(request),
            content_type='application/xml; charset=UTF-8')

    if 'ris' in request.GET:
        return render_to_response(
            'publications/publications.ris',
            {'publications': sum([y[1] for y in years], [])},
            context_instance=RequestContext(request),
            content_type='application/x-research-info-systems; charset=UTF-8')

    if 'rss' in request.GET:
        return render_to_response(
            'publications/publications.rss', {
                'url': 'http://' + request.get_host() + request.path,
                'publications': sum([y[1] for y in years], [])
            },
            context_instance=RequestContext(request),
            content_type='application/rss+xml; charset=UTF-8')

    # load custom links and files
    populate(publications)

    return render_to_response('publications/years.html', {'years': years},
                              context_instance=RequestContext(request))
コード例 #3
0
ファイル: list.py プロジェクト: kmisztal/SciJournal
def list(request, list):
    list = List.objects.filter(list__iexact=list)

    if not list:
        raise Http404

    list = list[0]
    publications = list.publication_set.all()
    publications = publications.order_by('-year', '-month', '-id')

    if 'plain' in request.GET:
        return render_to_response('publications/publications.txt',
                                  {'publications': publications},
                                  context_instance=RequestContext(request),
                                  content_type='text/plain; charset=UTF-8')

    if 'bibtex' in request.GET:
        return render_to_response('publications/publications.bib',
                                  {'publications': publications},
                                  context_instance=RequestContext(request),
                                  content_type='text/x-bibtex; charset=UTF-8')

    if 'mods' in request.GET:
        return render_to_response(
            'publications/publications.mods', {'publications': publications},
            context_instance=RequestContext(request),
            content_type='application/xml; charset=UTF-8')

    if 'ris' in request.GET:
        return render_to_response(
            'publications/publications.ris', {'publications': publications},
            context_instance=RequestContext(request),
            content_type='application/x-research-info-systems; charset=UTF-8')

    if 'rss' in request.GET:
        return render_to_response(
            'publications/publications.rss', {
                'url': 'http://' + request.get_host() + request.path,
                'publications': publications
            },
            context_instance=RequestContext(request),
            content_type='application/rss+xml; charset=UTF-8')

    # load custom links and files
    populate(publications)

    return render_to_response('publications/list.html', {
        'list': list,
        'publications': publications
    },
                              context_instance=RequestContext(request))
コード例 #4
0
ファイル: year.py プロジェクト: kmisztal/SciJournal
def year(request, year=None):
    years = []
    publications = Publication.objects.select_related()
    if year:
        publications = publications.filter(year=year, external=False)
    else:
        publications = publications.filter(external=False)
    publications = publications.order_by('-year', '-month', '-id')

    for publication in publications:
        if publication.type.hidden:
            continue
        if not years or (years[-1][0] != publication.year):
            years.append((publication.year, []))
        years[-1][1].append(publication)

    if 'plain' in request.GET:
        return render_to_response('publications/publications.txt', {
            'publications': sum([y[1] for y in years], [])
        }, context_instance=RequestContext(request), content_type='text/plain; charset=UTF-8')

    if 'bibtex' in request.GET:
        return render_to_response('publications/publications.bib', {
            'publications': sum([y[1] for y in years], [])
        }, context_instance=RequestContext(request), content_type='text/x-bibtex; charset=UTF-8')

    if 'mods' in request.GET:
        return render_to_response('publications/publications.mods', {
            'publications': sum([y[1] for y in years], [])
        }, context_instance=RequestContext(request), content_type='application/xml; charset=UTF-8')

    if 'ris' in request.GET:
        return render_to_response('publications/publications.ris', {
            'publications': sum([y[1] for y in years], [])
        }, context_instance=RequestContext(request), content_type='application/x-research-info-systems; charset=UTF-8')

    if 'rss' in request.GET:
        return render_to_response('publications/publications.rss', {
            'url': 'http://' + request.get_host() + request.path,
            'publications': sum([y[1] for y in years], [])
        }, context_instance=RequestContext(request), content_type='application/rss+xml; charset=UTF-8')

    # load custom links and files
    populate(publications)

    return render_to_response('publications/years.html', {
        'years': years
    }, context_instance=RequestContext(request))
コード例 #5
0
def get_publications(context, template='publications/publications.html'):
    """
    Get all publications.
    """

    types = Type.objects.filter(hidden=False)
    publications = Publication.objects.select_related()
    publications = publications.filter(external=False, type__in=types)
    publications = publications.order_by('-year', '-month', '-id')

    if not publications:
        return ''

    # load custom links and files
    populate(publications)

    return get_template(template).render(
        RequestContext(context['request'], {'publications': publications}))
コード例 #6
0
def get_publications(context, template='publications/publications.html'):
    """
	Get all publications.
	"""

    types = Type.objects.filter(hidden=False)
    publications = Publication.objects.select_related()
    publications = publications.filter(external=False, type__in=types)
    publications = publications.order_by('-year', '-month', '-id')

    if not publications:
        return ''

    # load custom links and files
    populate(publications)

    return render_template(template, context['request'],
                           {'publications': publications})
コード例 #7
0
ファイル: list.py プロジェクト: kmisztal/SciJournal
def list(request, list):
    list = List.objects.filter(list__iexact=list)

    if not list:
        raise Http404

    list = list[0]
    publications = list.publication_set.all()
    publications = publications.order_by('-year', '-month', '-id')

    if 'plain' in request.GET:
        return render_to_response('publications/publications.txt', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='text/plain; charset=UTF-8')

    if 'bibtex' in request.GET:
        return render_to_response('publications/publications.bib', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='text/x-bibtex; charset=UTF-8')

    if 'mods' in request.GET:
        return render_to_response('publications/publications.mods', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='application/xml; charset=UTF-8')

    if 'ris' in request.GET:
        return render_to_response('publications/publications.ris', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='application/x-research-info-systems; charset=UTF-8')

    if 'rss' in request.GET:
        return render_to_response('publications/publications.rss', {
            'url': 'http://' + request.get_host() + request.path,
            'publications': publications
        }, context_instance=RequestContext(request), content_type='application/rss+xml; charset=UTF-8')

    # load custom links and files
    populate(publications)

    return render_to_response('publications/list.html', {
        'list': list,
        'publications': publications
    }, context_instance=RequestContext(request))
コード例 #8
0
ファイル: keyword.py プロジェクト: kmisztal/SciJournal
def keyword(request, keyword):
    keyword = keyword.lower().replace(' ', '+')
    candidates = Publication.objects.filter(
        keywords__icontains=keyword.split('+')[0], external=False)
    publications = []

    for i, publication in enumerate(candidates):
        if keyword in [k[1] for k in publication.keywords_escaped()]:
            publications.append(publication)

    if 'plain' in request.GET:
        return render_to_response('publications/publications.txt',
                                  {'publications': publications},
                                  context_instance=RequestContext(request),
                                  content_type='text/plain; charset=UTF-8')

    if 'bibtex' in request.GET:
        return render_to_response('publications/publications.bib',
                                  {'publications': publications},
                                  context_instance=RequestContext(request),
                                  content_type='text/x-bibtex; charset=UTF-8')

    if 'mods' in request.GET:
        return render_to_response(
            'publications/publications.mods', {'publications': publications},
            context_instance=RequestContext(request),
            content_type='application/xml; charset=UTF-8')

    if 'ris' in request.GET:
        return render_to_response(
            'publications/publications.ris', {'publications': publications},
            context_instance=RequestContext(request),
            content_type='application/x-research-info-systems; charset=UTF-8')

    # load custom links and files
    populate(publications)

    return render_to_response('publications/keyword.html', {
        'publications': publications,
        'keyword': keyword.replace('+', ' ')
    },
                              context_instance=RequestContext(request))
コード例 #9
0
def get_publication_list(context, list, template='publications/publications.html'):
    """
    Get a publication list.
    """

    list = List.objects.filter(list__iexact=list)

    if not list:
        return ''

    list = list[0]
    publications = list.publication_set.all()
    publications = publications.order_by('-year', '-month', '-id')

    if not publications:
        return ''

    # load custom links and files
    populate(publications)

    return get_template(template).render(
        RequestContext(context['request'], {'list': list, 'publications': publications}))
コード例 #10
0
ファイル: keyword.py プロジェクト: kmisztal/SciJournal
def keyword(request, keyword):
    keyword = keyword.lower().replace(' ', '+')
    candidates = Publication.objects.filter(keywords__icontains=keyword.split('+')[0], external=False)
    publications = []

    for i, publication in enumerate(candidates):
        if keyword in [k[1] for k in publication.keywords_escaped()]:
            publications.append(publication)

    if 'plain' in request.GET:
        return render_to_response('publications/publications.txt', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='text/plain; charset=UTF-8')

    if 'bibtex' in request.GET:
        return render_to_response('publications/publications.bib', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='text/x-bibtex; charset=UTF-8')

    if 'mods' in request.GET:
        return render_to_response('publications/publications.mods', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='application/xml; charset=UTF-8')

    if 'ris' in request.GET:
        return render_to_response('publications/publications.ris', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='application/x-research-info-systems; charset=UTF-8')

    # load custom links and files
    populate(publications)

    return render_to_response('publications/keyword.html', {
        'publications': publications,
        'keyword': keyword.replace('+', ' ')
    }, context_instance=RequestContext(request))
コード例 #11
0
def author(request, name):
    fullname = capwords(name.replace('+', ' '))
    fullname = fullname.replace(' Von ', ' von ').replace(' Van ', ' van ')
    fullname = fullname.replace(' Der ', ' der ')

    # take care of dashes
    off = fullname.find('-')
    while off > 0:
        off += 1
        if off <= len(fullname):
            fullname = fullname[:off] + fullname[off].upper() + fullname[off +
                                                                         1:]
        off = fullname.find('-', off)

    # split into forename, middlenames and surname
    names = name.replace(' ', '+').split('+')

    # construct a liberal query
    surname = names[-1]
    surname = surname.replace(u'ä', u'%%')
    surname = surname.replace(u'ae', u'%%')
    surname = surname.replace(u'ö', u'%%')
    surname = surname.replace(u'oe', u'%%')
    surname = surname.replace(u'ü', u'%%')
    surname = surname.replace(u'ue', u'%%')
    surname = surname.replace(u'ß', u'%%')
    surname = surname.replace(u'ss', u'%%')

    query_str = u'SELECT * FROM {table} ' \
                'WHERE lower({table}.authors) LIKE lower(\'%%{surname}%%\') ' \
                'ORDER BY {table}.year DESC, {table}.month DESC, {table}.id DESC'
    query = Publication.objects.raw(
        query_str.format(table=Publication._meta.db_table, surname=surname))

    # find publications of this author
    publications = []
    publications_by_type = defaultdict(lambda: [])

    # further filter results
    if len(names) > 1:
        name_simple = Publication.simplify_name(names[0][0] + '. ' + names[-1])
        for publication in query:
            if name_simple in publication.authors_list_simple:
                publications.append(publication)
                publications_by_type[publication.type_id].append(publication)

    elif len(names) > 0:
        for publication in query:
            if Publication.simplify_name(
                    names[-1].lower()) in publication.authors_list_simple:
                publications.append(publication)
                publications_by_type[publication.type_id].append(publication)

    # attach publications to types
    types = Type.objects.filter(id__in=publications_by_type.keys())
    for t in types:
        t.publications = publications_by_type[t.id]

    if 'plain' in request.GET:
        return render(request,
                      'publications/publications.txt',
                      {'publications': publications},
                      content_type='text/plain; charset=UTF-8')

    if 'bibtex' in request.GET:
        return render(request,
                      'publications/publications.bib',
                      {'publications': publications},
                      content_type='text/x-bibtex; charset=UTF-8')

    if 'mods' in request.GET:
        return render(request,
                      'publications/publications.mods',
                      {'publications': publications},
                      content_type='application/xml; charset=UTF-8')

    if 'ris' in request.GET:
        return render(
            request,
            'publications/publications.ris', {'publications': publications},
            content_type='application/x-research-info-systems; charset=UTF-8')

    if 'rss' in request.GET:
        return render(request,
                      'publications/publications.rss', {
                          'url': 'http://' + request.get_host() + request.path,
                          'author': fullname,
                          'publications': publications
                      },
                      content_type='application/rss+xml; charset=UTF-8')

    # load custom links and files
    populate(publications)

    return render(request, 'publications/author.html', {
        'publications': publications,
        'types': types,
        'author': fullname
    })
コード例 #12
0
ファイル: person.py プロジェクト: kmisztal/SciJournal
def person(request, name):
    author = capwords(name.replace('+', ' '))
    author = author.replace(' Von ', ' von ').replace(' Van ', ' van ')
    author = author.replace(' Der ', ' der ')

    # take care of dashes
    off = author.find('-')
    while off > 0:
        off += 1
        if off <= len(author):
            author = author[:off] + author[off].upper() + author[off + 1:]
        off = author.find('-', off)

    # split into forename, middlenames and surname
    names = name.replace(' ', '+').split('+')

    # construct a liberal query
    surname = names[-1]
    surname = surname.replace(u'ä', u'%%')
    surname = surname.replace(u'ae', u'%%')
    surname = surname.replace(u'ö', u'%%')
    surname = surname.replace(u'oe', u'%%')
    surname = surname.replace(u'ü', u'%%')
    surname = surname.replace(u'ue', u'%%')
    surname = surname.replace(u'ß', u'%%')
    surname = surname.replace(u'ss', u'%%')

    query_str = u'SELECT * FROM {table} ' \
                'WHERE lower({table}.authors) LIKE lower(\'%%{surname}%%\') ' \
                'ORDER BY {table}.year DESC, {table}.month DESC, {table}.id DESC'
    query = Publication.objects.raw(
        query_str.format(table=Publication._meta.db_table, surname=surname))

    # find publications of this author
    publications = []
    publications_by_type = defaultdict(lambda: [])

    # further filter results
    if len(names) > 1:
        name_simple = Publication.simplify_name(names[0][0] + '. ' + names[-1])
        for publication in query:
            if name_simple in publication.authors_list_simple:
                publications.append(publication)
                publications_by_type[publication.type_id].append(publication)

    elif len(names) > 0:
        for publication in query:
            if Publication.simplify_name(names[-1].lower()) in publication.authors_list_simple:
                publications.append(publication)
                publications_by_type[publication.type_id].append(publication)

    # attach publications to types
    types = Type.objects.filter(id__in=publications_by_type.keys())
    for t in types:
        t.publications = publications_by_type[t.id]

    if 'plain' in request.GET:
        return render_to_response('publications/publications.txt', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='text/plain; charset=UTF-8')

    if 'bibtex' in request.GET:
        return render_to_response('publications/publications.bib', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='text/x-bibtex; charset=UTF-8')

    if 'mods' in request.GET:
        return render_to_response('publications/publications.mods', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='application/xml; charset=UTF-8')

    if 'ris' in request.GET:
        return render_to_response('publications/publications.ris', {
            'publications': publications
        }, context_instance=RequestContext(request), content_type='application/x-research-info-systems; charset=UTF-8')

    if 'rss' in request.GET:
        return render_to_response('publications/publications.rss', {
            'url': 'http://' + request.get_host() + request.path,
            'author': author,
            'publications': publications
        }, context_instance=RequestContext(request), content_type='application/rss+xml; charset=UTF-8')

    # load custom links and files
    populate(publications)

    return render_to_response('publications/person.html', {
        'publications': publications,
        'types': types,
        'author': author
    }, context_instance=RequestContext(request))