mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-06 13:01:50 +02:00
initial
This commit is contained in:
parent
4f1cf71256
commit
73748255b0
12 changed files with 88 additions and 13 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
2
.idea/.gitignore
vendored
Normal file
2
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Default ignored files
|
||||||
|
/workspace.xml
|
12
.idea/ihatemoney.iml
Normal file
12
.idea/ihatemoney.iml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
7
.idea/misc.xml
Normal file
7
.idea/misc.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
||||||
|
<component name="PyCharmProfessionalAdvertiser">
|
||||||
|
<option name="shown" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/ihatemoney.iml" filepath="$PROJECT_DIR$/.idea/ihatemoney.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -391,6 +391,14 @@ class Bill(db.Model):
|
||||||
"external_link": self.external_link,
|
"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):
|
def pay_each(self):
|
||||||
"""Compute what each share has to pay"""
|
"""Compute what each share has to pay"""
|
||||||
if self.owers:
|
if self.owers:
|
||||||
|
|
|
@ -270,6 +270,7 @@ footer .footer-left {
|
||||||
|
|
||||||
#new-bill {
|
#new-bill {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
|
z-index:100;
|
||||||
}
|
}
|
||||||
|
|
||||||
#previous-page {
|
#previous-page {
|
||||||
|
@ -422,7 +423,6 @@ tr.payer_line .balance-name {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 4.5rem;
|
top: 4.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
pointer-events: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.light {
|
.light {
|
||||||
|
|
|
@ -126,7 +126,7 @@
|
||||||
|
|
||||||
<div class="messages">
|
<div class="messages">
|
||||||
{% for message in get_flashed_messages() %}
|
{% for message in get_flashed_messages() %}
|
||||||
<div class="flash alert alert-success">{{ message }}</div>
|
<div style="z-index:2;" class="alert alert-success">{{ message }}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.undo').click(function(){
|
||||||
|
console.log("HI");
|
||||||
|
});
|
||||||
|
|
||||||
var highlight_owers = function(){
|
var highlight_owers = function(){
|
||||||
var ower_ids = $(this).attr("owers").split(',');
|
var ower_ids = $(this).attr("owers").split(',');
|
||||||
var payer_id = $(this).attr("payer");
|
var payer_id = $(this).attr("payer");
|
||||||
|
|
|
@ -27,6 +27,7 @@ from flask import (
|
||||||
url_for,
|
url_for,
|
||||||
send_file,
|
send_file,
|
||||||
send_from_directory,
|
send_from_directory,
|
||||||
|
Markup,
|
||||||
)
|
)
|
||||||
from flask_babel import get_locale, gettext as _
|
from flask_babel import get_locale, gettext as _
|
||||||
from flask_mail import Message
|
from flask_mail import Message
|
||||||
|
@ -111,8 +112,8 @@ def set_show_admin_dashboard_link(endpoint, values):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
g.show_admin_dashboard_link = (
|
g.show_admin_dashboard_link = (
|
||||||
current_app.config["ACTIVATE_ADMIN_DASHBOARD"]
|
current_app.config["ACTIVATE_ADMIN_DASHBOARD"]
|
||||||
and current_app.config["ADMIN_PASSWORD"]
|
and current_app.config["ADMIN_PASSWORD"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +168,7 @@ def admin():
|
||||||
if form.validate():
|
if form.validate():
|
||||||
# Valid password
|
# Valid password
|
||||||
if check_password_hash(
|
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["is_admin"] = True
|
||||||
session.update()
|
session.update()
|
||||||
|
@ -225,9 +226,9 @@ def authenticate(project_id=None):
|
||||||
# else do form authentication or token authentication
|
# else do form authentication or token authentication
|
||||||
is_post_auth = request.method == "POST" and form.validate()
|
is_post_auth = request.method == "POST" and form.validate()
|
||||||
if (
|
if (
|
||||||
is_post_auth
|
is_post_auth
|
||||||
and check_password_hash(project.password, form.password.data)
|
and check_password_hash(project.password, form.password.data)
|
||||||
or token_auth
|
or token_auth
|
||||||
):
|
):
|
||||||
# maintain a list of visited projects
|
# maintain a list of visited projects
|
||||||
if "projects" not in session:
|
if "projects" not in session:
|
||||||
|
@ -590,8 +591,8 @@ def list_bills():
|
||||||
# Preload the "owers" relationship for all bills
|
# Preload the "owers" relationship for all bills
|
||||||
bills = (
|
bills = (
|
||||||
g.project.get_bills()
|
g.project.get_bills()
|
||||||
.options(orm.subqueryload(Bill.owers))
|
.options(orm.subqueryload(Bill.owers))
|
||||||
.paginate(per_page=100, error_out=True)
|
.paginate(per_page=100, error_out=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
|
@ -622,8 +623,8 @@ def add_member():
|
||||||
def reactivate(member_id):
|
def reactivate(member_id):
|
||||||
person = (
|
person = (
|
||||||
Person.query.filter(Person.id == member_id)
|
Person.query.filter(Person.id == member_id)
|
||||||
.filter(Project.id == g.project.id)
|
.filter(Project.id == g.project.id)
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
if person:
|
if person:
|
||||||
person[0].activated = True
|
person[0].activated = True
|
||||||
|
@ -691,6 +692,22 @@ def add_bill():
|
||||||
return render_template("add_bill.html", form=form)
|
return render_template("add_bill.html", form=form)
|
||||||
|
|
||||||
|
|
||||||
|
@main.route("/<project_id>/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("/<project_id>/delete/<int:bill_id>")
|
@main.route("/<project_id>/delete/<int:bill_id>")
|
||||||
def delete_bill(bill_id):
|
def delete_bill(bill_id):
|
||||||
# fixme: everyone is able to delete a bill
|
# fixme: everyone is able to delete a bill
|
||||||
|
@ -700,7 +717,12 @@ def delete_bill(bill_id):
|
||||||
|
|
||||||
db.session.delete(bill)
|
db.session.delete(bill)
|
||||||
db.session.commit()
|
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 <a class="alert-link" href="' + url + '" id="undo"> undo </a>'
|
||||||
|
flash(Markup(alert))
|
||||||
|
|
||||||
return redirect(url_for(".list_bills"))
|
return redirect(url_for(".list_bills"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue