diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 00000000..1ab091c7
Binary files /dev/null and b/.DS_Store differ
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..e7e9d11d
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml
diff --git a/.idea/ihatemoney.iml b/.idea/ihatemoney.iml
new file mode 100644
index 00000000..8b8c3954
--- /dev/null
+++ b/.idea/ihatemoney.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 00000000..105ce2da
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..7a85af69
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..2a266402
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ihatemoney/models.py b/ihatemoney/models.py
index 4d32fd97..05897ba8 100644
--- a/ihatemoney/models.py
+++ b/ihatemoney/models.py
@@ -391,6 +391,14 @@ class Bill(db.Model):
"external_link": self.external_link,
}
+ def to_json(self):
+ bill_dict = self._to_serialize
+ owers_list = []
+ for ower in bill_dict['owers']:
+ owers_list.append(ower.id)
+ bill_dict['owers'] = owers_list
+ return bill_dict
+
def pay_each(self):
"""Compute what each share has to pay"""
if self.owers:
diff --git a/ihatemoney/static/css/main.css b/ihatemoney/static/css/main.css
index a646b175..04e0a66b 100644
--- a/ihatemoney/static/css/main.css
+++ b/ihatemoney/static/css/main.css
@@ -270,6 +270,7 @@ footer .footer-left {
#new-bill {
margin-top: 30px;
+ z-index:100;
}
#previous-page {
@@ -422,7 +423,6 @@ tr.payer_line .balance-name {
position: absolute;
top: 4.5rem;
width: 100%;
- pointer-events: none;
}
.light {
diff --git a/ihatemoney/templates/layout.html b/ihatemoney/templates/layout.html
index dc3d32f6..639429e7 100644
--- a/ihatemoney/templates/layout.html
+++ b/ihatemoney/templates/layout.html
@@ -126,7 +126,7 @@
{% for message in get_flashed_messages() %}
-
{{ message }}
+
{{ message }}
{% endfor %}
diff --git a/ihatemoney/templates/list_bills.html b/ihatemoney/templates/list_bills.html
index 0f2a68a5..9f53c5ba 100644
--- a/ihatemoney/templates/list_bills.html
+++ b/ihatemoney/templates/list_bills.html
@@ -17,6 +17,10 @@
});
});
+ $('.undo').click(function(){
+ console.log("HI");
+ });
+
var highlight_owers = function(){
var ower_ids = $(this).attr("owers").split(',');
var payer_id = $(this).attr("payer");
diff --git a/ihatemoney/web.py b/ihatemoney/web.py
index a3b10726..b4efaa84 100644
--- a/ihatemoney/web.py
+++ b/ihatemoney/web.py
@@ -27,6 +27,7 @@ from flask import (
url_for,
send_file,
send_from_directory,
+ Markup,
)
from flask_babel import get_locale, gettext as _
from flask_mail import Message
@@ -111,8 +112,8 @@ def set_show_admin_dashboard_link(endpoint, values):
"""
g.show_admin_dashboard_link = (
- current_app.config["ACTIVATE_ADMIN_DASHBOARD"]
- and current_app.config["ADMIN_PASSWORD"]
+ current_app.config["ACTIVATE_ADMIN_DASHBOARD"]
+ and current_app.config["ADMIN_PASSWORD"]
)
@@ -167,7 +168,7 @@ def admin():
if form.validate():
# Valid password
if check_password_hash(
- current_app.config["ADMIN_PASSWORD"], form.admin_password.data
+ current_app.config["ADMIN_PASSWORD"], form.admin_password.data
):
session["is_admin"] = True
session.update()
@@ -225,9 +226,9 @@ def authenticate(project_id=None):
# else do form authentication or token authentication
is_post_auth = request.method == "POST" and form.validate()
if (
- is_post_auth
- and check_password_hash(project.password, form.password.data)
- or token_auth
+ is_post_auth
+ and check_password_hash(project.password, form.password.data)
+ or token_auth
):
# maintain a list of visited projects
if "projects" not in session:
@@ -590,8 +591,8 @@ def list_bills():
# Preload the "owers" relationship for all bills
bills = (
g.project.get_bills()
- .options(orm.subqueryload(Bill.owers))
- .paginate(per_page=100, error_out=True)
+ .options(orm.subqueryload(Bill.owers))
+ .paginate(per_page=100, error_out=True)
)
return render_template(
@@ -622,8 +623,8 @@ def add_member():
def reactivate(member_id):
person = (
Person.query.filter(Person.id == member_id)
- .filter(Project.id == g.project.id)
- .all()
+ .filter(Project.id == g.project.id)
+ .all()
)
if person:
person[0].activated = True
@@ -691,6 +692,22 @@ def add_bill():
return render_template("add_bill.html", form=form)
+@main.route("//undo")
+def undo_delete_bill():
+ bill = Bill()
+ form = get_billform_for(g.project)
+ form.what = session["recently_deleted_bill"]["what"]
+ form.amount = session["recently_deleted_bill"]["amount"]
+ form.date = parse(session["recently_deleted_bill"]["date"])
+ form.payer = session["recently_deleted_bill"]["payer_id"]
+ form.payed_for = session["recently_deleted_bill"]["owers"]
+ form.external_link = session["recently_deleted_bill"]["external_link"]
+
+ db.session.add(form.fake_form(bill, g.project))
+ db.session.commit()
+ return redirect(url_for(".list_bills"))
+
+
@main.route("//delete/")
def delete_bill(bill_id):
# fixme: everyone is able to delete a bill
@@ -700,7 +717,12 @@ def delete_bill(bill_id):
db.session.delete(bill)
db.session.commit()
- flash(_("The bill has been deleted"))
+
+ session["test"] = bill.to_json()
+
+ url = url_for(".undo_delete_bill")
+ alert = 'The bill has been deleted undo '
+ flash(Markup(alert))
return redirect(url_for(".list_bills"))