예제 #1
0
def index():
    if session.forced_language == "en":
        locale = "en_US"
    elif session.forced_language == "de":
        locale = "de_DE"
    else:
        locale = ""

    ompdal = OMPDAL(db, myconf)

    press = ompdal.getPress(myconf.take("omp.press_id"))
    if not press:
        redirect(URL("home", "index"))
    press_settings = OMPSettings(ompdal.getPressSettings(press.press_id))

    ignored_submission_id = myconf.take("omp.ignore_submissions") if myconf.take("omp.ignore_submissions") else -1

    submissions = []
    for submission_row in ompdal.getSubmissionsByPress(press.press_id, ignored_submission_id):
        authors = [
            OMPItem(author, OMPSettings(ompdal.getAuthorSettings(author.author_id)))
            for author in ompdal.getAuthorsBySubmission(submission_row.submission_id)
        ]
        editors = [
            OMPItem(editor, OMPSettings(ompdal.getAuthorSettings(editor.author_id)))
            for editor in ompdal.getEditorsBySubmission(submission_row.submission_id)
        ]
        publication_dates = [
            dateFromRow(pd)
            for pf in ompdal.getAllPublicationFormatsBySubmission(
                submission_row.submission_id, available=True, approved=True
            )
            for pd in ompdal.getPublicationDatesByPublicationFormat(pf.publication_format_id)
        ]
        submission = OMPItem(
            submission_row,
            OMPSettings(ompdal.getSubmissionSettings(submission_row.submission_id)),
            {"authors": authors, "editors": editors},
        )
        series_row = ompdal.getSeries(submission_row.series_id)
        if series_row:
            submission.associated_items["series"] = OMPItem(
                series_row, OMPSettings(ompdal.getSeriesSettings(series_row.series_id))
            )
        if publication_dates:
            submission.associated_items["publication_dates"] = publication_dates

        submissions.append(submission)

    submissions = sorted(
        submissions, key=lambda s: min(s.associated_items.get("publication_dates", [datetime(1, 1, 1)])), reverse=True
    )

    return locals()
예제 #2
0
def index():
    if session.forced_language == 'en':
        locale = 'en_US'
    elif session.forced_language == 'de':
        locale = 'de_DE'
    else:
        locale = ''
    
    ompdal = OMPDAL(db, myconf)
    
    press = ompdal.getPress(myconf.take('omp.press_id'))
    if not press:
        redirect(URL('home', 'index'))            
    press_settings = OMPSettings(ompdal.getPressSettings(press.press_id))
    
    ignored_submission_id =  myconf.take('omp.ignore_submissions') if myconf.take('omp.ignore_submissions') else -1

    submissions = []
    for submission_row in ompdal.getSubmissionsByPress(press.press_id, ignored_submission_id):
        authors = [OMPItem(author, OMPSettings(ompdal.getAuthorSettings(author.author_id))) for author in ompdal.getAuthorsBySubmission(submission_row.submission_id)]
        editors = [OMPItem(editor, OMPSettings(ompdal.getAuthorSettings(editor.author_id))) for editor in ompdal.getEditorsBySubmission(submission_row.submission_id)]
        publication_dates = [dateFromRow(pd) for pf in ompdal.getAllPublicationFormatsBySubmission(submission_row.submission_id, available=True, approved=True) 
                                for pd in ompdal.getPublicationDatesByPublicationFormat(pf.publication_format_id)]
        submission = OMPItem(submission_row,
                             OMPSettings(ompdal.getSubmissionSettings(submission_row.submission_id)),
                             {'authors': authors, 'editors': editors}
        )
        series_row = ompdal.getSeries(submission_row.series_id)
        if series_row:
            submission.associated_items['series'] = OMPItem(series_row, OMPSettings(ompdal.getSeriesSettings(series_row.series_id)))
        if publication_dates:
            submission.associated_items['publication_dates'] = publication_dates
            
        submissions.append(submission)

    submissions = sorted(submissions, key=lambda s: min(s.associated_items.get('publication_dates', [datetime(1, 1, 1)])), reverse = True)
    
    return locals()
