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

Addition of an auto hiding user information message in the add user text field (with translation).

This commit is contained in:
Tinmn 2011-11-20 14:37:32 +01:00
parent 9962b6d60f
commit a5cc50b0c2
7 changed files with 365 additions and 312 deletions

View file

@ -141,7 +141,7 @@ class BillForm(Form):
class MemberForm(Form):
name = TextField(_("Name"), validators=[Required()])
name = TextField(_("Name"), validators=[Required()], default=_("Type user name here"))
submit = SubmitField(_("Add"))
def __init__(self, project, *args, **kwargs):
@ -149,6 +149,8 @@ class MemberForm(Form):
self.project = project
def validate_name(form, field):
if field.data == form.name.default:
raise ValidationError(_("User name incorrect"))
if Person.query.filter(Person.name == field.data)\
.filter(Person.project == form.project)\
.filter(Person.activated == True).all():

View file

@ -1,16 +1,16 @@
# Translations template for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
# Alexis Métaireau <alexis@notmyidea.org>, 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-11-01 13:04+0100\n"
"POT-Creation-Date: 2011-11-20 14:05+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Last-Translator: Quentin Roy <royque@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
@ -21,31 +21,27 @@ msgstr ""
msgid "Select All/None"
msgstr ""
#: forms.py:51
#: forms.py:57
msgid "Project name"
msgstr ""
#: forms.py:52 forms.py:77 forms.py:88
#: forms.py:58 forms.py:82 forms.py:93
msgid "Private code"
msgstr ""
#: forms.py:53
#: forms.py:59
msgid "Email"
msgstr ""
#: forms.py:54
msgid "Edit the project"
msgstr ""
#: forms.py:76 forms.py:87 forms.py:93
#: forms.py:81 forms.py:92 forms.py:98
msgid "Project identifier"
msgstr ""
#: forms.py:78 templates/send_invites.html:5
#: forms.py:83 templates/send_invites.html:5
msgid "Create the project"
msgstr ""
#: forms.py:83
#: forms.py:88
msgid ""
"The project identifier is used to log in and for the URL of the project. "
"We tried to generate an identifier for you but a project with this "
@ -53,80 +49,88 @@ msgid ""
"able to remember."
msgstr ""
#: forms.py:89
#: forms.py:94
msgid "Get in"
msgstr ""
#: forms.py:94
#: forms.py:99
msgid "Send me the code by email"
msgstr ""
#: forms.py:98
#: forms.py:103
msgid "This project does not exists"
msgstr ""
#: forms.py:102
#: forms.py:107
msgid "Date"
msgstr ""
#: forms.py:103
#: forms.py:108
msgid "What?"
msgstr ""
#: forms.py:104
#: forms.py:109
msgid "Payer"
msgstr ""
#: forms.py:105
#: forms.py:110
msgid "Amount paid"
msgstr ""
#: forms.py:106 templates/list_bills.html:98
#: forms.py:111 templates/list_bills.html:154
msgid "For whom?"
msgstr ""
#: forms.py:108
#: forms.py:113
msgid "Send the bill"
msgstr ""
#: forms.py:132
msgid "Bills can't be negative"
#: forms.py:139
msgid "Bills can't be null"
msgstr ""
#: forms.py:137
#: forms.py:144
msgid "Name"
msgstr ""
#: forms.py:138 templates/forms.html:91
#: forms.py:144
msgid "Type user name here"
msgstr ""
#: forms.py:145 templates/forms.html:94
msgid "Add"
msgstr ""
#: forms.py:148
#: forms.py:153
msgid "User name incorrect"
msgstr ""
#: forms.py:157
msgid "This project already have this member"
msgstr ""
#: forms.py:158
#: forms.py:167
msgid "People to notify"
msgstr ""
#: forms.py:159
#: forms.py:168
msgid "Send invites"
msgstr ""
#: forms.py:165
#: forms.py:174
#, python-format
msgid "The email %(email)s is not valid"
msgstr ""
#: forms.py:170
#: forms.py:179
msgid "Start date"
msgstr ""
#: forms.py:171
#: forms.py:180
msgid "End date"
msgstr ""
#: forms.py:172
#: forms.py:181
msgid "Name for this archive (optional)"
msgstr ""
@ -148,52 +152,52 @@ msgstr ""
msgid "a mail has been sent to you with the password"
msgstr ""
#: web.py:224
#: web.py:229
#, python-format
msgid "You have been invited to share your expenses for %(project)s"
msgstr ""
#: web.py:231
#: web.py:236
msgid "Your invitations have been sent"
msgstr ""
#: web.py:256
#: web.py:261
#, python-format
msgid "%(member)s had been added"
msgstr ""
#: web.py:268
#: web.py:273
#, python-format
msgid "%(name)s is part of this project again"
msgstr ""
#: web.py:276
#: web.py:281
#, python-format
msgid "User '%(name)s' has been deactivated"
msgstr ""
#: web.py:278
#: web.py:283
#, python-format
msgid "User '%(name)s' has been removed"
msgstr ""
#: web.py:295
#: web.py:300
msgid "The bill has been added"
msgstr ""
#: web.py:310
#: web.py:315
msgid "The bill has been deleted"
msgstr ""
#: web.py:328
#: web.py:333
msgid "The bill has been modified"
msgstr ""
#: web.py:352
#: web.py:357
msgid "The data from XX to XX has been archived"
msgstr ""
#: templates/add_bill.html:4 templates/edit_bill.html:4
#: templates/add_bill.html:19
msgid "Back to the list"
msgstr ""
@ -215,11 +219,12 @@ msgstr ""
msgid "Create a new project"
msgstr ""
#: templates/edit_bill.html:8
msgid "Edit a bill"
#: templates/edit_project.html:6 templates/list_bills.html:77
#: templates/list_bills.html:87
msgid "you sure?"
msgstr ""
#: templates/edit_project.html:4
#: templates/edit_project.html:11
msgid "Edit this project"
msgstr ""
@ -231,27 +236,36 @@ msgstr ""
msgid "Cancel"
msgstr ""
#: templates/forms.html:75
#: templates/forms.html:69
msgid "Edit the project"
msgstr ""
#: templates/forms.html:70 templates/list_bills.html:139
#: templates/list_bills.html:167
msgid "delete"
msgstr ""
#: templates/forms.html:78
msgid "Edit this bill"
msgstr ""
#: templates/forms.html:75
#: templates/forms.html:78
msgid "Add a bill"
msgstr ""
#: templates/forms.html:99
#: templates/forms.html:102
msgid "Send the invitations"
msgstr ""
#: templates/forms.html:100
#: templates/forms.html:103
msgid "No, thanks"
msgstr ""
#: templates/forms.html:106
#: templates/forms.html:109
msgid "Create an archive"
msgstr ""
#: templates/forms.html:112
#: templates/forms.html:115
msgid "Create the archive"
msgstr ""
@ -303,103 +317,95 @@ msgstr ""
msgid "Account manager"
msgstr ""
#: templates/layout.html:52
#: templates/layout.html:54
msgid "Bills"
msgstr ""
#: templates/layout.html:56
#: templates/layout.html:58
msgid "options"
msgstr ""
#: templates/layout.html:58
#: templates/layout.html:60
msgid "Project settings"
msgstr ""
#: templates/layout.html:62
#: templates/layout.html:64
msgid "switch to"
msgstr ""
#: templates/layout.html:65
#: templates/layout.html:67
msgid "Start a new project"
msgstr ""
#: templates/layout.html:67
#: templates/layout.html:69
msgid "Logout"
msgstr ""
#: templates/layout.html:93
#: templates/layout.html:95
msgid "This is a free software"
msgstr ""
#: templates/layout.html:93
#: templates/layout.html:95
msgid "you can contribute and improve it!"
msgstr ""
#: templates/list_bills.html:43
msgid "you sure?"
msgstr ""
#: templates/list_bills.html:62
#: templates/list_bills.html:115
msgid "Balance"
msgstr ""
#: templates/list_bills.html:78 templates/list_bills.html:108
msgid "delete"
msgstr ""
#: templates/list_bills.html:78
#: templates/list_bills.html:140
msgid "reactivate"
msgstr ""
#: templates/list_bills.html:89
#: templates/list_bills.html:144
msgid "The project identifier is"
msgstr ""
#: templates/list_bills.html:89
#: templates/list_bills.html:144
msgid "remember it!"
msgstr ""
#: templates/list_bills.html:90
#: templates/list_bills.html:145
msgid "Add a new bill"
msgstr ""
#: templates/list_bills.html:92
#: templates/list_bills.html:148
msgid "hide this form"
msgstr ""
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "When?"
msgstr ""
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "Who paid?"
msgstr ""
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "For what?"
msgstr ""
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "How much?"
msgstr ""
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "Actions"
msgstr ""
#: templates/list_bills.html:106
#: templates/list_bills.html:162
msgid "each"
msgstr ""
#: templates/list_bills.html:107
#: templates/list_bills.html:164
msgid "edit"
msgstr ""
#: templates/list_bills.html:115
#: templates/list_bills.html:177
msgid "Nothing to list yet. You probably want to"
msgstr ""
#: templates/list_bills.html:115
#: templates/list_bills.html:177
msgid "add a bill"
msgstr ""

