def perform_request_issue_control(journal_name, issues, action, ln=CFG_SITE_LANG): """ Central logic for issue control. Regenerates the flat files 'current_issue' and 'issue_group' of the journal that control which issue is currently active for the journal. Parameters: journal_name - the journal affected by 'action' issues - list of issues affected by 'action' TODO: check action - One of ['cfg', _('Add'), _('Refresh'), _('Publish'), _('Update')] ln - language """ _ = gettext_set_language(ln) out = "" if action == "cfg" or action == _("Refresh") or action == _("Add"): # find out if we are in update or release current_issue = get_current_issue(ln, journal_name) grouped_issues = get_grouped_issues(journal_name, current_issue) if current_issue != grouped_issues[-1]: # The current issue has "pending updates", i.e. is grouped # with unreleased issues. Propose to update these issues next_issue = grouped_issues[grouped_issues.index(current_issue) + 1] out = wjt.tmpl_admin_update_issue(ln, journal_name, next_issue, current_issue) else: # Propose a release next_issues = get_next_journal_issues( current_issue, journal_name, n=get_journal_issue_grouping(journal_name) ) if action == _("Refresh"): next_issues += issues next_issues = list(set(next_issues)) # avoid double entries elif action == _("Add"): next_issues += issues next_issues = list(set(next_issues)) # avoid double entries next_issues.sort(compare_issues) highest_issue_so_far = next_issues[-1] one_more_issue = get_next_journal_issues(highest_issue_so_far, journal_name, 1) next_issues += one_more_issue next_issues = list(set(next_issues)) # avoid double entries else: # get the next issue numbers to publish next_issues = get_next_journal_issues( current_issue, journal_name, n=get_journal_issue_grouping(journal_name) ) next_issues.sort(compare_issues) out = wjt.tmpl_admin_control_issue(ln, journal_name, next_issues) elif action == _("Publish"): # Publish the given issues (mark them as current issues) publish_issues = issues publish_issues = list(set(publish_issues)) # avoid double entries publish_issues.sort(compare_issues) if len(publish_issues) == 0: # User did not select an issue current_issue = get_current_issue(ln, journal_name) next_issues = get_next_journal_issues( current_issue, journal_name, n=get_journal_issue_grouping(journal_name) ) out = '<p style="color:#f00;text-align:center">' + _("Please select an issue") + "</p>" out += wjt.tmpl_admin_control_issue(ln, journal_name, next_issues) return out try: release_journal_issue(publish_issues, journal_name, ln) except InvenioWebJournalJournalIdNotFoundDBError, e: register_exception(req=None) return e.user_box() out = wjt.tmpl_admin_control_issue_success_msg(ln, publish_issues, journal_name)
issue_display = get_issue_number_display(issue_number, journal_name, ln) except InvenioWebJournalJournalIdNotFoundDBError, e: return e.user_box() except Exception, e: issue_display = issue_number issues = issue_display.split("/")[0] year = issue_display.split("/")[1] week_numbers = issues.split("-") if group_issues_date.lower() == 'yes': # Get release time of this issue (do not consider issue # "updates": take the earliest issue number of this group of # issues) grouped_issues = get_grouped_issues(journal_name, issue_number) if grouped_issues: issue_number = grouped_issues[0] if estimate_release_date.lower() == 'yes': # Get theoretical release date if granularity.lower() == 'day': granularity = DAILY elif granularity.lower() == 'week': granularity = WEEKLY elif granularity.lower() == 'month': granularity = MONTHLY else: granularity = None issue_release_time = issue_to_datetime(issue_number, journal_name, granularity)
""" if journal_name is None: try: journal_name = guess_journal_name(ln) except InvenioWebJournalNoJournalOnServerError, e: return e.user_box() if not can_read_xml_config(journal_name): return ( '<span style="color:#f00">Configuration could not be read. Please check that %s/webjournal/%s/%s-config.xml exists and can be read by the server.</span><br/>' % (CFG_ETCDIR, journal_name, journal_name) ) current_issue = get_current_issue(ln, journal_name) current_publication = get_issue_number_display(current_issue, journal_name, ln) issue_list = get_grouped_issues(journal_name, current_issue) next_issue_number = get_next_journal_issues(issue_list[-1], journal_name, 1) return wjt.tmpl_admin_administrate( journal_name, current_issue, current_publication, issue_list, next_issue_number[0], ln, as_editor=as_editor ) def perform_feature_record(journal_name, recid, img_url="", action="", ln=CFG_SITE_LANG): """ Interface to feature a record Used to list, add and remove featured records of the journal. Parameters: journal_name - the journal for which the article is featured
def test_get_grouped_issues(self): """webjournal - returns all the issues grouped with a given one""" issues = wju.get_grouped_issues('AtlantisTimes', '03/2009') self.assertEqual(issues[0], '02/2009') self.assertEqual(issues[1], '03/2009')
journal_name, ln) except InvenioWebJournalJournalIdNotFoundDBError, e: return e.user_box() except Exception, e: issue_display = issue_number issues = issue_display.split("/")[0] year = issue_display.split("/")[1] week_numbers = issues.split("-") if group_issues_date.lower() == 'yes': # Get release time of this issue (do not consider issue # "updates": take the earliest issue number of this group of # issues) grouped_issues = get_grouped_issues(journal_name, issue_number) if grouped_issues: issue_number = grouped_issues[0] if estimate_release_date.lower() == 'yes': # Get theoretical release date if granularity.lower() == 'day': granularity = DAILY elif granularity.lower() == 'week': granularity = WEEKLY elif granularity.lower() == 'month': granularity = MONTHLY else: granularity = None issue_release_time = issue_to_datetime(issue_number, journal_name,
def perform_request_issue_control(journal_name, issues, action, ln=CFG_SITE_LANG): """ Central logic for issue control. Regenerates the flat files 'current_issue' and 'issue_group' of the journal that control which issue is currently active for the journal. Parameters: journal_name - the journal affected by 'action' issues - list of issues affected by 'action' TODO: check action - One of ['cfg', _('Add'), _('Refresh'), _('Publish'), _('Update')] ln - language """ _ = gettext_set_language(ln) out = '' if action == "cfg" or action == _("Refresh") or action == _("Add"): # find out if we are in update or release current_issue = get_current_issue(ln, journal_name) grouped_issues = get_grouped_issues(journal_name, current_issue) if current_issue != grouped_issues[-1]: # The current issue has "pending updates", i.e. is grouped # with unreleased issues. Propose to update these issues next_issue = grouped_issues[grouped_issues.index(current_issue) + 1] out = wjt.tmpl_admin_update_issue(ln, journal_name, next_issue, current_issue) else: # Propose a release next_issues = get_next_journal_issues( current_issue, journal_name, n=get_journal_issue_grouping(journal_name)) if action == _("Refresh"): next_issues += issues next_issues = list(set(next_issues)) # avoid double entries elif action == _("Add"): next_issues += issues next_issues = list(set(next_issues)) # avoid double entries next_issues.sort(compare_issues) highest_issue_so_far = next_issues[-1] one_more_issue = get_next_journal_issues( highest_issue_so_far, journal_name, 1) next_issues += one_more_issue next_issues = list(set(next_issues)) # avoid double entries else: # get the next issue numbers to publish next_issues = get_next_journal_issues( current_issue, journal_name, n=get_journal_issue_grouping(journal_name)) next_issues.sort(compare_issues) out = wjt.tmpl_admin_control_issue(ln, journal_name, next_issues) elif action == _("Publish"): # Publish the given issues (mark them as current issues) publish_issues = issues publish_issues = list(set(publish_issues)) # avoid double entries publish_issues.sort(compare_issues) if len(publish_issues) == 0: # User did not select an issue current_issue = get_current_issue(ln, journal_name) next_issues = get_next_journal_issues( current_issue, journal_name, n=get_journal_issue_grouping(journal_name)) out = '<p style="color:#f00;text-align:center">' + \ _('Please select an issue') + '</p>' out += wjt.tmpl_admin_control_issue(ln, journal_name, next_issues) return out try: release_journal_issue(publish_issues, journal_name, ln) except InvenioWebJournalJournalIdNotFoundDBError, e: register_exception(req=None) return e.user_box() out = wjt.tmpl_admin_control_issue_success_msg(ln, publish_issues, journal_name)
with_editor_rights - True if can edit configuration. Read-only mode otherwise """ if journal_name is None: try: journal_name = guess_journal_name(ln) except InvenioWebJournalNoJournalOnServerError, e: return e.user_box() if not can_read_xml_config(journal_name): return '<span style="color:#f00">Configuration could not be read. Please check that %s/webjournal/%s/%s-config.xml exists and can be read by the server.</span><br/>' % ( CFG_ETCDIR, journal_name, journal_name) current_issue = get_current_issue(ln, journal_name) current_publication = get_issue_number_display(current_issue, journal_name, ln) issue_list = get_grouped_issues(journal_name, current_issue) next_issue_number = get_next_journal_issues(issue_list[-1], journal_name, 1) return wjt.tmpl_admin_administrate(journal_name, current_issue, current_publication, issue_list, next_issue_number[0], ln, as_editor=as_editor) def perform_feature_record(journal_name, recid, img_url='',