예제 #3
0
def book():
    if session.forced_language == 'en':
        locale = 'en_US'
    elif session.forced_language == 'de':
        locale = 'de_DE'
    else:
        locale = ''

    submission_id = request.args[0] if request.args else redirect(
        URL('home', 'index'))
    
    dal = OMPDAL(db, myconf)
    
    press = dal.getPress(myconf.take('omp.press_id'))
    if not press:
        redirect(URL('home', 'index'))
    press_settings = OMPSettings(dal.getPressSettings(press.press_id))
    
    # Get basic submission info (check, if submission is associated with the actual press and if the submission has been published)
    submission = dal.getPublishedSubmission(submission_id, press_id=myconf.take('omp.press_id'))
    if not submission:
        redirect(URL('home', 'index'))

    submission_settings = OMPSettings(dal.getSubmissionSettings(submission_id))
    
    # Get contributors and contributor settings
    editor_rows = dal.getEditorsBySubmission(submission_id)
    editors = [OMPItem(e, OMPSettings(dal.getAuthorSettings(e.author_id))) for e in editor_rows]

    # Do not load authors if the submission has editors
    authors = [] if editors else [OMPItem(a, OMPSettings(dal.getAuthorSettings(a.author_id))) for a in
                                  dal.getActualAuthorsBySubmission(submission_id, filter_browse=True)]
    
    # Get chapters and chapter authors
    chapters = []
    for chapter in dal.getChaptersBySubmission(submission_id):
        chapters.append(OMPItem(chapter,
                             OMPSettings(dal.getChapterSettings(chapter.chapter_id)),
                             {'authors': [OMPItem(a, OMPSettings(dal.getAuthorSettings(a.author_id))) for a in dal.getAuthorsByChapter(chapter.chapter_id)]})
        )
        
    # Get digital publication formats, settings, files, and identification codes
    digital_publication_formats = []
    for pf in dal.getDigitalPublicationFormats(submission_id, available=True, approved=True):
        publication_format = OMPItem(pf, 
            OMPSettings(dal.getPublicationFormatSettings(pf.publication_format_id)),
            {'identification_codes': dal.getIdentificationCodesByPublicationFormat(pf.publication_format_id),
             'publication_dates': dal.getPublicationDatesByPublicationFormat(pf.publication_format_id)}
        )
        full_file = dal.getLatestRevisionOfFullBookFileByPublicationFormat(submission_id, pf.publication_format_id)
        if full_file:
            publication_format.associated_items['full_file'] = OMPItem(full_file, OMPSettings(dal.getSubmissionFileSettings(full_file.file_id)))
        digital_publication_formats.append(publication_format)
        
        for chapter in chapters:
            chapter_file = dal.getLatestRevisionOfChapterFileByPublicationFormat(chapter.attributes.chapter_id, pf.publication_format_id)
            if chapter_file:
                chapter.associated_items.setdefault('files', {})[pf.publication_format_id] = OMPItem(chapter_file, OMPSettings(dal.getSubmissionFileSettings(chapter_file.file_id)))
            
    # Get physical publication formats, settings, and identification codes
    physical_publication_formats = []
    for pf in dal.getPhysicalPublicationFormats(submission_id, available=True, approved=True):
        physical_publication_formats.append(OMPItem(pf, 
            OMPSettings(dal.getPublicationFormatSettings(pf.publication_format_id)),
            {'identification_codes': dal.getIdentificationCodesByPublicationFormat(pf.publication_format_id),
             'publication_dates': dal.getPublicationDatesByPublicationFormat(pf.publication_format_id)})
        )
    
    pdf = dal.getPublicationFormatByName(submission_id, myconf.take('omp.doi_format_name')).first()
    # Get DOI from the format marked as DOI carrier
    if pdf:
        doi = OMPSettings(dal.getPublicationFormatSettings(pdf.publication_format_id)).getLocalizedValue("pub-id::doi", "")    # DOI always has empty locale
    else:
        doi = ""
        
    def get_first(l):
        if l:
            return l[0]
        else:
            return None
    
    date_published = None
    # Get the OMP publication date (column publication_date contains latest catalog entry edit date.) Try:
    # 1. Custom publication date entered for a publication format calles "PDF"
    if pdf:
        date_published = get_first([dateFromRow(pd) for pd in dal.getPublicationDatesByPublicationFormat(pdf.publication_format_id) if pd.role=="01"])
    # 2. Date on which the catalog entry was first published
    if not date_published:
        date_published = get_first([pd.date_logged for pd in dal.getMetaDataPublishedDates(submission_id)])
    # 3. Date on which the submission status was last modified (always set)
    if not date_published:
        date_published = submission.date_status_modified
        
    series = dal.getSeriesBySubmissionId(submission_id)
    if series:
        series = OMPItem(series, OMPSettings(dal.getSeriesSettings(series.series_id)))
    
    # Get purchase info
    representatives = dal.getRepresentativesBySubmission(submission_id, myconf.take('omp.representative_id_type'))
    
    #stats = OMPStats(myconf, db, locale)

    return locals()
