forked from DGNum/gestioCOF
PEP8
This commit is contained in:
parent
ba11aa49db
commit
7350006990
2 changed files with 44 additions and 44 deletions
26
kfet/urls.py
26
kfet/urls.py
|
@ -8,7 +8,7 @@ from kfet.decorators import teamkfet_required
|
|||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.Home.as_view(),
|
||||
name = 'kfet.home'),
|
||||
name='kfet.home'),
|
||||
url(r'^login/genericteam$', views.login_genericteam,
|
||||
name='kfet.login.genericteam'),
|
||||
url(r'^history$', views.history,
|
||||
|
@ -71,26 +71,26 @@ urlpatterns = [
|
|||
# Account - Statistics
|
||||
url('^accounts/(?P<trigramme>.{3})/stat/last/$',
|
||||
views.AccountStatLastAll.as_view(),
|
||||
name = 'kfet.account.stat.last'),
|
||||
name='kfet.account.stat.last'),
|
||||
url('^accounts/(?P<trigramme>.{3})/stat/last/month/$',
|
||||
views.AccountStatLastMonth.as_view(),
|
||||
name = 'kfet.account.stat.last.month'),
|
||||
name='kfet.account.stat.last.month'),
|
||||
url('^accounts/(?P<trigramme>.{3})/stat/last/week/$',
|
||||
views.AccountStatLastWeek.as_view(),
|
||||
name = 'kfet.account.stat.last.week'),
|
||||
name='kfet.account.stat.last.week'),
|
||||
url('^accounts/(?P<trigramme>.{3})/stat/last/day/$',
|
||||
views.AccountStatLastDay.as_view(),
|
||||
name = 'kfet.account.stat.last.day'),
|
||||
name='kfet.account.stat.last.day'),
|
||||
|
||||
url('^accounts/(?P<trigramme>.{3})/stat/balance/$',
|
||||
views.AccountStatBalanceAll.as_view(),
|
||||
name = 'kfet.account.stat.balance'),
|
||||
name='kfet.account.stat.balance'),
|
||||
url('^accounts/(?P<trigramme>.{3})/stat/balance/d/(?P<nb_date>\d*)/$',
|
||||
views.AccountStatBalance.as_view(),
|
||||
name = 'kfet.account.stat.balance.days'),
|
||||
name='kfet.account.stat.balance.days'),
|
||||
url('^accounts/(?P<trigramme>.{3})/stat/balance/anytime/$',
|
||||
views.AccountStatBalance.as_view(),
|
||||
name = 'kfet.account.stat.balance.anytime'),
|
||||
name='kfet.account.stat.balance.anytime'),
|
||||
|
||||
# -----
|
||||
# Checkout urls
|
||||
|
@ -157,20 +157,20 @@ urlpatterns = [
|
|||
# Article - Update
|
||||
url('^articles/(?P<pk>\d+)/edit$',
|
||||
teamkfet_required(views.ArticleUpdate.as_view()),
|
||||
name = 'kfet.article.update'),
|
||||
name='kfet.article.update'),
|
||||
# Article - Statistics
|
||||
url('^articles/(?P<pk>\d+)/stat/last/$',
|
||||
views.ArticleStatLastAll.as_view(),
|
||||
name = 'kfet.article.stat.last'),
|
||||
name='kfet.article.stat.last'),
|
||||
url('^articles/(?P<pk>\d+)/stat/last/month/$',
|
||||
views.ArticleStatLastMonth.as_view(),
|
||||
name = 'kfet.article.stat.last.month'),
|
||||
name='kfet.article.stat.last.month'),
|
||||
url('^articles/(?P<pk>\d+)/stat/last/week/$',
|
||||
views.ArticleStatLastWeek.as_view(),
|
||||
name = 'kfet.article.stat.last.week'),
|
||||
name='kfet.article.stat.last.week'),
|
||||
url('^articles/(?P<pk>\d+)/stat/last/day/$',
|
||||
views.ArticleStatLastDay.as_view(),
|
||||
name = 'kfet.article.stat.last.day'),
|
||||
name='kfet.article.stat.last.day'),
|
||||
|
||||
# -----
|
||||
# K-Psul urls
|
||||
|
|
|
@ -756,24 +756,24 @@ class CategoryUpdate(SuccessMessageMixin, UpdateView):
|
|||
# Article views
|
||||
# -----
|
||||
|
||||
# Article - General
|
||||
|
||||
# Article - General
|
||||
class ArticleList(ListView):
|
||||
queryset = (Article.objects
|
||||
.select_related('category')
|
||||
.prefetch_related(Prefetch('inventories',
|
||||
queryset = Inventory.objects.order_by('-at'),
|
||||
to_attr = 'inventory'))
|
||||
.order_by('category', '-is_sold', 'name'))
|
||||
.select_related('category')
|
||||
.prefetch_related(Prefetch('inventories',
|
||||
queryset=Inventory.objects.order_by('-at'),
|
||||
to_attr='inventory'))
|
||||
.order_by('category', '-is_sold', 'name'))
|
||||
template_name = 'kfet/article.html'
|
||||
context_object_name = 'articles'
|
||||
|
||||
# Article - Create
|
||||
|
||||
# Article - Create
|
||||
class ArticleCreate(SuccessMessageMixin, CreateView):
|
||||
model = Article
|
||||
template_name = 'kfet/article_create.html'
|
||||
form_class = ArticleForm
|
||||
model = Article
|
||||
template_name = 'kfet/article_create.html'
|
||||
form_class = ArticleForm
|
||||
success_message = 'Nouvel item : %(category)s - %(name)s'
|
||||
|
||||
# Surcharge de la validation
|
||||
|
@ -788,7 +788,7 @@ class ArticleCreate(SuccessMessageMixin, CreateView):
|
|||
# Save des suppliers déjà existant
|
||||
for supplier in form.cleaned_data['suppliers']:
|
||||
SupplierArticle.objects.create(
|
||||
article = article, supplier = supplier)
|
||||
article=article, supplier=supplier)
|
||||
|
||||
# Nouveau supplier
|
||||
supplier_new = form.cleaned_data['supplier_new'].strip()
|
||||
|
@ -797,49 +797,49 @@ class ArticleCreate(SuccessMessageMixin, CreateView):
|
|||
name=supplier_new)
|
||||
if created:
|
||||
SupplierArticle.objects.create(
|
||||
article = article, supplier = supplier)
|
||||
article=article, supplier=supplier)
|
||||
|
||||
# Inventaire avec stock initial
|
||||
inventory = Inventory()
|
||||
inventory.by = self.request.user.profile.account_kfet
|
||||
inventory.save()
|
||||
InventoryArticle.objects.create(
|
||||
inventory = inventory,
|
||||
article = article,
|
||||
stock_old = article.stock,
|
||||
stock_new = article.stock,
|
||||
inventory=inventory,
|
||||
article=article,
|
||||
stock_old=article.stock,
|
||||
stock_new=article.stock,
|
||||
)
|
||||
|
||||
# Creating
|
||||
return super(ArticleCreate, self).form_valid(form)
|
||||
|
||||
# Article - Read
|
||||
|
||||
# Article - Read
|
||||
class ArticleRead(DetailView):
|
||||
model = Article
|
||||
model = Article
|
||||
template_name = 'kfet/article_read.html'
|
||||
context_object_name = 'article'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ArticleRead, self).get_context_data(**kwargs)
|
||||
inventoryarts = (InventoryArticle.objects
|
||||
.filter(article = self.object)
|
||||
.select_related('inventory')
|
||||
.order_by('-inventory__at'))
|
||||
.filter(article=self.object)
|
||||
.select_related('inventory')
|
||||
.order_by('-inventory__at'))
|
||||
context['inventoryarts'] = inventoryarts
|
||||
supplierarts = (SupplierArticle.objects
|
||||
.filter(article = self.object)
|
||||
.select_related('supplier')
|
||||
.order_by('-at'))
|
||||
.filter(article=self.object)
|
||||
.select_related('supplier')
|
||||
.order_by('-at'))
|
||||
context['supplierarts'] = supplierarts
|
||||
return context
|
||||
|
||||
# Article - Update
|
||||
|
||||
# Article - Update
|
||||
class ArticleUpdate(SuccessMessageMixin, UpdateView):
|
||||
model = Article
|
||||
template_name = 'kfet/article_update.html'
|
||||
form_class = ArticleRestrictForm
|
||||
model = Article
|
||||
template_name = 'kfet/article_update.html'
|
||||
form_class = ArticleRestrictForm
|
||||
success_message = "Informations mises à jour pour l'article : %(name)s"
|
||||
|
||||
# Surcharge de la validation
|
||||
|
@ -855,13 +855,13 @@ class ArticleUpdate(SuccessMessageMixin, UpdateView):
|
|||
for supplier in form.cleaned_data['suppliers']:
|
||||
if supplier not in article.suppliers.all():
|
||||
SupplierArticle.objects.create(
|
||||
article = article, supplier = supplier)
|
||||
article=article, supplier=supplier)
|
||||
|
||||
# On vire les suppliers désélectionnés
|
||||
for supplier in article.suppliers.all():
|
||||
if supplier not in form.cleaned_data['suppliers']:
|
||||
SupplierArticle.objects.filter(
|
||||
article = article, supplier = supplier).delete()
|
||||
article=article, supplier=supplier).delete()
|
||||
|
||||
# Nouveau supplier
|
||||
supplier_new = form.cleaned_data['supplier_new'].strip()
|
||||
|
@ -870,7 +870,7 @@ class ArticleUpdate(SuccessMessageMixin, UpdateView):
|
|||
name=supplier_new)
|
||||
if created:
|
||||
SupplierArticle.objects.create(
|
||||
article = article, supplier = supplier)
|
||||
article=article, supplier=supplier)
|
||||
|
||||
# Updating
|
||||
return super(ArticleUpdate, self).form_valid(form)
|
||||
|
|
Loading…
Reference in a new issue