Merge branch 'sli' into 'master'

Download sellings as csv

See merge request !24
This commit is contained in:
Skia 2016-11-08 15:00:58 +01:00
commit ba6e2c3712
5 changed files with 95 additions and 46 deletions

View File

@ -7,6 +7,7 @@
{% csrf_token %} {% csrf_token %}
{{ form }} {{ form }}
<p><input type="submit" value="{% trans %}Show{% endtrans %}" /></p> <p><input type="submit" value="{% trans %}Show{% endtrans %}" /></p>
<p><input type="submit" value="{% trans %}Download as cvs{% endtrans %}" formaction="{{ url('club:sellings_csv', club_id=object.id) }}"/></p>
</form> </form>
<p> <p>
{% trans %}Quantity: {% endtrans %}{{ total_quantity }} {% trans %}units{% endtrans %}<br/> {% trans %}Quantity: {% endtrans %}{{ total_quantity }} {% trans %}units{% endtrans %}<br/>

View File

@ -10,6 +10,7 @@ urlpatterns = [
url(r'^(?P<club_id>[0-9]+)/members$', ClubMembersView.as_view(), name='club_members'), url(r'^(?P<club_id>[0-9]+)/members$', ClubMembersView.as_view(), name='club_members'),
url(r'^(?P<club_id>[0-9]+)/elderlies$', ClubOldMembersView.as_view(), name='club_old_members'), url(r'^(?P<club_id>[0-9]+)/elderlies$', ClubOldMembersView.as_view(), name='club_old_members'),
url(r'^(?P<club_id>[0-9]+)/sellings$', ClubSellingView.as_view(), name='club_sellings'), url(r'^(?P<club_id>[0-9]+)/sellings$', ClubSellingView.as_view(), name='club_sellings'),
url(r'^(?P<club_id>[0-9]+)/sellings/csv$', ClubSellingCSVView.as_view(), name='sellings_csv'),
url(r'^(?P<club_id>[0-9]+)/prop$', ClubEditPropView.as_view(), name='club_prop'), url(r'^(?P<club_id>[0-9]+)/prop$', ClubEditPropView.as_view(), name='club_prop'),
url(r'^(?P<club_id>[0-9]+)/tools$', ClubToolsView.as_view(), name='tools'), url(r'^(?P<club_id>[0-9]+)/tools$', ClubToolsView.as_view(), name='tools'),
url(r'^membership/(?P<membership_id>[0-9]+)/set_old$', MembershipSetOldView.as_view(), name='membership_set_old'), url(r'^membership/(?P<membership_id>[0-9]+)/set_old$', MembershipSetOldView.as_view(), name='membership_set_old'),

View File

@ -4,10 +4,11 @@ from django.views.generic import ListView, DetailView
from django.views.generic.edit import UpdateView, CreateView from django.views.generic.edit import UpdateView, CreateView
from django.forms import CheckboxSelectMultiple from django.forms import CheckboxSelectMultiple
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils import timezone from django.utils import timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext as _t
from django.conf import settings from django.conf import settings
from ajax_select.fields import AutoCompleteSelectField from ajax_select.fields import AutoCompleteSelectField
@ -203,6 +204,36 @@ class ClubSellingView(ClubTabsMixin, CanEditMixin, DetailView):
kwargs['form'] = form kwargs['form'] = form
return kwargs return kwargs
class ClubSellingCSVView(ClubSellingView):
"""
Generate sellings in csv for a given period
"""
def get(self, request, *args, **kwargs):
import csv
response = HttpResponse(content_type='text/csv')
self.object = self.get_object()
name = _("Sellings") + "_" + self.object.name + ".csv"
response['Content-Disposition'] = 'filename=' + name
kwargs = self.get_context_data(**kwargs)
writer = csv.writer(response, delimiter=";", lineterminator='\n', quoting=csv.QUOTE_ALL)
writer.writerow([_t('Date'),_t('Counter'),_t('Barman'),_t('Customer'),_t('Label'),
_t('Quantity'), _t('Total'),_t('Payment method')])
for o in kwargs['result']:
row = [o.date, o.counter]
if o.seller:
row.append(o.seller.get_display_name())
else: row.append('')
if o.customer:
row.append(o.customer.user.get_display_name())
else: row.append('')
row = row +[o.label, o.quantity, o.quantity * o.unit_price,
o.get_payment_method_display()]
writer.writerow(row)
return response
class ClubEditView(ClubTabsMixin, CanEditMixin, UpdateView): class ClubEditView(ClubTabsMixin, CanEditMixin, UpdateView):
""" """
Edit a Club's main informations (for the club's members) Edit a Club's main informations (for the club's members)