예제 #4
0
class Announcements:

    def __init__(self, conf, db, locale):
        self.locale = locale
        self.conf = conf
        self.ompdal = OMPDAL(db, conf)
        self.press_id = int(conf.take('omp.press_id'))
        self.press_settings = self.ompdal.getPressSettings(self.press_id)

    def get_status(self):

        ae = list(filter(lambda e: e['setting_name'] == 'enableAnnouncements', self.press_settings.as_list()))

        if ae:
            return ae[0]['setting_value']
        else:
            return []

    def get_number(self):

        nah = list(filter(lambda e: e['setting_name'] == 'numAnnouncementsHomepage', self.press_settings.as_list()))

        if nah:
            return int(nah[0]['setting_value'])
        else:
            return 6




    def create_announcement_list(self):
        now = datetime.datetime.now()
        def expires(e):
            if e['date_expire']:
                if e['date_expire'] > now :
                    return  True
                else:
                    return False
            else:
                return True

        news = self.ompdal.getAnnouncementsByPress(self.press_id).as_list()

        news= list(filter(lambda e: expires(e), news))

        if news:
            nl = list(map(lambda e: self.create_announcement(e), news))

            del nl[self.get_number():]
            return nl
        else:
            return []

    def create_announcement(self, a):

        n = self.ompdal.getAnnouncementSettings(a['announcement_id']).as_list()

        t= list(filter(lambda e: e['locale'] == self.locale and e['setting_name'] == 'title', n))
        title = t[0]['setting_value'] if t else ''

        ds = list(filter(lambda e: e['locale'] == self.locale and e['setting_name'] == 'descriptionShort', n))
        description_short = ds[0]['setting_value'] if ds else ''

        div = self.announcement_block(description_short, a, title)
        return div

    def announcement_block(self, description_short, a, title):

        ann = self.ompdal.getAnnouncementTypeSettings(a['type_id']).as_list()
        t = list(filter(lambda e: e['locale'] == self.locale and e['setting_name'] == 'name', ann))
        ann_type = t[0]['setting_value'] if t else self.conf.take('web.application')
        ann_type = ann_type.replace(' ','_').lower()
        img_url = URL('static', '{}{}{}'.format('images/press/home/announcements/',ann_type,'.png'))

        div_img = DIV(IMG(_src=img_url, _style="width: 50px;"),
                      _class="media-left pull-left")
        posted__date = a['date_posted'].date()
        div_date = P(posted__date.strftime("%d.%m.%Y "), _class="media-heading")
        div_heading = H5(XML(title))
        div_short_description = DIV(XML(description_short), _class="boxText")
        div_body = DIV(div_date, div_heading, div_short_description, _class="media-body")
        div = DIV(div_img, div_body, _class = "media")

        return div