View file

@ -15,3 +15,30 @@
}
}
// Automatically hide and show the default value of a text field
// handly in order to write user information in the text field.
// jquery selector should return only one text field.
var auto_hide_default_text = function(text_field_selector){
// record the text in the text field before the first text field focus
var default_text;
var hide_text = function(){
if(default_text==undefined){
default_text=this.value;
this.value="";
}
else if(this.value==default_text){
this.value="";
}
}
var show_text = function(){
if(this.value==""){
this.value=default_text;
}
}
var field = $(text_field_selector);
field.focus(hide_text);
field.blur(show_text);
}

View file

@ -1,4 +1,10 @@
{% extends "layout.html" %}
{% block head %}
<script src="{{ url_for("static", filename="ihatemoney/custom.js") }}"></script>
{% endblock %}
{% block js %}
auto_hide_default_text('#name');
{% endblock %}
{% block content %}
<form action="{{ url_for(".add_member") }}" method="post">
{{ forms.add_member(form) }}

View file

@ -30,11 +30,15 @@
return false;
}
auto_hide_default_text('#name');
$('#new-bill').click(show_form);
$('#empty-new-bill').click(show_form);
$('#hide-bill-form').click(hide_form);
$('#cancel-form').click(hide_form);
var tr_id;
var id;
@ -103,6 +107,7 @@
$.datepicker.setDefaults({'dateFormat': 'yy-mm-dd'});
$(".datepicker").datepicker($.datepicker.regional['{{ g.lang }}']);
{% endblock %}
{% block sidebar %}

