aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/submit/lib.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-11-14 11:06:10 -0600
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-11-14 11:06:10 -0600
commit5d754da741994ad3364fce6c57c1786b63ef292f (patch)
tree0a4c4dd32135de7b8eab355d2d76216aaff6f754 /mediagoblin/submit/lib.py
parent86d5cb8a5756ed9df721ec3dc2a0e53e5c8bd109 (diff)
downloadmediagoblin-5d754da741994ad3364fce6c57c1786b63ef292f.tar.lz
mediagoblin-5d754da741994ad3364fce6c57c1786b63ef292f.tar.xz
mediagoblin-5d754da741994ad3364fce6c57c1786b63ef292f.zip
Breaking out get_upload_file_limits into its own utility.
This commit sponsored by Mikael Nordfeldth. Thank you!
Diffstat (limited to 'mediagoblin/submit/lib.py')
-rw-r--r--mediagoblin/submit/lib.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/mediagoblin/submit/lib.py b/mediagoblin/submit/lib.py
index 1314df1e..975d920e 100644
--- a/mediagoblin/submit/lib.py
+++ b/mediagoblin/submit/lib.py
@@ -21,13 +21,13 @@ from os.path import splitext
from werkzeug.utils import secure_filename
from werkzeug.datastructures import FileStorage
+from mediagoblin import mg_globals
from mediagoblin.tools.text import convert_to_tag_list_of_dicts
from mediagoblin.db.models import MediaEntry
from mediagoblin.processing import mark_entry_failed
from mediagoblin.processing.task import ProcessMedia
from mediagoblin.notifications import add_comment_subscription
-from mediagoblin.media_types import sniff_media, \
- InvalidFileType, FileTypeNotSupported
+from mediagoblin.media_types import sniff_media
_log = logging.getLogger(__name__)
@@ -53,6 +53,20 @@ def new_upload_entry(user):
return entry
+def get_upload_file_limits(user):
+ """
+ Get the upload_limit and max_file_size for this user
+ """
+ if user.upload_limit >= 0:
+ upload_limit = user.upload_limit
+ else:
+ upload_limit = mg_globals.app_config.get('upload_limit', None)
+
+ max_file_size = mg_globals.app_config.get('max_file_size', None)
+
+ return upload_limit, max_file_size
+
+
class UploadLimitError(Exception):
"""
General exception for when an upload will be over some upload limit
@@ -173,6 +187,8 @@ def submit_media(mg_app, user, submitted_file, filename,
add_comment_subscription(user, entry)
+ return entry
+
def prepare_queue_task(app, entry, filename):
"""