예제 #5
0
def book():
    ompdal = OMPDAL(db, myconf)

    submission_id = request.args[
        0] if request.args and request.args[0].isdigit() else raise400()
    press_id = myconf.take('omp.press_id')
    editor_group_id = myconf.take('omp.editor_id', cast=int)
    author_group_id = myconf.take('omp.author_id', cast=int)
    chapter_author_group_id = myconf.take('omp.chapter_author_id', cast=int)
    translator_group_id = int(myconf.get('omp.translator_id')) if myconf.get(
        'omp.translator_id') else None

    press = ompdal.getPress(press_id)
    submission = ompdal.getPublishedSubmission(submission_id,
                                               press_id=press_id)
    if not submission or not press:
        raise HTTP(400)
    if len(request.args) > 1 and request.args[1][0] == 'c' and request.args[1][
            1:].isdigit():
        chapter_id = int(request.args[1][1:])
    elif len(request.args) > 1:
        redirect(URL(r=request, args=request.args[0:1]))
    else:
        chapter_id = 0

    submission_settings = OMPSettings(
        ompdal.getSubmissionSettings(submission_id))
    press_settings = OMPSettings(ompdal.getPressSettings(press.press_id))

    # Get chapters and chapter authors
    chapters = []
    chapter = {}
    for i in ompdal.getChaptersBySubmission(submission_id):
        item = OMPItem(
            i, OMPSettings(ompdal.getChapterSettings(i.chapter_id)), {
                'authors': [
                    OMPItem(a,
                            OMPSettings(ompdal.getAuthorSettings(a.author_id)))
                    for a in ompdal.getAuthorsByChapter(i.chapter_id)
                ]
            })
        chapters.append(item)

    contributors_by_group = defaultdict(list)
    contributors_by_id = {}
    for contrib in ompdal.getAuthorsBySubmission(submission_id,
                                                 filter_browse=True):
        contrib_item = OMPItem(
            contrib, OMPSettings(ompdal.getAuthorSettings(contrib.author_id)))
        contributors_by_group[contrib.user_group_id].append(contrib_item)
        contributors_by_id[contrib.author_id] = contrib_item

    editors = contributors_by_group[editor_group_id]
    authors = contributors_by_group[author_group_id]
    chapter_authors = contributors_by_group[chapter_author_group_id]
    # if no editors or authors are saved for this submission, treat chapter authors as authors
    if not editors and not authors:
        authors = chapter_authors
    translators = []
    if translator_group_id:
        translators = contributors_by_group[translator_group_id]
    # Get digital publication formats, settings, files, and identification codes
    c = None
    chapter_doi = None
    digital_publication_formats = []
    for pf in ompdal.getDigitalPublicationFormats(submission_id,
                                                  available=True,
                                                  approved=True):
        publication_format = OMPItem(
            pf,
            OMPSettings(
                ompdal.getPublicationFormatSettings(pf.publication_format_id)),
            {
                'identification_codes':
                ompdal.getIdentificationCodesByPublicationFormat(
                    pf.publication_format_id),
                'publication_dates':
                ompdal.getPublicationDatesByPublicationFormat(
                    pf.publication_format_id)
            })
        full_file = ompdal.getLatestRevisionOfFullBookFileByPublicationFormat(
            submission_id, pf.publication_format_id)
        full_epub_file = ompdal.getLatestRevisionOfEBook(
            submission_id, pf.publication_format_id)
        if full_epub_file:
            publication_format.associated_items['full_file'] = OMPItem(
                full_epub_file,
                OMPSettings(
                    ompdal.getSubmissionFileSettings(full_epub_file.file_id)))

        if full_file:
            publication_format.associated_items['full_file'] = OMPItem(
                full_file,
                OMPSettings(ompdal.getSubmissionFileSettings(
                    full_file.file_id)))

        digital_publication_formats.append(publication_format)

        for i in chapters:
            chapter_file = ompdal.getLatestRevisionOfChapterFileByPublicationFormat(
                i.attributes.chapter_id, pf.publication_format_id)
            if chapter_file:
                i.associated_items.setdefault(
                    'files', {})[pf.publication_format_id] = OMPItem(
                        chapter_file,
                        OMPSettings(
                            ompdal.getSubmissionFileSettings(
                                chapter_file.file_id)))
            if chapter_id > 0 and chapter_id == i.attributes.chapter_id:
                c = i
    if c:
        c_title = c.settings.getLocalizedValue('title', locale)
        c_subtitle = c.settings.getLocalizedValue('subtitle', locale)
        c_abstract = c.settings.getLocalizedValue('abstract', locale)
        c_authors = c.associated_items.get('authors', [])
        c_files = c.associated_items.get('files', {})
        chapter_doi = c.settings.getLocalizedValue(DOI_SETTING_NAME, '')

    # Get physical publication formats, settings, and identification codes
    physical_publication_formats = []
    for pf in ompdal.getPhysicalPublicationFormats(submission_id,
                                                   available=True,
                                                   approved=True):
        physical_publication_formats.append(
            OMPItem(
                pf,
                OMPSettings(
                    ompdal.getPublicationFormatSettings(
                        pf.publication_format_id)), {
                            'identification_codes':
                            ompdal.getIdentificationCodesByPublicationFormat(
                                pf.publication_format_id),
                            'publication_dates':
                            ompdal.getPublicationDatesByPublicationFormat(
                                pf.publication_format_id)
                        }))

    pdf = ompdal.getPublicationFormatByName(
        submission_id, myconf.take('omp.doi_format_name')).first()

    doi = ""
    submission_doi = submission_settings.getLocalizedValue(
        DOI_SETTING_NAME, '')
    if submission_doi:
        doi = submission_doi
    elif pdf:
        # DOI always has empty locale
        doi = OMPSettings(
            ompdal.getPublicationFormatSettings(
                pdf.publication_format_id)).getLocalizedValue(
                    DOI_SETTING_NAME, "")

    date_published = None
    date_first_published = None
    # Get the OMP publication date (column publication_date contains latest catalog entry edit date.) Try:
    # 1. Custom publication date entered for a publication format calles "PDF"
    if pdf:
        date_published = ompformat.dateFromRow(
            ompdal.getPublicationDatesByPublicationFormat(
                pdf.publication_format_id, "01").first())
        date_first_published = ompformat.dateFromRow(
            ompdal.getPublicationDatesByPublicationFormat(
                pdf.publication_format_id, "11").first())
    # 2. Date on which the catalog entry was first published
    if not date_published:
        metadatapublished_date = ompdal.getMetaDataPublishedDates(
            submission_id).first()
        date_published = metadatapublished_date.date_logged if metadatapublished_date else None
    # 3. Date on which the submission status was last modified (always set)
    if not date_published:
        date_published = submission.date_status_modified

    series = ompdal.getSeriesBySubmissionId(submission_id)
    if series:
        series = OMPItem(
            series, OMPSettings(ompdal.getSeriesSettings(series.series_id)))

    # Get purchase info
    representatives = ompdal.getRepresentativesBySubmission(
        submission_id, myconf.take('omp.representative_id_type'))

    # stats = OMPStats(myconf, db, locale)
    onix_types = ONIX_PRODUCT_IDENTIFIER_TYPE_CODES
    # submissions = sorted(submissions, key=lambda s: s.attributes['series_id'], reverse=True)
    pfs = digital_publication_formats + physical_publication_formats
    idntfrs = {}

    for p in pfs:
        for i in p.associated_items['identification_codes'].as_list():
            idntfrs['{}.{}'.format(
                i['code'], p.settings.getLocalizedValue(
                    'name',
                    locale))] = (i['value'], i['code'],
                                 p.settings.getLocalizedValue('name', locale))

    idntfrs = sorted(idntfrs.items(),
                     key=lambda i: IDENTIFIER_ORDER.index(
                         (i[0]) if i in IDENTIFIER_ORDER else '15.PDF'))

    category_row = ompdal.getCategoryBySubmissionId(submission_id)
    category = OMPItem(
        category_row,
        OMPSettings(ompdal.getCategorySettings(
            category_row.category_id))) if category_row else None

    cleanTitle = " ".join([
        submission_settings.getLocalizedValue('prefix', locale),
        submission_settings.getLocalizedValue('title', locale)
    ])
    subtitle = submission_settings.getLocalizedValue('subtitle', locale)
    abstract = submission_settings.getLocalizedValue('abstract', locale)
    series_name = ""

    if series:
        series_title = " ".join([
            series.settings.getLocalizedValue('prefix', locale),
            series.settings.getLocalizedValue('title', locale)
        ])
        series_subtitle = series.settings.getLocalizedValue('subtitle', locale)
        series_name = " – ".join(
            [t for t in [series_title.strip(), series_subtitle] if t])

    citation = ompformat.formatCitation(
        cleanTitle,
        subtitle,
        authors,
        editors,
        translators,
        date_published,
        press_settings.getLocalizedValue('location', ''),
        press_settings.getLocalizedValue('publisher', ''),
        locale=locale,
        series_name=series_name,
        series_pos=submission.series_position,
        max_contrib=3,
        date_first_published=date_first_published)
    if authors:
        attribution = ompformat.formatContributors(authors,
                                                   max_contributors=4,
                                                   with_and=True)
        additional_attribution = ompformat.formatAttribution(
            editors, [], translators, [])
        title_attribution = ompformat.formatName(authors[0].settings)
    elif editors:
        suffix = T("(Eds.)") if len(editors) > 1 else T("(Ed.)")
        title_attribution = "{} {}".format(
            ompformat.formatContributors(editors,
                                         max_contributors=4,
                                         with_and=True), suffix)
        attribution = "{} {}".format(
            ompformat.formatContributors(editors,
                                         max_contributors=100,
                                         with_and=True), suffix)
        additional_attribution = ""
    else:
        title_attribution = ompformat.formatName(chapter_authors[0].settings)
        attribution = ompformat.formatAttribution([], [], [], chapter_authors)
        additional_attribution = ""

    response.title = "{}: {} - {}".format(
        title_attribution, cleanTitle,
        settings.short_title if settings.short_title else settings.title)

    if c:
        # Select different template for chapters
        citation = ompformat.formatChapterCitation(citation, c, locale)
        response.view = 'catalog/book/chapter/index.html'
    return locals()