View file

@ -1,15 +1,15 @@
# French translations for PROJECT.
# Copyright (C) 2011 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
# Alexis Métaireau <alexis@notmyidea.org>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2011-11-01 13:04+0100\n"
"POT-Creation-Date: 2011-11-20 13:49+0100\n"
"PO-Revision-Date: 2011-10-14 23:51+0200\n"
"Last-Translator: Alexis Métaireau <alexis@notmyidea.org>\n"
"Last-Translator: Quentin Roy <royque@gmail.com>\n"
"Language-Team: fr <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n > 1)\n"
"MIME-Version: 1.0\n"
@ -21,31 +21,27 @@ msgstr ""
msgid "Select All/None"
msgstr "Cocher Tous/Aucun"
#: forms.py:51
#: forms.py:57
msgid "Project name"
msgstr "Nom de projet"
#: forms.py:52 forms.py:77 forms.py:88
#: forms.py:58 forms.py:82 forms.py:93
msgid "Private code"
msgstr "Code d'accès"
#: forms.py:53
#: forms.py:59
msgid "Email"
msgstr "Email"
#: forms.py:54
msgid "Edit the project"
msgstr "Éditer le projet"
#: forms.py:76 forms.py:87 forms.py:93
#: forms.py:81 forms.py:92 forms.py:98
msgid "Project identifier"
msgstr "Identifiant du projet"
#: forms.py:78 templates/send_invites.html:5
#: forms.py:83 templates/send_invites.html:5
msgid "Create the project"
msgstr "Créer le projet"
#: forms.py:83
#: forms.py:88
msgid ""
"The project identifier is used to log in and for the URL of the project. "
"We tried to generate an identifier for you but a project with this "
@ -57,80 +53,89 @@ msgstr ""
"celui ci existe déjà. Merci de créer un nouvel identifiant que vous serez"
" capable de retenir"
#: forms.py:89
#: forms.py:94
msgid "Get in"
msgstr "Entrer"
#: forms.py:94
#: forms.py:99
msgid "Send me the code by email"
msgstr "Envoyez moi le code par email"
#: forms.py:98
#: forms.py:103
msgid "This project does not exists"
msgstr "Ce projet n'existe pas"
#: forms.py:102
#: forms.py:107
msgid "Date"
msgstr "Date"
#: forms.py:103
#: forms.py:108
msgid "What?"
msgstr "Quoi ?"
#: forms.py:104
#: forms.py:109
msgid "Payer"
msgstr "Payeur"
#: forms.py:105
#: forms.py:110
msgid "Amount paid"
msgstr "Montant"
#: forms.py:106 templates/list_bills.html:98
#: forms.py:111 templates/list_bills.html:154
msgid "For whom?"
msgstr "Pour qui ?"
#: forms.py:108
#: forms.py:113
msgid "Send the bill"
msgstr "Enregistrer la facture"
#: forms.py:132
msgid "Bills can't be negative"
#: forms.py:139
#, fuzzy
msgid "Bills can't be null"
msgstr "Le montant d'une facture ne peut pas être négatif"
#: forms.py:137
#: forms.py:144
msgid "Name"
msgstr "Nom"
#: forms.py:138 templates/forms.html:91
#: forms.py:144
msgid "Type user name here"
msgstr "Nouveau participant"
#: forms.py:145 templates/forms.html:94
msgid "Add"
msgstr "Ajouter"
#: forms.py:148
#: forms.py:153
msgid "User name incorrect"
msgstr ""
#: forms.py:157
msgid "This project already have this member"
msgstr "Ce membre existe déjà pour ce projet"
#: forms.py:158
#: forms.py:167
msgid "People to notify"
msgstr "Personnes à prévenir"
#: forms.py:159
#: forms.py:168
msgid "Send invites"
msgstr "Envoyer les invitations"
#: forms.py:165
#: forms.py:174
#, python-format
msgid "The email %(email)s is not valid"
msgstr "L'email %(email)s est invalide"
#: forms.py:170
#: forms.py:179
msgid "Start date"
msgstr "Date de départ"
#: forms.py:171
#: forms.py:180
msgid "End date"
msgstr "Date de fin"
#: forms.py:172
#: forms.py:181
msgid "Name for this archive (optional)"
msgstr "Nom pour cette archive"
@ -152,52 +157,52 @@ msgstr "L'identifiant de ce projet est '%(project)s'"
msgid "a mail has been sent to you with the password"
msgstr "Un email vous a été envoyé avec le mot de passe"
#: web.py:224
#: web.py:229
#, python-format
msgid "You have been invited to share your expenses for %(project)s"
msgstr "Vous avez été invité à partager vos dépenses pour %(project)s"
#: web.py:231
#: web.py:236
msgid "Your invitations have been sent"
msgstr "Vos invitations ont bien été envoyées"
#: web.py:256
#: web.py:261
#, python-format
msgid "%(member)s had been added"
msgstr "%(member)s a bien été ajouté"
#: web.py:268
#: web.py:273
#, python-format
msgid "%(name)s is part of this project again"
msgstr "%(name)s a rejoint le projet"
#: web.py:276
#: web.py:281
#, python-format
msgid "User '%(name)s' has been deactivated"
msgstr "Le membre '%(name)s' a été désactivé"
#: web.py:278
#: web.py:283
#, python-format
msgid "User '%(name)s' has been removed"
msgstr "Le membre '%(name)s' a été supprimé"
#: web.py:295
#: web.py:300
msgid "The bill has been added"
msgstr "La facture a bien été ajoutée"
#: web.py:310
#: web.py:315
msgid "The bill has been deleted"
msgstr "La facture a été supprimée"
#: web.py:328
#: web.py:333
msgid "The bill has been modified"
msgstr "La facture a été modifiée"
#: web.py:352
#: web.py:357
msgid "The data from XX to XX has been archived"
msgstr "Les données de XX à XX ont été archivées"
#: templates/add_bill.html:4 templates/edit_bill.html:4
#: templates/add_bill.html:19
msgid "Back to the list"
msgstr "Retourner à la liste"
@ -219,11 +224,12 @@ msgstr " ?"
msgid "Create a new project"
msgstr "Créer un nouveau projet"
#: templates/edit_bill.html:8
msgid "Edit a bill"
msgstr "Éditer une facture"
#: templates/edit_project.html:6 templates/list_bills.html:77
#: templates/list_bills.html:87
msgid "you sure?"
msgstr "c'est sûr ?"
#: templates/edit_project.html:4
#: templates/edit_project.html:11
msgid "Edit this project"
msgstr "Éditer ce projet"
@ -235,27 +241,36 @@ msgstr "Vous ne vous souvenez plus du code d'accès ?"
msgid "Cancel"
msgstr "Annuler"
#: templates/forms.html:75
#: templates/forms.html:69
msgid "Edit the project"
msgstr "Éditer le projet"
#: templates/forms.html:70 templates/list_bills.html:139
#: templates/list_bills.html:167
msgid "delete"
msgstr "supprimer"
#: templates/forms.html:78
msgid "Edit this bill"
msgstr "Éditer cette facture"
#: templates/forms.html:75
#: templates/forms.html:78
msgid "Add a bill"
msgstr "Ajouter une facture"
#: templates/forms.html:99
#: templates/forms.html:102
msgid "Send the invitations"
msgstr "Envoyer les invitations"
#: templates/forms.html:100
#: templates/forms.html:103
msgid "No, thanks"
msgstr "Non merci"
#: templates/forms.html:106
#: templates/forms.html:109
msgid "Create an archive"
msgstr "Créer une archive"
#: templates/forms.html:112
#: templates/forms.html:115
msgid "Create the archive"
msgstr "Créer l'archive"
@ -307,103 +322,95 @@ msgstr "c'est parti !"
msgid "Account manager"
msgstr "Gestion de comptes"
#: templates/layout.html:52
#: templates/layout.html:54
msgid "Bills"
msgstr "Factures"
#: templates/layout.html:56
#: templates/layout.html:58
msgid "options"
msgstr "options"
#: templates/layout.html:58
#: templates/layout.html:60
msgid "Project settings"
msgstr "Options du projet"
#: templates/layout.html:62
#: templates/layout.html:64
msgid "switch to"
msgstr "aller à"
#: templates/layout.html:65
#: templates/layout.html:67
msgid "Start a new project"
msgstr "Nouveau projet"
#: templates/layout.html:67
#: templates/layout.html:69
msgid "Logout"
msgstr "Se déconnecter"
#: templates/layout.html:93
#: templates/layout.html:95
msgid "This is a free software"
msgstr "Ceci est un logiciel libre"
#: templates/layout.html:93
#: templates/layout.html:95
msgid "you can contribute and improve it!"
msgstr "vous pouvez y contribuer et l'améliorer"
#: templates/list_bills.html:43
msgid "you sure?"
msgstr "c'est sûr ?"
#: templates/list_bills.html:62
#: templates/list_bills.html:115
msgid "Balance"
msgstr "Balance"
#: templates/list_bills.html:78 templates/list_bills.html:108
msgid "delete"
msgstr "supprimer"
#: templates/list_bills.html:78
#: templates/list_bills.html:140
msgid "reactivate"
msgstr "ré-activer"
#: templates/list_bills.html:89
#: templates/list_bills.html:144
msgid "The project identifier is"
msgstr "L'identifiant de ce projet est"
#: templates/list_bills.html:89
#: templates/list_bills.html:144
msgid "remember it!"
msgstr "souvenez vous en !"
#: templates/list_bills.html:90
#: templates/list_bills.html:145
msgid "Add a new bill"
msgstr "Nouvelle facture"
#: templates/list_bills.html:92
#: templates/list_bills.html:148
msgid "hide this form"
msgstr "cacher ce formulaire"
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "When?"
msgstr "Quand ?"
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "Who paid?"
msgstr "Qui a payé ?"
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "For what?"
msgstr "Pour quoi ?"
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "How much?"
msgstr "Combien ?"
#: templates/list_bills.html:98
#: templates/list_bills.html:154
msgid "Actions"
msgstr "Actions"
#: templates/list_bills.html:106
#: templates/list_bills.html:162
msgid "each"
msgstr "chacun"
#: templates/list_bills.html:107
#: templates/list_bills.html:164
msgid "edit"
msgstr "éditer"
#: templates/list_bills.html:115
#: templates/list_bills.html:177
msgid "Nothing to list yet. You probably want to"
msgstr "Rien à lister pour l'instant. Vous voulez surement"
#: templates/list_bills.html:115
#: templates/list_bills.html:177
msgid "add a bill"
msgstr "ajouter une facture"