From 73748255b0e92fcec177b72064d9a63c73c6f966 Mon Sep 17 00:00:00 2001 From: rosechar Date: Sun, 12 Apr 2020 23:29:59 -0400 Subject: [PATCH] initial --- .DS_Store | Bin 0 -> 8196 bytes .idea/.gitignore | 2 + .idea/ihatemoney.iml | 12 +++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/misc.xml | 7 +++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ ihatemoney/models.py | 8 ++++ ihatemoney/static/css/main.css | 2 +- ihatemoney/templates/layout.html | 2 +- ihatemoney/templates/list_bills.html | 4 ++ ihatemoney/web.py | 44 +++++++++++++----- 12 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 .DS_Store create mode 100644 .idea/.gitignore create mode 100644 .idea/ihatemoney.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1ab091c79b847c371660fcd4b17cc7c2a898664c GIT binary patch literal 8196 zcmeHMTWl0n7(U;&zziMeP%2b(vs-H^!4kGmXb`2_8`=v}-IkV%w6i-S9i5#iJF{D$ zl&mHajUnnA7vm-I#o*;dK_9&(-rj6tAn^rFygaB0zK|H>f9A|K&2rCd) zAgn-Gfv^H$1#X23(3#Dfw7|J9wBZ<5AgsV`Spoijh*Rg746rEBe|6B{UjYdD6~J%w zO!olaCmvujz@k9km12t90|HkBR}2Vu(#N?uVKTs?K;h0H+!=zE5!_JVuTFk(-<%;S zFdV}QgcX=u0ls~fGLwxljd|DK-_sNBc-nH(r2jHKZkeu^NPLG#S^1*HOC(vAAD3V)#ywPtd%xn*->yeY9|sxdy<(voP5H*elLH6=@{>zf|z9?c#-HhFyN z#2Jwvf_DU~oR#m{g_5=0LWf8;GF?jc@=UTzE0kr?p5DG)k0>K*Re|!@J?@!~?d~yh zF5!q;=~C|98OQF=8C*YKP2hstZKE*Ca=Mi;Z6RnLlNYZ{T@5mW63bC?2+9<1< zG~iOYBE&|eNmgBX;3?vOaBWt$N~$goT3Xt$glL+^}hFp4!gZXml@^x9Pf}OOjNV+#v{3ms}S-lnCP&q%N5d zbD0jODBHw3Ssxo^IX1~ovD54g_CCA7F0xPAH*A_+W% zS~MVmCTvDC+R%eu^kEnp($HbxNx1M(zyyxtS)9akcpfj}G|u20UcsAq2k+uNe29U}Us-*}s@3uO^&6YF?P#BHwE&qkksf?+=MO3d>A@Hf&~>)xfG!)ad4K$6=HWAbN8e@uDMw>wPjT22uOkG5L7uqdb6-6zl z4I#AmZzt_yqQ20!MoG&8T}4Aok>r1i#$T~-*%kI15%?PW8;ena8q^YXH=qTrMBGkv zVJCLuQKT?{K^(*=Q8+^+&ceZAs<@za~0g!j)O{?Yoh__+cUX7E(Fea_mE-FH!$S*Kl^T3X}h>p0=eKMd(P9_W$* d76p=q+JF8-fcQ2Vp8vDI#)jv=&&S(k_y={)KG*;N literal 0 HcmV?d00001 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"))