diff --git a/forms.py b/forms.py deleted file mode 100644 index 287683c..0000000 --- a/forms.py +++ /dev/null @@ -1,31 +0,0 @@ -from flask_wtf import FlaskForm -from flask_wtf.file import FileField -from wtforms import RadioField, StringField - -class TranscriptionForm(FlaskForm): - xml_upload_remote = RadioField('Upload or get XML from SCTA?', default='remote', - description='If you want to use a local XML file, you can upload it. Otherwise you ' - 'can provide a SCTA resource id.', - choices=[('remote', 'Remote'), ('upload', 'Upload')]) - xslt_upload_default = RadioField('Upload or use default XSLT?', default='default', - description='Supply a custom xslt transformation stylesheet or use the default ' - 'system stylesheets. If the default system stylesheets are chosen, ' - 'the correct stylesheet will be determined based on the ' - 'schemaRef in the XML file.', - choices=[('default', 'Default'), ('upload', 'Upload')]) - pdf_tex = RadioField('Return PDF or TeX', description="Choose whether you want to get a PDF or TeX file.", - default='tex', choices=[('tex', 'TeX'), ('pdf', 'PDF')]) - scta_id = StringField('SCTA Id', description='The SCTA id is the id of the resource that you want to process. ' - 'Resource ids can be identified on scta.info. For instance scta.info/resource/deAnima' - ' lists all resource ids of De anima commentaries, ' - 'while scta.info/resource' - '/sententia lists all Sentence commentaries, and from there the ' - 'resource ids of each the relevant work items.') - xml_upload = FileField('XML Upload', - description='The uploaded file must be valid XML and in compliance with the LombardPress ' - 'Schema.') - xslt_upload = FileField('XSLT Upload') - diff --git a/upload_file.py b/upload_file.py deleted file mode 100644 index ba6db82..0000000 --- a/upload_file.py +++ /dev/null @@ -1,66 +0,0 @@ -import os - - -class UploadFile(): - def __init__(self, name, type=None, size=None, not_allowed_msg=''): - self.name = name - self.type = type - self.size = size - self.not_allowed_msg = not_allowed_msg - self.url = "data/%s" % name - self.thumbnail_url = "thumbnail/%s" % name - self.delete_url = "delete/%s" % name - self.delete_type = "DELETE" - - def is_image(self): - fileName, fileExtension = os.path.splitext(self.name.lower()) - - if fileExtension in ['.jpg', '.png', '.jpeg', '.bmp']: - return True - - return False - - def get_file(self): - if self.type != None: - # POST an image - if self.type.startswith('image'): - return {"name": self.name, - "type": self.type, - "size": self.size, - "url": self.url, - "thumbnailUrl": self.thumbnail_url, - "deleteUrl": self.delete_url, - "deleteType": self.delete_type, } - - # POST an normal file - elif self.not_allowed_msg == '': - return {"name": self.name, - "type": self.type, - "size": self.size, - "url": self.url, - "deleteUrl": self.delete_url, - "deleteType": self.delete_type, } - - # File type is not allowed - else: - return {"error": self.not_allowed_msg, - "name": self.name, - "type": self.type, - "size": self.size, } - - # GET image from disk - elif self.is_image(): - return {"name": self.name, - "size": self.size, - "url": self.url, - "thumbnailUrl": self.thumbnail_url, - "deleteUrl": self.delete_url, - "deleteType": self.delete_type, } - - # GET normal file from disk - else: - return {"name": self.name, - "size": self.size, - "url": self.url, - "deleteUrl": self.delete_url, - "deleteType": self.delete_type, } \ No newline at end of file