Skip to content

Commit

Permalink
Added check for input files
Browse files Browse the repository at this point in the history
  • Loading branch information
brinza888 committed Jan 20, 2022
1 parent 226acae commit 4b5fdc2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/handler/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tornado.web import HTTPError

from frontend.handler.base import BaseRequestHandler
from frontend.handler.editor import EditorHandler
from urpc.builder import bindings
from urpc.builder import firmware
from urpc.builder.adapters import tango
Expand Down Expand Up @@ -143,7 +144,8 @@ def get(self, action):

def post(self, action):
if action == "load":
if not self.request.files or len(self.request.files) == 0: # if user hasn"t recently loaded project file
if not self.request.files:
EditorHandler.messages["load-message"] = "No input file"
self.redirect(".." + self.reverse_url("main"))
file_info = self.request.files["project"][0]
ext = os.path.splitext(file_info["filename"])[1]
Expand All @@ -160,6 +162,9 @@ def post(self, action):

output_buffer, file_name, mime = BytesIO(), "", ""

if not self.request.files:
EditorHandler.messages["assembly-profiles-message"] = "No input file"
self.redirect(".." + self.reverse_url("main"))
files_info = self.request.files["profiles"]

profiles_list = []
Expand Down
2 changes: 2 additions & 0 deletions frontend/templates/editor/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<fieldset>
<input type="file" name="project">
<button type="submit" class="pure-button pure-button-primary">Load</button>
<span class="error-message">{{ messages.get("load-message", "") }}</span>
</fieldset>
</form>
<form class="pure-form pure-form-stacked" action="{{ reverse_url("project", "save")[1:] }}" method="get">
Expand Down Expand Up @@ -117,6 +118,7 @@
<fieldset>
<input type="file" name="profiles" multiple="True">
<button type="submit" class="pure-button pure-button-primary">Assemble</button>
<span class="error-message">{{ messages.get("assembly-profiles-message", "") }}</span>
</fieldset>
</form>

Expand Down

0 comments on commit 4b5fdc2

Please sign in to comment.