def perform_regenerate_issue(issue, journal_name, ln=CFG_SITE_LANG): """ Clears the cache for the given issue. Parameters: journal_name - the journal for which the cache should be deleted issue - the issue for which the cache should be deleted ln - language """ success = clear_cache_for_issue(journal_name, issue) if success: return wjt.tmpl_admin_regenerate_success(ln, journal_name, issue) else: return wjt.tmpl_admin_regenerate_error(ln, journal_name, issue)
def perform_regenerate_issue(issue, journal_name, ln=CFG_SITE_LANG, confirmed_p=False, publish_draft_articles_p=False): """ Clears the cache for the given issue. Parameters: journal_name - the journal for which the cache should be deleted issue - the issue for which the cache should be deleted ln - language confirmed_p - if True, regenerate. Else ask confirmation publish_draft_articles_p - should the remaining draft articles in the issue be made public? """ if not confirmed_p: # Ask user confirmation about the regeneration current_issue = get_current_issue(ln, journal_name) issue_released_p = not issue_is_later_than(issue, current_issue) return wjt.tmpl_admin_regenerate_confirm(ln, journal_name, issue, issue_released_p) else: # Regenerate the issue (clear the cache) success = clear_cache_for_issue(journal_name, issue) if publish_draft_articles_p: current_issue = get_current_issue(ln, journal_name) if not issue_is_later_than(issue, current_issue): # This issue is already released: we can safely publish # the articles. Otherwise we'll refuse to publish the drafts move_drafts_articles_to_ready(journal_name, issue) if success: return wjt.tmpl_admin_regenerate_success(ln, journal_name, issue) else: return wjt.tmpl_admin_regenerate_error(ln, journal_name, issue)
def test_clear_cache_for_issue(self): """webjournal - clears the cache of a whole issue""" value = wju.clear_cache_for_issue('AtlantisTimes', '03/2009') self.assertEqual(value, True)