diff --git a/.gitignore b/.gitignore
index b7e8680f..f0668257 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,5 @@ dist
build
.vscode
.env
-.pytest_cache
\ No newline at end of file
+.pytest_cache
+.idea/
diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py
index eb1bf2b9..dfe8a17e 100644
--- a/ihatemoney/forms.py
+++ b/ihatemoney/forms.py
@@ -10,6 +10,8 @@ from wtforms.validators import (
NumberRange,
Optional,
)
+from flask_wtf.file import FileField, FileAllowed, FileRequired
+
from flask_babel import lazy_gettext as _
from flask import request
from werkzeug.security import generate_password_hash
@@ -109,6 +111,12 @@ class EditProjectForm(FlaskForm):
return project
+class UploadForm(FlaskForm):
+ file = FileField('JSON', validators=[
+ FileRequired(),
+ FileAllowed(['json', 'JSON'], 'JSON only!')
+ ])
+
class ProjectForm(EditProjectForm):
id = StringField(_("Project identifier"), validators=[DataRequired()])
diff --git a/ihatemoney/templates/forms.html b/ihatemoney/templates/forms.html
index 12cc1651..48b55e96 100644
--- a/ihatemoney/templates/forms.html
+++ b/ihatemoney/templates/forms.html
@@ -85,6 +85,16 @@
{% endmacro %}
+{% macro upload_json(form) %}
+ {% include "display_errors.html" %}
+ {{ form.hidden_tag() }}
+ {{ form.file }}
+ {{ form.csrf_token() }}
+
+
+
+{% endmacro %}
+
{% macro add_bill(form, edit=False, title=True) %}