-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:IACR/latex-submit
- Loading branch information
Showing
11 changed files
with
120 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""This is used only if config.DEMO_INSTANCE is True, and is | ||
used to remove old articles. | ||
""" | ||
|
||
from datetime import datetime, timedelta | ||
from pathlib import Path | ||
import shutil | ||
|
||
from sqlalchemy import create_engine, select | ||
from sqlalchemy.orm import Session | ||
from . import scheduler | ||
from .metadata.db_models import PaperStatus | ||
|
||
def cleanup_task(): | ||
with scheduler.app.app_context(): | ||
if scheduler.app.config['DEBUG']: | ||
scheduler.app.logger.warning('skipping cleanup of existing papers') | ||
return | ||
if scheduler.app.config['DEMO_INSTANCE']: | ||
scheduler.app.logger.warning('cleanup should not be configured') | ||
return | ||
scheduler.app.logger.warning('cleaning up papers') | ||
submit_deadline = datetime.now() - timedelta(days=1) | ||
copyedit_deadline = datetime.now() - timedelta(days=4) | ||
engine = create_engine(scheduler.app.config['SQLALCHEMY_DATABASE_URI']) | ||
deleted_ids = set() | ||
with Session(engine) as session: | ||
papers = session.execute(select(PaperStatus)).scalars().all() | ||
for paper in papers: | ||
if paper.status == PaperStatus.PENDING.value and paper.lastmodified < submit_deadline: | ||
deleted_ids.add(paper.paperid) | ||
session.delete(paper) | ||
elif paper.lastmodified < copyedit_deadline: | ||
deleted_ids.add(paper.paperid) | ||
session.delete(paper) | ||
session.commit() | ||
engine.dispose(True) | ||
for paperid in deleted_ids: | ||
dir = Path(scheduler.app.config['DATA_DIR']) / Path(paperid) | ||
try: | ||
shutil.rmtree(dir) | ||
scheduler.app.logger.warning('Deleted {}'.format(dir.name)) | ||
except Exception as e: | ||
scheduler.app.logger.warning('Unable to delete the directory for the paper {}. ({})'.format(str(dir.absolute()), str(e))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,11 @@ class Config: | |
CROSSREF_PUBLISHER_EMAIL = '[email protected]' | ||
USERS = None | ||
TESTING = False | ||
DEMO_INSTANCE = False | ||
WTF_CSRF_TIME_LIMIT = None | ||
EXPORT_PATH = '/tmp' | ||
FUNDING_SEARCH_URL = '/searchapi/search' | ||
SUBMIT_BYPASS = 'testing' | ||
SUBMIT_BYPASS = '' # now deprecated and replaced by DEMO_INSTANCE | ||
JOURNALS = [ | ||
{ | ||
'hotcrp_key': 'cic', | ||
|
@@ -75,6 +76,7 @@ class DebugConfig(Config): | |
FLASK_ENV = 'development' | ||
DEBUG = True | ||
TESTING = True | ||
DEMO_INSTANCE = True | ||
# used by kevin. | ||
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://publication:st0remydata@localhost/publication' | ||
# SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://publication:mystuff@localhost/publication' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,4 @@ requests | |
docker | ||
markdown | ||
pymemcache | ||
apscheduler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters