Commit e1ce661a authored by Skia's avatar Skia
Browse files

Improvements in counter admin templates

parent d93dda1c
Pipeline #184 failed with stage
in 1 minute and 47 seconds
......@@ -66,7 +66,8 @@ class ProductsLookup(RightManagedLookupChannel):
model = Product
def get_query(self, q, request):
return (self.model.objects.filter(name__icontains=q) | self.model.objects.filter(code__icontains=q))[:50]
return (self.model.objects.filter(name__icontains=q) |
self.model.objects.filter(code__icontains=q)).filter(archived=False)[:50]
def format_item_display(self, item):
return item.name
......
......@@ -25,7 +25,7 @@
<h5>{% trans %}General management{% endtrans %}</h5>
<li><a href="{{ url('counter:admin_list') }}">{% trans %}General counters management{% endtrans %}</a></li>
<li><a href="{{ url('counter:product_list') }}">{% trans %}Products management{% endtrans %}</a></li>
<li><a href="{{ url('counter:producttype_list') }}">{% trans %}Products type management{% endtrans %}</a></li>
<li><a href="{{ url('counter:producttype_list') }}">{% trans %}Product types management{% endtrans %}</a></li>
{% endif %}
{% for b in settings.SITH_COUNTER_BARS %}
{% if user.is_in_group(b[1]+" admin") %}
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('counter', '0006_auto_20160831_1304'),
]
operations = [
migrations.AddField(
model_name='product',
name='archived',
field=models.BooleanField(verbose_name='archived', default=False),
),
]
......@@ -89,6 +89,7 @@ class Product(models.Model):
parent_product = models.ForeignKey('self', related_name='children_products', verbose_name=_("parent product"), null=True,
blank=True, on_delete=models.SET_NULL)
buying_groups = models.ManyToManyField(Group, related_name='products', verbose_name=_("buying groups"), blank=True)
archived = models.BooleanField(_("archived"), default=False)
class Meta:
verbose_name = _('product')
......@@ -184,7 +185,7 @@ class Counter(models.Model):
return bl[random.randrange(0, len(bl))]
def is_open(self):
return len(self.get_barmen_list()) > 0:
return len(self.get_barmen_list()) > 0
def barman_list(self):
return [b.id for b in self.get_barmen_list()]
......
{% extends "core/base.jinja" %}
{% block content %}
<div class="tool-bar">
<div>{% trans %}Counter administration{% endtrans %}</div>
<div class="tools">
<a href="{{ url('counter:admin_list') }}"
{%- if tab == "counters" -%}
class="selected_tab"
{%- endif -%}
>{% trans %}Counters{% endtrans %}</a>
<a href="{{ url('counter:product_list') }}"
{%- if tab == "products" -%}
class="selected_tab"
{%- endif -%}
>{% trans %}Products{% endtrans %}</a>
<a href="{{ url('counter:product_list_archived') }}"
{%- if tab == "archive" -%}
class="selected_tab"
{%- endif -%}
>{% trans %}Archived products{% endtrans %}</a>
<a href="{{ url('counter:producttype_list') }}"
{%- if tab == "product_types" -%}
class="selected_tab"
{%- endif -%}
>{% trans %}Product types{% endtrans %}</a>
</div>
<hr>
</div>
<div>
{% block admin_content %}
{% endblock %}
</div>
{% endblock %}
{% extends "core/base.jinja" %}
{% extends "counter/counter_base.jinja" %}
{% block title %}
{% trans %}Counter admin list{% endtrans %}
{% endblock %}
{% block content %}
{% block admin_content %}
<p><a href="{{ url('counter:new') }}">{% trans %}New counter{% endtrans %}</a></p>
{% if counter_list %}
<h3>{% trans %}Counter admin list{% endtrans %}</h3>
<h4>{% trans %}Eboutic{% endtrans %}</h4>
<ul>
{% for c in counter_list %}
<li>
{% if c.type == "EBOUTIC" %}
<a href="{{ url('eboutic:main') }}">{{ c }}</a> -
{% else %}
<a href="{{ url('counter:details', counter_id=c.id) }}">{{ c }}</a> -
{% for c in counter_list.filter(type="EBOUTIC").order_by('name') %}
<li>
<a href="{{ url('eboutic:main') }}">{{ c }}</a> -
{% if user.can_edit(c) %}
<a href="{{ url('counter:admin', counter_id=c.id) }}">{% trans %}Edit{% endtrans %}</a> -
{% endif %}
{% if user.is_owner(c) %}
<a href="{{ url('counter:prop_admin', counter_id=c.id) }}">{% trans %}Props{% endtrans %}</a>
{% endif %}
</li>
{% endfor %}
</ul>
<h4>{% trans %}Bars{% endtrans %}</h4>
<ul>
{% for c in counter_list.filter(type="BAR").order_by('name') %}
<li>
<a href="{{ url('counter:details', counter_id=c.id) }}">{{ c }}</a> -
{% if user.can_edit(c) %}
<a href="{{ url('counter:admin', counter_id=c.id) }}">{% trans %}Edit{% endtrans %}</a> -
{% endif %}
{% if user.is_owner(c) %}
<a href="{{ url('counter:prop_admin', counter_id=c.id) }}">{% trans %}Props{% endtrans %}</a>
{% endif %}
</li>
{% endfor %}
</ul>
<h4>{% trans %}Offices{% endtrans %}</h4>
<ul>
{% for c in counter_list.exclude(type="BAR").exclude(type="EBOUTIC").order_by('name') %}
<li>
<a href="{{ url('counter:details', counter_id=c.id) }}">{{ c }}</a> -
{% if user.can_edit(c) %}
<a href="{{ url('counter:admin', counter_id=c.id) }}">{% trans %}Edit{% endtrans %}</a> -
{% endif %}
......
{% extends "core/base.jinja" %}
{% extends "counter/counter_base.jinja" %}
{% block title %}
{% trans %}Product list{% endtrans %}
{% endblock %}
{% block content %}
{% block admin_content %}
{% if tab == "products" %}
<p><a href="{{ url('counter:new_product') }}">{% trans %}New product{% endtrans %}</a></p>
{% endif %}
{% if product_list %}
<h3>{% trans %}Product list{% endtrans %}</h3>
{% for t in ProductType.objects.all().order_by('name') %}
<h4>{{ t }}</h4>
<ul>
{% for p in product_list %}
{% for p in product_list.filter(product_type=t).all().order_by('name') %}
<li><a href="{{ url('counter:product_edit', product_id=p.id) }}">{{ p }}</a></li>
{% endfor %}
</ul>
{% endfor %}
{% else %}
{% trans %}There is no products in this website.{% endtrans %}
{% endif %}
......
{% extends "core/base.jinja" %}
{% extends "counter/counter_base.jinja" %}
{% block title %}
{% trans %}Product type list{% endtrans %}
{% endblock %}
{% block content %}
{% block admin_content %}
<p><a href="{{ url('counter:new_producttype') }}">{% trans %}New product type{% endtrans %}</a></p>
{% if producttype_list %}
<h3>{% trans %}Product type list{% endtrans %}</h3>
......
......@@ -14,6 +14,7 @@ urlpatterns = [
url(r'^admin/new$', CounterCreateView.as_view(), name='new'),
url(r'^admin/delete/(?P<counter_id>[0-9]+)$', CounterDeleteView.as_view(), name='delete'),
url(r'^admin/product/list$', ProductListView.as_view(), name='product_list'),
url(r'^admin/product/list_archived$', ProductArchivedListView.as_view(), name='product_list_archived'),
url(r'^admin/product/create$', ProductCreateView.as_view(), name='new_product'),
url(r'^admin/product/(?P<product_id>[0-9]+)$', ProductEditView.as_view(), name='product_edit'),
url(r'^admin/producttype/list$', ProductTypeListView.as_view(), name='producttype_list'),
......
......@@ -390,6 +390,11 @@ class CounterListView(CanViewMixin, ListView):
model = Counter
template_name = 'counter/counter_list.jinja'
def get_context_data(self, **kwargs):
kwargs = super(CounterListView, self).get_context_data(**kwargs)
kwargs['tab'] = "counters"
return kwargs
class CounterEditForm(forms.ModelForm):
class Meta:
model = Counter
......@@ -445,6 +450,11 @@ class ProductTypeListView(CanEditPropMixin, ListView):
model = ProductType
template_name = 'counter/producttype_list.jinja'
def get_context_data(self, **kwargs):
kwargs = super(ProductTypeListView, self).get_context_data(**kwargs)
kwargs['tab'] = "product_types"
return kwargs
class ProductTypeCreateView(CanCreateMixin, CreateView):
"""
A create view for the admins
......@@ -462,19 +472,39 @@ class ProductTypeEditView(CanEditPropMixin, UpdateView):
fields = ['name', 'description', 'icon']
pk_url_kwarg = "type_id"
class ProductArchivedListView(CanEditPropMixin, ListView):
"""
A list view for the admins
"""
model = Product
template_name = 'counter/product_list.jinja'
queryset = Product.objects.filter(archived=True)
ordering = ['name']
def get_context_data(self, **kwargs):
kwargs = super(ProductArchivedListView, self).get_context_data(**kwargs)
kwargs['tab'] = "archive"
return kwargs
class ProductListView(CanEditPropMixin, ListView):
"""
A list view for the admins
"""
model = Product
template_name = 'counter/product_list.jinja'
queryset = Product.objects.filter(archived=False)
ordering = ['name']
def get_context_data(self, **kwargs):
kwargs = super(ProductListView, self).get_context_data(**kwargs)
kwargs['tab'] = "products"
return kwargs
class ProductEditForm(forms.ModelForm):
class Meta:
model = Product
fields = ['name', 'description', 'product_type', 'code', 'parent_product', 'buying_groups', 'purchase_price',
'selling_price', 'special_selling_price', 'icon', 'club', 'limit_age', 'tray']
'selling_price', 'special_selling_price', 'icon', 'club', 'limit_age', 'tray', 'archived']
parent_product = AutoCompleteSelectField('products', show_help_text=False, label=_("Parent product"), required=False)
buying_groups = AutoCompleteSelectMultipleField('groups', show_help_text=False, help_text="", label=_("Buying groups"), required=False)
club = AutoCompleteSelectField('clubs', show_help_text=False)
......
......@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-02 21:18+0200\n"
"POT-Creation-Date: 2016-09-04 15:46+0200\n"
"PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n"
......@@ -18,7 +18,7 @@ msgstr ""
#: accounting/models.py:36 accounting/models.py:55 accounting/models.py:82
#: accounting/models.py:132 club/models.py:19 counter/models.py:52
#: counter/models.py:77 counter/models.py:111 launderette/models.py:15
#: counter/models.py:77 counter/models.py:112 launderette/models.py:15
#: launderette/models.py:60 launderette/models.py:85
msgid "name"
msgstr "nom"
......@@ -64,7 +64,7 @@ msgid "account number"
msgstr "numero de compte"
#: accounting/models.py:58 accounting/models.py:83 club/models.py:145
#: counter/models.py:86 counter/models.py:112
#: counter/models.py:86 counter/models.py:113
msgid "club"
msgstr "club"
......@@ -85,12 +85,12 @@ msgstr "Compte club"
msgid "%(club_account)s on %(bank_account)s"
msgstr "%(club_account)s sur %(bank_account)s"
#: accounting/models.py:130 club/models.py:146 counter/models.py:282
#: accounting/models.py:130 club/models.py:146 counter/models.py:280
#: launderette/models.py:122
msgid "start date"
msgstr "date de début"
#: accounting/models.py:131 club/models.py:147 counter/models.py:283
#: accounting/models.py:131 club/models.py:147 counter/models.py:281
msgid "end date"
msgstr "date de fin"
......@@ -103,7 +103,7 @@ msgid "club account"
msgstr "compte club"
#: accounting/models.py:135 accounting/models.py:178 counter/models.py:25
#: counter/models.py:200
#: counter/models.py:198
msgid "amount"
msgstr "montant"
......@@ -124,16 +124,16 @@ msgid "journal"
msgstr "classeur"
#: accounting/models.py:179 core/models.py:458 core/models.py:736
#: counter/models.py:203 counter/models.py:246 counter/models.py:296
#: counter/models.py:201 counter/models.py:244 counter/models.py:294
#: eboutic/models.py:15 eboutic/models.py:48
msgid "date"
msgstr "date"
#: accounting/models.py:180 counter/models.py:297
#: accounting/models.py:180 counter/models.py:295
msgid "comment"
msgstr "commentaire"
#: accounting/models.py:181 counter/models.py:204 counter/models.py:247
#: accounting/models.py:181 counter/models.py:202 counter/models.py:245
#: subscription/models.py:57
msgid "payment method"
msgstr "méthode de paiement"
......@@ -180,7 +180,7 @@ msgstr "Compte"
msgid "Company"
msgstr "Entreprise"
#: accounting/models.py:190 sith/settings.py:283 sith/settings_sample.py:272
#: accounting/models.py:190 sith/settings.py:285 sith/settings_sample.py:274
msgid "Other"
msgstr "Autre"
......@@ -230,7 +230,7 @@ msgstr "code"
msgid "An accounting type code contains only numbers"
msgstr "Un code comptable ne contient que des numéros"
#: accounting/models.py:282 accounting/models.py:308 counter/models.py:238
#: accounting/models.py:282 accounting/models.py:308 counter/models.py:236
msgid "label"
msgstr "intitulé"
......@@ -328,7 +328,9 @@ msgstr "Nouveau compte club"
#: club/templates/club/club_base.jinja:42 core/templates/core/file.jinja:38
#: core/templates/core/page.jinja:31 core/templates/core/user_base.jinja:33
#: core/templates/core/user_tools.jinja:33
#: counter/templates/counter/counter_list.jinja:20
#: counter/templates/counter/counter_list.jinja:17
#: counter/templates/counter/counter_list.jinja:31
#: counter/templates/counter/counter_list.jinja:45
#: launderette/templates/launderette/launderette_list.jinja:14
msgid "Edit"
msgstr "Éditer"
......@@ -470,7 +472,7 @@ msgid "Done"
msgstr "Effectué"
#: accounting/templates/accounting/journal_details.jinja:34
#: counter/views.py:566
#: counter/views.py:596
msgid "Comment"
msgstr "Commentaire"
......@@ -540,7 +542,7 @@ msgstr "Vous ne pouvez pas faire de boucles dans les clubs"
msgid "A club with that unix_name already exists"
msgstr "Un club avec ce nom UNIX existe déjà."
#: club/models.py:144 counter/models.py:280 counter/models.py:294
#: club/models.py:144 counter/models.py:278 counter/models.py:292
#: eboutic/models.py:14 eboutic/models.py:47 launderette/models.py:89
#: launderette/models.py:126
msgid "user"
......@@ -575,13 +577,15 @@ msgstr "Membres"
msgid "Old members"
msgstr "Anciens membres"
#: club/templates/club/club_base.jinja:34 core/templates/core/base.jinja:25
#: club/templates/club/club_base.jinja:34 core/templates/core/base.jinja:37
#: core/templates/core/user_base.jinja:19
msgid "Tools"
msgstr "Outils"
#: club/templates/club/club_base.jinja:50
#: counter/templates/counter/counter_list.jinja:23
#: counter/templates/counter/counter_list.jinja:20
#: counter/templates/counter/counter_list.jinja:34
#: counter/templates/counter/counter_list.jinja:48
msgid "Props"
msgstr "Propriétés"
......@@ -1080,52 +1084,52 @@ msgstr "Connexion"
msgid "Register"
msgstr "S'enregister"
#: core/templates/core/base.jinja:26
#: core/templates/core/base.jinja:38
msgid "Logout"
msgstr "Déconnexion"
#: core/templates/core/base.jinja:28 core/templates/core/base.jinja.py:29
#: core/templates/core/base.jinja:40 core/templates/core/base.jinja.py:41
msgid "Search"
msgstr "Recherche"
#: core/templates/core/base.jinja:51
#: core/templates/core/base.jinja:63
msgid "Main"
msgstr "Accueil"
#: core/templates/core/base.jinja:52
#: core/templates/core/base.jinja:64
msgid "Matmatronch"
msgstr "Matmatronch"
#: core/templates/core/base.jinja:53
#: core/templates/core/base.jinja:65
msgid "Wiki"
msgstr "Wiki"
#: core/templates/core/base.jinja:54
#: core/templates/core/base.jinja:66
msgid "SAS"
msgstr "SAS"
#: core/templates/core/base.jinja:55
#: core/templates/core/base.jinja:67
msgid "Forum"
msgstr "Forum"
#: core/templates/core/base.jinja:56
#: core/templates/core/base.jinja:68
msgid "Services"
msgstr "Services"
#: core/templates/core/base.jinja:57 core/templates/core/file.jinja:20
#: core/templates/core/base.jinja:69 core/templates/core/file.jinja:20
#: core/views/files.py:42
msgid "Files"
msgstr "Fichiers"
#: core/templates/core/base.jinja:58
#: core/templates/core/base.jinja:70
msgid "Sponsors"
msgstr "Partenaires"
#: core/templates/core/base.jinja:59
#: core/templates/core/base.jinja:71
msgid "Help"
msgstr "Aide"
#: core/templates/core/base.jinja:75
#: core/templates/core/base.jinja:87
msgid "Site made by good people"
msgstr "Site réalisé par des gens bons"
......@@ -1656,7 +1660,8 @@ msgstr "Gestion de Sith"
msgid "Subscriptions"
msgstr "Cotisations"
#: core/templates/core/user_tools.jinja:22 counter/views.py:481
#: core/templates/core/user_tools.jinja:22
#: counter/templates/counter/counter_base.jinja:11 counter/views.py:511
msgid "Counters"
msgstr "Comptoirs"
......@@ -1673,7 +1678,9 @@ msgid "Products management"
msgstr "Gestion des produits"
#: core/templates/core/user_tools.jinja:28
msgid "Products type management"
#, fuzzy
#| msgid "Products type management"
msgid "Product types management"
msgstr "Gestion des types de produit"
#: core/templates/core/user_tools.jinja:42
......@@ -1786,107 +1793,112 @@ msgstr "produit parent"
msgid "buying groups"
msgstr "groupe d'achat"
#: counter/models.py:94
#: counter/models.py:92
msgid "archived"
msgstr "archivé"
#: counter/models.py:95
msgid "product"
msgstr "produit"
#: counter/models.py:113
#: counter/models.py:114
msgid "products"
msgstr "produits"
#: counter/models.py:114
#: counter/models.py:115
msgid "counter type"
msgstr "type de comptoir"
#: counter/models.py:116
#: counter/models.py:117
msgid "Bar"
msgstr "Bar"
#: counter/models.py:116
#: counter/models.py:117
msgid "Office"
msgstr "Bureau"
#: counter/models.py:116 eboutic/templates/eboutic/eboutic_main.jinja:4
#: counter/models.py:117 counter/templates/counter/counter_list.jinja:11
#: eboutic/templates/eboutic/eboutic_main.jinja:4
#: eboutic/templates/eboutic/eboutic_main.jinja:24
#: eboutic/templates/eboutic/eboutic_makecommand.jinja:8
#: eboutic/templates/eboutic/eboutic_payment_result.jinja:4
#: sith/settings.py:282 sith/settings.py:290 sith/settings_sample.py:271
#: sith/settings_sample.py:279
#: sith/settings.py:284 sith/settings.py:292 sith/settings_sample.py:273
#: sith/settings_sample.py:281
msgid "Eboutic"
msgstr "Eboutic"
#: counter/models.py:117
#: counter/models.py:118
msgid "sellers"
msgstr "vendeurs"
#: counter/models.py:122 counter/models.py:281 counter/models.py:295
#: counter/models.py:123 counter/models.py:279 counter/models.py:293
#: launderette/models.py:16
msgid "counter"
msgstr "comptoir"
#: counter/models.py:206
#: counter/models.py:204
msgid "bank"
msgstr "banque"
#: counter/models.py:208 counter/models.py:249
#: counter/models.py:206 counter/models.py:247
msgid "is validated"
msgstr "est validé"
#: counter/models.py:211
#: counter/models.py:209
msgid "refilling"
msgstr "rechargement"
#: counter/models.py:242 eboutic/models.py:133
#: counter/models.py:240 eboutic/models.py:133
msgid "unit price"
msgstr "prix unitaire"
#: counter/models.py:243 counter/models.py:320 eboutic/models.py:134
#: counter/models.py:241 counter/models.py:318 eboutic/models.py:134
msgid "quantity"
msgstr "quantité"
#: counter/models.py:248
#: counter/models.py:246
msgid "Sith account"
msgstr "Compte utilisateur"
#: counter/models.py:248 sith/settings.py:275 sith/settings.py:280
#: sith/settings.py:302 sith/settings_sample.py:264
#: sith/settings_sample.py:269 sith/settings_sample.py:291
#: counter/models.py:246 sith/settings.py:277 sith/settings.py:282
#: sith/settings.py:304 sith/settings_sample.py:266
#: sith/settings_sample.py:271 sith/settings_sample.py:293
msgid "Credit card"
msgstr "Carte bancaire"
#: counter/models.py:252
#: counter/models.py:250
msgid "selling"
msgstr "vente"
#: counter/models.py:284
#: counter/models.py:282
msgid "last activity date"
msgstr "dernière activité"
#: counter/models.py:287
#: counter/models.py:285
msgid "permanency"
msgstr "permanence"
#: counter/models.py:298
#: counter/models.py:296
msgid "emptied"
msgstr "coffre vidée"
#: counter/models.py:301
#: counter/models.py:299
msgid "cash register summary"
msgstr "relevé de caisse"
#: counter/models.py:318
#: counter/models.py:316
msgid "cash summary"
msgstr "relevé"
#: counter/models.py:319
#: counter/models.py:317
msgid "value"
msgstr "valeur"