Compare commits
3 Commits
58eb61c201
...
f837501f10
Author | SHA1 | Date |
---|---|---|
Kostanjevec | f837501f10 | |
Kostanjevec | 68f50d7150 | |
Kostanjevec | 7ac982e2b5 |
2
auth.py
2
auth.py
|
@ -24,6 +24,8 @@ def register():
|
|||
error = 'Username is required.'
|
||||
elif not password:
|
||||
error = 'Password is required.'
|
||||
elif dbsession.query(User).filter(User.username == username).first() != None:
|
||||
error = "Username already exists, please choose another one"
|
||||
|
||||
if error is None:
|
||||
try:
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
{% block content %}
|
||||
{% if list_of_matches %}
|
||||
<table>
|
||||
{% for match in list_of_matches %}
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Users</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
{% for match in list_of_matches %}
|
||||
<TR>
|
||||
<TD>
|
||||
{{ match[0]['title'] }}
|
||||
|
@ -21,6 +22,9 @@
|
|||
{{ names_by_ids[card['owner_id']] }}
|
||||
{% endfor %}
|
||||
</TD>
|
||||
<TD>
|
||||
<a href="mailto:email@placeholder.com">send email</a>
|
||||
</TD>
|
||||
</TR>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
21
upload.py
21
upload.py
|
@ -34,26 +34,23 @@ def upload_file():
|
|||
username = session["username"]
|
||||
|
||||
if request.method == 'POST':
|
||||
#flask gets the file
|
||||
#print(list(request.files)[0][1])
|
||||
#upload = request.files["file"]
|
||||
#print(upload)
|
||||
|
||||
#uploads = list(request.files)[0]
|
||||
#print(uploads)
|
||||
print(request.files)
|
||||
#@TODO ta forloop bi lahko flashal postopoma
|
||||
for upload in request.files.getlist("file"):
|
||||
filename = secure_filename(upload.filename)
|
||||
# Is there really a file?
|
||||
if not filename:
|
||||
flash('There is no file. Try again?')
|
||||
|
||||
return render_template("menu/upload.html", username=username)
|
||||
|
||||
script_path = os.path.dirname(os.path.abspath(__file__))
|
||||
temp_path = os.path.join(script_path, "temp")
|
||||
#prevent duplicate filenames
|
||||
print(filename)
|
||||
if dbsession.query(Card).filter(Card.title == filename).first() != None:
|
||||
flash("Filename already in database, please rename if you want to upload: " + filename, 'error')
|
||||
continue
|
||||
|
||||
script_path = os.path.dirname(os.path.abspath(__file__)) #where are we
|
||||
temp_path = os.path.join(script_path, "temp") #where is the temp file
|
||||
|
||||
# @TODO ne dela za več fajlov
|
||||
# a lot of stuff can wrong here and nobody may know
|
||||
with tempfile.NamedTemporaryFile(dir=temp_path, delete=False) as fp:
|
||||
fp.write(upload.stream.read())
|
||||
|
|
Loading…
Reference in New Issue