1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Merge remote branches 'upstream/master' and 'origin/master'

This commit is contained in:
A.Avenel 2011-11-02 14:36:16 +01:00
commit 66bd6268fa
7 changed files with 30 additions and 8 deletions

View file

@ -56,7 +56,6 @@ class EditProjectForm(Form):
name = TextField(_("Project name"), validators=[Required()]) name = TextField(_("Project name"), validators=[Required()])
password = TextField(_("Private code"), validators=[Required()]) password = TextField(_("Private code"), validators=[Required()])
contact_email = TextField(_("Email"), validators=[Required(), Email()]) contact_email = TextField(_("Email"), validators=[Required(), Email()])
submit = SubmitField(_("Edit the project"))
def save(self): def save(self):
"""Create a new project with the information given by this form. """Create a new project with the information given by this form.

View file

@ -70,6 +70,10 @@ class Project(db.Model):
db.session.commit() db.session.commit()
return person return person
def remove_project(self):
db.session.delete(self)
db.session.commit()
def __repr__(self): def __repr__(self):
return "<Project %s>" % self.name return "<Project %s>" % self.name

View file

@ -1,5 +1,12 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% block js %}
$('#delete-project').click(function ()
{
$(this).html("<a style='color:red; ' href='{{ url_for('.remove_project') }}' >{{_("you sure?")}}</a>");
});
{% endblock %}
{% block content %} {% block content %}
<h2>{{ _("Edit this project") }}</h2> <h2>{{ _("Edit this project") }}</h2>
<form method="post"> <form method="post">

View file

@ -65,7 +65,10 @@
{{ input(form.name) }} {{ input(form.name) }}
{{ input(form.password) }} {{ input(form.password) }}
{{ input(form.contact_email) }} {{ input(form.contact_email) }}
{{ submit(form.submit) }} <div class="actions">
<button class="btn primary">{{ _("Edit the project") }}</button>
<a id="delete-project" style="color:red; margin-left:10px; cursor:pointer; ">{{ _("delete") }}</a>
</div>
{% endmacro %} {% endmacro %}

View file

@ -9,6 +9,8 @@
{% block head %}{% endblock %} {% block head %}{% endblock %}
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(document).ready(function(){ $(document).ready(function(){
var left = window.innerWidth/2-$('.flash').width()/2;
$(".flash").css({ "left": left+"px", "top":"45px" });
setTimeout(function(){ setTimeout(function(){
$(".flash").fadeOut("slow", function () { $(".flash").fadeOut("slow", function () {
$(".flash").remove(); $(".flash").remove();
@ -80,13 +82,13 @@
<div class="container-fluid" style="height: 100%; padding-left: 10px;"> <div class="container-fluid" style="height: 100%; padding-left: 10px;">
{% block sidebar %}{% endblock %} {% block sidebar %}{% endblock %}
<div class="content" style="margin-left: 250px;"> <div class="content" style="margin-left: 250px;">
{% for message in get_flashed_messages() %}
<div class="flash alert-message info"><p>{{ message }}</p></div>
{% endfor %}
{% block content %} {% block content %}
{% endblock %} {% endblock %}
</div> </div>
</div> </div>
{% for message in get_flashed_messages() %}
<div class="flash alert-message info" style="position:absolute;"><p>{{ message }}</p></div>
{% endfor %}
{% endblock %} {% endblock %}
{% block footer %} {% block footer %}
<div id="footer"> <div id="footer">

View file

@ -16,15 +16,17 @@
// display the form when clicking on the "add bill" button // display the form when clicking on the "add bill" button
var show_form = function(){ var show_form = function(){
$('#bill-form').show(70); $('#bill-form').slideDown(1000);
$("#hide-bill-form").show();
$("#new-bill").hide(); $("#new-bill").hide();
return false; return false;
} }
// and provide a mechanism to hide it back // and provide a mechanism to hide it back
var hide_form = function(){ var hide_form = function(){
$("#bill-form").hide(70); $("#bill-form").slideUp(1000);
$("#new-bill").show(); $("#new-bill").show();
$("#hide-bill-form").hide();
return false; return false;
} }
@ -138,7 +140,7 @@
<a id="new-bill" href="{{ url_for(".add_bill") }}" class="btn primary">{{ _("Add a new bill") }}</a> <a id="new-bill" href="{{ url_for(".add_bill") }}" class="btn primary">{{ _("Add a new bill") }}</a>
<form id="bill-form" action="{{ url_for(".add_bill") }}" method="post" style="display: none"> <form id="bill-form" action="{{ url_for(".add_bill") }}" method="post" style="display: none">
<a id="hide-bill-form" href="#">{{ _("hide this form") }}</a> <a class="btn primary" id="hide-bill-form" href="#">{{ _("hide this form") }}</a>
{{ forms.add_bill(bill_form) }} {{ forms.add_bill(bill_form) }}
</form> </form>

View file

@ -185,6 +185,11 @@ def edit_project():
return render_template("edit_project.html", form=form) return render_template("edit_project.html", form=form)
@main.route("/<project_id>/delete", methods=["GET"])
def remove_project():
g.project.remove_project()
return redirect(url_for(".home"))
@main.route("/exit") @main.route("/exit")
def exit(): def exit():