예제 #6
0
def index():
    ompdal = OMPDAL(db, myconf)
    press = ompdal.getPress(myconf.take('omp.press_id'))
    editor_group_id = myconf.take('omp.editor_id', cast=int)
    author_group_id = myconf.take('omp.author_id', cast=int)
    chapter_author_group_id = myconf.take('omp.chapter_author_id', cast=int)
    translator_group_id = int(myconf.get('omp.translator_id')) if myconf.get(
        'omp.translator_id') else None

    if not press:
        redirect(URL('home', 'index'))
    press_settings = OMPSettings(ompdal.getPressSettings(press.press_id))

    ignored_submission_id = myconf.take(
        'omp.ignore_submissions') if myconf.take(
            'omp.ignore_submissions') else -1

    submissions = []
    submission_rows = ompdal.getSubmissionsByPress(press.press_id,
                                                   ignored_submission_id)

    for submission_row in submission_rows:
        # Get contributors and contributor settings
        contributors_by_group = defaultdict(list)
        for contrib in ompdal.getAuthorsBySubmission(
                submission_row.submission_id, filter_browse=True):
            contrib_item = OMPItem(
                contrib,
                OMPSettings(ompdal.getAuthorSettings(contrib.author_id)))
            contributors_by_group[contrib.user_group_id].append(contrib_item)

        editors = contributors_by_group[editor_group_id]
        authors = contributors_by_group[author_group_id]
        chapter_authors = contributors_by_group[chapter_author_group_id]
        translators = []

        if translator_group_id:
            translators = contributors_by_group[translator_group_id]
        publication_dates = [
            ompformat.dateFromRow(pd)
            for pf in ompdal.getAllPublicationFormatsBySubmission(
                submission_row.submission_id, available=True, approved=True)
            for pd in ompdal.getPublicationDatesByPublicationFormat(
                pf.publication_format_id)
        ]
        for s in ompdal.getDigitalPublicationFormats(
                submission_row.submission_id, available=True, approved=True):
            if s['remote_url']:
                frontpage_url = s['remote_url']
                break
        else:
            frontpage_url = URL('book', args=[submission_row.submission_id])
        submission = OMPItem(
            submission_row,
            OMPSettings(
                ompdal.getSubmissionSettings(submission_row.submission_id)), {
                    'authors': authors,
                    'editors': editors,
                    'translators': translators,
                    'chapter_authors': chapter_authors,
                    'frontpage_url': frontpage_url
                })
        if authors:
            attribution = ompformat.formatContributors(authors,
                                                       max_contributors=4,
                                                       with_and=True)
            additional_attribution = ompformat.formatAttribution(
                editors, [], translators, [])
        else:
            attribution = ompformat.formatAttribution(editors, [], [],
                                                      chapter_authors)
            additional_attribution = ""
        submission.attribution = attribution
        submission.additional_attribution = additional_attribution
        category_row = ompdal.getCategoryBySubmissionId(
            submission_row.submission_id)
        if category_row:
            submission.associated_items['category'] = OMPItem(
                category_row,
                OMPSettings(
                    ompdal.getCategorySettings(category_row.category_id)))

        series_row = ompdal.getSeries(submission_row.series_id)
        if series_row:
            submission.associated_items['series'] = OMPItem(
                series_row,
                OMPSettings(ompdal.getSeriesSettings(series_row.series_id)))
        if publication_dates:
            submission.associated_items[
                'publication_dates'] = publication_dates

        submissions.append(submission)

    session.filters = request.vars.get('filter_by').strip('[').strip(
        ']') if request.vars.get('filter_by') else session.get('filters', '')
    session.per_page = int(
        request.vars.get('per_page')) if request.vars.get('per_page') else int(
            session.get('per_page', 20))
    if request.vars.get('sort_by'):
        session.sort_by = request.vars.get('sort_by')
    elif session.get('sort_by'):
        session.sort_by = session.get('sort_by')
    else:
        session.sort_by = 'datePublished-2'

    current = int(request.vars.get('page_nr', 1)) - 1

    b = Browser(submissions, current, locale, session.get('per_page'),
                session.get('sort_by'), session.get('filters'))
    submissions = b.process_submissions(submissions)

    return locals()