Binary file not shown.

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-03 16:28+0100\n" "POT-Creation-Date: 2016-11-07 22:00+0100\n"
"PO-Revision-Date: 2016-07-18\n" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n" "Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
@ -123,7 +123,7 @@ msgstr "numéro"
msgid "journal" msgid "journal"
msgstr "classeur" msgstr "classeur"
#: accounting/models.py:194 core/models.py:498 core/models.py:776 #: accounting/models.py:194 core/models.py:498 core/models.py:778
#: counter/models.py:237 counter/models.py:280 counter/models.py:397 #: counter/models.py:237 counter/models.py:280 counter/models.py:397
#: eboutic/models.py:15 eboutic/models.py:48 #: eboutic/models.py:15 eboutic/models.py:48
msgid "date" msgid "date"
@ -277,7 +277,7 @@ msgstr "Liste des types comptable"
#: accounting/templates/accounting/label_list.jinja:9 #: accounting/templates/accounting/label_list.jinja:9
#: accounting/templates/accounting/operation_edit.jinja:9 #: accounting/templates/accounting/operation_edit.jinja:9
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:9 #: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:9
#: core/templates/core/user_tools.jinja:42 #: core/templates/core/user_tools.jinja:43
msgid "Accounting" msgid "Accounting"
msgstr "Comptabilité" msgstr "Comptabilité"
@ -296,14 +296,14 @@ msgstr "Il n'y a pas de types comptable dans ce site web."
#: accounting/templates/accounting/bank_account_details.jinja:4 #: accounting/templates/accounting/bank_account_details.jinja:4
#: accounting/templates/accounting/bank_account_details.jinja:13 #: accounting/templates/accounting/bank_account_details.jinja:13
#: core/templates/core/user_tools.jinja:49 #: core/templates/core/user_tools.jinja:50
msgid "Bank account: " msgid "Bank account: "
msgstr "Compte en banque : " msgstr "Compte en banque : "
#: accounting/templates/accounting/bank_account_details.jinja:15 #: accounting/templates/accounting/bank_account_details.jinja:15
#: accounting/templates/accounting/club_account_details.jinja:16 #: accounting/templates/accounting/club_account_details.jinja:16
#: accounting/templates/accounting/label_list.jinja:21 #: accounting/templates/accounting/label_list.jinja:21
#: club/templates/club/club_sellings.jinja:48 #: club/templates/club/club_sellings.jinja:53
#: core/templates/core/file_detail.jinja:43 #: core/templates/core/file_detail.jinja:43
#: core/templates/core/group_list.jinja:13 core/templates/core/macros.jinja:66 #: core/templates/core/group_list.jinja:13 core/templates/core/macros.jinja:66
#: core/templates/core/user_account_detail.jinja:38 #: core/templates/core/user_account_detail.jinja:38
@ -316,7 +316,7 @@ msgid "Delete"
msgstr "Supprimer" msgstr "Supprimer"
#: accounting/templates/accounting/bank_account_details.jinja:17 #: accounting/templates/accounting/bank_account_details.jinja:17
#: club/views.py:31 core/views/user.py:130 #: club/views.py:32 core/views/user.py:130
msgid "Infos" msgid "Infos"
msgstr "Infos" msgstr "Infos"
@ -335,9 +335,9 @@ msgstr "Nouveau compte club"
#: accounting/templates/accounting/bank_account_details.jinja:26 #: accounting/templates/accounting/bank_account_details.jinja:26
#: accounting/templates/accounting/bank_account_list.jinja:21 #: accounting/templates/accounting/bank_account_list.jinja:21
#: accounting/templates/accounting/club_account_details.jinja:55 #: accounting/templates/accounting/club_account_details.jinja:55
#: accounting/templates/accounting/journal_details.jinja:70 club/views.py:53 #: accounting/templates/accounting/journal_details.jinja:70 club/views.py:54
#: core/templates/core/file.jinja:38 core/templates/core/page.jinja:31 #: core/templates/core/file.jinja:38 core/templates/core/page.jinja:31
#: core/templates/core/user_tools.jinja:35 core/views/user.py:147 #: core/templates/core/user_tools.jinja:36 core/views/user.py:147
#: counter/templates/counter/cash_summary_list.jinja:53 #: counter/templates/counter/cash_summary_list.jinja:53
#: counter/templates/counter/counter_list.jinja:17 #: counter/templates/counter/counter_list.jinja:17
#: counter/templates/counter/counter_list.jinja:32 #: counter/templates/counter/counter_list.jinja:32
@ -472,7 +472,7 @@ msgid "Nb"
msgstr "No" msgstr "No"
#: accounting/templates/accounting/journal_details.jinja:29 #: accounting/templates/accounting/journal_details.jinja:29
#: club/templates/club/club_sellings.jinja:18 #: club/templates/club/club_sellings.jinja:23
#: core/templates/core/user_account_detail.jinja:17 #: core/templates/core/user_account_detail.jinja:17
#: core/templates/core/user_account_detail.jinja:50 #: core/templates/core/user_account_detail.jinja:50
#: core/templates/core/user_account_detail.jinja:79 #: core/templates/core/user_account_detail.jinja:79
@ -483,7 +483,7 @@ msgid "Date"
msgstr "Date" msgstr "Date"
#: accounting/templates/accounting/journal_details.jinja:30 #: accounting/templates/accounting/journal_details.jinja:30
#: club/templates/club/club_sellings.jinja:22 #: club/templates/club/club_sellings.jinja:27
#: core/templates/core/user_account_detail.jinja:20 #: core/templates/core/user_account_detail.jinja:20
#: counter/templates/counter/last_ops.jinja:42 #: counter/templates/counter/last_ops.jinja:42
msgid "Label" msgid "Label"
@ -533,7 +533,8 @@ msgid "Edit operation"
msgstr "Éditer l'opération" msgstr "Éditer l'opération"
#: accounting/templates/accounting/operation_edit.jinja:40 #: accounting/templates/accounting/operation_edit.jinja:40
#: core/templates/core/create.jinja:12 core/templates/core/edit.jinja:12 #: core/templates/core/create.jinja:12 core/templates/core/edit.jinja:7
#: core/templates/core/edit.jinja.py:15 core/templates/core/edit.jinja:20
#: core/templates/core/file_edit.jinja:8 core/templates/core/page_prop.jinja:8 #: core/templates/core/file_edit.jinja:8 core/templates/core/page_prop.jinja:8
#: core/templates/core/pagerev_edit.jinja:24 #: core/templates/core/pagerev_edit.jinja:24
#: core/templates/core/user_godfathers.jinja:35 #: core/templates/core/user_godfathers.jinja:35
@ -619,6 +620,7 @@ msgid "Club list"
msgstr "Liste des clubs" msgstr "Liste des clubs"
#: club/templates/club/club_list.jinja:21 #: club/templates/club/club_list.jinja:21
#: core/templates/core/user_tools.jinja:19
msgid "New club" msgid "New club"
msgstr "Nouveau club" msgstr "Nouveau club"
@ -675,7 +677,7 @@ msgstr "Du"
msgid "To" msgid "To"
msgstr "Au" msgstr "Au"
#: club/templates/club/club_sellings.jinja:5 club/views.py:58 #: club/templates/club/club_sellings.jinja:5 club/views.py:59
#: counter/templates/counter/counter_main.jinja:19 #: counter/templates/counter/counter_main.jinja:19
#: counter/templates/counter/last_ops.jinja:35 #: counter/templates/counter/last_ops.jinja:35
msgid "Sellings" msgid "Sellings"
@ -686,29 +688,33 @@ msgstr "Ventes"
msgid "Show" msgid "Show"
msgstr "Montrer" msgstr "Montrer"
#: club/templates/club/club_sellings.jinja:12 #: club/templates/club/club_sellings.jinja:10
msgid "Download as cvs"
msgstr "Télécharger en csv"
#: club/templates/club/club_sellings.jinja:13
msgid "Quantity: " msgid "Quantity: "
msgstr "Quantité : " msgstr "Quantité : "
#: club/templates/club/club_sellings.jinja:12 #: club/templates/club/club_sellings.jinja:13
msgid "units" msgid "units"
msgstr "unités" msgstr "unités"
#: club/templates/club/club_sellings.jinja:13 #: club/templates/club/club_sellings.jinja:14
#: counter/templates/counter/counter_click.jinja:70 #: counter/templates/counter/counter_click.jinja:70
#: counter/templates/counter/counter_main.jinja:28 #: counter/templates/counter/counter_main.jinja:28
#: eboutic/templates/eboutic/eboutic_main.jinja:34 #: eboutic/templates/eboutic/eboutic_main.jinja:34
msgid "Total: " msgid "Total: "
msgstr "Total : " msgstr "Total : "
#: club/templates/club/club_sellings.jinja:19 club/views.py:165 #: club/templates/club/club_sellings.jinja:24 club/views.py:166
#: core/templates/core/user_account_detail.jinja:18 #: core/templates/core/user_account_detail.jinja:18
#: core/templates/core/user_account_detail.jinja:51 #: core/templates/core/user_account_detail.jinja:51
#: counter/templates/counter/cash_summary_list.jinja:33 counter/views.py:78 #: counter/templates/counter/cash_summary_list.jinja:33 counter/views.py:78
msgid "Counter" msgid "Counter"
msgstr "Comptoir" msgstr "Comptoir"
#: club/templates/club/club_sellings.jinja:20 #: club/templates/club/club_sellings.jinja:25
#: core/templates/core/user_account_detail.jinja:19 #: core/templates/core/user_account_detail.jinja:19
#: core/templates/core/user_account_detail.jinja:52 #: core/templates/core/user_account_detail.jinja:52
#: counter/templates/counter/last_ops.jinja:15 #: counter/templates/counter/last_ops.jinja:15
@ -716,21 +722,21 @@ msgstr "Comptoir"
msgid "Barman" msgid "Barman"
msgstr "Barman" msgstr "Barman"
#: club/templates/club/club_sellings.jinja:21 #: club/templates/club/club_sellings.jinja:26
#: counter/templates/counter/counter_click.jinja:29 #: counter/templates/counter/counter_click.jinja:29
#: counter/templates/counter/last_ops.jinja:16 #: counter/templates/counter/last_ops.jinja:16
#: counter/templates/counter/last_ops.jinja:41 #: counter/templates/counter/last_ops.jinja:41
msgid "Customer" msgid "Customer"
msgstr "Client" msgstr "Client"
#: club/templates/club/club_sellings.jinja:23 #: club/templates/club/club_sellings.jinja:28
#: core/templates/core/user_account_detail.jinja:21 #: core/templates/core/user_account_detail.jinja:21
#: core/templates/core/user_stats.jinja:28 #: core/templates/core/user_stats.jinja:28
#: counter/templates/counter/last_ops.jinja:43 #: counter/templates/counter/last_ops.jinja:43
msgid "Quantity" msgid "Quantity"
msgstr "Quantité" msgstr "Quantité"
#: club/templates/club/club_sellings.jinja:24 #: club/templates/club/club_sellings.jinja:29
#: core/templates/core/user_account.jinja:10 #: core/templates/core/user_account.jinja:10
#: core/templates/core/user_account_detail.jinja:22 #: core/templates/core/user_account_detail.jinja:22
#: counter/templates/counter/cash_summary_list.jinja:35 #: counter/templates/counter/cash_summary_list.jinja:35
@ -739,7 +745,7 @@ msgstr "Quantité"
msgid "Total" msgid "Total"
msgstr "Total" msgstr "Total"
#: club/templates/club/club_sellings.jinja:25 #: club/templates/club/club_sellings.jinja:30
#: core/templates/core/user_account_detail.jinja:23 #: core/templates/core/user_account_detail.jinja:23
#: core/templates/core/user_account_detail.jinja:54 #: core/templates/core/user_account_detail.jinja:54
#: counter/templates/counter/last_ops.jinja:18 #: counter/templates/counter/last_ops.jinja:18
@ -748,7 +754,7 @@ msgid "Payment method"
msgstr "Méthode de paiement" msgstr "Méthode de paiement"
#: club/templates/club/club_tools.jinja:4 #: club/templates/club/club_tools.jinja:4
#: core/templates/core/user_tools.jinja:61 #: core/templates/core/user_tools.jinja:62
msgid "Club tools" msgid "Club tools"
msgstr "Outils club" msgstr "Outils club"
@ -764,37 +770,37 @@ msgstr "Comptabilité : "
msgid "Manage launderettes" msgid "Manage launderettes"
msgstr "Gestion des laveries" msgstr "Gestion des laveries"
#: club/views.py:37 #: club/views.py:38
msgid "Members" msgid "Members"
msgstr "Membres" msgstr "Membres"
#: club/views.py:42 #: club/views.py:43
msgid "Old members" msgid "Old members"
msgstr "Anciens membres" msgstr "Anciens membres"
#: club/views.py:48 core/templates/core/base.jinja:40 core/views/user.py:141 #: club/views.py:49 core/templates/core/base.jinja:40 core/views/user.py:141
msgid "Tools" msgid "Tools"
msgstr "Outils" msgstr "Outils"
#: club/views.py:64 counter/templates/counter/counter_list.jinja:21 #: club/views.py:65 counter/templates/counter/counter_list.jinja:21
#: counter/templates/counter/counter_list.jinja:36 #: counter/templates/counter/counter_list.jinja:36
#: counter/templates/counter/counter_list.jinja:51 #: counter/templates/counter/counter_list.jinja:51
msgid "Props" msgid "Props"
msgstr "Propriétés" msgstr "Propriétés"
#: club/views.py:102 core/views/forms.py:204 counter/views.py:39 #: club/views.py:103 core/views/forms.py:204 counter/views.py:39
msgid "Select user" msgid "Select user"
msgstr "Choisir un utilisateur" msgstr "Choisir un utilisateur"
#: club/views.py:163 counter/views.py:909 #: club/views.py:164 counter/views.py:909
msgid "Begin date" msgid "Begin date"
msgstr "Date de début" msgstr "Date de début"
#: club/views.py:164 counter/views.py:910 #: club/views.py:165 counter/views.py:910
msgid "End date" msgid "End date"
msgstr "Date de fin" msgstr "Date de fin"
#: club/views.py:178 core/templates/core/user_stats.jinja:27 #: club/views.py:179 core/templates/core/user_stats.jinja:27
#: counter/views.py:990 #: counter/views.py:990
msgid "Product" msgid "Product"
msgstr "Produit" msgstr "Produit"
@ -1171,23 +1177,33 @@ msgstr "nom de la page"
msgid "owner group" msgid "owner group"
msgstr "groupe propriétaire" msgstr "groupe propriétaire"
#: core/models.py:660 #: core/models.py:633
#, fuzzy
#| msgid "Select user"
msgid "lock user"
msgstr "Choisir un utilisateur"
#: core/models.py:634
msgid "lock_timeout"
msgstr ""
#: core/models.py:661
msgid "Duplicate page" msgid "Duplicate page"
msgstr "Une page de ce nom existe déjà" msgstr "Une page de ce nom existe déjà"
#: core/models.py:666 #: core/models.py:667
msgid "Loop in page tree" msgid "Loop in page tree"
msgstr "Boucle dans l'arborescence des pages" msgstr "Boucle dans l'arborescence des pages"
#: core/models.py:773 #: core/models.py:775
msgid "revision" msgid "revision"
msgstr "révision" msgstr "révision"
#: core/models.py:774 #: core/models.py:776
msgid "page title" msgid "page title"
msgstr "titre de la page" msgstr "titre de la page"
#: core/models.py:775 #: core/models.py:777
msgid "page content" msgid "page content"
msgstr "contenu de la page" msgstr "contenu de la page"
@ -1294,7 +1310,7 @@ msgstr "Confirmation"
msgid "Cancel" msgid "Cancel"
msgstr "Annuler" msgstr "Annuler"
#: core/templates/core/edit.jinja:4 core/templates/core/edit.jinja.py:8 #: core/templates/core/edit.jinja:5 core/templates/core/edit.jinja.py:13
#: core/templates/core/file_edit.jinja:4 #: core/templates/core/file_edit.jinja:4
#: counter/templates/counter/cash_register_summary.jinja:4 #: counter/templates/counter/cash_register_summary.jinja:4
#, python-format #, python-format
@ -1843,44 +1859,44 @@ msgstr "Fusionner deux utilisateurs"
msgid "Subscriptions" msgid "Subscriptions"
msgstr "Cotisations" msgstr "Cotisations"
#: core/templates/core/user_tools.jinja:23 counter/views.py:449 #: core/templates/core/user_tools.jinja:24 counter/views.py:449
#: counter/views.py:598 #: counter/views.py:598
msgid "Counters" msgid "Counters"
msgstr "Comptoirs" msgstr "Comptoirs"
#: core/templates/core/user_tools.jinja:26 #: core/templates/core/user_tools.jinja:27
msgid "General management" msgid "General management"
msgstr "Gestion générale" msgstr "Gestion générale"
#: core/templates/core/user_tools.jinja:27 #: core/templates/core/user_tools.jinja:28
msgid "General counters management" msgid "General counters management"
msgstr "Gestion générale des comptoirs" msgstr "Gestion générale des comptoirs"
#: core/templates/core/user_tools.jinja:28 #: core/templates/core/user_tools.jinja:29
msgid "Products management" msgid "Products management"
msgstr "Gestion des produits" msgstr "Gestion des produits"
#: core/templates/core/user_tools.jinja:29 #: core/templates/core/user_tools.jinja:30
msgid "Product types management" msgid "Product types management"
msgstr "Gestion des types de produit" msgstr "Gestion des types de produit"
#: core/templates/core/user_tools.jinja:30 #: core/templates/core/user_tools.jinja:31
#: counter/templates/counter/cash_summary_list.jinja:23 counter/views.py:469 #: counter/templates/counter/cash_summary_list.jinja:23 counter/views.py:469
msgid "Cash register summaries" msgid "Cash register summaries"
msgstr "Relevés de caisse" msgstr "Relevés de caisse"
#: core/templates/core/user_tools.jinja:36 core/views/user.py:169 #: core/templates/core/user_tools.jinja:37 core/views/user.py:169
#: counter/templates/counter/counter_list.jinja:18 #: counter/templates/counter/counter_list.jinja:18
#: counter/templates/counter/counter_list.jinja:33 #: counter/templates/counter/counter_list.jinja:33
#: counter/templates/counter/counter_list.jinja:48 #: counter/templates/counter/counter_list.jinja:48
msgid "Stats" msgid "Stats"
msgstr "Stats" msgstr "Stats"
#: core/templates/core/user_tools.jinja:45 #: core/templates/core/user_tools.jinja:46
msgid "General accounting" msgid "General accounting"
msgstr "Comptabilité générale" msgstr "Comptabilité générale"
#: core/templates/core/user_tools.jinja:54 #: core/templates/core/user_tools.jinja:55
msgid "Club account: " msgid "Club account: "
msgstr "Compte club : " msgstr "Compte club : "